Exemple #1
0
        public void PopulateBOQSummaryControl()
        {
            this.Cursor = Cursors.WaitCursor;
            try
            {
                ServiceSalesQuotationBOQ _service = new ServiceSalesQuotationBOQ();
                _service.UpdateSalesQuotationBOQSummary(this.BOQ_MODEL);
                gridBOQSheets.DataSource = BOQ_MODEL.SUMMARY.datatableBOQSheets;

                gridBOQSheets.Columns[_service.COL_BOQ_SUMMARY_SRNO].Width = 100;
                gridBOQSheets.Columns[_service.COL_BOQ_SUMMARY_MATERIAL_TOTAL].HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight;
                gridBOQSheets.Columns[_service.COL_BOQ_SUMMARY_MATERIAL_TOTAL].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
                gridBOQSheets.Columns[_service.COL_BOQ_SUMMARY_MATERIAL_TOTAL].DefaultCellStyle.Format    = "0.00";
                gridBOQSheets.Columns[_service.COL_BOQ_SUMMARY_MATERIAL_TOTAL].ValueType = typeof(double);
                gridBOQSheets.Columns[_service.COL_BOQ_SUMMARY_MATERIAL_TOTAL].Width     = (int)(gridBOQSheets.Width * .15);

                gridBOQSheets.Columns[_service.COL_BOQ_SUMMARY_INSTALLATION_TOTAL].HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight;
                gridBOQSheets.Columns[_service.COL_BOQ_SUMMARY_INSTALLATION_TOTAL].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
                gridBOQSheets.Columns[_service.COL_BOQ_SUMMARY_INSTALLATION_TOTAL].DefaultCellStyle.Format    = "0.00";
                gridBOQSheets.Columns[_service.COL_BOQ_SUMMARY_INSTALLATION_TOTAL].ValueType = typeof(double);
                gridBOQSheets.Columns[_service.COL_BOQ_SUMMARY_INSTALLATION_TOTAL].Width     = (int)(gridBOQSheets.Width * .15);


                gridBOQSheets.Columns[_service.COL_BOQ_SUMMARY_TOTAL].HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight;
                gridBOQSheets.Columns[_service.COL_BOQ_SUMMARY_TOTAL].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
                gridBOQSheets.Columns[_service.COL_BOQ_SUMMARY_TOTAL].DefaultCellStyle.Format    = "0.00";
                gridBOQSheets.Columns[_service.COL_BOQ_SUMMARY_TOTAL].ValueType = typeof(double);
                gridBOQSheets.Columns[_service.COL_BOQ_SUMMARY_TOTAL].Width     = (int)(gridBOQSheets.Width * .15);



                headerGroupMaterialSupply.ValuesPrimary.Heading = string.Format("{0:0.00}", BOQ_MODEL.SUMMARY.MaterialAmountForAllSheets);


                // MATERIAL SUPPLY DISCOUNT


                txtMaterialDiscountValue.Text = string.Format("{0:0.00}", BOQ_MODEL.SUMMARY.MaterialDiscount.ItemChargeValue);
                headerGroupMaterialDiscount.ValuesPrimary.Description = string.Format("{0:0.00}", BOQ_MODEL.SUMMARY.MaterialDiscountAmount);
                if (BOQ_MODEL.SUMMARY.MaterialDiscount.ItemChargeType == ITEM_CHARGE_TYPE.PERCENTAGE)
                {
                    rbtnMaterialDiscountPercent.Checked = true;
                }
                if (BOQ_MODEL.SUMMARY.MaterialDiscount.ItemChargeType == ITEM_CHARGE_TYPE.LUMPSUM)
                {
                    rbtnMaterialDiscountLumsum.Checked = true;
                }

                // MATERIAL SUPPLY GST

                txtMaterialCGSTPercent.Text = string.Format("{0:0.00}", BOQ_MODEL.SUMMARY.MaterialGST.CGST_PERCENT);
                txtMaterialSGSTPercent.Text = string.Format("{0:0.00}", BOQ_MODEL.SUMMARY.MaterialGST.SGST_PERCENT);
                txtMaterialIGSTPercent.Text = string.Format("{0:0.00}", BOQ_MODEL.SUMMARY.MaterialGST.IGST_PERCENT);
                headerGroupMaterialGST.ValuesPrimary.Description = string.Format("{0:0.00}", BOQ_MODEL.SUMMARY.MaterialGST.GST_TOTAL_AMOUNT);
                headerGroupMaterialGST.ValuesSecondary.Heading   = string.Format("SGST: {0:0.00}   CGST: {1:0.00}   IGST: {2:0.00}", BOQ_MODEL.SUMMARY.MaterialGST.SGST_AMOUNT, BOQ_MODEL.SUMMARY.MaterialGST.CGST_AMOUNT, BOQ_MODEL.SUMMARY.MaterialGST.IGST_AMOUNT);

                headerGroupMaterialSupply.ValuesSecondary.Description = string.Format("{0:0.00}", BOQ_MODEL.SUMMARY.MaterialFinalAmount);

                // INSTALLTATION AND SERVICES

                headerGroupInstallation.ValuesPrimary.Heading = string.Format("{0:0.00}", BOQ_MODEL.SUMMARY.InstallationAmountForAllSheets);
                // INSTALLATION DISCOUNT

                txtInstallationDiscountValue.Text = string.Format("{0:0.00}", BOQ_MODEL.SUMMARY.InstallationDiscount.ItemChargeValue);
                headerGroupInstallationDiscount.ValuesPrimary.Description = string.Format("{0:0.00}", BOQ_MODEL.SUMMARY.InstallationDiscountAmount);
                if (BOQ_MODEL.SUMMARY.InstallationDiscount.ItemChargeType == ITEM_CHARGE_TYPE.PERCENTAGE)
                {
                    rbtnInstallationDiscountPercent.Checked = true;
                }
                if (BOQ_MODEL.SUMMARY.InstallationDiscount.ItemChargeType == ITEM_CHARGE_TYPE.LUMPSUM)
                {
                    rbtnInstallationDiscountLumsum.Checked = true;
                }

                // INSTALLATION GST


                txtInstallationCGSTPercent.Text = string.Format("{0:0.00}", BOQ_MODEL.SUMMARY.InstallationGST.CGST_PERCENT);
                txtInstallationSGSTPercent.Text = string.Format("{0:0.00}", BOQ_MODEL.SUMMARY.InstallationGST.SGST_PERCENT);
                txtInstallationIGSTPercent.Text = string.Format("{0:0.00}", BOQ_MODEL.SUMMARY.InstallationGST.IGST_PERCENT);
                headerGroupInstallationGST.ValuesPrimary.Description = string.Format("{0:0.00}", BOQ_MODEL.SUMMARY.InstallationGST.GST_TOTAL_AMOUNT);
                headerGroupInstallationGST.ValuesSecondary.Heading   = string.Format("SGST: {0:0.00}   CGST: {1:0.00}   IGST: {2:0.00}", BOQ_MODEL.SUMMARY.InstallationGST.SGST_AMOUNT, BOQ_MODEL.SUMMARY.InstallationGST.CGST_AMOUNT, BOQ_MODEL.SUMMARY.InstallationGST.IGST_AMOUNT);

                headerGroupInstallation.ValuesSecondary.Description = string.Format("{0:0.00}", BOQ_MODEL.SUMMARY.InstallationFinalAmount);

                headerGroupMain.ValuesSecondary.Heading = string.Format("{0:0.00}", BOQ_MODEL.SUMMARY.QuotationFinalAmount);
            }
            catch (Exception ex)
            {
                string errMessage = ex.Message;
                if (ex.InnerException != null)
                {
                    errMessage += string.Format("\n{0}", ex.InnerException.Message);
                }
                MessageBox.Show(errMessage, "ControlSalesQuotationBOQSummary::PopulateBOQSummaryControl", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            this.Cursor = Cursors.Default;
        }
        public void PoulateSalesQuotationMasterInfo()
        {
            try
            {
                TBL_MP_CRM_SalesQuotation dbModel = (new ServiceSalesQuotation()).GetSalesQuotationMasterDBInfo(this.SelectedQuotationID);
                if (dbModel != null)
                {
                    txtSalesQuotationNo.Text   = dbModel.Quotation_No;
                    txtSalesQuotationDate.Text = dbModel.Quotation_Date.ToString("dd MMM yyyy");
                    txtSalesEnquiryNo.Text     = dbModel.TBL_MP_CRM_SalesEnquiry.SalesEnquiry_No;
                    txtSalesEnquiryDate.Text   = dbModel.TBL_MP_CRM_SalesEnquiry.SalesEnquiry_Date.ToString("dd MMM yyyy");
                    txtClientName.Text         = dbModel.Tbl_MP_Master_Party.PartyName;
                    txtRemarks.Text            = dbModel.Remarks;

                    // GETTING SALES QUOTATION STATUS
                    SelectListItem selStatus = (new ServiceSalesQuotation()).GetAllActiveQuotationStatusesList().Where(x => x.ID == dbModel.FK_Userlist_Quotation_Status_ID).FirstOrDefault();
                    if (selStatus != null)
                    {
                        lblQuotationStatus.Text = String.Format("STATUS : {0}", selStatus.Description);
                    }


                    ServiceEmployee        _empService = new ServiceEmployee();
                    TBL_MP_Master_Employee obj         = _empService.GetEmployeeDbRecordByID(dbModel.FK_RepresentativeID);
                    if (obj != null)
                    {
                        txtSalesRepresentativeName.Text = obj.EmployeeName;
                        lblSalesRepresentativeCode.Text = string.Format("Code: {0}", obj.EmployeeCode);
                    }
                    obj = _empService.GetEmployeeDbRecordByID(dbModel.FK_BOQRepresentativeID);
                    if (obj != null)
                    {
                        txtBOQRepresentativeName.Text = obj.EmployeeName;
                        lblBoqRepresentativeCode.Text = string.Format("Code: {0}", obj.EmployeeCode);
                    }
                    headerBottom.Values.Heading = string.Format("Created: {0} dt. {1}", ServiceEmployee.GetEmployeeNameByID(dbModel.FK_PreparedBy), dbModel.CreatedDatetime);
                    if (dbModel.LastModifiedBy != null)
                    {
                        headerBottom.Values.Description = string.Format("Modified: {0} dt. {1}", ServiceEmployee.GetEmployeeNameByID((int)dbModel.LastModifiedBy), dbModel.LastModifiedDate);
                    }
                    else
                    {
                        headerBottom.Values.Description = string.Empty;
                    }

                    lblQuotationApprovalInfo.Text = "Unapproved Quotation";
                    lblQuotationApprovalInfo.StateCommon.Back.Color1 = (dbModel.FK_ApprovedBy == null) ? Color.Red : Color.Green;
                    WhosWhoModel premission = Program.CONTROL_ACCESS.ListControlAccess.Where(x => x.FormID == DB_FORM_IDs.SALES_QUOTATION).FirstOrDefault();
                    if (premission != null)
                    {
                        if (premission.CanApprove)
                        {
                            if (dbModel.FK_ApprovedBy == null)
                            {
                                btnApprove.Visible = true;
                            }
                            else
                            {
                                lblQuotationApprovalInfo.Text = string.Format("Approved: {0}", ServiceEmployee.GetEmployeeNameByID((int)dbModel.FK_ApprovedBy));
                                btnApprove.Visible            = false;
                            }
                        }
                        else
                        {
                            btnApprove.Visible = false;
                        }
                    }
                }

                ServiceSalesQuotationBOQ _service = new ServiceSalesQuotationBOQ();
                SalesQuotationBOQSummary model    = _service.GetQuotationBOQSummaryForQuotationID(this.SelectedQuotationID);
                if (model != null)
                {
                    PopulateBOQSummary(model);
                }
            }
            catch (Exception ex)
            {
                string errMessage = ex.Message;
                if (ex.InnerException != null)
                {
                    errMessage += string.Format("\n{0}", ex.InnerException.Message);
                }
                MessageBox.Show(errMessage, "ControlSalesQuotaionGeneralDetails::PoulateSalesQuotationMasterInfo", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }