Exemplo n.º 1
0
        private void gridRoles_RowEnter(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                if (e.RowIndex >= 0)
                {
                    SelectedRoleID = (int)gridRoles.Rows[e.RowIndex].Cells["ID"].Value;
                    headerGroupModule.ValuesPrimary.Heading = string.Format("[{0}] - Accessible Modules", gridRoles.Rows[e.RowIndex].Cells["Description"].Value);
                    PopulateRoleModules();
                }

                headerGroupDeleteRole.ValuesPrimary.Heading = string.Empty;
                txtDeleteRoleInfo.Text = string.Empty;

                bool isactive = (bool)gridRoles.Rows[e.RowIndex].Cells["IsActive"].Value;
                if (isactive)
                {
                    btnAddNewRole.Enabled  = ComponentFactory.Krypton.Toolkit.ButtonEnabled.True;
                    btnEditRole.Enabled    = ComponentFactory.Krypton.Toolkit.ButtonEnabled.True;
                    btnDeleteRole.Enabled  = ComponentFactory.Krypton.Toolkit.ButtonEnabled.True;
                    btnRestoreRole.Enabled = ComponentFactory.Krypton.Toolkit.ButtonEnabled.False;

                    headerGroupModule.Enabled = headerGroupForms.Enabled = true;
                }
                else
                {
                    btnAddNewRole.Enabled  = ComponentFactory.Krypton.Toolkit.ButtonEnabled.False;
                    btnEditRole.Enabled    = ComponentFactory.Krypton.Toolkit.ButtonEnabled.False;
                    btnDeleteRole.Enabled  = ComponentFactory.Krypton.Toolkit.ButtonEnabled.False;
                    btnRestoreRole.Enabled = ComponentFactory.Krypton.Toolkit.ButtonEnabled.True;

                    headerGroupModule.Enabled = headerGroupForms.Enabled = false;
                }

                TBL_MP_Master_Role dbRole = (new ServiceRoles()).GetRoleDBRecordByID(this.SelectedRoleID);
                if (dbRole != null)
                {
                    if (dbRole.DeletedBy != null)
                    {
                        string empName = ServiceEmployee.GetEmployeeNameByID((int)dbRole.DeletedBy);
                        headerGroupDeleteRole.ValuesPrimary.Heading = string.Format("Deleted by {0} dt. {1}", empName, dbRole.DeleteDatetime.Value.ToString("dd MMM yy hh:mmtt"));
                    }
                    txtDeleteRoleInfo.Text = dbRole.DeleteRemarks;
                }
            }
            catch (Exception ex)
            {
                string errMessage = ex.Message;
                if (ex.InnerException != null)
                {
                    errMessage += string.Format("\n{0}", ex.InnerException.Message);
                }
                MessageBox.Show(errMessage, "pageRoleManager::gridRoles_RowEnter", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 2
0
        public async Task <bool> SendEmail(int fromEmpID, String msgFrom, string msgTo, string Subject, string msgBody)
        {
            MailMessage mailMessage     = new MailMessage();
            string      strPassword     = ServiceEmployee.GetEmailPasswordForEmployee(fromEmpID);
            string      strEmailAddress = ServiceEmployee.GetEmployeeEmailByID(fromEmpID);
            string      strEmpName      = ServiceEmployee.GetEmployeeNameByID(fromEmpID);

            if (strPassword == string.Empty)
            {
                MessageBox.Show("You cannot send Emails, unless you set your valid Password.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }


            if (!new EmailAddressAttribute().IsValid(strEmailAddress))
            {
                MessageBox.Show("It appears that you have not set your Email Address in the Employee database or is Invalid.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
            mailMessage.From = new MailAddress(strEmailAddress, strEmpName);
            foreach (var address in msgTo.Split(new[] { ";" }, StringSplitOptions.RemoveEmptyEntries))
            {
                if (new EmailAddressAttribute().IsValid(address))
                {
                    mailMessage.To.Add(address);
                }
            }
            if (mailMessage.To.Count == 0)
            {
                MessageBox.Show("Invalid number of Recipients or Invalid Email Address", "Terminating", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }

            mailMessage.Subject    = Subject;
            mailMessage.Body       = msgBody;
            mailMessage.IsBodyHtml = false;

            //SmtpClient smtp = new SmtpClient(Properties.Settings.Default.EMAIL_SERVER.ToString());
            //smtp.Port = int.Parse(Properties.Settings.Default.EMAIL_PORT.ToString());
            //smtp.Credentials = new NetworkCredential(strEmailAddress, strPassword);
            //smtp.EnableSsl = Properties.Settings.Default.EMAIL_ENABLE_SSL;
            SmtpClient smtp = new SmtpClient(ConfigurationManager.AppSettings["EMAIL_SERVER"].ToString());

            smtp.Port        = int.Parse(ConfigurationManager.AppSettings["EMAIL_PORT"].ToString());
            smtp.Credentials = new NetworkCredential(strEmailAddress, strPassword);
            smtp.EnableSsl   = (ConfigurationManager.AppSettings["EMAIL_ENABLE_SSL"].ToString() == "True") ? true : false;



            await smtp.SendMailAsync(mailMessage);

            return(true);
        }
Exemplo n.º 3
0
        private void gridModules_RowEnter(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                headerGroupDeleteModule.ValuesPrimary.Heading = string.Empty;
                txtDeleteModuleInfo.Text = string.Empty;

                if (e.RowIndex >= 0)
                {
                    SelectedModuleID = (int)gridModules.Rows[e.RowIndex].Cells["ID"].Value;
                    PopulateForms();
                }
                bool isactive = (bool)gridModules.Rows[e.RowIndex].Cells["IsActive"].Value;
                if (isactive)
                {
                    btnRestoreModule.Enabled = ComponentFactory.Krypton.Toolkit.ButtonEnabled.False;
                    btnEditModule.Enabled    = ComponentFactory.Krypton.Toolkit.ButtonEnabled.True;
                    btnDeleteModule.Enabled  = ComponentFactory.Krypton.Toolkit.ButtonEnabled.True;

                    btnAddNewForm.Enabled  = ComponentFactory.Krypton.Toolkit.ButtonEnabled.True;
                    btnEditForm.Enabled    = ComponentFactory.Krypton.Toolkit.ButtonEnabled.True;
                    btnDeleteForm.Enabled  = ComponentFactory.Krypton.Toolkit.ButtonEnabled.True;
                    btnRestoreForm.Enabled = ComponentFactory.Krypton.Toolkit.ButtonEnabled.False;
                }
                else
                {
                    btnRestoreModule.Enabled = ComponentFactory.Krypton.Toolkit.ButtonEnabled.True;
                    btnEditModule.Enabled    = ComponentFactory.Krypton.Toolkit.ButtonEnabled.False;
                    btnDeleteModule.Enabled  = ComponentFactory.Krypton.Toolkit.ButtonEnabled.False;

                    btnAddNewForm.Enabled  = ComponentFactory.Krypton.Toolkit.ButtonEnabled.False;
                    btnEditForm.Enabled    = ComponentFactory.Krypton.Toolkit.ButtonEnabled.False;
                    btnDeleteForm.Enabled  = ComponentFactory.Krypton.Toolkit.ButtonEnabled.False;
                    btnRestoreForm.Enabled = ComponentFactory.Krypton.Toolkit.ButtonEnabled.False;
                }

                Tbl_MP_Master_Module dbModule = (new ServiceModules()).GetModuleDBRecordByID(this.SelectedModuleID);
                if (dbModule != null)
                {
                    if (dbModule.DeletedBy != null)
                    {
                        string empName = ServiceEmployee.GetEmployeeNameByID((int)dbModule.DeletedBy);
                        headerGroupDeleteModule.ValuesPrimary.Heading = string.Format("Deleted by {0} dt. {1}", empName, dbModule.DeleteDatetime.Value.ToString("dd MMM yy hh:mmtt"));
                    }
                    txtDeleteModuleInfo.Text = dbModule.DeleteRemarks;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "pageModules::gridModules_RowEnter", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 4
0
 public void ScatterData()
 {
     try
     {
         TBL_MP_Master_Employee_LeaveConfiguration model = (new ServiceEmployee()).GetEmpLeaveInfoDbRecord(this.PK_LeaveID);
         if (model != null)
         {
             if (EmployeeID != 0)
             {
                 headerEmployeeName.Values.Description = ServiceEmployee.GetEmployeeNameByID(model.FK_EmployeeID);
             }
             txtLimitDays.Text                    = model.CarryForwardLimitDays.ToString();
             txtMaxDaysallow.Text                 = model.MaxDaysAllow.ToString();
             cboLeaveType.SelectedItem            = ((List <SelectListItem>)cboLeaveType.DataSource).Where(x => x.ID == model.FK_LeaveTypeID).FirstOrDefault();
             chkApplicableProbationPeriod.Checked = model.ApplicableInProbation;
             chkLeaveCarryForward.Checked         = model.CarryForwardLeave;
             chkLeaveEncashable.Checked           = model.LeaveEnchashable;
             txtLeaveOpeningBalance.Text          = model.LeavesEarned.ToString();
             chkIsActive.Checked                  = model.IsActive;
             this.SeledctedYearID                 = model.FK_FinYearID;
             if (this.SeledctedYearID != 0)
             {
                 cboYear.SelectedItem = ((List <SelectListItem>)cboYear.DataSource).Where(x => x.ID == this.SeledctedYearID).FirstOrDefault();
             }
             if (model.LeaveEnchashable)
             {
                 string[] IDs = model.EncashableSalaryHeadIDs.Split(',');
                 foreach (string headID in IDs)
                 {
                     foreach (DataGridViewRow mRow in gridAllounces.Rows)
                     {
                         if (mRow.Cells["ID"].Value.ToString().Trim() == headID.Trim())
                         {
                             mRow.Cells["IsActive"].Value = true;
                         }
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         string errMessage = ex.Message;
         if (ex.InnerException != null)
         {
             errMessage += string.Format("\n{0}", ex.InnerException.Message);
         }
         MessageBox.Show(errMessage, "frmAddEditEmployeeLeaveConfig::ScatterData", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Exemplo n.º 5
0
 public void SetDefaultNew()
 {
     try
     {
         int leadStatusOpen = Program.LIST_DEFAULTS[(int)APP_DEFAULT_VALUES.DefaultLeadStatusID].DEFAULT_VALUE;
         int currID         = Program.LIST_DEFAULTS[(int)APP_DEFAULT_VALUES.DefaultCurrencyID].DEFAULT_VALUE;
         cboAgencies.Enabled             = btnAddAgency.Enabled = false;
         cboSalesLeadStatus.SelectedItem = ((List <SelectListItem>)cboSalesLeadStatus.DataSource).Where(x => x.ID == leadStatusOpen).FirstOrDefault();
         cboCurrency.SelectedItem        = ((List <SelectListItem>)cboCurrency.DataSource).Where(x => x.ID == currID).FirstOrDefault();
         txtGeneratedBy.Text             = ServiceEmployee.GetEmployeeNameByID(Program.CURR_USER.EmployeeID);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "frmSalesLead::SetDefaultNew", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
        public void PrepareCalendarSummary()
        {
            try
            {
                headerGroupMain.ValuesPrimary.Heading = string.Format("Attendance {1} {0}",
                                                                      ServiceEmployee.GetEmployeeNameByID(this.EmployeeID),
                                                                      AttendanceMonth.ToString("MMMM yyyy"));

                lblTotalDays.Text = lblNonWorkingDays.Text = lblPaidDays.Text = string.Empty;
                lblPL.Text        = lblCL.Text = lblSL.Text = lblCompOff.Text = string.Empty;
                lblPresent.Text   = lblAbsent.Text = lblOutdoor.Text = lblLateComing.Text = lblEarlyLeaving.Text = string.Empty;

                MODEL = (new ServiceAttendance()).GetAttendanceSummaryOfEmployeeForMonth(this.EmployeeID, this.AttendanceMonth);
                if (MODEL != null)
                {
                    lblTotalDays.Text      = MODEL.TotalDays.Text;
                    lblNonWorkingDays.Text = MODEL.NonWorkingDays.Text;
                    lblPaidDays.Text       = MODEL.PaidDays.Text;
                    if (MODEL.PaidDays.Days > MODEL.TotalDays.Days)
                    {
                        lblPaidDays.Text = MODEL.TotalDays.Text;
                    }
                    lblPL.Text           = MODEL.PLs.Text;
                    lblCL.Text           = MODEL.CLs.Text;
                    lblSL.Text           = MODEL.SLs.Text;
                    lblCompOff.Text      = MODEL.CompOffs.Text;
                    lblPresent.Text      = MODEL.Present.Text;
                    lblAbsent.Text       = MODEL.Absent.Text;
                    lblOutdoor.Text      = MODEL.Outdoor.Text;
                    lblLateComing.Text   = MODEL.LateComings.Text;
                    lblEarlyLeaving.Text = MODEL.EarlyGoings.Text;
                }
            }
            catch (Exception ex)
            {
                string errMessage = ex.Message;
                if (ex.InnerException != null)
                {
                    errMessage += string.Format("\n{0}", ex.InnerException.Message);
                }
                MessageBox.Show(errMessage, "ControlEmployeeAttendanceSummary::PrepareCalendarSummary", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 7
0
        private void frmAddEditEmployeeLeaveConfig_Load(object sender, EventArgs e)
        {
            try
            {
                PopulateFinancialYearDropdown();
                PopulateleaveTypeDropDown();
                PopulateAllounceSalaryHeads();
                if (PK_LeaveID == 0)
                {
                    if (EmployeeID != 0)
                    {
                        headerEmployeeName.Values.Description = ServiceEmployee.GetEmployeeNameByID(this.EmployeeID);
                    }
                    txtLimitDays.Text            = txtMaxDaysallow.Text = String.Empty;
                    chkLeaveCarryForward.Checked = chkApplicableProbationPeriod.Checked = chkLeaveEncashable.Checked = false;
                    chkIsActive.Checked          = true;

                    if (this.SeledctedYearID != 0)
                    {
                        cboYear.SelectedItem = ((List <SelectListItem>)cboYear.DataSource).Where(x => x.ID == this.SeledctedYearID).FirstOrDefault();
                    }
                }
                else
                {
                    ScatterData();
                }
            }
            catch (Exception ex)
            {
                string errMessage = ex.Message;
                if (ex.InnerException != null)
                {
                    errMessage += string.Format("\n{0}", ex.InnerException.Message);
                }
                MessageBox.Show(errMessage, "frmAddEditEmployeeLeaveConfig::frmAddEditEmployeeLeaveConfig_Load", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 8
0
        private void btnSearchGeneratedBy_Click(object sender, EventArgs e)
        {
            frmGridMultiSelect frm = null;

            switch (_EnqGeneratedBy)
            {
            case "A":
                frm = new frmGridMultiSelect(APP_ENTITIES.AGENTS, APP_ENTITIES.none, 0);
                frm.SingleSelect = true;
                if (frm.ShowDialog() == DialogResult.OK)
                {
                    BindingList <MultiSelectListItem> selectedIDs = frm.SelectedItems;
                    if (selectedIDs != null)
                    {
                        this.GeneratorEmployeeID = 0;
                        this.GeneratorAgentID    = selectedIDs[0].ID;
                        txtGeneratdBy.Text       = _UNIT.PartiesService.GetPartyNameByPartyID(GeneratorAgentID);
                    }
                }
                break;

            case "E":
                frm = new frmGridMultiSelect(APP_ENTITIES.EMPLOYEES, APP_ENTITIES.none, 0);
                frm.SingleSelect = true;
                if (frm.ShowDialog() == DialogResult.OK)
                {
                    BindingList <MultiSelectListItem> selectedIDs = frm.SelectedItems;
                    if (selectedIDs != null)
                    {
                        this.GeneratorEmployeeID = selectedIDs[0].ID;
                        this.GeneratorAgentID    = 0;
                        txtGeneratdBy.Text       = ServiceEmployee.GetEmployeeNameByID(GeneratorEmployeeID);
                    }
                }
                break;
            }
        }
        public void PopulateAdditionalInfo()
        {
            pictureBoxItemImage.Image = null;
            btnUploadPicture.Enabled  = ButtonEnabled.False;
            txtCreatedBy.Text         = txtModifiedBy.Text = lblBaseUOM.Text = lblPurchaseUOM.Text = string.Empty;
            try
            {
                TBL_MP_Master_Item item = (new ServiceInventoryItems()).GetItemDBRecord(this.SelectedItemID);
                if (item != null)
                {
                    ServiceEmployee _serviceEmp = new ServiceEmployee();
                    if (item.CreatedBy != null)
                    {
                        txtCreatedBy.Text = string.Format("{0}\n{1}", ServiceEmployee.GetEmployeeNameByID((int)item.CreatedBy), item.CreatedDatetime.Value.ToString("dd MMM yy hh:mmtt"));
                    }
                    if (item.LastModifiedBy != null)
                    {
                        txtModifiedBy.Text = string.Format("{0}\n{1}", ServiceEmployee.GetEmployeeNameByID((int)item.LastModifiedBy), item.LastModifiedDate.Value.ToString("dd MMM yy hh:mmtt"));
                    }

                    List <SelectListItem> lstUOMs = (new ServiceMASTERS()).GetAllUOMs();
                    if (item.Fk_UserList_BaseUOM_ID != null)
                    {
                        lblBaseUOM.Text = string.Format("Base UOM : {0}", lstUOMs.Where(x => x.ID == item.Fk_UserList_BaseUOM_ID).FirstOrDefault().Description);
                    }
                    if (item.Fk_UserList_PurchaseUOM_ID != null)
                    {
                        lblPurchaseUOM.Text = string.Format("Purchase UOM : {0}", lstUOMs.Where(x => x.ID == item.Fk_UserList_PurchaseUOM_ID).FirstOrDefault().Description);
                    }


                    if (item.ImageFileName != null)
                    {
                        string filePath = string.Format("{0}{1}", AppCommon.GetInventoryItemImagePath(), item.ImageFileName);
                        if (File.Exists(filePath))
                        {
                            byte[] array = File.ReadAllBytes(filePath);
                            Bitmap image;
                            using (MemoryStream stream = new MemoryStream(array))
                            {
                                image = new Bitmap(stream);
                            }
                            pictureBoxItemImage.Image = image;
                        }
                    }


                    txtDeleteInfo.Text = string.Empty;
                    bool isActive = (bool)item.IsActive;
                    if (!isActive)
                    {
                        String empName = string.Empty;
                        string delDate = string.Empty;
                        if (item.DeletedBy != null)
                        {
                            empName = ServiceEmployee.GetEmployeeNameByID((int)item.DeletedBy);
                        }
                        if (item.DeletedBy != null)
                        {
                            delDate = item.DeleteDatetime.Value.ToString("dd MMM yy hh:mmtt");
                        }
                        headerGroupDelete.ValuesPrimary.Heading = string.Format("DELETED : {0} DT. {1}", empName, delDate);
                        txtDeleteInfo.Text       = string.Format("{0}", item.DeleteRemarks);
                        btnUploadPicture.Enabled = ButtonEnabled.False;
                    }
                    else
                    {
                        btnUploadPicture.Enabled = ButtonEnabled.True;
                        headerGroupDelete.ValuesPrimary.Heading = string.Format("ACTIVE ITEM");
                        txtDeleteInfo.Text = string.Format("{0}", item.DeleteRemarks);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "ctrlInventoryItemAdditionalInfo::PopulateAdditionalInfo", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 10
0
 private void gridParties_RowEnter(object sender, DataGridViewCellEventArgs e)
 {
     try
     {
         if (e.RowIndex >= 0)
         {
             if (gridParties.Rows.Count > 0)
             {
                 txtRemarks.Text      = String.Empty;
                 this.SelectedPartyID = (int)gridParties.Rows[e.RowIndex].Cells["ID"].Value;
                 string[] arrString = gridParties.Rows[e.RowIndex].Cells["Description"].Value.ToString().Split('\n');
                 headerContacts.Values.Heading = string.Format("{0} Contacts", arrString[0]);
                 bool active = bool.Parse(gridParties.Rows[e.RowIndex].Cells["IsActive"].Value.ToString());
                 if (!active)
                 {
                     btnDeleteParty.Text    = "&Undelete Party";
                     btnEditParty.Enabled   = ComponentFactory.Krypton.Toolkit.ButtonEnabled.False;
                     headerContacts.Enabled = false;
                     Tbl_MP_Master_Party dbParty = (new ServiceParties()).GetPartyByPartyID(this.SelectedPartyID);
                     if (dbParty != null)
                     {
                         string strTitle = string.Empty;
                         if (dbParty.DeletedBy != null)
                         {
                             strTitle = string.Format("DELETED BY {0} DT. {1}", ServiceEmployee.GetEmployeeNameByID((int)dbParty.DeletedBy), dbParty.DeleteDateTime.Value.ToString("dd MMM yy HH:mmtt"));
                         }
                         headerGroupDelete.ValuesPrimary.Heading = strTitle;
                         txtRemarks.Text = dbParty.DeleteRemarks;
                     }
                 }
                 else
                 {
                     headerGroupDelete.ValuesPrimary.Heading = "ACTIVE PARTY";
                     btnDeleteParty.Text    = "&Delete Party";
                     btnEditParty.Enabled   = ComponentFactory.Krypton.Toolkit.ButtonEnabled.True;
                     headerContacts.Enabled = true;
                     Tbl_MP_Master_Party dbParty = (new ServiceParties()).GetPartyByPartyID(this.SelectedPartyID);
                     if (dbParty != null)
                     {
                         txtRemarks.Text = dbParty.DeleteRemarks;
                     }
                 }
                 OnPartySelectionchange();
             }
             SetPermissionwiseButtonStatus();
         }
     }
     catch (Exception ex)
     {
         string errMessage = ex.Message;
         if (ex.InnerException != null)
         {
             errMessage += string.Format("\n{0}", ex.InnerException.Message);
         }
         MessageBox.Show(errMessage, "PageParties::gridParties_RowEnter", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Exemplo n.º 11
0
        private void OnAttachmentSelectionChange()
        {
            try
            {
                if (this.SelectedAttachmentID != 0)
                {
                    btnUndeleteAtachment.Enabled = ComponentFactory.Krypton.Toolkit.ButtonEnabled.True;
                }
                switch (this.SELECTED_ENTITY_TYPE)
                {
                case APP_ENTITIES.INVENTORY_ITEM_ATTACHMENT:
                    TBL_MP_Master_Item_Attachments itemAttachment = (new ServiceInventoryItems()).GetInventoryItemAttachmentDBRecord(this.SelectedAttachmentID);
                    if (itemAttachment != null)
                    {
                        headerGroupDeleteInfo.ValuesPrimary.Heading = string.Format("DELETED BY {0} DT. {1}", ServiceEmployee.GetEmployeeNameByID((int)itemAttachment.DeletedBy), itemAttachment.DeleteDatetime.Value.ToString("dd MMM yy hh:mmtt"));
                        txtDeleteRemark.Text = itemAttachment.DeleteRemarks;
                    }
                    break;

                case APP_ENTITIES.SALES_LEAD_ATTACHMENT:
                    TBL_MP_CRM_SM_SalesLead_Attachment LeadAttachment = (new ServiceSalesLead()).GetSalesLeadAttachmentDBRecord(this.SelectedAttachmentID);
                    if (LeadAttachment != null)
                    {
                        headerGroupDeleteInfo.ValuesPrimary.Heading = string.Format("DELETED BY {0} DT. {1}", ServiceEmployee.GetEmployeeNameByID((int)LeadAttachment.DeletedBy), LeadAttachment.DeleteDatetime.Value.ToString("dd MMM yy hh:mmtt"));
                        txtDeleteRemark.Text = LeadAttachment.DeleteRemarks;
                    }
                    break;

                case APP_ENTITIES.SALES_ENQUIRY_ATTACHMENT:
                    TBL_MP_CRM_SalesEnquiry_Attachments EnqAttachment = (new ServiceSalesEnquiry()).GetSalesEnquiryAttachmentDBRecord(this.SelectedAttachmentID);
                    if (EnqAttachment != null)
                    {
                        headerGroupDeleteInfo.ValuesPrimary.Heading = string.Format("DELETED BY {0} DT. {1}", ServiceEmployee.GetEmployeeNameByID((int)EnqAttachment.DeletedBy), EnqAttachment.DeletedDatetime.Value.ToString("dd MMM yy hh:mmtt"));
                        txtDeleteRemark.Text = EnqAttachment.DeleteRemarks;
                    }
                    break;

                case APP_ENTITIES.SALES_QUOTATION_ATTACHMENT:
                    TBL_MP_CRM_SalesQuotation_Attachments QuotAttachment = (new ServiceSalesQuotation()).GetSalesQuotationAttachmentDBRecord(this.SelectedAttachmentID);
                    if (QuotAttachment != null)
                    {
                        headerGroupDeleteInfo.ValuesPrimary.Heading = string.Format("DELETED BY {0} DT. {1}", ServiceEmployee.GetEmployeeNameByID((int)QuotAttachment.DeletedBy), QuotAttachment.DeletedDatetime.Value.ToString("dd MMM yy hh:mmtt"));
                        txtDeleteRemark.Text = QuotAttachment.DeleteRemarks;
                    }
                    break;

                case APP_ENTITIES.SALES_ORDER_ATTACHMENT:
                    TBL_MP_CRM_SalesOrder_Attachment OrderAttachment = (new ServiceSalesOrder()).GetSalesOrderAttachmentDBRecord(this.SelectedAttachmentID);
                    if (OrderAttachment != null)
                    {
                        headerGroupDeleteInfo.ValuesPrimary.Heading = string.Format("DELETED BY {0} DT. {1}", ServiceEmployee.GetEmployeeNameByID((int)OrderAttachment.DeletedBy), OrderAttachment.DeleteDatetime.Value.ToString("dd MMM yy hh:mmtt"));
                        txtDeleteRemark.Text = OrderAttachment.DeleteRemarks;
                    }
                    break;

                case APP_ENTITIES.EMPLOYEES_ATTACHMENT:
                    TBL_MP_Master_Employee_Attachment EmpAttachment = (new ServiceEmployee()).GetEmployeeAttachmentDBRecord(this.SelectedAttachmentID);
                    if (EmpAttachment != null)
                    {
                        headerGroupDeleteInfo.ValuesPrimary.Heading = string.Format("DELETED BY {0} DT. {1}", ServiceEmployee.GetEmployeeNameByID((int)EmpAttachment.DeletedBy), EmpAttachment.DeleteDatetime.Value.ToString("dd MMM yy hh:mmtt"));
                        txtDeleteRemark.Text = EmpAttachment.DeleteRemarks;
                    }
                    break;
                }
                if (this.SelectedAttachmentPath.Trim().ToLower().EndsWith("msg"))
                {
                    PopulateOutlookViewer();
                }
                if (this.SelectedAttachmentPath.Trim().ToLower().EndsWith("pdf"))
                {
                    PopulateDocumentViewer();
                }
                if (this.SelectedAttachmentPath.Trim().ToLower().EndsWith("jpg"))
                {
                    PopulateDocumentViewer();
                }
                if (this.SelectedAttachmentPath.Trim().ToLower().EndsWith("jpeg"))
                {
                    PopulateDocumentViewer();
                }
                if (this.SelectedAttachmentPath.Trim().ToLower().EndsWith("png"))
                {
                    PopulateDocumentViewer();
                }
                if (this.SelectedAttachmentPath.Trim().ToLower().EndsWith("gif"))
                {
                    PopulateDocumentViewer();
                }
                if (this.SelectedAttachmentPath.Trim().ToLower().EndsWith("docx"))
                {
                    PopulateDocumentViewer();
                }
                if (this.SelectedAttachmentPath.Trim().ToLower().EndsWith("doc"))
                {
                    PopulateDocumentViewer();
                }
                if (this.SelectedAttachmentPath.Trim().ToLower().EndsWith("xls"))
                {
                    PopulateDocumentViewer();
                }
                if (this.SelectedAttachmentPath.Trim().ToLower().EndsWith("xlsx"))
                {
                    PopulateDocumentViewer();
                }
            }
            catch (Exception ex)
            {
                string errMessage = ex.Message;
                if (ex.InnerException != null)
                {
                    errMessage += string.Format("\n{0}", ex.InnerException.Message);
                }
                MessageBox.Show(ex.Message, "pageDeletedAttachments::OnAttachmentSelectionChange", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 12
0
        public void ScatterData()
        {
            try
            {
                model = _UNIT.SalesLeadService.GetLeadMasterDBInfo(this.SelectedLeadID);
                if (model != null)
                {
                    txtLeadNumber.Text = model.LeadNo;
                    dtLeadDate.Value   = model.LeadDate;

                    txtLeadRequirements.Text   = model.LeadRequirement;
                    txtGeneratedBy.Text        = ServiceEmployee.GetEmployeeNameByID((int)model.FK_LeadGeneratedBy);
                    cboAssignedTo.SelectedItem = ((List <SelectListItem>)cboAssignedTo.DataSource).Where(x => x.ID == model.FK_LeadAssignTo).FirstOrDefault();

                    cboSalesLeadStatus.SelectedItem = ((List <SelectListItem>)cboSalesLeadStatus.DataSource).Where(x => x.ID == model.FK_Status).FirstOrDefault();
                    if (model.FK_Status == Program.LIST_DEFAULTS[(int)APP_DEFAULT_VALUES.LeadStatusClose].DEFAULT_VALUE)
                    {
                        txtReasonLost.Text             = model.ReasonClose;
                        tabPageLeadCloseReason.Visible = true;
                    }

                    cboCompanies.SelectedItem = ((List <SelectListItem>)cboCompanies.DataSource).Where(x => x.ID == model.FK_PartyID).FirstOrDefault();
                    //scatter lead contacts
                    this.SelectedPartyID = ((SelectListItem)cboCompanies.SelectedItem).ID;
                    PopulateContactsGrid();
                    List <SelectContactModel> lstContacts = _UNIT.SalesLeadService.GetContactsForLeadID(this.SelectedLeadID);
                    if (lstContacts != null)
                    {
                        foreach (SelectContactModel contact in (List <SelectContactModel>)gridContacts.DataSource)
                        {
                            SelectContactModel found = lstContacts.Where(x => x.ContactID == contact.ContactID).FirstOrDefault();
                            if (found != null)
                            {
                                contact.Selected = true;
                            }
                        }
                    }

                    cboLeadSources.SelectedItem = ((List <SelectListItem>)cboLeadSources.DataSource).Where(x => x.ID == model.FK_LeadSource).FirstOrDefault();
                    if (model.FK_LeadSource == Program.LIST_DEFAULTS[(int)APP_DEFAULT_VALUES.LeadSourceAgency].DEFAULT_VALUE)
                    {
                        cboAgencies.SelectedItem = ((List <SelectListItem>)cboAgencies.DataSource).Where(x => x.ID == model.FK_AgentID).FirstOrDefault();
                        cboAgencies.Enabled      = btnAddAgency.Enabled = true;
                    }
                    else
                    {
                        cboAgencies.Enabled = btnAddAgency.Enabled = false;
                    }

                    if (model.EstimatedValue != null)
                    {
                        txtEstimatedValue.Text   = string.Format("{0:0.00}", model.EstimatedValue);
                        cboCurrency.SelectedItem = ((List <SelectListItem>)cboCurrency.DataSource).Where(x => x.ID == model.FK_EstimatedCurrency).FirstOrDefault();
                    }
                    else
                    {
                        txtEstimatedValue.Text = string.Empty;
                    }

                    cboProjectSector.SelectedItem = ((List <SelectListItem>)cboProjectSector.DataSource).Where(x => x.ID == model.FK_ProjectType).FirstOrDefault();

                    txtLeadRequirements.Text = model.LeadRequirement;
                }
                Application.DoEvents();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "frmSalesLead::ScatterData", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        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);
            }
        }
Exemplo n.º 14
0
        private void ScatterData()
        {
            if (this.SalesQuotationID == 0)
            {
                return;
            }
            try
            {
                string strMessage = string.Empty;
                TBL_MP_CRM_SalesQuotation model = (new ServiceSalesQuotation()).GetSalesQuotationMasterDBInfo(this.SalesQuotationID);
                if (model != null)
                {
                    this.Text = "SALES QUOTATION (EDIT)";
                    txtQuotationNumber.Text     = model.Quotation_No;
                    txtQuotationNumber.ReadOnly = true;
                    dtQuotationDate.Value       = model.Quotation_Date;
                    txtQuotationValidDays.Text  = model.Quotation_ValidDays.ToString();
                    txtQuotationExpiryDate.Text = string.Format("{0}", model.Quotation_Date.AddDays(model.Quotation_ValidDays).ToString("dd MMM yyyy"));

                    cboQuotationStatus.SelectedItem     = ((List <SelectListItem>)cboQuotationStatus.DataSource).Where(x => x.ID == model.FK_Userlist_Quotation_Status_ID).FirstOrDefault();
                    cboQuotationPriority.SelectedItem   = ((List <SelectListItem>)cboQuotationPriority.DataSource).Where(x => x.ID == model.FK_Userlist_Priority_ID).FirstOrDefault();
                    cboSalesRepresentative.SelectedItem = ((List <SelectListItem>)cboSalesRepresentative.DataSource).Where(x => x.ID == model.FK_RepresentativeID).FirstOrDefault();
                    cboQuotationStatus.SelectNextControl(dtQuotationDate, true, false, false, true);
                    if (cboSalesRepresentative.SelectedItem == null)
                    {
                        string empName = ServiceEmployee.GetEmployeeNameByID(model.FK_RepresentativeID);
                        strMessage += string.Format("\nUnable to locate Employee {0} in active Employees list.", empName);
                        List <SelectListItem> lstemployees = (new ServiceEmployee()).GetAllActiveEmployees();
                        SelectListItem        newRep       = new SelectListItem()
                        {
                            ID = model.FK_RepresentativeID, Description = empName
                        };
                        lstemployees.Add(newRep);
                        cboSalesRepresentative.DataSource   = lstemployees;
                        cboSalesRepresentative.SelectedItem = newRep;
                    }
                    //BOQ REPRESENTATIVE
                    if (model.FK_BOQRepresentativeID > 0)
                    {
                        cboBOQRepresentative.SelectedItem = ((List <SelectListItem>)cboBOQRepresentative.DataSource).Where(x => x.ID == model.FK_BOQRepresentativeID).FirstOrDefault();
                    }

                    this.SelectedSalesEnquiryID = model.FK_Sales_Enquiry_ID;
                    PopulateSelectedSalesEnquiryInfo();
                    TBL_MP_CRM_SalesEnquiry objEnquiry = model.TBL_MP_CRM_SalesEnquiry;
                    if (objEnquiry != null)
                    {
                        txtEnquiryNumber.Text         = string.Format("{0} dt. {1}", objEnquiry.SalesEnquiry_No, objEnquiry.SalesEnquiry_Date.ToString("dd MMM yyyy"));
                        txtProjectName.Text           = objEnquiry.Project_Name;
                        cboProjectSector.SelectedItem = ((List <SelectListItem>)cboProjectSector.DataSource).Where(x => x.ID == model.FK_Userlist_ProjectSector_ID).FirstOrDefault();
                        PopulateCitiesDropdown((int)objEnquiry.FK_Project_State_ID);
                        cboProjectLocation.SelectedItem = ((List <SelectListItem>)cboProjectLocation.DataSource).Where(x => x.ID == model.FK_Project_City_ID).FirstOrDefault();
                    }
                    Tbl_MP_Master_Party party = model.Tbl_MP_Master_Party;
                    if (party != null)
                    {
                        cboClient.SelectedItem = ((List <SelectListItem>)cboClient.DataSource).Where(x => x.ID == model.FK_Customer_ID).FirstOrDefault();
                        if (cboClient.SelectedItem == null)
                        {
                            strMessage += string.Format("\nUnable to locate Customer {0} in active Customers list.", party.PartyName);
                        }
                    }

                    txtRemarks.Text = model.Remarks;
                    if (model.FK_Userlist_Quotation_Status_ID == this.STATUS_CLOSED_ID || model.FK_Userlist_Quotation_Status_ID == this.STATUS_LOST_ID)
                    {
                        txtReasonClosedLost.Text            = model.ReasonClose.ToString();
                        tabPageQuotationCloseReason.Visible = true;
                    }
                    else
                    {
                        tabPageQuotationCloseReason.Visible = false;
                    }

                    tabRemarks.SelectedPage = tabPageQuotationRemarks;

                    if (strMessage != string.Empty)
                    {
                        MessageBox.Show(strMessage);
                    }
                    dtQuotationDate.Focus();
                    Application.DoEvents();
                }
            }
            catch (Exception ex)
            {
                string errMessage = ex.Message;
                if (ex.InnerException != null)
                {
                    errMessage += string.Format("\n{0}", ex.InnerException.Message);
                }
                MessageBox.Show(errMessage, "frmSalesQuotation::ScatterData", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        public void PoulateEnquiryMasterInfo()
        {
            try
            {
                DoBlanks();
                TBL_MP_CRM_SalesEnquiry _masterInfo    = (new ServiceSalesEnquiry()).GetEnquiryMasterDBInfo(SelectedEnquiryID);
                ServiceMASTERS          _masterService = new ServiceMASTERS();
                if (_masterInfo != null)
                {
                    txtLeadInfo.Text = "--";
                    if (_masterInfo.TBL_MP_CRM_SM_SalesLead != null)
                    {
                        txtLeadInfo.Text = string.Format("{0} dt. {1}", _masterInfo.TBL_MP_CRM_SM_SalesLead.LeadNo, _masterInfo.TBL_MP_CRM_SM_SalesLead.LeadDate.ToString("dd MMM yyyy"));
                    }

                    txtEnquiryInfo.Text = string.Format("{0}  dt. {1}", _masterInfo.SalesEnquiry_No, _masterInfo.SalesEnquiry_Date.ToString("dd MMM yyyy hh:mmtt"));

                    if (_masterInfo.Enquiry_Due_Date != null)
                    {
                        txtEnquiryDueDate.Text = string.Format("{0}", _masterInfo.Enquiry_Due_Date.Value.ToString("dd MMM yyyy"));
                    }

                    txtEnquiryGeneratedBy.Text = (_masterInfo.Enquiry_Genrated_By == "R") ? "REFERENCE" : ((_masterInfo.Enquiry_Genrated_By == "A") ? "AGENT" : "EMPLOYEE");
                    txtGeneratedByName.Text    = _masterInfo.Enquiry_Genrated_By_Name;
                    if (_masterInfo.FK_Userlist_EnquirySource_ID != 0)
                    {
                        txtEnquirySource.Text = _masterService.GetAllSalesEnquirySources().Where(x => x.ID == _masterInfo.FK_Userlist_EnquirySource_ID).FirstOrDefault().Description.ToUpper();
                    }
                    else
                    {
                        txtEnquirySource.Text = "--";
                    }

                    if (_masterInfo.FK_Userlist_Submission_Mode_ID != 0)
                    {
                        txtSubmissionMode.Text = _masterService.GetAllSalesEnquirySubmissionMode().Where(x => x.ID == _masterInfo.FK_Userlist_Submission_Mode_ID).FirstOrDefault().Description.ToUpper();
                    }
                    else
                    {
                        txtSubmissionMode.Text = "--";
                    }

                    if (_masterInfo.FK_Userlist_Enquiry_Status_ID != 0)
                    {
                        txtEnquiryStatus.Text = _masterService.GetAllSalesEnquiryStatuses().Where(x => x.ID == _masterInfo.FK_Userlist_Enquiry_Status_ID).FirstOrDefault().Description.ToUpper();
                    }
                    else
                    {
                        txtEnquiryStatus.Text = "--";
                    }
                    headerStatus.Text = string.Format("Status : {0}", txtEnquiryStatus.Text.ToUpper());
                    if (_masterInfo.FK_Userlist_Enquiry_Status_ID != Program.LIST_DEFAULTS[(int)APP_DEFAULT_VALUES.EnquiryStatusOpen].DEFAULT_VALUE)
                    {
                        txtStatusDetails.Text = _masterInfo.ReasonClose;
                    }
                    else
                    {
                        txtStatusDetails.Text = string.Empty;
                    }

                    txtDescription.Text = _masterInfo.General_Description;
                    if (_masterInfo.FK_AssignedTo != 0)
                    {
                        txtAssignedTo.Text = ServiceEmployee.GetEmployeeNameByID(_masterInfo.FK_AssignedTo);
                    }
                    else
                    {
                        txtAssignedTo.Text = "--";
                    }

                    if (_masterInfo.FK_Userlist_ProjectType_ID != 0)
                    {
                        txtProjectSector.Text = _masterService.GetAllProjectSectors().Where(x => x.ID == _masterInfo.FK_Userlist_ProjectType_ID).FirstOrDefault().Description.ToUpper();
                    }
                    else
                    {
                        txtProjectSector.Text = "--";
                    }

                    txtProjectName.Text  = _masterInfo.Project_Name;
                    txtProjectValue.Text = string.Format("{0:0.00}", _masterInfo.Project_Value);

                    if (_masterInfo.FK_Userlist_ProjectStatus_ID != 0)
                    {
                        txtProjectStatus.Text = _masterService.GetAllProjectStatuses().Where(x => x.ID == _masterInfo.FK_Userlist_ProjectStatus_ID).FirstOrDefault().Description.ToUpper();
                    }
                    else
                    {
                        txtProjectStatus.Text = "--";
                    }

                    if (_masterInfo.FK_Userlist_Project_SubType_ID != 0)
                    {
                        txtProjectSubType.Text = _masterService.GetAllProjectTypes().Where(x => x.ID == _masterInfo.FK_Userlist_Project_SubType_ID).FirstOrDefault().Description.ToUpper();
                    }
                    else
                    {
                        txtProjectSubType.Text = "--";
                    }


                    if (_masterInfo.FK_Project_Country_ID != null)
                    {
                        if (_masterInfo.FK_Project_Country_ID != 0)
                        {
                            txtProjectCountry.Text = _masterService.GetAllCountries().Where(x => x.ID == _masterInfo.FK_Project_Country_ID).FirstOrDefault().Description.ToUpper();
                        }
                        else
                        {
                            txtProjectCountry.Text = "--";
                        }
                    }
                    if (_masterInfo.FK_Project_State_ID != null)
                    {
                        if (_masterInfo.FK_Project_State_ID != 0)
                        {
                            txtProjectState.Text = _masterService.GetAllStatesForCountry((int)_masterInfo.FK_Project_Country_ID).Where(x => x.ID == _masterInfo.FK_Project_State_ID).FirstOrDefault().Description.ToUpper();
                        }
                        else
                        {
                            txtProjectState.Text = "--";
                        }
                    }
                    if (_masterInfo.FK_Project_City_ID != null)
                    {
                        if (_masterInfo.FK_Project_City_ID != 0)
                        {
                            txtProjectCity.Text = _masterService.GetAllCitiesForState((int)_masterInfo.FK_Project_State_ID).Where(x => x.ID == _masterInfo.FK_Project_City_ID).FirstOrDefault().Description.ToUpper();
                        }
                        else
                        {
                            txtProjectCity.Text = "--";
                        }
                    }

                    if (_masterInfo.FK_PreparedBy != null)
                    {
                        string strPreparedByName = ServiceEmployee.GetEmployeeNameByID((int)_masterInfo.FK_PreparedBy);
                        headerBottom.Values.Heading = string.Format("Created : {0} {1}", strPreparedByName, _masterInfo.CreatedDatetime.Value.ToString("dd MMM yyyy hh:mmtt"));
                    }
                    if (_masterInfo.LastModifiedBy != null)
                    {
                        string strModifiedByName = ServiceEmployee.GetEmployeeNameByID((int)_masterInfo.LastModifiedBy);
                        headerBottom.Values.Description = string.Format("Modified : {0} {1}", strModifiedByName, _masterInfo.LastModifiedDate.Value.ToString("dd MMM yyyy hh:mmtt"));
                    }

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

                    if (!ReadOnly)
                    {
                        WhosWhoModel model = Program.CONTROL_ACCESS.ListControlAccess.Where(x => x.FormID == this.SALES_ENQUIRY_FORM_ID).FirstOrDefault();
                        if (model != null)
                        {
                            if (model.CanApprove)
                            {
                                if (_masterInfo.FK_ApprovedBy == null)
                                {
                                    btnApproveEnquiry.Visible = true;
                                }
                                else
                                {
                                    btnApproveEnquiry.Visible = false;
                                }
                            }
                            else
                            {
                                btnApproveEnquiry.Visible = false;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "ctrlSalesEnquiryGeneralDetails::PoulateEnquiryMasterInfo", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        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;
        }