public bool deletedata(En_SanPham en) { string query = string.Format("DELETE FROM SanPham WHERE MaSP=@MaSP"); SqlParameter[] sqlPara = new SqlParameter[1]; sqlPara[0] = new SqlParameter("@MaSP", en.MaSP); return(cnn.executeDeleteQuery(query, sqlPara)); }
public bool updatedata(En_SanPham en) { string query = string.Format("UPDATE SanPham SET TenSP=@TenSP, DonViTinh=@DonViTinh, DonGiaMua=@DonGiaMua, SoTon=@SoTon WHERE MaSP=@MaSP"); SqlParameter[] sqlPara = new SqlParameter[5]; sqlPara[0] = new SqlParameter("@TenSP", en.TenSP); sqlPara[1] = new SqlParameter("@DonViTinh", en.DonVi); sqlPara[2] = new SqlParameter("@DonGiaMua", en.DonGia); sqlPara[3] = new SqlParameter("@SoTon", en.SoTon); sqlPara[4] = new SqlParameter("@MaSP", en.MaSP); return(cnn.executeUpdateQuery(query, sqlPara)); }
public bool insertdata(En_SanPham en) { string query = string.Format("INSERT INTO SanPham(TenSP, DonViTinh, DonGiaMua, SoTon, MaLoai) VALUES(@TenSP,@DonViTinh,@DonGiaMua,@SoTon,@MaLoai)"); SqlParameter[] sqlPara = new SqlParameter[5]; sqlPara[0] = new SqlParameter("@TenSP", en.TenSP); sqlPara[1] = new SqlParameter("@DonViTinh", en.DonVi); sqlPara[2] = new SqlParameter("@DonGiaMua", en.DonGia); sqlPara[3] = new SqlParameter("@SoTon", en.SoTon); sqlPara[4] = new SqlParameter("@MaLoai", en.MaLoai); return(cnn.executeInsertQuery(query, sqlPara)); }
//End Controls public Form2() { InitializeComponent(); //Set up the form. this.MaximizeBox = false; this.MinimizeBox = false; this.Size = new System.Drawing.Size(545, 374); this.Text = "Sản phẩm"; this.FormBorderStyle = FormBorderStyle.FixedDialog; this.StartPosition = FormStartPosition.CenterScreen; //Label this.lblLoaiSP.Text = "Loại SP"; this.lblLoaiSP.Location = new System.Drawing.Point(12, 15); this.lblLoaiSP.Size = new System.Drawing.Size(44, 13); this.lblTenSP.Text = "Tên SP"; this.lblTenSP.Location = new System.Drawing.Point(189, 15); this.lblTenSP.Size = new System.Drawing.Size(43, 13); this.lblDonVi.Text = "Đơn vị"; this.lblDonVi.Location = new System.Drawing.Point(394, 15); this.lblDonVi.Size = new System.Drawing.Size(38, 13); this.lblDonGia.Text = "Đơn giá"; this.lblDonGia.Location = new System.Drawing.Point(189, 41); this.lblDonGia.Size = new System.Drawing.Size(44, 13); this.lblSoTon.Text = "Số tồn"; this.lblSoTon.Location = new System.Drawing.Point(394, 41); this.lblSoTon.Size = new System.Drawing.Size(38, 13); //End Label //ComboBox this.cboLoaiSP.DropDownStyle = ComboBoxStyle.DropDownList; this.cboLoaiSP.Location = new System.Drawing.Point(62, 12); this.cboLoaiSP.Size = new System.Drawing.Size(121, 21); //End ComboBox //Textbox this.txtTenSP.Location = new System.Drawing.Point(238, 12); this.txtTenSP.Size = new System.Drawing.Size(150, 20); this.txtDonVi.Location = new System.Drawing.Point(438, 12); this.txtDonVi.Size = new System.Drawing.Size(80, 20); this.txtDonGia.Location = new System.Drawing.Point(239, 38); this.txtDonGia.Size = new System.Drawing.Size(80, 20); this.txtSoTon.Location = new System.Drawing.Point(438, 38); this.txtSoTon.Size = new System.Drawing.Size(80, 20); //End Textbox //Button this.btnThemMoi.Text = "Thêm mới"; this.btnThemMoi.Location = new System.Drawing.Point(62, 64); this.btnThemMoi.Size = new System.Drawing.Size(75, 23); this.btnCapNhat.Text = "Cập nhật"; this.btnCapNhat.Location = new System.Drawing.Point(143, 64); this.btnCapNhat.Size = new System.Drawing.Size(75, 23); this.btnXoa.Text = "Xóa"; this.btnXoa.Location = new System.Drawing.Point(224, 64); this.btnXoa.Size = new System.Drawing.Size(75, 23); //End Button //Listview listView1.FullRowSelect = true; this.listView1.Location = new System.Drawing.Point(62, 93); this.listView1.Size = new System.Drawing.Size(456, 236); //End Listview this.Controls.Add(lblLoaiSP); this.Controls.Add(lblTenSP); this.Controls.Add(lblDonVi); this.Controls.Add(lblDonGia); this.Controls.Add(lblSoTon); this.Controls.Add(cboLoaiSP); this.Controls.Add(txtTenSP); this.Controls.Add(txtDonVi); this.Controls.Add(txtDonGia); this.Controls.Add(txtSoTon); this.Controls.Add(btnThemMoi); this.Controls.Add(btnCapNhat); this.Controls.Add(btnXoa); this.Controls.Add(listView1); en = new En_SanPham(); NapLoaiSP(); NapSanPham(); this.cboLoaiSP.SelectedIndexChanged += new System.EventHandler(this.cboLoaiSP_SelectedIndexChange); listView1.Click += new System.EventHandler(this.listView1_SelectedIndexChange); btnThemMoi.Click += new System.EventHandler(this.btnThemMoi_Click); btnCapNhat.Click += new System.EventHandler(this.btnCapNhat_Click); btnXoa.Click += new System.EventHandler(this.btnXoa_Click); }
public void deletedata(En_SanPham en) { dal.deletedata(en); }
public void updatedata(En_SanPham en) { dal.updatedata(en); }
public void insertdata(En_SanPham en) { dal.insertdata(en); }