Exemple #1
0
        public void PopulateProjectGeneralInfo()
        {
            this.Cursor = Cursors.WaitCursor;
            Application.UseWaitCursor = true;
            ServiceProject _service = new ServiceProject();

            try
            {
                SelectListItem           selItem = null;
                List <SelectListItem>    lst     = _service.GetAllProjectStatuses();
                TBL_MP_PMC_ProjectMaster model   = (new ServiceProject()).GetProjectDBInfoByID(this.SelectedProjectID);

                if (model != null)
                {
                    headerGroupMain.ValuesPrimary.Heading = model.ProjectNumber;
                    selItem        = lst.Where(x => x.ID == model.FK_ProjectStatusID).FirstOrDefault();
                    txtStatus.Text = selItem.Description;

                    txtProjectNo.Text        = model.ProjectNumber;
                    txtProjectName.Text      = model.ProjectName;
                    dtProjectDate.Value      = (DateTime)model.ProjectDate;
                    dtProjectStartDate.Value = (DateTime)model.StartDate;
                    dtProjectEndDate.Value   = (DateTime)model.EndDate;

                    // txtBillingAddress.Text = Project_generalInfo.BillingClientAddressID.ToString();
                    // txtClientAddress.Text = Project_generalInfo.SiteClientAddressID.ToString();
                    ServiceProject serviceProject = new ServiceProject();
                    txtBillingAddress.Text   = serviceProject.GetProjectBillingAddress((int)model.PK_ProjectID);
                    txtClientAddress.Text    = serviceProject.GetProjectSiteAddress((int)model.PK_ProjectID);
                    lblCreatedDateTime.Text  = model.CreatedDatetime.ToString();
                    lblModifiedDateTime.Text = model.ModifiedDatetime.ToString();
                    ServiceEmployee       emp  = new ServiceEmployee();
                    List <SelectListItem> lst1 = emp.GetAllEmployees();
                    selItem           = lst1.Where(x => x.ID == model.CreatedBy).FirstOrDefault();
                    lblCreatedBy.Text = selItem.Description;
                    List <SelectListItem> lst2 = emp.GetAllEmployees();
                    selItem            = lst2.Where(x => x.ID == model.ModifiedBy).FirstOrDefault();
                    lblModifiedBy.Text = selItem.Description;

                    TBL_MP_Admin_Company_Master myComp = (new ServiceMASTERS()).MyCompanyInfo();
                    if (myComp != null)
                    {
                        txtCompanyAddress.Text = myComp.Address;
                    }
                }
                else
                {
                    txtProjectNo.Text          = txtProjectName.Text = txtStatus.Text =
                        txtBillingAddress.Text = txtClientAddress.Text = txtCompanyAddress.Text = string.Empty;
                    dtProjectDate.Checked      = dtProjectStartDate.Checked = dtProjectEndDate.Checked = false;
                }
            }
            catch (Exception ex)
            {
                string errMessage = ex.Message;
                if (ex.InnerException != null)
                {
                    errMessage += string.Format("\n{0}", ex.InnerException.Message);
                }
                MessageBox.Show(errMessage, "ControlProjectGeneralInfo::PopulateProjectGeneralInfo", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            this.Cursor = Cursors.Default;
            Application.UseWaitCursor = false;
        }
        public void PopulateSalesOrderGeneralInfo()
        {
            this.Cursor = Cursors.WaitCursor;
            ServiceSalesOrder _service = new ServiceSalesOrder();

            try
            {
                //btnApproveSO.Visible = true;
                DoBlanks();
                SelectListItem        selItem = null;
                List <SelectListItem> lst     = _service.GetAllSalesOrderStatuses();

                TBL_MP_CRM_SalesOrder model = (new ServiceSalesOrder()).GetSalesOrderDBInfoByID(SelectedSalesOrderID);
                if (model != null)
                {
                    headerGroupMain.ValuesPrimary.Heading = model.SalesOrderNo;
                    //  lblSOApprovalInfo.Text =model.FK_ApprovedBy.ToString();
                    // lblSOApprovalInfo.StateCommon.Back.Color1 = (model.IsApproved) ? Color.Green : Color.Red;


                    selItem          = lst.Where(x => x.ID == model.FK_SalesOrderStatus).FirstOrDefault();
                    txtSOStatus.Text = selItem.Description;

                    lst              = (new ServiceMASTERS()).GetAllPOSources();
                    selItem          = lst.Where(x => x.ID == model.FK_POSource).FirstOrDefault();
                    txtPOSource.Text = selItem.Description;

                    if (model.MaterialSupplyPONo != null)
                    {
                        txtMaterialSupplyInfo.Text = string.Format("{0} dt. {1}\nfor {2} days till {3}",
                                                                   model.MaterialSupplyPONo,
                                                                   ((DateTime)model.MaterialSupplyPODate).ToString("dd MMM yyyy"),
                                                                   model.MaterialSupplyPOValidDays,
                                                                   ((DateTime)model.MaterialSupplyPOExpiryDate).ToString("dd/MM/yy"));
                    }


                    if (model.InstallationServicePONo != null)
                    {
                        txtInstallationServicesInfo.Text = string.Format("{0} dt. {1}\nfor {2} days till {3}",
                                                                         model.InstallationServicePONo,
                                                                         ((DateTime)model.InstallationServicePODate).ToString("dd MMM yyyy"),
                                                                         model.InstallationServicePOValidDays,
                                                                         ((DateTime)model.InstallationServicePOExpiryDate).ToString("dd/MM/yy"));
                    }
                    if (model.FK_ClientID != null)
                    {
                        txtClientName.Text = String.Format("{0} ({1}) ",
                                                           model.Tbl_MP_Master_Party.PartyName,
                                                           model.Tbl_MP_Master_Party.PartyCode);
                    }
                    if (model.FK_QuotationID != null)
                    {
                        txtQuotationInfo.Text = String.Format("{0} dt. {1} ",
                                                              model.TBL_MP_CRM_SalesQuotation.Quotation_No,
                                                              model.TBL_MP_CRM_SalesQuotation.Quotation_Date.ToString("dd MMM yyyy"));
                    }

                    if (model.FK_ProjectID != null)
                    {
                        headerProject.Values.Heading = "PROJECT: " + model.TBL_MP_PMC_ProjectMaster.ProjectNumber;
                        txtProjectName.Text          = model.TBL_MP_PMC_ProjectMaster.ProjectName;
                        txtStartDate.Text            = model.TBL_MP_PMC_ProjectMaster.StartDate.ToString("dd MMM yyyy");
                        txtEndDate.Text = model.TBL_MP_PMC_ProjectMaster.EndDate.ToString("dd MMM yyyy");
                        ServiceProject serviceProject = new ServiceProject();
                        txtBillingAddress.Text = serviceProject.GetProjectBillingAddress((int)model.FK_ProjectID);
                        txtSiteAddr.Text       = serviceProject.GetProjectSiteAddress((int)model.FK_ProjectID);
                    }

                    if (model.FK_ApprovedBy == null)
                    {
                        lblSOApprovalInfo.Text = "UN-APPROVED";
                        lblSOApprovalInfo.StateCommon.Back.Color1 = Color.Red;
                    }
                    else
                    {
                        lblSOApprovalInfo.Text = string.Format("APPROVED : {0}", ServiceEmployee.GetEmployeeNameByID((int)model.FK_ApprovedBy));
                        lblSOApprovalInfo.StateCommon.Back.Color1 = Color.Green;
                    }

                    if (!ReadOnly)
                    {
                        WhosWhoModel modell = Program.CONTROL_ACCESS.ListControlAccess.Where(x => x.FormID == this.SALES_ORDER_FORM_ID).FirstOrDefault();
                        if (modell != null)
                        {
                            if (modell.CanApprove)
                            {
                                if (model.FK_ApprovedBy == null)
                                {
                                    btnApproveSO.Visible = true;
                                }
                                else
                                {
                                    btnApproveSO.Visible = false;
                                }
                            }
                            else
                            {
                                btnApproveSO.Visible = false;
                            }
                        }
                    }

                    /*
                     * lblSOApprovalInfo.Text = "Unapproved Order";
                     * lblSOApprovalInfo.StateCommon.Back.Color1 = (model.FK_ApprovedBy == null) ? Color.Red : Color.Green;
                     * WhosWhoModel premission = Program.CONTROL_ACCESS.ListControlAccess.Where(x => x.FormID == DB_FORM_IDs.SALES_ORDER).FirstOrDefault();
                     * if (premission != null)
                     * {
                     *   if (premission.CanApprove)
                     *       if (model.FK_ApprovedBy == null)
                     *           btnApproveSO.Visible = true;
                     *       else
                     *       {
                     *           lblSOApprovalInfo.Text = string.Format("Approved: {0}", ServiceEmployee.GetEmployeeNameByID((int)model.FK_ApprovedBy));
                     *           btnApproveSO.Visible = false;
                     *       }
                     *   else
                     *       btnApproveSO.Visible = false;
                     * }
                     */
                }
            }
            catch (Exception ex)
            {
                string errMessage = ex.Message;
                if (ex.InnerException != null)
                {
                    errMessage += string.Format("\n{0}", ex.InnerException.Message);
                }
                MessageBox.Show(ex.Message, "ControlSalesOrderGeneralInfo::PopulateSalesOrderGeneralInfo", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            this.Cursor = Cursors.Default;
        }