public void SetCBB() { if (combobox_namenv.Items != null) { combobox_namenv.Items.Clear(); } SE_07 db = new SE_07(); foreach (NhanVien i in db.NhanViens) { combobox_namenv.Items.Add(new CBBItems { Value = i.nvID, Text = i.nvName }); } if (comboBox_role.Items != null) { comboBox_role.Items.Clear(); } comboBox_role.Items.Add(new CBBItems { Value = 1, Text = "admin" }); comboBox_role.Items.Add(new CBBItems { Value = 2, Text = "nhanvien" }); }
private void Button_ok_Click(object sender, EventArgs e) { SE_07 db = new SE_07(); int count = 0; if (textBox_pass.Text != "") { count += 1; } if (textBox_username.Text != "") { count += 1; } if (count == 2) { try { string role = comboBox_role.SelectedItem.ToString(); string user = textBox_username.Text; string pass = textBox_pass.Text; foreach (TaiKhoan i in db.TaiKhoans) { if (user == i.UserName) { { MessageBox.Show("Tên đăng nhập đã tồn tại!"); } } else { count += 1; if (count == db.TaiKhoans.Count()) { TaiKhoan tk = new TaiKhoan { nvID = ((CBBItems)combobox_namenv.SelectedItem).Value, UserName = user, Pass = pass, Type = role }; BLL_NhanVien.Instance.AddTaiKhoan_Bll(tk); MessageBox.Show("Tạo tài khoản thành công"); this.Dispose(); } } } } catch (Exception ex) { MessageBox.Show(ex.Message); } } else { MessageBox.Show("Bạn chưa nhập đầy đủ tài khoản hoặc mật khẩu "); } }
private void DataGridView1_RowHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e) { DataGridViewSelectedRowCollection r = dataGridView1.SelectedRows; SE_07 db = new SE_07(); if (r.Count == 1) { int khid = Convert.ToInt32(r[0].Cells["khID"].Value.ToString()); textBox_agekh.Text = Convert.ToInt32(db.KhachHangs.Where(p => p.khID == khid).Select(p => p.Age).FirstOrDefault()).ToString(); textBox_namenv.Text = db.KhachHangs.Where(p => p.khID == khid).Select(p => p.khName).FirstOrDefault(); textBox_sdtkh.Text = db.KhachHangs.Where(p => p.khID == khid).Select(p => p.khPhone).FirstOrDefault(); } }
private void DataGridView1_RowHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e) { DataGridViewSelectedRowCollection r = dataGridView1.SelectedRows; SE_07 db = new SE_07(); if (r.Count == 1) { int NvID = Convert.ToInt32(r[0].Cells["nvID"].Value.ToString()); textBox_namenv.Text = db.NhanViens.Where(p => p.nvID == NvID).Select(p => p.nvName).FirstOrDefault(); textBox_cmndnv.Text = db.NhanViens.Where(p => p.nvID == NvID).Select(p => p.nvIDNumber).FirstOrDefault(); textBox_diachinv.Text = db.NhanViens.Where(p => p.nvID == NvID).Select(p => p.nvAddress).FirstOrDefault(); textBox_luongnv.Text = db.NhanViens.Where(p => p.nvID == NvID).Select(p => p.Salary).FirstOrDefault(); textBox_sdtnv.Text = db.NhanViens.Where(p => p.nvID == NvID).Select(p => p.nvPhone).FirstOrDefault(); dateTimePicker1.Value = Convert.ToDateTime(db.NhanViens.Where(p => p.nvID == NvID).Select(p => p.nvDOB).FirstOrDefault().ToString()); } }
private void DataGridView1_RowHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e) { //int thanhtien = 0; DataGridViewSelectedRowCollection r = dataGridView1.SelectedRows; SE_07 db = new SE_07(); if (r.Count == 1) { int bid = Convert.ToInt32(r[0].Cells["bID"].Value.ToString()); dataGridView2.DataSource = db.DetailBills.Where(p => p.bID == bid).Select(p => new { p.SanPham.spName, p.SanPham.Unit, p.Quantity, p.SanPham.Price }).ToList(); textBox_thanhtien.Text = db.Bills.Where(p => p.bID == bid).Select(p => p.Total).FirstOrDefault(); } //foreach (DataGridViewRow i in dataGridView2.Rows) //{ // thanhtien += Convert.ToInt32(i.Cells["Quantity"].Value)* Convert.ToInt32(i.Cells["Price"].Value); //} //textBox_thanhtien.Text = thanhtien.ToString(); }
public void ShowDTGV() { SE_07 db = new SE_07(); dataGridView1.DataSource = db.NhanViens.Select(p => new { p.nvID, p.nvName, p.nvIDNumber, p.nvPhone, p.nvDOB, p.Salary, p.nvAddress }).ToList(); }
public void ShowDTGV() { SE_07 db = new SE_07(); dataGridView1.DataSource = db.KhachHangs.Select(p => new { p.khID, p.khName, p.Age, p.khPhone }).ToList(); }