コード例 #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (cboModule.EditValue == null)
            {
                MessageBox.Show("Bạn phải chọn một module!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            try
            {
                grvCost.FocusedRowHandle = grvCostTM.FocusedRowHandle = -1;

                #region Chi phí sản xuất
                if (grvCost.RowCount > 0)
                {
                    for (int i = 0; i < grvCost.RowCount; i++)
                    {
                        int thisDepartmentID    = TextUtils.ToInt(grvCost.GetRowCellValue(i, colDepartmentID));
                        int defaultDepartmentID = TextUtils.ToInt(grvCost.GetRowCellValue(i, colDID));
                        if (thisDepartmentID == defaultDepartmentID)
                        {
                            continue;
                        }

                        CostSummaryModuleModel sxModel = new CostSummaryModuleModel();
                        int sxID = TextUtils.ToInt(grvCost.GetRowCellValue(i, colID));
                        if (sxID > 0)
                        {
                            sxModel = (CostSummaryModuleModel)CostSummaryModuleBO.Instance.FindByPK(sxID);
                        }

                        sxModel.CostDetailID = TextUtils.ToInt(grvCost.GetRowCellValue(i, colCostDetailID));
                        sxModel.BaoGiaID     = BaoGia.ID;
                        sxModel.DepartmentID = TextUtils.ToInt(grvCost.GetRowCellValue(i, colDepartmentID));
                        sxModel.ModuleCode   = cboModule.EditValue.ToString();

                        if (sxID > 0)
                        {
                            CostSummaryModuleBO.Instance.Update(sxModel);
                        }
                        else
                        {
                            CostSummaryModuleBO.Instance.Insert(sxModel);
                        }
                    }
                }
                #endregion

                #region Chi phí thương mại
                if (grvCostTM.RowCount > 0)
                {
                    for (int i = 0; i < grvCostTM.RowCount; i++)
                    {
                        int thisDepartmentID    = TextUtils.ToInt(grvCostTM.GetRowCellValue(i, colDepartmentIDTM));
                        int defaultDepartmentID = TextUtils.ToInt(grvCostTM.GetRowCellValue(i, colDIDTM));
                        if (thisDepartmentID == defaultDepartmentID)
                        {
                            continue;
                        }

                        CostSummaryModuleModel tmModel = new CostSummaryModuleModel();
                        int tmID = TextUtils.ToInt(grvCostTM.GetRowCellValue(i, colIDTM));
                        if (tmID > 0)
                        {
                            tmModel = (CostSummaryModuleModel)CostSummaryModuleBO.Instance.FindByPK(tmID);
                        }

                        tmModel.CostDetailID = TextUtils.ToInt(grvCostTM.GetRowCellValue(i, colCostDetailIDTM));
                        tmModel.BaoGiaID     = BaoGia.ID;
                        tmModel.DepartmentID = TextUtils.ToInt(grvCostTM.GetRowCellValue(i, colDepartmentIDTM));
                        tmModel.ModuleCode   = cboModule.EditValue.ToString();

                        if (tmID > 0)
                        {
                            CostSummaryModuleBO.Instance.Update(tmModel);
                        }
                        else
                        {
                            CostSummaryModuleBO.Instance.Insert(tmModel);
                        }
                    }
                }
                #endregion

                #region Update Báo giá
                //BaoGia.TotalPhatSinh = TextUtils.ToDecimal(colDiffPrice.SummaryItem.SummaryValue);
                BaoGia.TotalSX   = TextUtils.ToDecimal(colTotal.SummaryItem.SummaryValue);
                BaoGia.TotalDkSX = TextUtils.ToDecimal(colTotalReal.SummaryItem.SummaryValue);
                BaoGia.TotalTM   = TextUtils.ToDecimal(colTotalTM.SummaryItem.SummaryValue);
                BaoGia.TotalDkTM = TextUtils.ToDecimal(colTotalRealTM.SummaryItem.SummaryValue);
                BaoGiaBO.Instance.Update(BaoGia);
                #endregion
            }
            catch (Exception ex)
            {
                MessageBox.Show("Lỗi: " + ex.Message, TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            MessageBox.Show("Ghi dữ liệu thành công!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
コード例 #2
0
 protected CostSummaryModuleFacade(CostSummaryModuleModel model) : base(model)
 {
 }