private void btnEdit_Click(object sender, EventArgs e) { _rownIndex = grvData.FocusedRowHandle; int id = TextUtils.ToInt(grvData.GetFocusedRowCellValue(colID)); if (id == 0) { return; } T_DM_FCMModel model = (T_DM_FCMModel)T_DM_FCMBO.Instance.FindByPK(id); frmFCMdetail frm = new frmFCMdetail(); frm.FCM = model; frm.LoadDataChange += main_LoadDataChange; frm.Show(); }
protected T_DM_FCMFacade(T_DM_FCMModel model) : base(model) { }
private void btnBrowse_Click(object sender, EventArgs e) { if (TextUtils.ToInt(cboPhongBan.SelectedValue) == 0) { MessageBox.Show("Bạn phải chọn một phòng phụ trách.", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } OpenFileDialog ofd = new OpenFileDialog(); ofd.Multiselect = false; if (ofd.ShowDialog() == DialogResult.OK) { using (WaitDialogForm fWait = new WaitDialogForm("Vui lòng chờ trong giây lát...", "Đang tạo load dữ liệu...")) { fcm = new T_DM_FCMModel(); DataTable dt = new DataTable(); DataRow[] drs = null; txtDMVTPath.Text = ofd.FileName; if (TextUtils.ToInt(cboPhongBan.SelectedValue) == 40) { dt = TextUtils.ExcelToDatatableNoHeader(txtDMVTPath.Text, "Sheet1"); if (dt.Rows.Count == 0) { return; } txtProjectCode.Text = TextUtils.ToString(dt.Rows[3]["F4"]); txtHopDong.Text = TextUtils.ToString(dt.Rows[7]["F7"]); txtTotalBanHang.EditValue = TextUtils.ToDecimal(dt.Rows[19]["F7"]); txtTotalBX.EditValue = TextUtils.ToDecimal(dt.Rows[18]["F7"]); txtTotalHD.EditValue = TextUtils.ToDecimal(dt.Rows[11]["F7"]); txtTotalNC.EditValue = TextUtils.ToDecimal(dt.Rows[16]["F7"]); txtTotalPB.EditValue = TextUtils.ToDecimal(dt.Rows[17]["F7"]); txtTotalProfit.EditValue = TextUtils.ToDecimal(dt.Rows[20]["F7"]); txtTotalReal.EditValue = TextUtils.ToDecimal(dt.Rows[14]["F7"]); txtTotalTPA.EditValue = TextUtils.ToDecimal(dt.Rows[12]["F7"]); txtTotalTrienKhai.EditValue = TextUtils.ToDecimal(dt.Rows[15]["F7"]); txtTotalVAT.EditValue = TextUtils.ToDecimal(dt.Rows[13]["F7"]); txtTotalVT.EditValue = TextUtils.ToDecimal(dt.Rows[24]["F7"]); drs = dt.Select("F2 is null and F3 is not null and F3 like 'C%'"); colCode.FieldName = "F3"; } else { dt = TextUtils.ExcelToDatatableNoHeader(txtDMVTPath.Text, "INPUT"); if (dt.Rows.Count == 0) { return; } txtProjectCode.Text = TextUtils.ToString(dt.Rows[4]["F4"]); txtHopDong.Text = TextUtils.ToString(dt.Rows[8]["F7"]); txtTotalBanHang.EditValue = TextUtils.ToDecimal(dt.Rows[48]["F7"]); txtTotalBX.EditValue = TextUtils.ToDecimal(dt.Rows[19]["F7"]); txtTotalHD.EditValue = TextUtils.ToDecimal(dt.Rows[12]["F7"]); txtTotalNC.EditValue = TextUtils.ToDecimal(dt.Rows[17]["F7"]); txtTotalPB.EditValue = TextUtils.ToDecimal(dt.Rows[18]["F7"]); txtTotalProfit.EditValue = TextUtils.ToDecimal(dt.Rows[20]["F7"]); txtTotalReal.EditValue = TextUtils.ToDecimal(dt.Rows[15]["F7"]); txtTotalTPA.EditValue = TextUtils.ToDecimal(dt.Rows[13]["F7"]); txtTotalTrienKhai.EditValue = TextUtils.ToDecimal(dt.Rows[16]["F7"]); txtTotalVAT.EditValue = TextUtils.ToDecimal(dt.Rows[14]["F7"]); txtTotalVT.EditValue = TextUtils.ToDecimal(dt.Rows[22]["F7"]); drs = dt.Select("F2 is not null and F2 like 'C%'"); colCode.FieldName = "F2"; } if (drs.Length > 0) { dt = drs.CopyToDataTable(); } dt.Columns.Add("DepartmentID", typeof(int)); foreach (DataRow row in dt.Rows) { string kmpCode = ""; if (TextUtils.ToInt(cboPhongBan.SelectedValue) == 40) { kmpCode = TextUtils.ToString(row["F3"]); } else { kmpCode = TextUtils.ToString(row["F2"]); } DataTable dtKMP = LibIE.Select("select top 1 [PK_ID],[C_ISKD] from T_DM_KMP where C_MA = '" + kmpCode + "'"); if (dtKMP.Rows.Count == 0) { continue; } int isKD = TextUtils.ToInt(dtKMP.Rows[0]["C_ISKD"]); int pk_KMP = TextUtils.ToInt(dtKMP.Rows[0]["PK_ID"]); if (isKD == 1) { row["DepartmentID"] = TextUtils.ToInt(cboPhongBan.SelectedValue); } else { int pk_PhanXuong = TextUtils.ToInt(LibIE.ExcuteScalar("select top 1 [PK_PHANXUONG] from T_DM_PHANXUONG_KMP_Link where [PK_KMP] = " + pk_KMP)); if (pk_PhanXuong == 0) { continue; } row["DepartmentID"] = pk_PhanXuong; } } grdData.DataSource = dt; } } }