public List <MultiSelectListItem> GetAllQuotationsForSelectintoReview()
        {
            List <MultiSelectListItem> lst = new List <MultiSelectListItem>();

            try
            {
                string     strQuery  = "Select PK_QUOTATION_ID from TBL_MP_CRM_SalesQuotation where quotation_no NOT LIKE '%AMMEND%' AND PK_QUOTATION_ID NOT IN(SELECT DISTINCT FK_QUOTATIONID FROM TBL_MP_CRM_SalesQuotation_Review)";
                List <int> lstQuotes = _dbContext.Database.SqlQuery <int>(strQuery).ToList();
                foreach (int quoteID in lstQuotes)
                {
                    TBL_MP_CRM_SalesQuotation dbQuote = _dbContext.TBL_MP_CRM_SalesQuotation.Where(x => x.PK_Quotation_ID == quoteID).FirstOrDefault();
                    if (dbQuote != null)
                    {
                        lst.Add(new MultiSelectListItem()
                        {
                            ID          = dbQuote.PK_Quotation_ID,
                            Description = string.Format("{0} dt. {1}\n{2}", dbQuote.Quotation_No, dbQuote.Quotation_Date.ToString("dd MMM yy"), dbQuote.Tbl_MP_Master_Party.PartyName)
                        });
                    }
                }
            }
            catch (Exception ex)
            {
                string errMessage = ex.Message;
                if (ex.InnerException != null)
                {
                    errMessage += string.Format("\n{0}", ex.InnerException.Message);
                }
                MessageBox.Show(errMessage, "ServiceSalesQuotationReview::GetAllQuotationsForSelectintoReview", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            return(lst);
        }
 private void PopulateClientInfo()
 {
     try
     {
         headerGroupClient.ValuesPrimary.Heading = "CLIENT:";
         txtClientInfo.Text = string.Empty;
         TBL_MP_CRM_SalesQuotation objQuotation = (new ServiceSalesQuotation()).GetSalesQuotationMasterDBInfo(this.SelectedQuotationID);
         if (objQuotation == null)
         {
             return;
         }
         SelectedClientID = (int)objQuotation.FK_Customer_ID;
         headerGroupClient.ValuesPrimary.Heading = string.Format("CLIENT: {0}", objQuotation.Tbl_MP_Master_Party.PartyCode);
         string strInfo = objQuotation.Tbl_MP_Master_Party.PartyName.ToUpper();
         strInfo                       += string.Format("\nemail: {0} Website: {1}", objQuotation.Tbl_MP_Master_Party.EmailID, objQuotation.Tbl_MP_Master_Party.Website);
         strInfo                       += string.Format("\nGST NO: {0}", objQuotation.Tbl_MP_Master_Party.GSTNO);
         txtClientInfo.Text             = strInfo;
         gridCompanyContacts.DataSource = (new ServiceContacts()).GetMultiSelectListContactsForParty(this.SelectedClientID);
     }
     catch (Exception ex)
     {
         string errMessage = ex.Message;
         if (ex.InnerException != null)
         {
             errMessage += string.Format("\n{0}", ex.InnerException.Message);
         }
         MessageBox.Show(errMessage, "ControlSalesQuotationClientDetails::PopulateClientInfo", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
        public ScheduleCallAddEditModel GetSchdeuledCallAddEditModelForSchedule(int scheduleID)
        {
            ScheduleCallAddEditModel model = new ScheduleCallAddEditModel()
            {
                ScheduleID = scheduleID
            };

            try
            {
                TBL_MP_CRM_ScheduleCallLog log = _dbContext.TBL_MP_CRM_ScheduleCallLog.Where(x => x.ScheduleID == model.ScheduleID).FirstOrDefault();
                if (log != null)
                {
                    model.SOURCE_ENTITY    = (APP_ENTITIES)log.EntityType;
                    model.SOURCE_ENTITY_ID = (int)log.EntityID;
                    model.DB_MODEL         = log;
                    model.listAssignees    = this.GelAllAssigneesForSchedule(model.ScheduleID);
                    string strCaption = string.Empty;
                    switch (model.SOURCE_ENTITY)
                    {
                    case APP_ENTITIES.SALES_LEAD:
                        LeadMasterInfoModel leadInfo = (new ServiceSalesLead(_dbContext)).GetLeadMasterInfo(model.SOURCE_ENTITY_ID);
                        strCaption = string.Format("LEAD: {0} {1} dt. {2}", leadInfo.LeadNo, leadInfo.LeadName, leadInfo.LeadDate.Value.ToString("dd MMM yyyy"));
                        break;

                    case APP_ENTITIES.SALES_ENQUIRY:
                        TBL_MP_CRM_SalesEnquiry EnquiryInfo = (new ServiceSalesEnquiry(_dbContext)).GetEnquiryMasterDBInfo(model.SOURCE_ENTITY_ID);
                        strCaption = string.Format("ENQURIY: {0} dt. {1}", EnquiryInfo.SalesEnquiry_No, EnquiryInfo.SalesEnquiry_Date.ToString("dd MMM yyyy"));
                        break;

                    case APP_ENTITIES.SALES_QUOTATION:
                        TBL_MP_CRM_SalesQuotation QuotationInfo = (new ServiceSalesQuotation(_dbContext)).GetSalesQuotationMasterDBInfo(model.SOURCE_ENTITY_ID);
                        strCaption = string.Format("QUOTATION: {0} dt. {1}", QuotationInfo.Quotation_No, QuotationInfo.Quotation_Date.ToString("dd MMM yyyy"));
                        break;

                    case APP_ENTITIES.SALES_ORDER:
                        TBL_MP_CRM_SalesOrder OrderInfo = (new ServiceSalesOrder(_dbContext)).GetSalesOrderDBInfoByID(model.SOURCE_ENTITY_ID);
                        strCaption = string.Format("ORDER: {0} dt. {1}", OrderInfo.SalesOrderNo, OrderInfo.SalesOrderDate.ToString("dd MMM yyyy"));
                        break;
                    }
                    model.HeaderTitle = strCaption;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "ServiceScheduleCallLog::GetSchdeuledCallInfo", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            return(model);
        }
        private void PopulateConsultantInfo()
        {
            try
            {
                headerGroupConsultant.ValuesPrimary.Heading = "CONSULTANT:";
                txtConsultantInfo.Text = string.Empty;
                TBL_MP_CRM_SalesQuotation objQuotation = (new ServiceSalesQuotation()).GetSalesQuotationMasterDBInfo(this.SelectedQuotationID);
                if (objQuotation == null)
                {
                    return;
                }
                if (objQuotation.TBL_MP_CRM_SalesEnquiry.Enquiry_Genrated_By != "A")
                {
                    headerGroupConsultant.Enabled = false;
                    return;
                }
                else
                if (!ReadOnly)
                {
                    headerGroupConsultant.Enabled = true;
                }

                this.SelectedConsultantID = (int)objQuotation.TBL_MP_CRM_SalesEnquiry.FK_EnqGenerated_Agent_ID;
                Tbl_MP_Master_Party dbParty = (new ServiceParties()).GetPartyByPartyID(this.SelectedConsultantID);

                headerGroupConsultant.ValuesPrimary.Heading = string.Format("CONSULTANT: {0}", objQuotation.TBL_MP_CRM_SalesEnquiry.Enquiry_Genrated_By_Name);
                string strInfo = objQuotation.TBL_MP_CRM_SalesEnquiry.Enquiry_Genrated_By_Name.ToUpper();
                strInfo += string.Format("\nemail: {0} Website: {1}", dbParty.EmailID, dbParty.Website);
                strInfo += string.Format("\nGST NO: {0}", dbParty.GSTNO);
                txtConsultantInfo.Text            = strInfo;
                gridConsultantContacts.DataSource = (new ServiceContacts()).GetMultiSelectListContactsForParty(this.SelectedConsultantID);
            }
            catch (Exception ex)
            {
                string errMessage = ex.Message;
                if (ex.InnerException != null)
                {
                    errMessage += string.Format("\n{0}", ex.InnerException.Message);
                }
                MessageBox.Show(errMessage, "ControlSalesQuotationClientDetails::PopulateConsultantInfo", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #5
0
 private void PopulateSpecialNotes()
 {
     try
     {
         TBL_MP_CRM_SalesQuotation dbModel = (new ServiceSalesQuotation()).GetSalesQuotationMasterDBInfo(this.SelectedQuotationID);
         if (dbModel != null)
         {
             txtSpecialNotes.Text = dbModel.SpecialNotes;
         }
     }
     catch (Exception ex)
     {
         string errMessage = ex.Message;
         if (ex.InnerException != null)
         {
             errMessage += string.Format("\n{0}", ex.InnerException.Message);
         }
         MessageBox.Show(errMessage, "ControlSalesQuotationTermsAndCondition::PopulateSpecialNotes", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Beispiel #6
0
 private void PopulateSalesQuotationInfo()
 {
     try
     {
         TBL_MP_CRM_SalesQuotation dbModel = (new ServiceSalesQuotation()).GetSalesQuotationMasterDBInfo(this.SelectedQuotationID);
         if (dbModel != null)
         {
             txtQuotationNumber.Text = string.Format("{0}  dt. {1}", dbModel.Quotation_No, dbModel.Quotation_Date.ToString("dd MMM yyyy"));
             int clientID = dbModel.FK_Customer_ID;
             cboClient.SelectedItem = ((List <SelectListItem>)cboClient.DataSource).Where(x => x.ID == clientID).FirstOrDefault();
         }
     }
     catch (Exception ex)
     {
         string errMessage = ex.Message;
         if (ex.InnerException != null)
         {
             errMessage += string.Format("\n{0}", ex.InnerException.Message);
         }
         MessageBox.Show(errMessage, "frmSO_Primary::PopulateSalesQuotationInfo", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
        public void PrepareForInsert()
        {
            DB_MODEL = new TBL_MP_CRM_ScheduleCallLog();
            string strCaption          = string.Empty;
            string strContactNames     = string.Empty;
            string strContactNumbers   = string.Empty;
            string strContactAddresses = string.Empty;

            try
            {
                switch (this.SOURCE_ENTITY)
                {
                case APP_ENTITIES.SALES_LEAD:
                    LeadMasterInfoModel leadInfo = (new ServiceSalesLead()).GetLeadMasterInfo(this.SOURCE_ENTITY_ID);
                    strCaption            = string.Format("LEAD: {0} {1} dt. {2}", leadInfo.LeadNo, leadInfo.LeadName, leadInfo.LeadDate.Value.ToString("dd MMM yyyy"));
                    DB_MODEL.CustomerName = leadInfo.LeadName;

                    List <SelectContactModel> listContacts = (new ServiceSalesLead()).GetContactsForLeadID(this.SOURCE_ENTITY_ID);
                    DB_MODEL.ContactPerson = string.Empty;
                    foreach (SelectContactModel model in listContacts)
                    {
                        string[] names = model.Description1.Split('\n');
                        DB_MODEL.ContactPerson += names[0] + ", ";
                        DB_MODEL.ContactNumber += model.Description2 + ", ";
                        DB_MODEL.Location      += model.Description1.Replace(names[0], "");
                    }

                    DB_MODEL.ContactPerson = DB_MODEL.ContactPerson.TrimEnd(' ').TrimEnd(',');
                    DB_MODEL.ContactNumber = DB_MODEL.ContactNumber.TrimEnd(' ').TrimEnd(',');

                    break;

                case APP_ENTITIES.SALES_ENQUIRY:
                    TBL_MP_CRM_SalesEnquiry dbEnquiry = (new ServiceSalesEnquiry()).GetEnquiryMasterDBInfo(this.SOURCE_ENTITY_ID);
                    strCaption            = string.Format("ENQUIRY: {0} {1} dt. {2}", dbEnquiry.SalesEnquiry_No, dbEnquiry.Project_Name, dbEnquiry.SalesEnquiry_Date.ToString("dd MMM yyyy"));
                    DB_MODEL.CustomerName = dbEnquiry.Tbl_MP_Master_Party.PartyName;
                    List <TBL_MP_CRM_SM_ContactReferences> listEnquiryContacts = (new ServiceSalesEnquiry()).GetAllCompanyContactsForSalesEnquiryDB(this.SOURCE_ENTITY_ID);
                    strContactNames = strContactNumbers = strContactAddresses = string.Empty;
                    foreach (TBL_MP_CRM_SM_ContactReferences refContact in listEnquiryContacts)
                    {
                        strContactNames     += string.Format("{0}\n", refContact.Tbl_MP_Master_PartyContact_Detail.ContactPersoneName);
                        strContactAddresses += string.Format("{0}\n\n", refContact.Tbl_MP_Master_PartyContact_Detail.Address);
                        strContactNumbers   += string.Format("Mobile: {0}  {1}", refContact.Tbl_MP_Master_PartyContact_Detail.MobileNo, refContact.Tbl_MP_Master_PartyContact_Detail.AltMobileNo);
                        strContactNumbers   += string.Format("Tel: {0}  {1}\n", refContact.Tbl_MP_Master_PartyContact_Detail.TelephoneNo, refContact.Tbl_MP_Master_PartyContact_Detail.AltTelephoneNo);
                    }

                    DB_MODEL.ContactPerson = strContactNames.TrimEnd(' ').TrimEnd(',');
                    DB_MODEL.ContactNumber = strContactNumbers.TrimEnd(' ').TrimEnd(',');
                    DB_MODEL.Location      = strContactAddresses;
                    break;

                case APP_ENTITIES.SALES_QUOTATION:
                    TBL_MP_CRM_SalesQuotation dbQuote = (new ServiceSalesQuotation()).GetSalesQuotationMasterDBInfo(this.SOURCE_ENTITY_ID);
                    strCaption            = string.Format("ENQUIRY: {0} dt. {1}", dbQuote.Quotation_No, dbQuote.Quotation_Date.ToString("dd MMM yyyy"));
                    DB_MODEL.CustomerName = dbQuote.Tbl_MP_Master_Party.PartyName;
                    List <TBL_MP_CRM_SM_ContactReferences> listQuoteContacts = (new ServiceSalesQuotation()).GetAllCompanyContactsForSalesQuotationDB(this.SOURCE_ENTITY_ID);
                    strContactNames = strContactNumbers = strContactAddresses = string.Empty;
                    foreach (TBL_MP_CRM_SM_ContactReferences refContact in listQuoteContacts)
                    {
                        strContactNames     += string.Format("{0}\n", refContact.Tbl_MP_Master_PartyContact_Detail.ContactPersoneName);
                        strContactAddresses += string.Format("{0}\n\n", refContact.Tbl_MP_Master_PartyContact_Detail.Address);
                        strContactNumbers   += string.Format("Mobile: {0}  {1}", refContact.Tbl_MP_Master_PartyContact_Detail.MobileNo, refContact.Tbl_MP_Master_PartyContact_Detail.AltMobileNo);
                        strContactNumbers   += string.Format("Tel: {0}  {1}\n", refContact.Tbl_MP_Master_PartyContact_Detail.TelephoneNo, refContact.Tbl_MP_Master_PartyContact_Detail.AltTelephoneNo);
                    }

                    DB_MODEL.ContactPerson = strContactNames.TrimEnd(' ').TrimEnd(',');
                    DB_MODEL.ContactNumber = strContactNumbers.TrimEnd(' ').TrimEnd(',');
                    DB_MODEL.Location      = strContactAddresses;
                    break;

                case APP_ENTITIES.SALES_ORDER:
                    TBL_MP_CRM_SalesOrder dbOrder = (new ServiceSalesOrder()).GetSalesOrderDBInfoByID(this.SOURCE_ENTITY_ID);
                    strCaption            = string.Format("ORDER: {0} dt. {1}", dbOrder.SalesOrderNo, dbOrder.SalesOrderDate.ToString("dd MMM yyyy"));
                    DB_MODEL.CustomerName = dbOrder.Tbl_MP_Master_Party.PartyName;
                    List <TBL_MP_CRM_SM_ContactReferences> listOrderContacts = (new ServiceSalesOrder()).GetAllCompanyContactsForSalesOrderDB(this.SOURCE_ENTITY_ID);
                    strContactNames = strContactNumbers = strContactAddresses = string.Empty;
                    foreach (TBL_MP_CRM_SM_ContactReferences refContact in listOrderContacts)
                    {
                        strContactNames     += string.Format("{0}\n", refContact.Tbl_MP_Master_PartyContact_Detail.ContactPersoneName);
                        strContactAddresses += string.Format("{0}\n\n", refContact.Tbl_MP_Master_PartyContact_Detail.Address);
                        strContactNumbers   += string.Format("Mobile: {0}  {1}", refContact.Tbl_MP_Master_PartyContact_Detail.MobileNo, refContact.Tbl_MP_Master_PartyContact_Detail.AltMobileNo);
                        strContactNumbers   += string.Format("Tel: {0}  {1}\n", refContact.Tbl_MP_Master_PartyContact_Detail.TelephoneNo, refContact.Tbl_MP_Master_PartyContact_Detail.AltTelephoneNo);
                    }

                    DB_MODEL.ContactPerson = strContactNames.TrimEnd(' ').TrimEnd(',');
                    DB_MODEL.ContactNumber = strContactNumbers.TrimEnd(' ').TrimEnd(',');
                    DB_MODEL.Location      = strContactAddresses;
                    break;
                }

                DateTime currDatetime = AppCommon.GetServerDateTime();
                DB_MODEL.StartAt  = currDatetime;
                DB_MODEL.EndsAt   = currDatetime.AddDays(1);
                DB_MODEL.Reminder = currDatetime.AddHours(-1);
                HeaderTitle       = strCaption;

                BindingList <MultiSelectListItem> allEmployees = AppCommon.ConvertToBindingList <MultiSelectListItem>((new ServiceMASTERS()).GetAllEmployeesMultiSelect());
                this.listAssignees = new BindingList <MultiSelectListItem>();
                MultiSelectListItem emp = allEmployees.Where(x => x.ID == currEmpID).FirstOrDefault();
                if (emp != null)
                {
                    this.listAssignees.Add(emp);
                }
            }
            catch (Exception ex)
            {
                string errMessage = ex.Message;
                if (ex.InnerException != null)
                {
                    errMessage += string.Format("\n{0}", ex.InnerException.Message);
                }
                MessageBox.Show(errMessage, "ScheduleCallAddEditModel::PrepareForInsert", 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);
            }
        }
Beispiel #9
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            TBL_MP_CRM_SalesQuotation objQuote      = null;
            ServiceSalesQuotation     _serviceQuote = null;

            try
            {
                errorProvider1.Clear();
                if (this.ValidateChildren())
                {
                    _serviceQuote = new ServiceSalesQuotation();;
                    if (this.SalesQuotationID == 0)
                    {
                        objQuote = new TBL_MP_CRM_SalesQuotation();
                        objQuote.PK_Quotation_ID = 0;
                        objQuote.FK_YearID       = Program.CURR_USER.FinYearID;
                        objQuote.FK_BranchID     = Program.CURR_USER.BranchID;
                        objQuote.FK_CompanyID    = Program.CURR_USER.CompanyID;
                        objQuote.Quotation_No    = txtQuotationNumber.Text.ToUpper().Trim();
                        //objQuote.Quotation_No = _serviceQuote.GenerateNewSalesQuotationNumber(objQuote.FK_YearID,objQuote.FK_BranchID,objQuote.FK_CompanyID);
                    }
                    else
                    {
                        objQuote = _serviceQuote.GetSalesQuotationMasterDBInfo(this.SalesQuotationID);
                    }

                    // GATHER DATA
                    objQuote.Quotation_Date = dtQuotationDate.Value;
                    objQuote.FK_Userlist_Quotation_Status_ID = ((SelectListItem)cboQuotationStatus.SelectedItem).ID;
                    objQuote.Quotation_ValidDays             = int.Parse(txtQuotationValidDays.Text);
                    objQuote.FK_Userlist_Priority_ID         = ((SelectListItem)cboQuotationPriority.SelectedItem).ID;
                    objQuote.FK_RepresentativeID             = ((SelectListItem)cboSalesRepresentative.SelectedItem).ID;
                    objQuote.FK_BOQRepresentativeID          = ((SelectListItem)cboBOQRepresentative.SelectedItem).ID;
                    objQuote.FK_Sales_Enquiry_ID             = this.SelectedSalesEnquiryID;
                    objQuote.FK_Customer_ID               = ((SelectListItem)cboClient.SelectedItem).ID;
                    objQuote.Project_Name                 = txtProjectName.Text.Trim();
                    objQuote.FK_Project_City_ID           = ((SelectListItem)cboProjectLocation.SelectedItem).ID;
                    objQuote.FK_Userlist_ProjectSector_ID = ((SelectListItem)cboProjectSector.SelectedItem).ID;

                    objQuote.Remarks     = txtRemarks.Text;
                    objQuote.ReasonClose = txtReasonClosedLost.Text;

                    if (this.SalesQuotationID == 0)
                    {
                        this.SalesQuotationID = _serviceQuote.AddNewQuotation(objQuote);
                        _serviceQuote.GenerateDefaultsFromSalesEnquiryIntoSalesQuotation(this.SelectedSalesEnquiryID, SalesQuotationID);
                    }
                    else
                    {
                        objQuote.LastModifiedBy   = Program.CURR_USER.EmployeeID;
                        objQuote.LastModifiedDate = AppCommon.GetServerDateTime();
                        _serviceQuote.UpdateSalesQuotation(objQuote);
                    }

                    this.DialogResult = DialogResult.OK;
                }
            }
            catch (Exception ex)
            {
                string errMessage = ex.Message;
                if (ex.InnerException != null)
                {
                    errMessage += string.Format("\n{0}", ex.InnerException.Message);
                }
                MessageBox.Show(errMessage, "frmSalesQuotation::btnSave_Click", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #10
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 async Task <int> AddNewScheduleCall(ScheduleCallAddEditModel model, int createdBy)
        {
            string strMessage      = string.Empty;
            string strAssignees    = string.Empty;
            string strRequirements = string.Empty;

            try
            {
                progressForm      = new frmProgress();
                progressForm.Text = "CREATING A NEW SCHEDULE CALL";
                progressForm.lblProgressText.Text = "Inserting a New Business Schecule Call";
                progressForm.Show();
                Application.DoEvents();


                model.DB_MODEL.EntityType      = (int)model.SOURCE_ENTITY;
                model.DB_MODEL.EntityID        = (int)model.SOURCE_ENTITY_ID;
                model.DB_MODEL.CreatedBy       = createdBy;
                model.DB_MODEL.CreatedDatetime = AppCommon.GetServerDateTime();
                model.DB_MODEL.Reminder        = model.DB_MODEL.Reminder;
                model.DB_MODEL.IsDeleted       = false;
                model.DB_MODEL.Completed       = false;
                _dbContext.TBL_MP_CRM_ScheduleCallLog.Add(model.DB_MODEL);
                _dbContext.SaveChanges();
                model.ScheduleID = model.DB_MODEL.ScheduleID;

                progressForm.SetProgress(30, string.Format("\nSuccess ID: {0}\n\nInserting Assignees for this schedule in Database.", model.ScheduleID));
                Application.DoEvents();
                string mailTo = string.Empty;
                foreach (MultiSelectListItem item in model.listAssignees)
                {
                    _dbContext.TBL_MP_CRM_ScheduleCallLogAssignee.Add(new TBL_MP_CRM_ScheduleCallLogAssignee()
                    {
                        EmployeeID = item.ID,
                        IsDeleted  = false,
                        ScheduleID = model.ScheduleID
                    });
                    strAssignees += item.Description.Split('\n')[0] + " , ";
                    _dbContext.SaveChanges();
                    mailTo += ServiceEmployee.GetEmployeeEmailByID(item.ID) + ";";
                }
                strAssignees = strAssignees.TrimEnd(' ').TrimEnd(',');
                mailTo      += "*****@*****.**";
                progressForm.SetProgress(60, string.Format("\nSuccess: {0} Assignee(s) inserted in Database for Schdeule #{1}", model.listAssignees.Count, model.ScheduleID));
                progressForm.SetProgress(60, string.Format("\n\n\nSending Email to {0}", mailTo.Replace(";", "; ")));
                Application.DoEvents();
                ServiceEmail mail       = new ServiceEmail();
                string       strSubject = string.Format("New Schedule Call: {0}", model.DB_MODEL.Subject.ToUpper());

                switch (model.SOURCE_ENTITY)
                {
                case APP_ENTITIES.SALES_LEAD:
                    LeadMasterInfoModel lead = (new ServiceSalesLead(_dbContext)).GetLeadMasterInfo(model.SOURCE_ENTITY_ID);
                    if (lead != null)
                    {
                        strMessage     += String.Format("\n\n\nLead No.: {0} dt. {1}\nParty Name: {2}\n", lead.LeadNo, lead.LeadDate.Value.ToString("dd MMMyy"), lead.LeadName);
                        strRequirements = string.Format("Lead Requirements:\n{0}", lead.LeadRequirement);
                    }
                    break;

                case APP_ENTITIES.SALES_ENQUIRY:
                    TBL_MP_CRM_SalesEnquiry enquiry = (new ServiceSalesEnquiry(_dbContext)).GetEnquiryMasterDBInfo(model.SOURCE_ENTITY_ID);
                    if (enquiry != null)
                    {
                        strMessage += String.Format("\n\n\nEnquiry No.: {0} dt. {1}\nParty Name: {2}\n",
                                                    enquiry.SalesEnquiry_No,
                                                    enquiry.SalesEnquiry_Date.ToString("dd MMMyy"),
                                                    enquiry.Tbl_MP_Master_Party.PartyName);
                        strRequirements = string.Format("Description:\n{0}", enquiry.General_Description);
                    }
                    break;

                case APP_ENTITIES.SALES_QUOTATION:
                    TBL_MP_CRM_SalesQuotation quotation = (new ServiceSalesQuotation(_dbContext)).GetSalesQuotationMasterDBInfo(model.SOURCE_ENTITY_ID);
                    if (quotation != null)
                    {
                        strMessage += String.Format("\n\n\n Quotation No.: {0} dt. {1}\nParty Name: {2}\n",
                                                    quotation.Quotation_No,
                                                    quotation.Quotation_Date.ToString("dd MMMyy"),
                                                    quotation.Tbl_MP_Master_Party.PartyName);
                        strRequirements = string.Format("Special Note:\n{0}", quotation.SpecialNotes);
                    }
                    break;

                case APP_ENTITIES.SALES_ORDER:
                    TBL_MP_CRM_SalesOrder order = (new ServiceSalesOrder(_dbContext)).GetSalesOrderDBInfoByID(model.SOURCE_ENTITY_ID);
                    if (order != null)
                    {
                        strMessage += String.Format("\n\n\n Order No.: {0} dt. {1}\nParty Name: {2}\n",
                                                    order.SalesOrderNo,
                                                    order.SalesOrderDate.ToString("dd MMMyy"),
                                                    order.Tbl_MP_Master_Party.PartyName);
                        strRequirements = string.Empty;
                    }
                    break;
                }
                strMessage += string.Format("\nContact Person(s) : {0}", model.DB_MODEL.ContactPerson);
                strMessage += string.Format("\nContact Number(s) : {0}", model.DB_MODEL.ContactNumber);
                strMessage += string.Format("\nAddress : {0}", model.DB_MODEL.Location);
                strMessage += string.Format("\n\nSCHEDULE\nSchedule Type: {0}", (new ServiceMASTERS(_dbContext)).GetAllScheduleCallActions().Where(x => x.ID == model.DB_MODEL.ActionID).FirstOrDefault().Description);
                strMessage += string.Format("\nSchdeule Date: {0}\nSchedule Time:{1}", model.DB_MODEL.StartAt.Value.ToString("dd MMM yyyy"), model.DB_MODEL.StartAt.Value.ToString("hh:mm tt"));
                strMessage += string.Format("\nPlan/Action: {0}", model.DB_MODEL.Subject.ToUpper());
                strMessage += string.Format("\nRemarks: {0}\n", model.DB_MODEL.Remarks);


                strMessage += string.Format("\nAssigned To : {0}", strAssignees);

                strMessage += string.Format("\n\n{0}", strRequirements);


                string strEmailFrom = ServiceEmployee.GetEmployeeEmailByID(createdBy);
                await mail.SendScheduleCallCreatedEmailNotification(createdBy, strEmailFrom, mailTo, strSubject, strMessage);

                Application.DoEvents();
                progressForm.Close();
                this.IsScuccess = true;
                return(model.ScheduleID);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "ServiceScheduleCallLog::AddNewScheduleCall", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            return(model.ScheduleID);
        }
        public void PopulateSalesQuotationBOQ()
        {
            MODEL = null;
            tabBOQSheets.Pages.Clear();
            Application.DoEvents();
            try
            {
                // check if to be set readonly
                TBL_MP_CRM_SalesQuotation dbQuotation = (new ServiceSalesQuotation()).GetSalesQuotationMasterDBInfo(SalesQuotationID);
                this.ReadOnly = (dbQuotation.FK_BOQRepresentativeID != Program.CURR_USER.EmployeeID);

                headerBOQMenu.Values.Heading = String.Empty;
                MODEL = (new ServiceSalesQuotationBOQ()).GetBOQViewModelForQuotation(this.SalesQuotationID);
                if (MODEL == null)
                {
                    MODEL = (new ServiceSalesQuotationBOQ()).GenerateDefaultBOQForSalesQuotation(this.SalesQuotationID);
                }

                if (MODEL != null)
                {
                    headerBOQMenu.Values.Heading = MODEL.BOQ_NUMBER;
                    // CREATE ALL SHEETS
                    foreach (SalesQuotationBOQSheet sheet in MODEL.SHEETS)
                    {
                        KryptonPage pageBOQSheet = new KryptonPage()
                        {
                            Text = sheet.SheetName, Name = string.Format("page{0}", tabBOQSheets.Pages.Count + 1)
                        };
                        ControlSalesQuotationBOQSheet _sheetControl = new ControlSalesQuotationBOQSheet(sheet);
                        _sheetControl.OnValueChanged += _sheetControl_OnValueChanged;
                        _sheetControl.BOQ_MODEL       = MODEL;
                        pageBOQSheet.Controls.Add(_sheetControl);
                        _sheetControl.Dock = DockStyle.Fill;
                        tabBOQSheets.Pages.Add(pageBOQSheet);
                        _sheetControl.ParentTabPage = pageBOQSheet;
                        _sheetControl.PopulateBOQItemsGrid();
                        _sheetControl.Visible  = true;
                        _sheetControl.ReadOnly = this._ReadOnly;
                        //pageBOQSheet.Show();
                        _sheetControl.SetBOQItemsGridColumnSettings();
                        _sheetControl.SetBOQItemsGridColumnFormatting();
                        pageBOQSheet.Refresh();
                        tabBOQSheets.SelectedPage = pageBOQSheet;
                        Application.DoEvents();
                    }

                    // ADD BOQ SUMMARY TAB
                    pageBOQsummary = new KryptonPage()
                    {
                        Text = "SUMMARY", Name = "tabPageBOQSummary"
                    };
                    _BOQSummaryControl      = new ControlSalesQuotationBOQSummary(MODEL);
                    _BOQSummaryControl.Dock = DockStyle.Fill;
                    pageBOQsummary.Controls.Add(_BOQSummaryControl);
                    tabBOQSheets.Pages.Add(pageBOQsummary);
                    _BOQSummaryControl.PopulateBOQSummaryControl();
                    _BOQSummaryControl.ReadOnly = this._ReadOnly;
                }

                // perform grid formatting and column settings again
                foreach (KryptonPage page in tabBOQSheets.Pages)
                {
                    if (page.Controls[0].GetType() == typeof(ControlSalesQuotationBOQSheet))
                    {
                        ControlSalesQuotationBOQSheet sheet = (ControlSalesQuotationBOQSheet)page.Controls[0];
                        sheet.SetBOQItemsGridColumnSettings();
                        sheet.SetBOQItemsGridColumnFormatting();
                    }
                }
            }
            catch (Exception ex)
            {
                string errMessage = ex.Message;
                if (ex.InnerException != null)
                {
                    errMessage += string.Format("\n{0}", ex.InnerException.Message);
                }
                MessageBox.Show(errMessage, "ControlSalesQuotationBOQ::PopulateSalesQuotationBOQ", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }