private void OnDisplayCongTacNgoaiGioList() { Result result = CongTacNgoaiGioBus.GetCongTacNgoaiGioList(_tuNgay, _denNgay, _tenNhanVien); if (result.IsOK) { MethodInvoker method = delegate { ClearData(); DataTable dt = result.QueryResult as DataTable; dgCongTacNgoaiGio.DataSource = result.QueryResult; lbKetQuaTimDuoc.Text = string.Format("Kết quả tìm được: {0}", dt.Rows.Count); }; if (InvokeRequired) { BeginInvoke(method); } else { method.Invoke(); } } else { MsgBox.Show(Application.ProductName, result.GetErrorAsString("CongTacNgoaiGioBus.GetCongTacNgoaiGioList"), IconType.Error); Utility.WriteToTraceLog(result.GetErrorAsString("CongTacNgoaiGioBus.GetCongTacNgoaiGioList")); } }
private void OnSaveInfo() { try { MethodInvoker method = delegate { _congTacNgoaiGio.Ngay = dtpkNgay.Value; _congTacNgoaiGio.TenNguoiLam = txtTenNguoiLam.Text; _congTacNgoaiGio.MucDich = txtMucDich.Text; _congTacNgoaiGio.GioVao = dtpkGioVao.Value; _congTacNgoaiGio.GioRa = dtpkGioRa.Value; _congTacNgoaiGio.KetQuaDanhGia = txtKetQuaDanhGia.Text; _congTacNgoaiGio.NguoiDeXuatGUID = Guid.Parse(cboNguoiDeXuat.SelectedValue.ToString()); _congTacNgoaiGio.GhiChu = txtGhiChu.Text; _congTacNgoaiGio.Status = (byte)Status.Actived; if (_isNew) { _congTacNgoaiGio.CreatedDate = DateTime.Now; _congTacNgoaiGio.CreatedBy = Guid.Parse(Global.UserGUID); } else { _congTacNgoaiGio.UpdatedDate = DateTime.Now; _congTacNgoaiGio.UpdatedBy = Guid.Parse(Global.UserGUID); } Result result = CongTacNgoaiGioBus.InsertCongTacNgoaiGio(_congTacNgoaiGio); if (!result.IsOK) { MsgBox.Show(this.Text, result.GetErrorAsString("CongTacNgoaiGioBus.InsertCongTacNgoaiGio"), IconType.Error); Utility.WriteToTraceLog(result.GetErrorAsString("CongTacNgoaiGioBus.InsertCongTacNgoaiGio")); this.DialogResult = System.Windows.Forms.DialogResult.Cancel; } }; if (InvokeRequired) { BeginInvoke(method); } else { method.Invoke(); } } catch (Exception e) { MsgBox.Show(this.Text, e.Message, IconType.Error); Utility.WriteToTraceLog(e.Message); } }
private void OnDelete() { List <string> deletedKeyList = new List <string>(); List <DataRow> deletedRows = new List <DataRow>(); DataTable dt = dgCongTacNgoaiGio.DataSource as DataTable; if (dt == null || dt.Rows.Count <= 0) { return; } foreach (DataRow row in dt.Rows) { if (Boolean.Parse(row["Checked"].ToString())) { deletedKeyList.Add(row["CongTacNgoaiGioGUID"].ToString()); deletedRows.Add(row); } } if (deletedKeyList.Count > 0) { if (MsgBox.Question(Application.ProductName, "Bạn có muốn xóa những công tác ngoài giờ mà bạn đã đánh dấu ?") == DialogResult.Yes) { Result result = CongTacNgoaiGioBus.DeleteCongTacNgoaiGio(deletedKeyList); if (result.IsOK) { foreach (DataRow row in deletedRows) { dt.Rows.Remove(row); } } else { MsgBox.Show(Application.ProductName, result.GetErrorAsString("CongTacNgoaiGioBus.DeleteCongTacNgoaiGio"), IconType.Error); Utility.WriteToTraceLog(result.GetErrorAsString("CongTacNgoaiGioBus.DeleteCongTacNgoaiGio")); } } } else { MsgBox.Show(Application.ProductName, "Vui lòng đánh dấu những công tác ngoài giờ cần xóa.", IconType.Information); } }