private void LoadData1() { btnSave.Visible = false; flpDiemDanh.Visible = false; blCa = new BLCa(); dsCaNgay = blCa.dsCaNgay(); mangCa = new RadioButton[dsCaNgay.Count]; for (int i = 0; i < dsCaNgay.Count; i++) { mangCa[i] = new RadioButton(); mangCa[i].Size = new System.Drawing.Size(212, 40); mangCa[i].Location = new System.Drawing.Point(3, 3 + i * 40); mangCa[i].Padding = new System.Windows.Forms.Padding(20, 0, 0, 0); if (dsCaNgay[i].MaCa.Hour == 7) { mangCa[i].Text = "Ca Sáng"; mangCa[i].Tag = 7; } else if (dsCaNgay[i].MaCa.Hour == 12) { mangCa[i].Text = "Ca Trưa"; mangCa[i].Tag = 12; } else if (dsCaNgay[i].MaCa.Hour == 17) { mangCa[i].Text = "Ca Chiều"; mangCa[i].Tag = 17; } } for (int i = 0; i < dsCaNgay.Count; i++) { mangCa[i].Click += Shift_Click; flpCa.Controls.Add(mangCa[i]); } }
private void LoadToShift() { BLCa blca = new BLCa(); cbb_to_shift.Items.Clear(); List <CA> dsca = new List <CA>(); dsca = blca.LoadShift(); foreach (var item in dsca) { cbb_to_shift.Items.Add(item.MaCa.ToString()); } }
private void btnShift_Click(object sender, EventArgs e) { BLCa blCa = new BLCa(); var dsCa = blCa.dsCa(); if (DateTime.Now.Hour >= 7 && DateTime.Now.Hour < 12) { var ds = (from ca in dsCa where ca.MaCa.Day == DateTime.Now.Day && ca.MaCa.Month == DateTime.Now.Month && ca.MaCa.Year == DateTime.Now.Year && ca.MaCa.Hour >= 7 && ca.MaCa.Hour < 12 select ca.MaCa).ToList(); if (ds.Count == 0) { string message; DateTime dt = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 7, 0, 0); blCa.Insert(dt, out message); } } else if (DateTime.Now.Hour >= 12 && DateTime.Now.Hour < 17) { var ds = (from ca in dsCa where ca.MaCa.Day == DateTime.Now.Day && ca.MaCa.Month == DateTime.Now.Month && ca.MaCa.Year == DateTime.Now.Year && ca.MaCa.Hour >= 12 && ca.MaCa.Hour < 17 select ca.MaCa).ToList(); if (ds.Count == 0) { string message; DateTime dt = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 12, 0, 0); blCa.Insert(dt, out message); } } else if (DateTime.Now.Hour >= 17 && DateTime.Now.Hour < 22) { var ds = (from ca in dsCa where ca.MaCa.Day == DateTime.Now.Day && ca.MaCa.Month == DateTime.Now.Month && ca.MaCa.Year == DateTime.Now.Year && ca.MaCa.Hour >= 17 && ca.MaCa.Hour < 22 select ca.MaCa).ToList(); if (ds.Count == 0) { string message; DateTime dt = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 17, 0, 0); blCa.Insert(dt, out message); } } this.WindowState = FormWindowState.Maximized; btnMaximize.Visible = false; btnRestore.Visible = true; pnShow.Controls.Clear(); Shift shift = new Shift(); shift.Dock = DockStyle.Fill; pnShow.Controls.Add(shift); }
private void btnSave_Click(object sender, EventArgs e) { if (this.add) { BLPhanCong blpc = new BLPhanCong(); BLNhanVien blnv = new BLNhanVien(); BLCa blca = new BLCa(); CA caa = new CA(); List <CA> dsca = new List <CA>(); List <NHANVIEN> dsnv = new List <NHANVIEN>(); dsnv = blnv.dsNhanVien(); dsca = blca.LoadShift(); NHANVIEN nv = new NHANVIEN(); nv = dsnv.Find(x => (x.MaNV == int.Parse(cbb_emp_ID.SelectedItem.ToString()))); caa = dsca.Find(x => (x.MaCa == int.Parse(cbb_to_shift.SelectedItem.ToString()))); if (blpc.AddPC(nv, caa)) { MessageBox.Show("SUCCESS!"); } else { MessageBox.Show("FAIL"); } } else { BLPhanCong blpc = new BLPhanCong(); BLNhanVien blnv = new BLNhanVien(); BLCa blca = new BLCa(); CA TOcaa = new CA(); CA Frcaa = new CA(); List <CA> dsca = new List <CA>(); List <NHANVIEN> dsnv = new List <NHANVIEN>(); dsnv = blnv.dsNhanVien(); dsca = blca.LoadShift(); NHANVIEN nv = new NHANVIEN(); nv = dsnv.Find(x => (x.MaNV == int.Parse(cbb_emp_ID.SelectedItem.ToString()))); TOcaa = dsca.Find(x => (x.MaCa == int.Parse(cbb_to_shift.SelectedItem.ToString()))); Frcaa = dsca.Find(x => (x.MaCa == int.Parse(cbb_shift.SelectedItem.ToString()))); if (blpc.EditPC(nv, Frcaa, TOcaa)) { MessageBox.Show("SUCCESS!"); } else { MessageBox.Show("FAIL"); } } }
private void btnSave_Click(object sender, EventArgs e) { if (this.add) { BLPhanCong blpc = new BLPhanCong(); BLNhanVien blnv = new BLNhanVien(); BLCa blca = new BLCa(); NhanVien nv = new NhanVien(); int manv = int.Parse(cbb_emp_ID.SelectedItem.ToString()); int maca = int.Parse(cbb_to_shift.SelectedItem.ToString()); if (blpc.AddPC(manv, maca, out string err)) { MessageBox.Show("SUCCESS!"); } else { MessageBox.Show("FAIL ", err); } } else { BLPhanCong blpc = new BLPhanCong(); BLNhanVien blnv = new BLNhanVien(); int TOcaa; int Frcaa; int nv; nv = int.Parse(cbb_emp_ID.SelectedItem.ToString()); TOcaa = int.Parse(cbb_to_shift.SelectedItem.ToString()); Frcaa = int.Parse(cbb_shift.SelectedItem.ToString()); if (blpc.Update(nv, Frcaa, TOcaa, out string err)) { MessageBox.Show("SUCCESS!"); } else { MessageBox.Show(err); } } }
private void LoadToShift() { BLCa blca = new BLCa(); cbb_to_shift.Items.Clear(); //List<Ca> dsca = new List<Ca>(); DataSet dsca = blca.LoadShift(); //foreach (var item in dsca) //{ // cbb_to_shift.Items.Add(item.MaCa.ToString()); //} for (int i = 0; i < dsca.Tables[0].Rows.Count; i++) { DataRow row = dsca.Tables[0].Rows[i]; var x = row.ItemArray.ToList(); cbb_to_shift.Items.Add(x[0]); } }