⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 addshangpin.cs

📁 网上购物中介
💻 CS
📖 第 1 页 / 共 2 页
字号:
			this.button2.Text = "入库";
			this.button2.Click += new System.EventHandler(this.button2_Click);
			// 
			// button3
			// 
			this.button3.Location = new System.Drawing.Point(256, 344);
			this.button3.Name = "button3";
			this.button3.Size = new System.Drawing.Size(80, 24);
			this.button3.TabIndex = 18;
			this.button3.Text = " 取消";
			// 
			// button4
			// 
			this.button4.Location = new System.Drawing.Point(416, 344);
			this.button4.Name = "button4";
			this.button4.Size = new System.Drawing.Size(80, 24);
			this.button4.TabIndex = 19;
			this.button4.Text = " 退出";
			this.button4.Click += new System.EventHandler(this.button4_Click);
			// 
			// label9
			// 
			this.label9.Location = new System.Drawing.Point(48, 264);
			this.label9.Name = "label9";
			this.label9.Size = new System.Drawing.Size(40, 23);
			this.label9.TabIndex = 20;
			this.label9.Text = "备注";
			// 
			// textBox7
			// 
			this.textBox7.Location = new System.Drawing.Point(104, 256);
			this.textBox7.Multiline = true;
			this.textBox7.Name = "textBox7";
			this.textBox7.Size = new System.Drawing.Size(392, 64);
			this.textBox7.TabIndex = 21;
			this.textBox7.Text = "";
			// 
			// dataGrid1
			// 
			this.dataGrid1.AlternatingBackColor = System.Drawing.Color.WhiteSmoke;
			this.dataGrid1.BackColor = System.Drawing.Color.Gainsboro;
			this.dataGrid1.BackgroundColor = System.Drawing.Color.DarkGray;
			this.dataGrid1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
			this.dataGrid1.CaptionBackColor = System.Drawing.Color.DarkKhaki;
			this.dataGrid1.CaptionFont = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Bold);
			this.dataGrid1.CaptionForeColor = System.Drawing.Color.Black;
			this.dataGrid1.DataMember = "";
			this.dataGrid1.Dock = System.Windows.Forms.DockStyle.Bottom;
			this.dataGrid1.FlatMode = true;
			this.dataGrid1.Font = new System.Drawing.Font("Times New Roman", 9F);
			this.dataGrid1.ForeColor = System.Drawing.Color.Black;
			this.dataGrid1.GridLineColor = System.Drawing.Color.Silver;
			this.dataGrid1.HeaderBackColor = System.Drawing.Color.Black;
			this.dataGrid1.HeaderFont = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Bold);
			this.dataGrid1.HeaderForeColor = System.Drawing.Color.White;
			this.dataGrid1.LinkColor = System.Drawing.Color.DarkSlateBlue;
			this.dataGrid1.Location = new System.Drawing.Point(0, 388);
			this.dataGrid1.Name = "dataGrid1";
			this.dataGrid1.ParentRowsBackColor = System.Drawing.Color.LightGray;
			this.dataGrid1.ParentRowsForeColor = System.Drawing.Color.Black;
			this.dataGrid1.SelectionBackColor = System.Drawing.Color.Firebrick;
			this.dataGrid1.SelectionForeColor = System.Drawing.Color.White;
			this.dataGrid1.Size = new System.Drawing.Size(576, 96);
			this.dataGrid1.TabIndex = 22;
			// 
			// groupBox1
			// 
			this.groupBox1.Controls.Add(this.radioButton2);
			this.groupBox1.Controls.Add(this.radioButton1);
			this.groupBox1.Location = new System.Drawing.Point(32, 0);
			this.groupBox1.Name = "groupBox1";
			this.groupBox1.Size = new System.Drawing.Size(520, 48);
			this.groupBox1.TabIndex = 23;
			this.groupBox1.TabStop = false;
			// 
			// radioButton2
			// 
			this.radioButton2.ForeColor = System.Drawing.Color.RoyalBlue;
			this.radioButton2.Location = new System.Drawing.Point(288, 16);
			this.radioButton2.Name = "radioButton2";
			this.radioButton2.Size = new System.Drawing.Size(88, 24);
			this.radioButton2.TabIndex = 1;
			this.radioButton2.Text = "出售商品";
			this.radioButton2.CheckedChanged += new System.EventHandler(this.radioButton2_CheckedChanged);
			// 
			// radioButton1
			// 
			this.radioButton1.ForeColor = System.Drawing.Color.RoyalBlue;
			this.radioButton1.Location = new System.Drawing.Point(128, 16);
			this.radioButton1.Name = "radioButton1";
			this.radioButton1.Size = new System.Drawing.Size(88, 24);
			this.radioButton1.TabIndex = 0;
			this.radioButton1.Text = "展出商品";
			this.radioButton1.CheckedChanged += new System.EventHandler(this.radioButton1_CheckedChanged);
			// 
			// addShangpin
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(576, 484);
			this.Controls.Add(this.groupBox1);
			this.Controls.Add(this.dataGrid1);
			this.Controls.Add(this.textBox7);
			this.Controls.Add(this.label9);
			this.Controls.Add(this.button4);
			this.Controls.Add(this.button3);
			this.Controls.Add(this.button2);
			this.Controls.Add(this.button1);
			this.Controls.Add(this.textBox6);
			this.Controls.Add(this.label8);
			this.Controls.Add(this.textBox5);
			this.Controls.Add(this.label7);
			this.Controls.Add(this.textBox4);
			this.Controls.Add(this.label6);
			this.Controls.Add(this.textBox3);
			this.Controls.Add(this.label5);
			this.Controls.Add(this.comboBox2);
			this.Controls.Add(this.label4);
			this.Controls.Add(this.textBox2);
			this.Controls.Add(this.label3);
			this.Controls.Add(this.comboBox1);
			this.Controls.Add(this.textBox1);
			this.Controls.Add(this.label2);
			this.Controls.Add(this.label1);
			this.Name = "addShangpin";
			this.Text = "添加商品信息";
			this.Load += new System.EventHandler(this.addShangpin_Load);
			((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
			this.groupBox1.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion

		private void comboBox1_SelectedIndexChanged(object sender, System.EventArgs e)
		{
		
		}

		private void button1_Click(object sender, System.EventArgs e)
		{
			this.openFileDialog1.ShowDialog();
			this.textBox6.Text=openFileDialog1.FileName.ToString();
		}

		private void button4_Click(object sender, System.EventArgs e)
		{
			this.Dispose();
		}

		private void button2_Click(object sender, System.EventArgs e)
		{
			string id=textBox1.Text.Trim();
			if(id.Equals(""))
			{
				MessageBox.Show("ID编号不能为空!");
				textBox1.Focus();
				return;
			}
            string name=textBox2.Text.Trim();;
		    string type=comboBox1.Text.Trim();
			string tgs=comboBox2.Text.Trim();
			if(type.Equals("请选择"))
			{
				MessageBox.Show("请选择类型!");
				this.comboBox1.Focus();
				return;
			}
			if(tgs.Equals("请选择"))
			{
				MessageBox.Show("请选择提供商!");
				this.comboBox2.Focus();
				return;
			}
			string scj=textBox3.Text.Trim();;
			string newprice=textBox4.Text.Trim();
			string total=textBox5.Text.Trim();
			//if()
			string tupian=textBox6.Text.Trim().ToString();
			string beizhu=textBox7.Text.Trim();
			string insert=null;
			int i=0;
			string table=null;
			if(this.radioButton1.Checked)
			{
				insert="'"+id+"','"+type+"','"+name+"','"+tgs+"','"+scj+"','"+newprice+"','"+tupian+"','"+beizhu+"'";
				table="展出商品";
				this.comboBox2.Enabled=true;
			}
			else if(this.radioButton2.Checked)
			{
				insert="'"+id+"','"+type+"','"+name+"','"+scj+"','"+newprice+"','"+total+"','"+tupian+"','"+beizhu+"'";
				this.comboBox2.Enabled=false;
				i=1;
				table="出售商品";
			}
			else
			{
				MessageBox.Show("请选择插入的表!");
				radioButton1.Focus();
				return;
			}
			if(_3DLib.InsertIntoSp.checkOnlyOne(i,id)==1)
			{
				MessageBox.Show("该ID号已经被使用!请重新选择!");
				return;
			}
			System.Data.DataTable dt=new System.Data.DataTable();
			if(_3DLib.InsertIntoSp.insertInto(i,insert)==1)
			{
				MessageBox.Show(name+"成功添加!");
				dt=_3DLib.SelectAll.getOneInfo(table,name,"名称");
				OleDbDataAdapter da=new OleDbDataAdapter();
                this.dataGrid1.DataSource=dt;
			}
			else 
			{
				MessageBox.Show("商品添加失败!");
				return;
			}
		}

		private void addShangpin_Load(object sender, System.EventArgs e)
		{
			object[] my=_3DLib.InitComcoBox.getItem("提供商");
			this.comboBox2.Items.AddRange(my);
			object[] my1=_3DLib.InitComcoBox.getItem("类别");
			this.comboBox1.Items.AddRange(my1);
		}

		private void textBox5_TextChanged(object sender, System.EventArgs e)
		{
			if(textBox5.Text.Length>4)
			{
				MessageBox.Show("目前时间的范围在1900-9999之间,请修改年数!");
				this.textBox5.Focus();
			}
			else if(textBox5.Text.Length==4) this.comboBox1.Focus();
		}

		private void radioButton1_CheckedChanged(object sender, System.EventArgs e)
		{
			this.textBox5.Enabled=false;
			this.comboBox2.Enabled=true;
		}

		private void radioButton2_CheckedChanged(object sender, System.EventArgs e)
		{
			this.comboBox2.Enabled=false;
			this.textBox5.Enabled=true;
		}

		private void textBox1_TextChanged(object sender, System.EventArgs e)
		{
//			if(this.textBox1)
			     this.textBox1.BackColor=Color.Cyan;
		}
		private void textBox1_GotFoucs(object sender, System.EventArgs e)
		{
			this.textBox1.BackColor=Color.Cyan;
		}

	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -