private void PopulateMessageBodyDefault() { switch (this.SOURCE_ENTITY) { case APP_ENTITIES.SALES_LEAD: LeadMasterInfoModel model = (new ServiceSalesLead()).GetLeadMasterInfo(this.SOURCE_ENTITY_ID); if (model != null) { txtMessage.Text = string.Format("\n\nLead : {0} dt. {1}", model.LeadNo, model.LeadDate.Value.ToString("dd MMM yyyy")); txtMessage.Text += string.Format("\nParty : {0} ", model.LeadName); txtMessage.Text += string.Format("\nRequirement:\n{0} ", model.LeadRequirement); } break; case APP_ENTITIES.SALES_ENQUIRY: TBL_MP_CRM_SalesEnquiry dbEnquiry = (new ServiceSalesEnquiry()).GetEnquiryMasterDBInfo(this.SOURCE_ENTITY_ID); if (dbEnquiry != null) { txtMessage.Text = string.Format("\n\nEnquiry : {0} dt. {1}", dbEnquiry.SalesEnquiry_No, dbEnquiry.SalesEnquiry_Date.ToString("dd MMM yyyy")); txtMessage.Text += string.Format("\nParty : {0} ", dbEnquiry.Tbl_MP_Master_Party.PartyName); txtMessage.Text += string.Format("\nRequirement:\n{0} ", dbEnquiry.General_Description); } break; } }
private void PopulateClientInfo() { try { headerGroupClient.ValuesPrimary.Heading = "CLIENT:"; txtClientInfo.Text = string.Empty; TBL_MP_CRM_SalesEnquiry objEnquiry = (new ServiceSalesEnquiry()).GetEnquiryMasterDBInfo(this.SelectedEnquiryID); if (objEnquiry == null) { return; } SelectedClientID = (int)objEnquiry.FK_Customer_ID; headerGroupClient.ValuesPrimary.Heading = string.Format("CLIENT: {0}", objEnquiry.Tbl_MP_Master_Party.PartyCode); string strInfo = objEnquiry.Tbl_MP_Master_Party.PartyName.ToUpper(); strInfo += string.Format("\nemail: {0} Website: {1}", objEnquiry.Tbl_MP_Master_Party.EmailID, objEnquiry.Tbl_MP_Master_Party.Website); strInfo += string.Format("\nGST NO: {0}", objEnquiry.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, "ControlSalesEnquiryClientIDetails::PopulateClientInfo", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void PopulateSelectedSalesEnquiryInfo() { try { TBL_MP_CRM_SalesEnquiry objEnquiry = (new ServiceSalesEnquiry()).GetEnquiryMasterDBInfo(SelectedSalesEnquiryID); 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 == objEnquiry.FK_Userlist_ProjectType_ID).FirstOrDefault(); PopulateCitiesDropdown((int)objEnquiry.FK_Project_State_ID); cboProjectLocation.SelectedItem = ((List <SelectListItem>)cboProjectLocation.DataSource).Where(x => x.ID == objEnquiry.FK_Project_City_ID).FirstOrDefault(); } Tbl_MP_Master_Party party = objEnquiry.Tbl_MP_Master_Party; if (party != null) { cboClient.SelectedItem = ((List <SelectListItem>)cboClient.DataSource).Where(x => x.ID == objEnquiry.FK_Customer_ID).FirstOrDefault(); } } catch (Exception ex) { string errMessage = ex.Message; if (ex.InnerException != null) { errMessage += string.Format("\n{0}", ex.InnerException.Message); } MessageBox.Show(errMessage, "frmSalesQuotation::PopulateSelectedSalesEnquiryInfo", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public string GenerateDesignBOQNumber(int salesEnquiryID) { string strNumber = string.Empty; TBL_MP_CRM_SalesEnquiry enquiry = (new ServiceSalesEnquiry()).GetEnquiryMasterDBInfo(salesEnquiryID); if (enquiry != null) { strNumber = enquiry.SalesEnquiry_No; } int cnt = _dbContext.TBL_MP_CRM_SalesEnquiry_BOQ.Where(x => x.ENQUIRY_ID == salesEnquiryID).Count(); strNumber = string.Format("{0}#D{1}", strNumber, (++cnt).ToString().PadLeft(3, '0')); return(strNumber); }
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); }
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); } }
private void GatherData() { try { if (this.SalesEnquiryID == 0) { EnquiryModel = new TBL_MP_CRM_SalesEnquiry(); EnquiryModel.SalesEnquiry_No = _UNIT.SalesEnquiryService.GenerateNewSalesEnquiryNumber(Program.CURR_USER.FinYearID, Program.CURR_USER.BranchID, Program.CURR_USER.CompanyID); } else { EnquiryModel = _UNIT.AppDBContext.TBL_MP_CRM_SalesEnquiry.Where(x => x.PK_SalesEnquiryID == this.SalesEnquiryID).FirstOrDefault(); } EnquiryModel.SalesEnquiry_Date = dtEnquiryDate.Value; EnquiryModel.Enquiry_Due_Date = dtEnquiryDueDate.Value; EnquiryModel.FK_SalesLeadID = this.selectedSalesLeadID; EnquiryModel.Enquiry_Genrated_By = _EnqGeneratedBy; EnquiryModel.Enquiry_Genrated_By_Name = txtGeneratdBy.Text; if (rboEmployee.Checked) { EnquiryModel.FK_EnqGenerated_Employee_ID = GeneratorEmployeeID; } if (rboAgent.Checked) { EnquiryModel.FK_EnqGenerated_Agent_ID = GeneratorAgentID; } EnquiryModel.Project_Name = txtProjectName.Text; EnquiryModel.General_Description = txtDescription.Text; EnquiryModel.FK_Userlist_Enquiry_Status_ID = (int)cboEnquiryStatus.SelectedValue; if (EnquiryModel.FK_Userlist_Enquiry_Status_ID == STATUS_CLOSED_ID || EnquiryModel.FK_Userlist_Enquiry_Status_ID == STATUS_LOST_ID) { EnquiryModel.ReasonClose = txtReasonLost.Text; } EnquiryModel.FK_AssignedTo = (int)cboAssignedTo.SelectedValue; EnquiryModel.FK_Userlist_ProjectType_ID = (int)cboProjectSector.SelectedValue; EnquiryModel.FK_Userlist_Project_SubType_ID = (int)cboProjectSubType.SelectedValue; EnquiryModel.FK_Userlist_EnquiryType_ID = (int)cboSalesEnquiryType.SelectedValue; EnquiryModel.FK_Userlist_Submission_Mode_ID = (int)cboSumissionMode.SelectedValue; EnquiryModel.FK_Userlist_EnquirySource_ID = (int)cboEnquirySource.SelectedValue; EnquiryModel.FK_Userlist_ProjectStatus_ID = (int)cboProjectStatus.SelectedValue; EnquiryModel.Project_Value = decimal.Parse(txtProjectValue.Text.Trim()); EnquiryModel.FK_Project_Country_ID = (int)cboProjectCounty.SelectedValue; EnquiryModel.FK_Project_State_ID = (int)cboProjectState.SelectedValue; EnquiryModel.FK_Project_City_ID = (int)cboProjectCity.SelectedValue; TBL_MP_CRM_SM_SalesLead lead = _UNIT.SalesLeadService.GetLeadMasterDBInfo(this.selectedSalesLeadID); if (lead != null) { EnquiryModel.FK_Customer_ID = lead.FK_PartyID; EnquiryModel.Customer_Name = _UNIT.PartiesService.GetPartyNameByPartyID((int)lead.FK_PartyID); //EnquiryModel.Customer_Address] [varchar] (2000) NULL, } if (this.SalesEnquiryID == 0) { EnquiryModel.FK_PreparedBy = Program.CURR_USER.EmployeeID; EnquiryModel.FK_CompanyID = Program.CURR_USER.CompanyID; EnquiryModel.FK_BranchID = Program.CURR_USER.BranchID; EnquiryModel.FK_YearID = Program.CURR_USER.FinYearID; EnquiryModel.IsActive = true; EnquiryModel.CreatedDatetime = AppCommon.GetServerDateTime(); } else { EnquiryModel.LastModifiedDate = AppCommon.GetServerDateTime(); EnquiryModel.LastModifiedBy = Program.CURR_USER.EmployeeID; } } catch (Exception ex) { string errMessage = ex.Message; if (ex.InnerException != null) { errMessage += string.Format("\n{0}", ex.InnerException.Message); } MessageBox.Show(errMessage, "frmSalesEnquiry::GatherData", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void ScatterData() { if (this.SalesEnquiryID == 0) { return; } try { EnquiryModel = _UNIT.AppDBContext.TBL_MP_CRM_SalesEnquiry.Where(x => x.PK_SalesEnquiryID == this.SalesEnquiryID).FirstOrDefault(); if (EnquiryModel != null) { txtEnquiryNo.Text = EnquiryModel.SalesEnquiry_No; dtEnquiryDate.Value = EnquiryModel.SalesEnquiry_Date; dtEnquiryDueDate.Value = EnquiryModel.Enquiry_Due_Date.Value; cboSalesEnquiryType.SelectedItem = ((List <SelectListItem>)cboSalesEnquiryType.DataSource).Where(x => x.ID == EnquiryModel.FK_Userlist_EnquiryType_ID).FirstOrDefault(); cboSumissionMode.SelectedItem = ((List <SelectListItem>)cboSumissionMode.DataSource).Where(x => x.ID == EnquiryModel.FK_Userlist_Submission_Mode_ID).FirstOrDefault(); cboEnquirySource.SelectedItem = ((List <SelectListItem>)cboEnquirySource.DataSource).Where(x => x.ID == EnquiryModel.FK_Userlist_EnquirySource_ID).FirstOrDefault(); cboEnquiryStatus.SelectedItem = ((List <SelectListItem>)cboEnquiryStatus.DataSource).Where(x => x.ID == EnquiryModel.FK_Userlist_Enquiry_Status_ID).FirstOrDefault(); cboAssignedTo.SelectedItem = ((List <SelectListItem>)cboAssignedTo.DataSource).Where(x => x.ID == EnquiryModel.FK_AssignedTo).FirstOrDefault(); if (EnquiryModel.FK_Userlist_Enquiry_Status_ID == STATUS_CLOSED_ID || EnquiryModel.FK_Userlist_Enquiry_Status_ID == STATUS_LOST_ID) { EnquiryModel.ReasonClose = txtReasonLost.Text; tabPageLeadCloseReason.Visible = true; } TBL_MP_CRM_SM_SalesLead lead = _UNIT.SalesLeadService.GetLeadMasterDBInfo((int)EnquiryModel.FK_SalesLeadID); if (lead != null) { selectedSalesLeadID = lead.PK_SalesLeadID; PopulateSaleLead(); } txtDescription.Text = EnquiryModel.General_Description; txtProjectName.Text = EnquiryModel.Project_Name; SelectedCountryID = (int)EnquiryModel.FK_Project_Country_ID; cboProjectCounty.SelectedItem = ((List <SelectListItem>)cboProjectCounty.DataSource).Where(x => x.ID == SelectedCountryID).FirstOrDefault(); PopulateProjectStatesDropDowns(); SelectedStateID = (int)EnquiryModel.FK_Project_State_ID; cboProjectState.SelectedItem = ((List <SelectListItem>)cboProjectState.DataSource).Where(x => x.ID == SelectedStateID).FirstOrDefault(); PopulateProjectCitiesDropDowns(); SelectedCityID = (int)EnquiryModel.FK_Project_City_ID; cboProjectCity.SelectedItem = ((List <SelectListItem>)cboProjectCity.DataSource).Where(x => x.ID == SelectedCityID).FirstOrDefault(); txtProjectValue.Text = string.Format("{0:0.00}", EnquiryModel.Project_Value); cboProjectSector.SelectedItem = ((List <SelectListItem>)cboProjectSector.DataSource).Where(x => x.ID == EnquiryModel.FK_Userlist_ProjectType_ID).FirstOrDefault(); cboProjectSubType.SelectedItem = ((List <SelectListItem>)cboProjectSubType.DataSource).Where(x => x.ID == EnquiryModel.FK_Userlist_Project_SubType_ID).FirstOrDefault(); cboProjectStatus.SelectedItem = ((List <SelectListItem>)cboProjectStatus.DataSource).Where(x => x.ID == EnquiryModel.FK_Userlist_ProjectStatus_ID).FirstOrDefault(); switch (EnquiryModel.Enquiry_Genrated_By) { case "R": rboRefrence.Checked = true; break; case "A": rboAgent.Checked = true; GeneratorAgentID = (int)EnquiryModel.FK_EnqGenerated_Agent_ID; break; case "E": rboEmployee.Checked = true; GeneratorEmployeeID = (int)EnquiryModel.FK_EnqGenerated_Employee_ID; break; } _EnqGeneratedBy = EnquiryModel.Enquiry_Genrated_By; txtGeneratdBy.Text = EnquiryModel.Enquiry_Genrated_By_Name; } } catch (Exception ex) { string errMessage = ex.Message; if (ex.InnerException != null) { errMessage += string.Format("\n{0}", ex.InnerException.Message); } MessageBox.Show(errMessage, "frmSalesEnquiry::ScatterData", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
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 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); }