private void button4_Click(object sender, EventArgs e) { //try //{ //if(ModuleDB.cnn.State==ConnectionState.Closed) // { // ModuleDB.cnn.Open(); // } //SqlCommand cmm = new SqlCommand("DELETE From TBL_LOAISANPHAM WHERE MASANPHAM='" + tbxmasanpham.Text+"'",ModuleDB.cnn); //cmm.ExecuteNonQuery(); // ModuleDB.cnn.Close(); //} //catch(Exception EX) //{ // throw EX; //} DataClasses1DataContext db = new DataClasses1DataContext(); TBL_LOAISANPHAM a = new TBL_LOAISANPHAM(); a = db.TBL_LOAISANPHAMs.Single(p => p.MASANPHAM.Equals(tbxmasanpham.Text)); db.TBL_LOAISANPHAMs.DeleteOnSubmit(a); db.SubmitChanges(); xoatronglist(); i--; MessageBox.Show("Xóa thành công"); loadimagelist(); loadlistviewmonan(); }
private void button12_Click(object sender, EventArgs e) { DataClasses1DataContext db = new DataClasses1DataContext(); tbsanpham = db.GetTable <TBL_HOADONCT>(); int i = 1; TBL_HOADONCT a = new TBL_HOADONCT(); TBL_LOAISANPHAM b = new TBL_LOAISANPHAM(); a.PHANBIET = i; a.MASAPHAM = cbxtensanpham.SelectedValue.ToString(); a.TENSANPHAM = cbxtensanpham.Text; a.SOLUONG = (int)numericUpDownsoluong.Value; a.MAHDBAN = tbxmahoadon.Text; b = db.TBL_LOAISANPHAMs.Single(p => p.MASANPHAM.Equals(a.MASAPHAM)); a.GIA = b.DONGIA * (double)numericUpDownsoluong.Value; a.THANHTOAN = false; a.SOBAN = int.Parse(tbxtenban.Text.Substring(4, 1)); db.TBL_HOADONCTs.InsertOnSubmit(a); db.SubmitChanges(); tbhoadonct.ghi(); datagridviewspdadat.AutoGenerateColumns = false; datagridviewspdadat.DataSource = tbsanpham.Where(p => p.MAHDBAN.Equals(tbxmahoadon.Text)); loadtongtien(); i++; }
private void button7_Click(object sender, EventArgs e) { DataClasses1DataContext db = new DataClasses1DataContext(); TBL_LOAISANPHAM a = new TBL_LOAISANPHAM(); a = db.TBL_LOAISANPHAMs.Single(p => p.TENSANPHAM.Equals(tbxtensanpham.Text)); //MessageBox.Show(monan.Text); tbxmasanpham.Text = a.MASANPHAM; numupdowgia.Value = System.Decimal.Parse(a.DONGIA.ToString()); numericUpDown1.Value = System.Decimal.Parse(a.SOLUONG.ToString()); btxoa.Enabled = true; }
private void button7_Click(object sender, EventArgs e) { DataClasses1DataContext db = new DataClasses1DataContext(); TBL_LOAISANPHAM b = new TBL_LOAISANPHAM(); b = db.TBL_LOAISANPHAMs.Single(p => p.TENSANPHAM.Equals(tbxtensanpham.Text)); // ListViewItem monan = listviewnuocuong.FindItemWithText(tbxtensanpham.Text, true, 0); //MessageBox.Show(monan.Text); tbxmasanpham.Text = b.MASANPHAM; numupdowgia.Value = System.Decimal.Parse(b.DONGIA.ToString()); numericUpDownSL1.Value = System.Decimal.Parse(b.SOLUONG.ToString()); buttonxoanuoc.Enabled = true; }
private void button4_Click(object sender, EventArgs e) { DataClasses1DataContext db = new DataClasses1DataContext(); TBL_LOAISANPHAM b = new TBL_LOAISANPHAM(); b = db.TBL_LOAISANPHAMs.Single(p => p.MASANPHAM.Equals(tbxmasanpham.Text)); db.TBL_LOAISANPHAMs.DeleteOnSubmit(b); xoatronglist(); i--; MessageBox.Show("Xóa thành công"); loadimagelist(); loadlistviewnuocuong(); }
private void saveimages() { MemoryStream stream = new MemoryStream(); pictureBox1.Image.Save(stream, ImageFormat.Png); DataClasses1DataContext lsanpham = new DataClasses1DataContext(); TBL_LOAISANPHAM tblloaisanpham = new TBL_LOAISANPHAM(); tblloaisanpham.HINH = stream.GetBuffer(); tblloaisanpham.MASANPHAM = tbxmasanpham1.Text; tblloaisanpham.TENSANPHAM = tbxtensanpham1.Text; tblloaisanpham.SOLUONG = (int)numericUpDownsoluong.Value; tblloaisanpham.DONGIA = (int)numupdow2.Value; tblloaisanpham.LOAISANPHAM = "MON"; lsanpham.TBL_LOAISANPHAMs.InsertOnSubmit(tblloaisanpham); lsanpham.SubmitChanges(); }
private void button3_Click_1(object sender, EventArgs e) { phanbiet = -1; DataClasses1DataContext db = new DataClasses1DataContext(); foreach (ListViewItem r in listViewmonan.Items) { if (r.Selected == true) { tbxmasanpham1.Text = r.SubItems[1].Text; TBL_LOAISANPHAM b = new TBL_LOAISANPHAM(); b = db.TBL_LOAISANPHAMs.Single(p => p.MASANPHAM.Equals(tbxmasanpham1.Text)); tbxtensanpham1.Text = b.TENSANPHAM; numupdow2.Value = (int)b.DONGIA; numericUpDownsoluong.Value = (int)b.SOLUONG; } } }
private void repairdatabase() { MemoryStream stream = new MemoryStream(); pictureBox1.Image.Save(stream, ImageFormat.Png); DataClasses1DataContext lsanpham = new DataClasses1DataContext(); TBL_LOAISANPHAM tblloaisanpham = new TBL_LOAISANPHAM(); tblloaisanpham = lsanpham.TBL_LOAISANPHAMs.Single(p => p.MASANPHAM.Equals(tbxmasanpham1.Text)); tblloaisanpham.HINH = stream.ToArray(); tblloaisanpham.TENSANPHAM = tbxtensanpham1.Text; tblloaisanpham.SOLUONG = (int)numericUpDownsoluong.Value; tblloaisanpham.DONGIA = (int)numupdow2.Value; lsanpham.SubmitChanges(); }
partial void DeleteTBL_LOAISANPHAM(TBL_LOAISANPHAM instance);
partial void UpdateTBL_LOAISANPHAM(TBL_LOAISANPHAM instance);
partial void InsertTBL_LOAISANPHAM(TBL_LOAISANPHAM instance);