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 Form1() { InitializeComponent(); //Set up the form. this.MaximizeBox = false; this.MinimizeBox = false; this.Size = new System.Drawing.Size(450, 450); this.Text = "Sản phẩm"; this.FormBorderStyle = FormBorderStyle.FixedDialog; this.StartPosition = FormStartPosition.CenterScreen; //Label this.lblLoaiSP.Text = "Loại Sản Phẩm"; this.lblLoaiSP.Location = new System.Drawing.Point(12, 15); this.lblLoaiSP.Size = new System.Drawing.Size(79, 13); this.lblTenSP.Text = "Tên Sản Phẩm"; this.lblTenSP.Location = new System.Drawing.Point(12, 42); this.lblTenSP.Size = new System.Drawing.Size(78, 13); this.lblDonGia.Text = "Đơn giá"; this.lblDonGia.Location = new System.Drawing.Point(12, 68); this.lblDonGia.Size = new System.Drawing.Size(44, 13); this.lblDonVi.Text = "Đơn vị tính"; this.lblDonVi.Location = new System.Drawing.Point(265, 42); this.lblDonVi.Size = new System.Drawing.Size(60, 13); this.lblSoTon.Text = "Số tồn"; this.lblSoTon.Location = new System.Drawing.Point(265, 68); this.lblSoTon.Size = new System.Drawing.Size(38, 13); //End Label //ComboBox this.cboLoaiSP.DropDownStyle = ComboBoxStyle.DropDownList; this.cboLoaiSP.Location = new System.Drawing.Point(97, 12); this.cboLoaiSP.Size = new System.Drawing.Size(121, 21); //End ComboBox //Textbox this.txtTenSP.Location = new System.Drawing.Point(97, 39); this.txtTenSP.Size = new System.Drawing.Size(162, 20); this.txtDonGia.Location = new System.Drawing.Point(97, 65); this.txtDonGia.Size = new System.Drawing.Size(121, 20); this.txtDonVi.Location = new System.Drawing.Point(331, 39); this.txtDonVi.Size = new System.Drawing.Size(97, 20); this.txtSoTon.Location = new System.Drawing.Point(331, 65); this.txtSoTon.Size = new System.Drawing.Size(97, 20); //End Textbox //Button this.btnMore.Text = "..."; this.btnMore.Location = new System.Drawing.Point(224, 10); this.btnMore.Size = new System.Drawing.Size(35, 23); this.btnThemMoi.Text = "Thêm mới"; this.btnThemMoi.Location = new System.Drawing.Point(12, 91); this.btnThemMoi.Size = new System.Drawing.Size(75, 23); this.btnCapNhat.Text = "Cập nhật"; this.btnCapNhat.Location = new System.Drawing.Point(93, 91); this.btnCapNhat.Size = new System.Drawing.Size(75, 23); this.btnXoa.Text = "Xóa"; this.btnXoa.Location = new System.Drawing.Point(174, 91); this.btnXoa.Size = new System.Drawing.Size(75, 23); this.btnThoat.Text = "Thoát"; this.btnThoat.Location = new System.Drawing.Point(255, 91); this.btnThoat.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 //DataGridView this.dgv.AllowUserToAddRows = false; this.dgv.AllowUserToDeleteRows = false; this.dgv.ReadOnly = true; this.dgv.MultiSelect = false; this.dgv.SelectionMode = DataGridViewSelectionMode.FullRowSelect; this.dgv.Location = new System.Drawing.Point(12, 120); this.dgv.Size = new System.Drawing.Size(416, 285); //End DataGridView 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(btnMore); this.Controls.Add(btnThemMoi); this.Controls.Add(btnCapNhat); this.Controls.Add(btnXoa); this.Controls.Add(btnThoat); //this.Controls.Add(listView1); this.Controls.Add(dgv); en = new En_SanPham(); NapLoaiSP(); NapSanPham(); this.cboLoaiSP.SelectedIndexChanged += new System.EventHandler(this.cboLoaiSP_SelectedIndexChange); //listView1.Click += new System.EventHandler(this.listView1_SelectedIndexChange); this.dgv.Click += new System.EventHandler(this.dgv_SelectedIndexChange); btnMore.Click += new System.EventHandler(this.btnMore_Click); btnThemMoi.Click += new System.EventHandler(this.btnThemMoi_Click); btnCapNhat.Click += new System.EventHandler(this.btnCapNhat_Click); btnXoa.Click += new System.EventHandler(this.btnXoa_Click); btnThoat.Click += new System.EventHandler(this.btnThoat_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); }