private void btnluu_Click(object sender, EventArgs e) { bool flag; if (rdbnam.Checked == true) { flag = true; } else { flag = false; } using (_db = new QLSQADataContext()) { db_KhachHang user = new db_KhachHang { TenKH = txttenkh.Text, DiaChiKH = txtdiachi.Text, sdtKH = txtsdt.Text, EmailKH = txtemail.Text, GioiTInh = flag, NgaySinh = dateTimePicker1.Value }; _db.db_KhachHangs.InsertOnSubmit(user); _db.SubmitChanges(); loadata(); }; MessageBox.Show("Thêm thành công", "Thông báo", MessageBoxButtons.OK); enableNutLenh(false); cleardata(); }
private void loadata() { using (_db = new QLSQADataContext()) { dataGridView1.DataSource = _db.db_KhachHangs; } }
private void btnsua_Click(object sender, EventArgs e) { bool flag; int pid = Convert.ToInt32(dataGridView1.CurrentRow.Cells[0].Value.ToString()); if (rdbnam.Checked == true) { flag = true; } else { flag = false; } using (_db = new QLSQADataContext()) { var item = _db.db_KhachHangs.Where(r => r.MaKH == pid).FirstOrDefault(); item.TenKH = txttenkh.Text; item.DiaChiKH = txtdiachi.Text; item.sdtKH = txtsdt.Text; item.EmailKH = txtemail.Text; item.GioiTInh = flag; item.NgaySinh = dateTimePicker1.Value; _db.SubmitChanges(); loadata(); } MessageBox.Show("Sửa thành công", "Thông báo", MessageBoxButtons.OK); cleardata(); }
private void btnsua_Click(object sender, EventArgs e) { bool flag; int pid = Convert.ToInt32(dataGridView1.CurrentRow.Cells[0].Value.ToString()); if (rdbnam.Checked == true) { flag = true; } else { flag = false; } using (_db = new QLSQADataContext()) { var item = _db.db_Users.Where(r => r.MaNV == pid).FirstOrDefault(); item.TenNV = txttnd.Text; item.TenDangNhap = txttdn.Text; item.MatKhau = txtmk.Text; item.EmailDK = txtemail.Text; item.Vaitro = cmbvaitro.SelectedItem.ToString(); item.GioiTinhDK = flag; item.NgaySinh = dateTimePicker1.Value; _db.SubmitChanges(); loadata(); } MessageBox.Show("Sửa thành công", "Thông báo", MessageBoxButtons.OK); cleardata(); }
private void loadata() { using (QLSQADataContext _db = new QLSQADataContext()) { dataGridView1.DataSource = _db.db_SanPhams; } }
private void btnluu_Click(object sender, EventArgs e) { bool flag; if (rdbnam.Checked == true) { flag = true; } else { flag = false; } using (_db = new QLSQADataContext()) { db_User user = new db_User { TenNV = txttnd.Text, TenDangNhap = txttdn.Text, MatKhau = txtmk.Text, EmailDK = txtemail.Text, Vaitro = cmbvaitro.SelectedItem.ToString(), GioiTinhDK = flag, NgaySinh = dateTimePicker1.Value }; _db.db_Users.InsertOnSubmit(user); _db.SubmitChanges(); loadata(); }; MessageBox.Show("Thêm thành công", "Thông báo", MessageBoxButtons.OK); enableNutLenh(false); cleardata(); }
private void loadgrid() { dataGridView2.AutoGenerateColumns = false; QLSQADataContext _db = new QLSQADataContext(); dataGridView2.DataSource = _db.db_HoaDons; }
private void loadcmb() { using (QLSQADataContext db = new QLSQADataContext()) { cmbtkh.DataSource = db.db_KhachHangs.ToList(); cmbtkh.ValueMember = "MaKH"; cmbtkh.DisplayMember = "TenKH"; cbotsp.DataSource = db.db_SanPhams.ToList(); cbotsp.ValueMember = "MaSP"; cbotsp.DisplayMember = "TenSP"; } }
private void btnx_Click(object sender, EventArgs e) { int pid = Convert.ToInt32(dataGridView1.CurrentRow.Cells[0].Value.ToString()); using (_db = new QLSQADataContext()) { var item = _db.db_KhachHangs.Where(r => r.MaKH == pid).FirstOrDefault(); _db.db_KhachHangs.DeleteOnSubmit(item); _db.SubmitChanges(); loadata(); } MessageBox.Show("Xóa thành công", "Thông báo", MessageBoxButtons.OK); cleardata(); }
private void simpleButton1_Click(object sender, EventArgs e) { using (_db = new QLSQADataContext()) { var item = _db.db_KhachHangs.Where(r => r.TenKH.Contains(txttenkh.Text) && r.DiaChiKH.Contains(txtdiachi.Text) && r.EmailKH.Contains(txtemail.Text)); if (item != null) { dataGridView1.DataSource = item; } else if (item == null) { MessageBox.Show("Không", "Thông báo", MessageBoxButtons.OK); } cleardata(); } }
private void simpleButton1_Click(object sender, EventArgs e) { using (QLSQADataContext _db = new QLSQADataContext()) { var item = _db.db_SanPhams.Where(r => r.TenSP.Contains(txttensp.Text)); if (item != null) { dataGridView1.DataSource = item; } else if (item == null) { MessageBox.Show("Không", "Thông báo", MessageBoxButtons.OK); } cleardata(); } }
private void simpleButton1_Click(object sender, EventArgs e) { using (_db = new QLSQADataContext()) { var item = _db.db_Users.Where(r => r.TenNV.Contains(txttnd.Text) && r.TenDangNhap.Contains(txttdn.Text) && r.EmailDK.Contains(txtemail.Text)); if (item != null) { dataGridView1.DataSource = item; } else if (item == null) { MessageBox.Show("Không", "Thông báo", MessageBoxButtons.OK); } cleardata(); } }
private void btnsua_Click(object sender, EventArgs e) { int pid = Convert.ToInt32(dataGridView1.CurrentRow.Cells[0].Value.ToString()); using (QLSQADataContext _db = new QLSQADataContext()) { var item = _db.db_SanPhams.Where(r => r.MaSP == pid).FirstOrDefault(); item.TenSP = txttensp.Text; item.AnhSP = txtanh.Text; item.SoLuongSP = Convert.ToInt32(txtsoluong.Text); item.GiaSP = Convert.ToDouble(txtgia.Text); _db.SubmitChanges(); loadata(); } MessageBox.Show("Sửa thành công", "Thông báo", MessageBoxButtons.OK); cleardata(); }
private void cmbtkh_SelectedIndexChanged(object sender, EventArgs e) { QLSQADataContext _db = new QLSQADataContext(); var item = (from tb in _db.db_KhachHangs select tb).First(); txtdc.Text = item.DiaChiKH.ToString(); txtsdt.Text = item.sdtKH.ToString(); if (cmbtkh.SelectedIndex > 0) { var item1 = (from tb in _db.db_KhachHangs where tb.MaKH == int.Parse(cmbtkh.SelectedValue.ToString()) select tb).Single(); txtdc.Text = item1.DiaChiKH.ToString(); txtsdt.Text = item1.sdtKH.ToString(); } }
private void btnluu_Click(object sender, EventArgs e) { using (QLSQADataContext _db = new QLSQADataContext()) { db_SanPham product = new db_SanPham { TenSP = txttensp.Text, AnhSP = txtanh.Text, SoLuongSP = Convert.ToInt32(txtsoluong.Text), GiaSP = Convert.ToDouble(txtgia.Text), }; _db.db_SanPhams.InsertOnSubmit(product); _db.SubmitChanges(); loadata(); }; MessageBox.Show("Thêm thành công", "Thông báo", MessageBoxButtons.OK); enableNutLenh(false); cleardata(); }
private void btnluusp_Click(object sender, EventArgs e) { _db.SubmitChanges(); QLSQADataContext ql = new QLSQADataContext(); double tongtien = 0; var item = (from tb in ql.db_ChiTietDonHangs join tb1 in ql.db_HoaDons on tb.MaHD equals tb1.MaHD where tb.MaHD == lblmhd.Text select tb).ToList(); foreach (var hd in item) { tongtien += (double)hd.ThanhTien; } label3.Text = tongtien.ToString(); using (QLSQADataContext dbnew = new QLSQADataContext()) { var item1 = dbnew.db_HoaDons.Where(r => r.MaHD == txtmhd.Text).Single(); item1.TongTien = tongtien; dbnew.SubmitChanges(); dataGridView1.Rows.Clear(); loadgrid(); } }