- using System;
- using System.Collections.Generic;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading;
- using System.Windows.Forms;
- using System.Configuration;
- using Reliance.CMS.Common.Helper;
- using System.IO;
- using System.Runtime.Remoting.Messaging;
- using Reliance_CMS.FSMService;
- using Reliance_CMS.SolomonService;
- using SHDocVw;
- using System.Data;
- using System.Runtime.InteropServices;
- namespace Reliance_CMS
- {
- /// <summary>
- /// Author: Mohammed El-Araby
- /// Created: October, 2012
- /// Description: Desktop Form
- /// </summary>
- public partial class FrmReliance_CMS : Form
- {
- [DllImport("KERNEL32.DLL", EntryPoint = "SetProcessWorkingSetSize", SetLastError = true, CallingConvention = CallingConvention.StdCall)]
- internal static extern bool SetProcessWorkingSetSize(IntPtr pProcess, int dwMinimumWorkingSetSize, int dwMaximumWorkingSetSize);
- [DllImport("KERNEL32.DLL", EntryPoint = "GetCurrentProcess", SetLastError = true, CallingConvention = CallingConvention.StdCall)]
- internal static extern IntPtr GetCurrentProcess();
- StickyMessage stickyMessage = new StickyMessage();
- private SyncSrv.SynchronizationServiceClient _syncServClient;
- private SolomonService.CMS_ServiceBookingClient SolomonService;
- private SolomonService.SolomonCustomerInfo solomonCustomer;
- private FSMService.CMS_ServiceBookingClient FSMService;
- private FSMService.SolomonCustomerInfo fsmCustomer;
- private Thread _thrSyncSer;
- private ServiceCallParams _serviceCallParams;
- private ServiceCallParams _SiteSearchserviceCallParams;
- private string _creationTypeParam;
- private bool _isNewCustomer;
- public bool HasNewNote
- {
- get
- {
- var hf = GetHiddenNote();
- if (hf != null)
- return hf.GetAttribute("value") == "1" ? true : false;
- return false;
- }
- set
- {
- var hf = GetHiddenNote();
- if (hf != null)
- hf.SetAttribute("value", value ? "1" : "0");
- }
- }
- private HtmlElement GetHiddenNote()
- {
- HtmlElement element = null;
- if (wbCRMSuperScreen.Document != null)
- {
- if (wbCRMSuperScreen.Document.Window.Frames.Count > 0)
- {
- foreach (HtmlWindow item in wbCRMSuperScreen.Document.Window.Frames)
- {
- if (item.Frames.Count > 0)
- {
- foreach (HtmlWindow item1 in item.Frames)
- {
- element = item1.Document.GetElementById("hdnNote");
- if (element != null)
- return element;
- }
- }
- }
- }
- }
- return element;
- }
- // create new popup
- FrmPopup popup;
- public FrmReliance_CMS()
- {
- InitializeComponent();
- }
- private void frmReliance_CMS_Load(object sender, EventArgs e)
- {
- //Log method start
- LogWrapper.LogMethodStart("frmReliance_CMS_Load(object sender, EventArgs e)", new string[] { "sender", "e" }, new object[] { sender, e });
- DBConfigurations.LoadConfigurations();
- // Code updated By Mohamed ElAtafy to View CRM Organization Name ISR# 52899
- LblCRMIndicator.Text = ConfigurationManager.AppSettings["CMSInstanceDisplayName"];
- LblCRMIndicator2.Text = LblCRMIndicator.Text;
- /***********************************************************************************************************/
- popup = new FrmPopup(false);
- dgvSearchResultSearchSites.AutoGenerateColumns = false;
- dgvSearchResult.AutoGenerateColumns = false;
- Screen Srn = Screen.PrimaryScreen;
- int tempHeight = Srn.Bounds.Width;
- int tempWidth = Srn.Bounds.Height;
- if (tempHeight == 1024 && tempWidth == 768)
- {
- this.Size = new Size(832, 726);
- dgvSearchResult.Columns["CustomerCode"].Width = 80;
- dgvSearchResult.Columns["PremiseCode"].Width = 80;
- dgvSearchResult.Columns["CustomerName"].Width = 120;
- dgvSearchResult.Columns["Address2"].Width = 80;
- dgvSearchResult.Columns["CustomerType"].Width = 80;
- dgvSearchResult.Columns["CustomerStatus"].Width = 75;
- dgvSearchResult.Columns["CrmID"].Width = 100;
- dgvSearchResult.Columns["CrmGUID"].Width = 100;
- }
- this.Height = Screen.PrimaryScreen.WorkingArea.Height;
- try
- {
- //Fill customer type dropdown list
- BindCustomerTypeddl();
- //Watch for changes in the given Sticky key. By calling this function, you register to receive events of type StickyValueChanged for the key you specify
- stickyData.WatchStickyValue(ConfigurationManager.AppSettings["UPSTARTAppID"], ConfigurationManager.AppSettings["SEARCHKey"]);
- stickyData.WatchStickyValue(ConfigurationManager.AppSettings["AvayaAppID"], ConfigurationManager.AppSettings["AvayaKey"]);
- }
- catch (Exception exception)
- {
- HandleExceptions(exception);
- }
- CenterToScreen();
- //To Add new Web Control on the screen called webQASSearch
- //webQASSearch.Navigate("http://" + ConfigurationManager.AppSettings["ServerName"] + "/" + ConfigurationManager.AppSettings["WebResourcesVirualDirectory"] + "/CMSQAS.htm");
- //Log method End
- LogWrapper.LogMethodEnd("frmReliance_CMS_Load(object sender, EventArgs e)", true);
- LoadLookups();
- }
- private void LoadLookups()
- {
- LoadDirections();
- LoadSuffix();
- LoadUnitType();
- LoadProvince();
- }
- private void LoadProvince()
- {
- string CanadaCode = "CAN";
- if(ConfigurationManager.AppSettings["CanadaCode"]!=null && !string.IsNullOrEmpty(ConfigurationManager.AppSettings["CanadaCode"]))
- CanadaCode=ConfigurationManager.AppSettings["CanadaCode"];
- DataSet ds = Reliance.CMS.CRM.Helper.CMSCRMDataAccessWrapper.GetProvincesByCountry(true, CanadaCode);
- if (ds != null)
- {
- ddlProvince.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDown;
- ddlProvince.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
- ddlProvince.AutoCompleteSource = AutoCompleteSource.ListItems;
- DataTable t = new DataTable();
- t.Columns.Add("Description", typeof(string));
- t.Columns.Add("Code", typeof(string));
- foreach (DataRow dr in ds.Tables[0].Rows)
- {
- //Description
- // ddlProvince.Items.Add(dr["Code"]).ToString();
- t.Rows.Add(dr["Description"].ToString(), dr["Code"].ToString());
- }
- ddlProvince.DataSource = t;
- ddlProvince.ValueMember = "Code";
- ddlProvince.DisplayMember = "Description";
- ddlProvince.SelectedItem = null;
- }
- }
- private void LoadUnitType()
- {
- DataSet ds = Reliance.CMS.CRM.Helper.CMSCRMDataAccessWrapper.GetUnitTypes(true);
- if (ds != null)
- {
- ddlUnitType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDown;
- ddlUnitType.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
- ddlUnitType.AutoCompleteSource = AutoCompleteSource.ListItems;
- DataTable t = new DataTable();
- t.Columns.Add("Code", typeof(string));
- t.Columns.Add("Id", typeof(string));
- foreach (DataRow dr in ds.Tables[0].Rows)
- {
- t.Rows.Add(dr["Code"].ToString(), dr["Id"].ToString());
- }
- ddlUnitType.DataSource = t;
- ddlUnitType.ValueMember = "Id";
- ddlUnitType.DisplayMember = "Code";
- ddlUnitType.SelectedItem = null;
- }
- }
- private void LoadSuffix()
- {
- DataSet ds = Reliance.CMS.CRM.Helper.CMSCRMDataAccessWrapper.GetSuffix(true);
- if (ds != null)
- {
- ddlSuffix.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDown;
- ddlSuffix.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
- ddlSuffix.AutoCompleteSource = AutoCompleteSource.ListItems;
- DataTable t = new DataTable();
- t.Columns.Add("Code", typeof(string));
- t.Columns.Add("Id", typeof(string));
- foreach (DataRow dr in ds.Tables[0].Rows)
- {
- t.Rows.Add(dr["Code"].ToString(), dr["Id"].ToString());
- }
- ddlSuffix.DataSource = t;
- ddlSuffix.ValueMember = "Id";
- ddlSuffix.DisplayMember = "Code";
- ddlSuffix.SelectedItem = null;
- }
- }
- private void LoadDirections()
- {
- DataSet ds = Reliance.CMS.CRM.Helper.CMSCRMDataAccessWrapper.GetDirections(true);
- if (ds != null)
- {
- //Pre Direction
- ddlPreDir.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDown;
- ddlPreDir.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
- ddlPreDir.AutoCompleteSource = AutoCompleteSource.ListItems;
- ////Post Direction
- ddlPostDir.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDown;
- ddlPostDir.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
- ddlPostDir.AutoCompleteSource = AutoCompleteSource.ListItems;
- DataTable t1 = new DataTable();
- t1.Columns.Add("Code", typeof(string));
- t1.Columns.Add("Id", typeof(string));
- DataTable t2 = new DataTable();
- t2.Columns.Add("Code", typeof(string));
- t2.Columns.Add("Id", typeof(string));
- foreach (DataRow dr in ds.Tables[0].Rows)
- {
- t1.Rows.Add(dr["Code"].ToString(), dr["Id"].ToString());
- t2.Rows.Add(dr["Code"].ToString(), dr["Id"].ToString());
- }
- ddlPreDir.DataSource = t1;
- ddlPreDir.ValueMember = "Id";
- ddlPreDir.DisplayMember = "Code";
- ddlPreDir.SelectedItem = null;
- ddlPostDir.DataSource = t2;
- ddlPostDir.ValueMember = "Id";
- ddlPostDir.DisplayMember = "Code";
- ddlPostDir.SelectedItem = null;
- }
- }
- /// <summary>
- /// The connection with CTI System is fully established
- /// </summary>
- private void stickyData_NowConnected(object sender, EventArgs e)
- {
- //Log method start
- LogWrapper.LogMethodStart("stickyData_NowConnected(object sender, EventArgs e)", new string[] { "sender", "e" }, new object[] { sender, e });
- //Log Message: Now Connected
- LogWrapper.LogInformation(Messages.Inf0101020001, "0101020001");
- //Log method End
- LogWrapper.LogMethodEnd("stickyData_NowConnected(object sender, EventArgs e)", true);
- }
- /// <summary>
- /// The connection with CTI System is lost
- /// </summary>
- private void stickyData_NowDisconnected(object sender, EventArgs e)
- {
- //Log method start
- LogWrapper.LogMethodStart("stickyData_NowDisconnected(object sender, EventArgs e)", new string[] { "sender", "e" }, new object[] { sender, e });
- //Log Message: Now Disconnected
- LogWrapper.LogInformation(Messages.Inf0101030001, "0101030001");
- //Log method End
- LogWrapper.LogMethodEnd("stickyData_NowDisconnected(object sender, EventArgs e)", true);
- }
- /// <summary>
- /// This event is fired when a problem is encountered with CTI connection, such as a version mismatch between the control and the CT client software
- /// </summary>
- private void stickyData_Problem(object sender, UpstreamWorks.SDK.Components.ProblemEventArgs e)
- {
- //Log method start
- LogWrapper.LogMethodStart("stickyData_Problem(object sender, UpstreamWorks.SDK.Components.ProblemEventArgs e)", new string[] { "sender", "e" }, new object[] { sender, e });
- //Log Message: A problem is encountered with CTI connection
- LogWrapper.LogInformation(Messages.Err0101040001, "0101040001");
- //Log method End
- LogWrapper.LogMethodEnd("stickyData_Problem(object sender, UpstreamWorks.SDK.Components.ProblemEventArgs e)", true);
- }
- /// <summary>
- /// This event fires when the sticky value being watched has changed
- /// </summary>
- private void stickyData_StickyValueChanged(object sender, UpstreamWorks.SDK.Components.StickyValueChangedEventArgs e)
- {
- //Log method start
- LogWrapper.LogMethodStart("stickyData_StickyValueChanged(object sender, UpstreamWorks.SDK.Components.StickyValueChangedEventArgs e)", new string[] { "sender", "e" }, new object[] { sender, e });
- try
- {
- stickyMessage.ApplicationID = e.ApplicationId.Trim();
- stickyMessage.Msgkey = e.Key.Trim();
- stickyMessage.MsgValue = e.Value.Trim();
- if (stickyMessage.IsUpStartAckMsg())
- {
- //Ignore and log debug
- LogWrapper.LogInformation(Messages.Inf0101070001);
- }
- else if (stickyMessage.IsCMSAckMsg())
- {
- //Log and display a notification message i.e. message has been successfully sent to Upstart
- LogWrapper.LogInformation(Messages.Inf0101070002);
- }
- else if (stickyMessage.IsCMSMsg())
- {
- //Ignore and log debug
- LogWrapper.LogInformation(Messages.Inf0101070003);
- }
- else if (stickyMessage.ValidateAvayaMessage())
- {
- //Reset application controls
- ResetCMSDesktopApp();
- //Open either search screen or super screen
- var objCust = stickyMessage.ParseAvayaMsg();
- // Get Cust Id from the CRM and the customer type
- SearchByCustPremCode(objCust);
- }
- else if (stickyMessage.ValidateStickyMessage())
- {
- //Reset application controls
- ResetCMSDesktopApp();
- //Open either search screen or super screen
- OpenSuitableTab(stickyMessage.ParseSearchMsg());
- //Normal UpStart messages to be processed
- SendAckMSG();
- }
- }
- catch (Exception exception)
- {
- HandleExceptions(exception);
- }
- //Log method End
- LogWrapper.LogMethodEnd("stickyData_StickyValueChanged(object sender, UpstreamWorks.SDK.Components.StickyValueChangedEventArgs e)", true);
- }
- /// <summary>
- /// Send successfully received acknowledgement message to UpStart
- /// </summary>
- void SendAckMSG()
- {
- //Log method start
- LogWrapper.LogMethodStart("SendAckMSG()", null, null);
- //Send acknowledgement to UpStart
- stickyData.SetSticky(stickyMessage.ApplicationID, stickyMessage.Msgkey, stickyMessage.SuccessMSG);
- //Log method End
- LogWrapper.LogMethodEnd("SendAckMSG()", true);
- }
- /// <summary>
- /// Open either advanced search tab or CRM tab with customer info
- /// </summary>
- /// <param name="customer">Customer Information</param>
- void OpenSuitableTab(Customer customer)
- {
- //Log method start
- LogWrapper.LogMethodStart("OpenSuitableTab(Customer customer)", new string[] { "customer" }, new object[] { customer });
- if (customer.Match.ToUpper() == stickyMessage.MultipleMatch || customer.Match.ToUpper() == stickyMessage.MultipleMatchSystem)
- {
- //Multiple match
- //Open advanced search with customer info
- BindCusInfoToSearchScreen(customer);
- //Display the matched records in the gridview
- SearchCustomer();
- }
- else if (customer.Match.ToUpper() == stickyMessage.NoMatch)
- {
- //No match
- //Open advanced search with customer info
- BindCusInfoToSearchScreen(customer);
- //Empty gripview with message no data found
- }
- else
- {
- //Single match
- //Open the super screen with customer info
- OpenAccountInfoTab(customer);
- }
- //Log method End
- LogWrapper.LogMethodEnd("OpenSuitableTab(Customer customer)", true);
- }
- /// <summary>
- /// Open advanced search with customer info.
- /// </summary>
- /// <param name="customer">Customer Information</param>
- void BindCusInfoToSearchScreen(Customer customer)
- {
- //Log method start
- LogWrapper.LogMethodStart("BindCusInfoToSearchScreen(Customer customer)", new string[] { "customer" }, new object[] { customer });
- //Open search screen
- tcRelianceDesktop.SelectedTab = tbCustomersSearch;
- //Bing customer info. to the screen
- if (!string.IsNullOrEmpty(customer.Phone))
- txtPhoneNo.Text = customer.Phone;
- if (!string.IsNullOrEmpty(customer.Street))
- txtStreetNo.Text = customer.Street;
- if (!string.IsNullOrEmpty(customer.Bkend))
- {
- //Banner customer
- if (customer.Bkend.ToUpper() == stickyMessage.BannerCust)
- ddlCustomerType.SelectedItem = Messages.CustRental;
- //Solomon Customer
- else
- ddlCustomerType.SelectedItem = Messages.CustWarranty;
- }
- else
- //No match
- ddlCustomerType.SelectedItem = Messages.CustBoth;
- //Log method End
- LogWrapper.LogMethodEnd("BindCusInfoToSearchScreen(Customer customer)", true);
- }
- Customer _Customer = new Customer();
- string PageLayoutId = "";
- /// <summary>
- /// Open Account Information Tab
- /// </summary>
- /// <param name="customer">Customer Information</param>
- void OpenAccountInfoTab(Customer customer)
- {
- _isNewCustomer = false;
- _Customer = customer;
- //Log method start
- LogWrapper.LogMethodStart("OpenAccountInfoTab(Customer customer)", new string[] { "customer" }, new object[] { customer });
- if (!string.IsNullOrEmpty(customer.Bkend) && customer.Bkend.Equals(stickyMessage.BannerCust))
- //Banner customer
- PageLayoutId = ConfigurationManager.AppSettings["BannerPageLayoutId"];
- else
- //Solomon customer
- PageLayoutId = ConfigurationManager.AppSettings["SolomonPageLayoutId"];
- string curDir = Directory.GetCurrentDirectory();
- //WaitUntilIEisFree();
- //CreateNewIEControl();
- CheckOpenedServiceBookingWindow();
- RefreshwebBroswerControl();
- wbCRMSuperScreen.Navigate(String.Format("file:///{0}/progress.htm", curDir));
- refreshed = false;
- //Open super screen
- tcRelianceDesktop.SelectedTab = tbAccountInfo;
- //Log method End
- LogWrapper.LogMethodEnd("OpenAccountInfoTab(Customer customer)", true);
- }
- /// <summary>
- /// Webbroswer control has extensive memory leak issue. This function does not totlally resolve the isssue
- /// but reduces the effect
- /// </summary>
- private void RefreshwebBroswerControl()
- {
- this.wbCRMSuperScreen.Dispose();
- this.wbCRMSuperScreen = null;
- this.tbAccountInfo.Controls.Remove(this.wbCRMSuperScreen);
- IntPtr pHandle = GetCurrentProcess();
- SetProcessWorkingSetSize(pHandle, -1, -1);
- GC.Collect();
- GC.WaitForPendingFinalizers();
- GC.Collect();
- this.wbCRMSuperScreen = new System.Windows.Forms.WebBrowser();
- this.wbCRMSuperScreen.Dock = System.Windows.Forms.DockStyle.Fill;
- this.wbCRMSuperScreen.Location = new System.Drawing.Point(3, 3);
- this.wbCRMSuperScreen.Margin = new System.Windows.Forms.Padding(0);
- this.wbCRMSuperScreen.MinimumSize = new System.Drawing.Size(20, 20);
- this.wbCRMSuperScreen.Name = "wbCRMSuperScreen";
- this.wbCRMSuperScreen.Size = new System.Drawing.Size(1013, 697);
- this.wbCRMSuperScreen.TabIndex = 6;
- this.wbCRMSuperScreen.Url = new System.Uri("", System.UriKind.Relative);
- this.wbCRMSuperScreen.DocumentCompleted += new System.Windows.Forms.WebBrowserDocumentCompletedEventHandler(this.wbCRMSuperScreen_DocumentCompleted);
- this.wbCRMSuperScreen.Navigated += new System.Windows.Forms.WebBrowserNavigatedEventHandler(this.wbCRMSuperScreen_Navigated);
- this.tbAccountInfo.Controls.Add(this.wbCRMSuperScreen);
- this.wbCRMSuperScreen.Show();
- }
- void OpenNewCustomerTab()
- {
- _isNewCustomer = true;
- LogWrapper.LogMethodStart("OpenNewCustomerTab()", null, null);
- PageLayoutId = ConfigurationManager.AppSettings["NewCustomerPageLayoutId"];
- string curDir = Directory.GetCurrentDirectory();
- CheckOpenedServiceBookingWindow();
- wbCRMSuperScreen.Navigate(String.Format("file:///{0}/progress.htm", curDir));
- //Open super screen
- tcRelianceDesktop.SelectedTab = tbAccountInfo;
- LogWrapper.LogMethodEnd("OpenNewCustomerTab()", true);
- }
- /// <summary>
- /// tarek said: performance fix and resource in use fix
- /// </summary>
- private void CreateNewIEControl()
- {
- wbCRMSuperScreen.Dispose();
- System.GC.Collect();
- this.wbCRMSuperScreen = new System.Windows.Forms.WebBrowser();
- this.wbCRMSuperScreen.Dock = System.Windows.Forms.DockStyle.Fill;
- this.wbCRMSuperScreen.Location = new System.Drawing.Point(3, 3);
- this.wbCRMSuperScreen.Margin = new System.Windows.Forms.Padding(0);
- this.wbCRMSuperScreen.MinimumSize = new System.Drawing.Size(20, 20);
- this.wbCRMSuperScreen.Name = "wbCRMSuperScreen";
- this.wbCRMSuperScreen.Size = new System.Drawing.Size(1006, 899);
- this.wbCRMSuperScreen.TabIndex = 6;
- this.wbCRMSuperScreen.Url = new System.Uri("", System.UriKind.Relative);
- this.tbAccountInfo.Controls.Add(this.wbCRMSuperScreen);
- this.wbCRMSuperScreen.Navigated += new System.Windows.Forms.WebBrowserNavigatedEventHandler(this.wbCRMSuperScreen_Navigated);
- }
- /// <summary>
- /// Handle application exceptions
- /// </summary>
- /// <param name="exception">Exception</param>
- void HandleExceptions(Exception exception)
- {
- //Log method start
- LogWrapper.LogMethodStart("HandleExceptions(Exception exception)", new string[] { "exception" }, new object[] { exception });
- LogWrapper.LogError(exception.Message);
- //Only validation exceptions(custom exceptions) will be sent to UPSTART
- if (exception.Source == stickyMessage.ExceptionSource)
- stickyData.SetSticky(stickyMessage.ApplicationID, stickyMessage.Msgkey, stickyMessage.FailureMSG + exception.Message);
- if (ConfigurationManager.AppSettings["ThrowExceptions"] == Enums.ThrowExceptions.Yes.ToString())
- throw exception;
- else
- MessageBox.Show(Messages.Err0101080001, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
- //Log method End
- LogWrapper.LogMethodEnd("HandleExceptions(Exception exception)", true);
- }
- /// <summary>
- /// Reset application controls
- /// </summary>
- public void ResetCMSDesktopApp()
- {
- //reset search screen controls
- ResetAdvancedSearch(pnlSearchFields);
- //clear grid
- var lstCustomer = new List<SearchSrv.respCustomerTable>(); // Empty data source to avoid losing grid columns if we set its data source with null
- dgvSearchResult.DataSource = lstCustomer;
- lblNotMsg.Text = string.Empty;
- lblSearchResults.Text = @"Search Results";
- ddlPreDir.SelectedItem = null;
- ddlSuffix.SelectedItem = null;
- ddlPostDir.SelectedItem = null;
- ddlProvince.SelectedItem = null;
- ddlUnitType.SelectedItem = null;
- validCity = validFirstName = validLastName = ValidPhoneNo = validPostalCode = validPostDir = validPreDir = validProvince = validStreetName = validStreetNo = validSuffix = validUnitNum = validUnitType = true;
- }
- /// <summary>
- /// Reset Advanced search tab controls
- /// </summary>
- /// <param name="form">Application Form</param>
- public void ResetAdvancedSearch(Control form)
- {
- //remove recursion and clear controls by their names
- foreach (Control ctrl in form.Controls)
- {
- if (ctrl.Controls.Count > 0)
- ResetAdvancedSearch(ctrl);
- //Reset the control
- Reset(ctrl);
- }
- }
- /// <summary>
- /// Reset application control
- /// </summary>
- /// <param name="ctrl">Control to be reset</param>
- public void Reset(Control ctrl)
- {
- TextBox tb = ctrl as TextBox;
- if (tb != null)
- {
- if (tb != null)
- {
- //Clear textbox
- tb.ResetText();
- }
- }
- else
- {
- ComboBox dd = ctrl as ComboBox;
- if (dd != null)
- {
- if (dd != null)
- {
- //reset dropdown list
- dd.SelectedIndex = 0;
- }
- }
- }
- }
- /// <summary>
- /// Validate customer information that user enters in the search fields
- /// </summary>
- /// <returns>true: valid, false: not valid</returns>
- bool ValidateCustomer()
- {
- if (!String.IsNullOrEmpty(txtServiceCallId.Text.Trim()))
- {
- //check if other search criteria exists
- if (!string.IsNullOrEmpty(txtCustomerCode.Text.Trim()) || !string.IsNullOrEmpty(txtPremiseCode.Text.Trim()) || !string.IsNullOrEmpty(txtLastName.Text.Trim()) ||
- !string.IsNullOrEmpty(txtFirstName.Text.Trim()) || !string.IsNullOrEmpty(txtPhoneNo.Text.Trim()) || !string.IsNullOrEmpty(txtStreetNo.Text.Trim()) ||
- !string.IsNullOrEmpty(txtStreetName.Text.Trim()) || !string.IsNullOrEmpty(txtPostalCode.Text.Trim()) || !string.IsNullOrEmpty(txtUnitNum.Text.Trim()) ||
- !string.IsNullOrEmpty(txtCity.Text.Trim()))
- {
- MessageBox.Show(Messages.Err0102220023);
- return false;
- }
- else
- return true;
- }
- //Validate if all fields are empty
- if (string.IsNullOrEmpty(txtCustomerCode.Text.Trim()) &&
- string.IsNullOrEmpty(txtPremiseCode.Text.Trim()) &&
- string.IsNullOrEmpty(txtLastName.Text.Trim()) &&
- string.IsNullOrEmpty(txtFirstName.Text.Trim()) &&
- string.IsNullOrEmpty(txtPhoneNo.Text.Trim()) &&
- string.IsNullOrEmpty(txtStreetNo.Text.Trim()) &&
- string.IsNullOrEmpty(txtStreetName.Text.Trim()) &&
- string.IsNullOrEmpty(txtPostalCode.Text.Trim()) &&
- string.IsNullOrEmpty(txtUnitNum.Text.Trim()) &&
- string.IsNullOrEmpty(txtCity.Text.Trim()))
- {
- MessageBox.Show(Messages.Err0101050001);
- return false;
- }
- //Validate if customer types only premise code and selects solomon customer
- if (string.IsNullOrEmpty(txtCustomerCode.Text.Trim()) &&
- !string.IsNullOrEmpty(txtPremiseCode.Text.Trim()) &&
- string.IsNullOrEmpty(txtLastName.Text.Trim()) &&
- string.IsNullOrEmpty(txtFirstName.Text.Trim()) &&
- string.IsNullOrEmpty(txtPhoneNo.Text.Trim()) &&
- string.IsNullOrEmpty(txtStreetNo.Text.Trim()) &&
- string.IsNullOrEmpty(txtStreetName.Text.Trim()) &&
- string.IsNullOrEmpty(txtPostalCode.Text.Trim()) &&
- string.IsNullOrEmpty(txtUnitNum.Text.Trim()) &&
- string.IsNullOrEmpty(txtCity.Text.Trim()) &&
- ddlCustomerType.SelectedItem == Messages.CustWarranty)
- {
- MessageBox.Show(Messages.Err0101050006);
- return false;
- }
- //Validate existence of first name without last name
- if (!string.IsNullOrEmpty(txtFirstName.Text.Trim()) && string.IsNullOrEmpty(txtLastName.Text.Trim()))
- {
- MessageBox.Show(Messages.Err0101050002);
- return false;
- }
- /* Cancelled By Client Request //Validate length of premise code
- if (!string.IsNullOrEmpty(txtPremiseCode.Text.Trim()) && txtPremiseCode.Text.Trim().Length != 7)
- {
- MessageBox.Show(Messages.Err0101050003);
- return false;
- }*/
- //If there is no street name/number in an Addr1 field, then it is not a valid address that CMS needs to search
- //Validate if there is a street number without street name in the search fields
- if (string.IsNullOrEmpty(txtStreetName.Text.Trim())
- && (!string.IsNullOrEmpty(txtStreetNo.Text.Trim()) ||
- !string.IsNullOrEmpty(txtPostalCode.Text.Trim())
- ))
- {
- MessageBox.Show(Messages.Err0101050004);
- return false;
- }
- //Validate length of phone number
- if (!string.IsNullOrEmpty(txtPhoneNo.Text.Trim()) && txtPhoneNo.Text.Trim().Length < 3)
- {
- MessageBox.Show(Messages.Err0101050005);
- return false;
- }
- //Valid customer info.
- return true;
- }
- /// <summary>
- /// Search by service call id
- /// </summary>
- void SearchByServiceCallID()
- {
- LogWrapper.LogMethodStart("SearchByServiceCallID()", null, null);
- SearchSrv.SearchByServiceCallIDRequest req = new SearchSrv.SearchByServiceCallIDRequest();
- req.ServiceCallID = txtServiceCallId.Text.Trim();
- SearchSrv.WcfService_Reliance_HVAC_CTI_IVRIntegration_OrchestrationsClient ws = new SearchSrv.WcfService_Reliance_HVAC_CTI_IVRIntegration_OrchestrationsClient();
- SearchSrv.SearchByServiceCallIDResponse rsp = ws.SearchByServiceCallIDRequest(req);
- List<SearchSrv.respCustomerTable> lstCustomer = null;
- if (rsp.resp.CustomerDataSet != null)
- {
- lstCustomer = rsp.resp.CustomerDataSet.ToList();
- _serviceCallParams = new ServiceCallParams();
- _serviceCallParams.ServiceCallID = req.ServiceCallID;
- _serviceCallParams.ServiceCallStatus = rsp.ServiceCallStatus;
- }
- //Display message "No data found" if no results returned
- if (lstCustomer == null || lstCustomer.Count == 0)
- lblNotMsg.Text = Messages.Inf0101060001;
- else
- {
- lblNotMsg.Text = string.Empty;
- BindSearchResults(lstCustomer);
- }
- //Log method End
- LogWrapper.LogMethodEnd("SearchByServiceCallID()", true);
- }
- void SearchByCustPremCode(Customer cust)
- {
- var rq = new SearchSrv.req();
- rq.CustomerCode = cust.Cust;
- rq.PremiseCode = cust.Prem;
- rq.BackEnd = "";
- rq.MaxLimit = "1";
- var ws = new SearchSrv.WcfService_Reliance_HVAC_CTI_IVRIntegration_OrchestrationsClient();
- var rsp = ws.Request(rq);
- List<SearchSrv.respCustomerTable> lstCustomer = null;
- if (rsp.CustomerDataSet != null)
- lstCustomer = rsp.CustomerDataSet.ToList();
- if (lstCustomer == null || lstCustomer.Count == 0)
- {
- lblNotMsg.Text = Messages.Inf0101060001;
- }
- else
- {
- if (lstCustomer[0].CustomerType == Messages.CustRental)
- cust.Bkend = "B";
- else
- cust.Bkend = "S";
- cust.CrmGuID = lstCustomer[0].CrmGUID;
- OpenAccountInfoTab(cust);
- }
- }
- /// <summary>
- /// search by any other search criteria other than service call id
- /// </summary>
- void SearchByAccountInfo()
- {
- LogWrapper.LogMethodStart("SearchByAccountInfo()", null, null);
- const string rentalCustomer = "B";
- const string warrantyCustomer = "S";
- //Fill search results gridview with customers info.
- SearchSrv.req rq = new SearchSrv.req();
- rq.CustomerCode = txtCustomerCode.Text.Trim();
- rq.PremiseCode = txtPremiseCode.Text.Trim();
- rq.LastName = txtLastName.Text.Trim();
- rq.FirstName = txtFirstName.Text.Trim();
- rq.PhoneNumber = txtPhoneNo.Text.Trim();
- rq.StreetNumber = txtStreetNo.Text.Trim();
- rq.PreDir = ddlPreDir.SelectedItem != null ? ((System.Data.DataRowView)(ddlPreDir.SelectedItem)).Row.ItemArray[1].ToString() : "";
- rq.StreetName = txtStreetName.Text.Trim();
- rq.Suffix = ddlSuffix.SelectedItem != null ? ((System.Data.DataRowView)(ddlSuffix.SelectedItem)).Row.ItemArray[1].ToString() : "";
- rq.PostDir = ddlPostDir.SelectedItem != null ? ((System.Data.DataRowView)(ddlPostDir.SelectedItem)).Row.ItemArray[1].ToString() : "";
- rq.UnitType = ddlUnitType.SelectedItem != null ? ((System.Data.DataRowView)(ddlUnitType.SelectedItem)).Row.ItemArray[1].ToString() : "";
- rq.UnitNum = txtUnitNum.Text.Trim();
- rq.City = txtCity.Text.Trim();
- rq.Province = ddlProvince.SelectedItem != null ? ((System.Data.DataRowView)(ddlProvince.SelectedItem)).Row.ItemArray[1].ToString() : "";
- rq.PostalCode = txtPostalCode.Text.Trim();
- //”Rental”: Returns Banner customers only – “Warranty”: Returns Solomon customers only
- if (ddlCustomerType.SelectedItem == Messages.CustRental)
- //Banner customer
- rq.BackEnd = rentalCustomer;
- else if (ddlCustomerType.SelectedItem == Messages.CustWarranty)
- //Solomon customer
- rq.BackEnd = warrantyCustomer;
- else
- {
- //Both
- //If user types only premise code and selects both customers
- if (string.IsNullOrEmpty(txtCustomerCode.Text.Trim()) &&
- !string.IsNullOrEmpty(txtPremiseCode.Text.Trim()) &&
- string.IsNullOrEmpty(txtLastName.Text.Trim()) &&
- string.IsNullOrEmpty(txtFirstName.Text.Trim()) &&
- string.IsNullOrEmpty(txtPhoneNo.Text.Trim()) &&
- string.IsNullOrEmpty(txtStreetNo.Text.Trim()) &&
- string.IsNullOrEmpty(txtStreetName.Text.Trim()) &&
- string.IsNullOrEmpty(txtPostalCode.Text.Trim()) &&
- string.IsNullOrEmpty(txtUnitNum.Text.Trim()) &&
- string.IsNullOrEmpty(txtCity.Text.Trim()))
- //Search in Banner only
- rq.BackEnd = rentalCustomer;
- else
- //Search in both Banner and Solomon
- rq.BackEnd = "";
- }
- // Read a configurable integer from config file;
- rq.MaxLimit = ConfigurationManager.AppSettings["MaxDisplayedRecords"];
- SearchSrv.WcfService_Reliance_HVAC_CTI_IVRIntegration_OrchestrationsClient ws = new SearchSrv.WcfService_Reliance_HVAC_CTI_IVRIntegration_OrchestrationsClient();
- SearchSrv.resp rsp = ws.Request(rq);
- //Clear notification message label
- lblNotMsg.Text = string.Empty;
- List<SearchSrv.respCustomerTable> lstCustomer = null;
- if (rsp.CustomerDataSet != null)
- lstCustomer = rsp.CustomerDataSet.ToList();
- //Display message "No data found" if no results returned
- if (lstCustomer == null || lstCustomer.Count == 0)
- {
- lblNotMsg.Text = Messages.Inf0101060001;
- }
- else
- {
- //Display only configurable no. of records from each type if they exceed the maximum
- if (lstCustomer.Count > Convert.ToInt32(ConfigurationManager.AppSettings["MaxDisplayedRecords"]))
- {
- //Display message "The number of search results exceeds the display maximum"
- lblNotMsg.Text = Messages.Inf0101060002;
- //Bind only the configured no. of records from each source
- lstCustomer =
- lstCustomer.Take(Convert.ToInt32(ConfigurationManager.AppSettings["MaxDisplayedRecords"])).ToList();
- }
- BindSearchResults(lstCustomer);
- }
- LogWrapper.LogMethodEnd("SearchByAccountInfo()", true);
- }
- /// <summary>
- /// Change the accepti button of the form according to the selected index
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tcRelianceDesktop_SelectedIndexChanged(object sender, EventArgs e)
- {
- if (tcRelianceDesktop.SelectedIndex == 2)
- {
- this.AcceptButton = btnSearchSitesSearch;
- }
- else
- {
- this.AcceptButton = btnSearch;
- }
- ShowHideNotesIcons(false);
- }
- /// <summary>
- /// Bind search results to result grid
- /// </summary>
- /// <param name="resultSet">list of respCustomerTable to bind to result grid</param>
- void BindSearchResults(List<SearchSrv.respCustomerTable> resultSet, ServiceCallParams serviceCall = null)
- {
- LogWrapper.LogMethodStart("BindSearchResults(List<SearchSrv.respCustomerTable> resultSet)", new string[] { "resultSet" }, resultSet.ToArray<object>());
- //Display the no. of displayed recoeds as "Search Results ([N])"
- lblSearchResults.Text = "Search Results (" + resultSet.Count() + ")";
- //Map data grid colums names with data source table columns names
- dgvSearchResult.Columns["CustomerCode"].DataPropertyName = "CustomerCode";
- dgvSearchResult.Columns["PremiseCode"].DataPropertyName = "PremiseCode";
- dgvSearchResult.Columns["CustomerName"].DataPropertyName = "CustomerName";
- dgvSearchResult.Columns["Address"].DataPropertyName = "Address1";
- dgvSearchResult.Columns["Address2"].DataPropertyName = "Address2";
- dgvSearchResult.Columns["CustomerType"].DataPropertyName = "CustomerType";
- dgvSearchResult.Columns["CustomerStatus"].DataPropertyName = "CustomerStatus";
- dgvSearchResult.Columns["CrmID"].DataPropertyName = "CrmID";
- dgvSearchResult.Columns["CrmGUID"].DataPropertyName = "CrmGUID";
- dgvSearchResult.DataSource = resultSet;
- //Log method End
- LogWrapper.LogMethodEnd("BindSearchResults(List<SearchSrv.respCustomerTable> resultSet)", true);
- }
- /// <summary>
- /// Bind customers to gridview
- /// </summary>
- void SearchCustomer()
- {
- //Log method start
- LogWrapper.LogMethodStart("SearchCustomer()", null, null);
- if (!String.IsNullOrEmpty(txtServiceCallId.Text.Trim()))
- SearchByServiceCallID();
- else
- SearchByAccountInfo();
- //Log method End
- LogWrapper.LogMethodEnd("SearchCustomer()", true);
- }
- private void dgvSearchResult_CellContentClick(object sender, DataGridViewCellEventArgs e)
- {
- //Log method start
- LogWrapper.LogMethodStart("dgvSearchResult_CellContentClick(object sender, DataGridViewCellEventArgs e)", new string[] { "sender", "e" }, new object[] { sender, e });
- try
- {
- if (e.RowIndex >= 0) //user didn't click on the header
- {
- //Check whether user clicked on "Customer Name" column
- if (dgvSearchResult.Columns[e.ColumnIndex].Name == "CustomerName")
- {
- //show progress cursor
- this.Cursor = System.Windows.Forms.Cursors.WaitCursor;
- //Send selected row index
- Customer customer = GetSelectedCustomer(e.RowIndex);
- //Send customer identifier to UPSTART
- SendCustIDToUpStart(customer);
- //Open the super screen with customer info
- OpenAccountInfoTab(customer);
- }
- }
- }
- catch (Exception exception)
- {
- HandleExceptions(exception);
- }
- finally
- {
- //hide progress cursor
- this.Cursor = System.Windows.Forms.Cursors.Default;
- }
- //Log method End
- LogWrapper.LogMethodEnd("dgvSearchResult_CellContentClick(object sender, DataGridViewCellEventArgs e)", true);
- }
- /// <summary>
- /// Get selected customer info. from grid view
- /// </summary>
- /// <param name="selectedRow">Selected row index</param>
- /// <returns>Selected customer information</returns>
- Customer GetSelectedCustomer(int selectedRow)
- {
- //Log method start
- LogWrapper.LogMethodStart("GetSelectedCustomer(int selectedRow)", new string[] { "selectedRow" }, new object[] { selectedRow });
- var customer = new Customer();
- if (dgvSearchResult.Rows[selectedRow].Cells["CustomerType"].Value != null
- && !string.IsNullOrEmpty(dgvSearchResult.Rows[selectedRow].Cells["CustomerType"].Value.ToString().Trim()))
- {
- string custCode = "";
- string premCode = "";
- if (dgvSearchResult.Rows[selectedRow].Cells["CustomerCode"].Value != null
- && !string.IsNullOrEmpty(dgvSearchResult.Rows[selectedRow].Cells["CustomerCode"].Value.ToString().Trim()))
- custCode = dgvSearchResult.Rows[selectedRow].Cells["CustomerCode"].Value.ToString().Trim();
- else
- //Customer Code is null or empty
- throw new System.ArgumentException("0101150001: " + Messages.Err0101150001);
- if (dgvSearchResult.Rows[selectedRow].Cells["PremiseCode"].Value != null
- && !string.IsNullOrEmpty(dgvSearchResult.Rows[selectedRow].Cells["PremiseCode"].Value.ToString().Trim()))
- premCode = dgvSearchResult.Rows[selectedRow].Cells["PremiseCode"].Value.ToString().Trim();
- else
- //Premise Code is null or emty
- throw new System.ArgumentException("0101150002: " + Messages.Err0101150002);
- string isBanner = "False";
- //Banner customer
- if (dgvSearchResult.Rows[selectedRow].Cells["CustomerType"].Value.ToString().ToUpper().Trim() == Messages.CustRental.ToUpper())
- {
- customer.Cust = custCode;
- customer.Prem = premCode;
- customer.Bkend = stickyMessage.BannerCust;
- isBanner = "True";
- }
- //Solomon customer
- else if (dgvSearchResult.Rows[selectedRow].Cells["CustomerType"].Value.ToString().ToUpper().Trim() == Messages.CustWarranty.ToUpper())
- {
- customer.SlmnID = custCode;
- customer.SlmnSite = premCode;
- customer.Bkend = stickyMessage.SolomonCust;
- isBanner = "False";
- }
- if (dgvSearchResult.Rows[selectedRow].Cells["CrmID"].Value != null
- && !string.IsNullOrEmpty(dgvSearchResult.Rows[selectedRow].Cells["CrmID"].Value.ToString().Trim()))
- customer.CrmID = dgvSearchResult.Rows[selectedRow].Cells["CrmID"].Value.ToString().Trim();
- else
- //CrmID is null or empty
- throw new System.ArgumentException("0101150004: " + Messages.Err0101150004);
- if (dgvSearchResult.Rows[selectedRow].Cells["CrmGuID"].Value != null
- && !string.IsNullOrEmpty(dgvSearchResult.Rows[selectedRow].Cells["CrmGuID"].Value.ToString().Trim()))
- customer.CrmGuID = dgvSearchResult.Rows[selectedRow].Cells["CrmGuID"].Value.ToString().Trim();
- else
- //CrmGuID is null or empty
- throw new System.ArgumentException("0101150005: " + Messages.Err0101150005);
- //Sync CRM Record from Solomon or Banner if sync flag is true
- if (ConfigurationManager.AppSettings["Sync"] == "true")
- Sync(isBanner, ref customer);
- }
- else
- //Customer Type is null or emty
- throw new ArgumentException("0101150003: " + Messages.Err0101150003);
- //Log method End
- LogWrapper.LogMethodEnd("GetSelectedCustomer(int selectedRow)", true);
- return customer;
- }
- private bool _firstTime;
- void Sync(string isBanner, ref Customer customer)
- {
- try
- {
- if (_syncServClient == null || (_syncServClient.State != System.ServiceModel.CommunicationState.Opened &&
- _syncServClient.State != System.ServiceModel.CommunicationState.Opening))
- OpenSyncService();
- else if (_syncServClient.State == System.ServiceModel.CommunicationState.Opening)
- while (_syncServClient.State == System.ServiceModel.CommunicationState.Opening)
- {
- // do nothing
- }
- var objCmsAccount = _syncServClient.Sync(isBanner, "0", customer.Cust, customer.Prem,
- customer.SlmnID, customer.SlmnSite);
- _syncServClient.Close();
- }
- catch (Exception ex)
- {
- if (_syncServClient.State == System.ServiceModel.CommunicationState.Faulted && !_firstTime)
- {
- _syncServClient = null;
- Sync(isBanner, ref customer);
- _firstTime = true;
- }
- else
- {
- HandleExceptions(ex);
- }
- }
- }
- /// <summary>
- /// Send customer identifier to UpStart
- /// </summary>
- /// <param name="customer">Customer Information</param>
- void SendCustIDToUpStart(Customer customer)
- {
- //Log method start
- LogWrapper.LogMethodStart("SendCustIDToUpStart(Customer customer)", new string[] { "customer" }, new object[] { customer });
- //When the customer has been located, CMS has to send the following update to UpStart:
- //Example:
- //ApplicationId: CMS
- //Key:UPDATE
- //Value:PREM=xxxxxxx,CUST=xxxxxxx,CRMID=CRM-31765,CRMGUID=05C0B7BA-C7DF-49C7-A08A-7CB294B3A674 when the customer was found in Banner or
- //Value:SLMNID=xxxx,SLMNSITE=xxxx,CRMID=CRM-31765,CRMGUID=05C0B7BA-C7DF-49C7-A08A-7CB294B3A674 when the customer was found in Solomon
- StringBuilder msgValue = new StringBuilder();
- //Construct the message
- //Banner customer
- if (customer.Bkend == stickyMessage.BannerCust)
- {
- msgValue.Append(stickyMessage.PremKey).Append("=").Append(customer.Prem).Append(",");
- msgValue.Append(stickyMessage.CustKey).Append("=").Append(customer.Cust).Append(",");
- }
- //Solomon customer
- else if (customer.Bkend == stickyMessage.SolomonCust)
- {
- msgValue.Append(stickyMessage.SlmnIDKey).Append("=").Append(customer.SlmnID).Append(",");
- msgValue.Append(stickyMessage.SlmnSiteKey).Append("=").Append(customer.SlmnSite).Append(",");
- }
- msgValue.Append(stickyMessage.CrmIDKey).Append("=").Append(customer.CrmID).Append(",");
- msgValue.Append(stickyMessage.CrmGuIDKey).Append("=").Append(customer.CrmGuID);
- //Watch for changes in the given Sticky key. By calling this function, you register to receive events of type StickyValueChanged for the key you specify
- stickyData.WatchStickyValue(ConfigurationManager.AppSettings["CMSAppID"], ConfigurationManager.AppSettings["UPDATEKey"]);
- //Send the message to UpStart
- stickyData.SetSticky(ConfigurationManager.AppSettings["CMSAppID"], ConfigurationManager.AppSettings["UPDATEKey"], msgValue.ToString());
- //Log method End
- LogWrapper.LogMethodEnd("SendCustIDToUpStart(Customer customer)", true);
- }
- /// <summary>
- /// Fill customer type dropdown list
- /// </summary>
- void BindCustomerTypeddl()
- {
- //Log method start
- LogWrapper.LogMethodStart("BindCustomerTypeddl()", null, null);
- ddlCustomerType.Items.Add(Messages.CustBoth);
- ddlCustomerType.Items.Add(Messages.CustRental);
- ddlCustomerType.Items.Add(Messages.CustWarranty);
- ddlCustomerType.SelectedItem = Messages.CustBoth;
- //Log method End
- LogWrapper.LogMethodEnd("BindCustomerTypeddl()", true);
- }
- private void btnSearch_Click(object sender, EventArgs e)
- {
- try
- {
- //Validate entered customer information
- if (!validCity || !validFirstName || !validLastName || !ValidPhoneNo || !validPostalCode || !validPostDir || !validPreDir || !validProvince || !validStreetName || !validStreetNo || !validSuffix || !validUnitNum || !validUnitType)
- return;
- if (ValidateCustomer())
- {
- // open sync service connection in a different thread to save time
- if (_syncServClient == null || (_syncServClient.State != System.ServiceModel.CommunicationState.Opened && _syncServClient.State != System.ServiceModel.CommunicationState.Opening))
- {
- _thrSyncSer = new Thread(OpenSyncService);
- _thrSyncSer.Start();
- }
- //show progress cursor
- this.Cursor = System.Windows.Forms.Cursors.WaitCursor;
- //Enable create COD customer and create site buttons
- btnCreateCOD.Enabled = true;
- btnCreateSite.Enabled = true;
- //Bind customers information to search results gridview
- _serviceCallParams = null;
- SearchCustomer();
- }
- }
- catch (Exception exception)
- {
- HandleExceptions(exception);
- }
- finally
- {
- //hide progress cursor
- this.Cursor = System.Windows.Forms.Cursors.Default;
- }
- }
- void OpenSyncService()
- {
- try
- {
- LogWrapper.LogMethodStart("OpenSyncService()", null, null);
- _syncServClient = new SyncSrv.SynchronizationServiceClient();
- if (ConfigurationManager.AppSettings["UserCustomSyncServiceAuth"] == "1")
- {
- _syncServClient.ClientCredentials.Windows.AllowNtlm = true;
- _syncServClient.ClientCredentials.Windows.ClientCredential =
- new System.Net.NetworkCredential(ConfigurationManager.AppSettings["SyncServiceAuthUserName"], ConfigurationManager.AppSettings["SyncServiceAuthPassword"]);
- }
- _syncServClient.Open();
- }
- catch (Exception ex)
- {
- HandleExceptions(ex);
- }
- finally
- {
- if (_thrSyncSer != null)
- _thrSyncSer.Abort();
- LogWrapper.LogMethodEnd("OpenSyncService()", true);
- }
- }
- bool refreshed;
- FrmNotesIcons frmNotesIcons;
- private void wbCRMSuperScreen_Navigated(object sender, WebBrowserNavigatedEventArgs e)
- {
- try
- {
- if (e.Url.AbsoluteUri.ToLower().Contains("progress.htm"))
- {
- if (!_isNewCustomer)
- {
- string serviceCallParams = string.Empty;
- //Open CRM screen(super screen)
- if (_serviceCallParams != null && !string.IsNullOrEmpty(_serviceCallParams.ServiceCallID) && !string.IsNullOrEmpty(_serviceCallParams.ServiceCallStatus))
- serviceCallParams = System.Uri.EscapeDataString(string.Format("&servicecallid_1={0}&servicecallstatus_1={1}", _serviceCallParams.ServiceCallID, _serviceCallParams.ServiceCallStatus));
- wbCRMSuperScreen.Navigate("http://" + ConfigurationManager.AppSettings["ServerName"] + "/" + ConfigurationManager.AppSettings["OrgName"] + "/main.aspx?etc=2&extraqs=%3fformId%3d" + PageLayoutId + "%26_gridType%3d2%26etc%3d2%26id%3d%257b" + _Customer.CrmGuID + "%257d%26pagemode%3diframe%26preloadcache%3d1350819428384%26rskey%3d251585687" + serviceCallParams + "&pagetype=entityrecord");
- }
- else
- {
- wbCRMSuperScreen.Navigate("http://" + ConfigurationManager.AppSettings["ServerName"] + "/" + ConfigurationManager.AppSettings["OrgName"] + "/main.aspx?etc=2&extraqs=%3fformId%3d" + PageLayoutId + "%26pagemode%3diframe%26preloadcache%3d1380621615237" + _creationTypeParam + "&pagetype=entityrecord");
- }
- ShowHideNotesIcons(true);
- return;
- }
- if (!refreshed && ConfigurationManager.AppSettings["RefreshOption"] == ((int)Enums.RefreshOption.Completely).ToString())
- //Remove caching by getting the latest version of the web page
- wbCRMSuperScreen.Refresh(WebBrowserRefreshOption.Completely);
- else if (!refreshed && ConfigurationManager.AppSettings["RefreshOption"] == ((int)Enums.RefreshOption.IfExpired).ToString())
- //Request update only if the current web page has expired
- wbCRMSuperScreen.Refresh(WebBrowserRefreshOption.IfExpired);
- }
- catch (Exception exception)
- {
- HandleExceptions(exception);
- }
- refreshed = true;
- }
- private void btnClear_Click(object sender, EventArgs e)
- {
- ResetCMSDesktopApp();
- }
- private void btnCreateSite_Click(object sender, EventArgs e)
- {
- _creationTypeParam = System.Uri.EscapeDataString("&creationtype_1=175650002");
- OpenNewCustomerTab();
- }
- private void btnCreateCOD_Click(object sender, EventArgs e)
- {
- _creationTypeParam = System.Uri.EscapeDataString("&creationtype_1=175650001");
- OpenNewCustomerTab();
- }
- #region "Search Sites"
- #region "Events"
- /// <summary>
- /// clear site search button clicked
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnClearSerchSites_Click(object sender, EventArgs e)
- {
- try
- {
- //clear grid
- var lstCustomer = new List<SearchSrv.respCustomerTable>(); // Empty data source to avoid losing grid columns if we set its data source with null
- dgvSearchResultSearchSites.DataSource = lstCustomer;
- lblNoteMsgSearchSites.Text = string.Empty;
- lblSearchResultsSearchSites.Text = @"Search Results";
- //reset the text boxes
- ResetSearchSites((Button)sender);
- }
- catch (Exception ex)
- {
- HandleExceptions(ex);
- }
- }
- /// <summary>
- /// Search sites button clicked
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnSearchSitesSearch_Click(object sender, EventArgs e)
- {
- try
- {
- LogWrapper.LogMethodStart("frmReliance_CMS.btnSearchSitesSearch_Click", null, null);
- //Validate entered customer information
- if (ValidateSearchSites())
- {
- //show progress cursor
- this.Cursor = System.Windows.Forms.Cursors.WaitCursor;
- //Bind customers information to search results gridview
- _SiteSearchserviceCallParams = null;
- //search the sites with the given data
- searchSites();
- }
- LogWrapper.LogMethodEnd("frmReliance_CMS.btnSearchSitesSearch_Click", true);
- }
- catch (Exception exception)
- {
- HandleExceptions(exception);
- }
- finally
- {
- //hide progress cursor
- this.Cursor = System.Windows.Forms.Cursors.Default;
- }
- }
- /// <summary>
- /// Search sites grid cell contetnt clicked
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void dgvSearchResultSearchSites_CellContentClick(object sender, DataGridViewCellEventArgs e)
- {
- try
- {
- if (e.RowIndex >= 0) //user didn't click on the header
- {
- //user clicked on the customer name column
- if (dgvSearchResultSearchSites.Columns[e.ColumnIndex].DataPropertyName.Equals("CustomerName"))
- {
- string customerCode = getGridViewCellValueByDataPropertyName(dgvSearchResultSearchSites, e.RowIndex, "CustomerCode");
- string premiseCode = getGridViewCellValueByDataPropertyName(dgvSearchResultSearchSites, e.RowIndex, "PremiseCode");
- string switchFsmSolomonChar = getGridViewCellValueByDataPropertyName(dgvSearchResultSearchSites, e.RowIndex, "CustomerType").ToLower();
- //string placeId = "", addressId="";
- // set popup customer information fields
- switch (switchFsmSolomonChar)
- {
- case "f":
- FSMService = new FSMService.CMS_ServiceBookingClient();
- FSMService.Open();
- fsmCustomer = FSMService.GetFSMCustomer(customerCode, premiseCode);
- //var place = FSMService.GetPlaceByCustomerCode(customerCode);
- //placeId= place != null ? place.Place_id : "";
- //var address = FSMService.GetAddressByPremiseCode(premiseCode);
- //addressId= address != null ? address.Address_id : "";
- if (fsmCustomer != null)
- {
- popup.CustomerName = fsmCustomer.Name ?? "";
- popup.Telephone = fsmCustomer.Phone ?? "";
- popup.CityProvPostal = (fsmCustomer.City != null ? fsmCustomer.City.Trim() : "") + ", " + (fsmCustomer.Province != null ? fsmCustomer.Province.Trim() : "") + " " + (fsmCustomer.PostalCode != null ? fsmCustomer.PostalCode.Trim() : "");
- popup.Address = (fsmCustomer.Address1 != null ? fsmCustomer.Address1.Trim() : "") + " " + (fsmCustomer.Address2 != null ? fsmCustomer.Address2.Trim() : "");
- }
- break;
- case "s":
- default:
- SolomonService = new SolomonService.CMS_ServiceBookingClient();
- SolomonService.Open();
- solomonCustomer = SolomonService.GetSolomonCustomer(customerCode, premiseCode);
- if (solomonCustomer != null)
- {
- popup.CustomerName = solomonCustomer.Name;
- popup.Telephone = solomonCustomer.Phone;
- popup.CityProvPostal = solomonCustomer.City.Trim() + ", " + solomonCustomer.Province.Trim() + " " + solomonCustomer.PostalCode.Trim();
- popup.Address = solomonCustomer.Address1.Trim() + " " + solomonCustomer.Address2.Trim();
- }
- break;
- }
- popup.FsmSolomonSwitch = switchFsmSolomonChar;
- string serviceCallParams = string.Empty;
- //Open CRM screen(super screen)
- if (_SiteSearchserviceCallParams != null && !string.IsNullOrEmpty(_SiteSearchserviceCallParams.ServiceCallID) && !string.IsNullOrEmpty(_SiteSearchserviceCallParams.ServiceCallStatus))
- serviceCallParams = string.Format("&servicecallid={0}&servicecallstatus={1}", _SiteSearchserviceCallParams.ServiceCallID, _SiteSearchserviceCallParams.ServiceCallStatus);
- popup.setRibbonTitle("Service Orders");
- popup.setURL("http://" + ConfigurationManager.AppSettings["ServerName"] + "/" +
- "ISV/CMS/SB/ServiceOrders.htm?customerid=" + customerCode + "&shiptoid=" +
- premiseCode + "&solomonbannerflag=1&useCrm=no&isSite=1" + serviceCallParams +
- "&SwitchFsmSolomon=" + switchFsmSolomonChar
- //+(placeId == "" ? "" : "&PlaceId=" + placeId) +
- //(addressId == "" ? "" : "&AddressId=" + addressId)
- );
- popup.centerPopup();
- popup.ShowDialog();
- }
- }
- }
- catch (Exception ex)
- {
- HandleExceptions(ex);
- }
- }
- #endregion
- #region "Private Methods"
- /// <summary>
- /// validates the search criteria for the site search form
- /// </summary>
- /// <returns></returns>
- bool ValidateSearchSites()
- {
- try
- {
- if (!String.IsNullOrEmpty(txtServiceCallIdSearchSites.Text.Trim()))
- {
- //check if other search criteria exists
- if (!string.IsNullOrEmpty(txtLastNameSearchSites.Text.Trim()) ||
- !string.IsNullOrEmpty(txtFirstNameSearchSites.Text.Trim()) || !string.IsNullOrEmpty(txtPhoneNumberSearchSites.Text.Trim()) || !string.IsNullOrEmpty(txtStreetNoSearchSites.Text.Trim()) ||
- !string.IsNullOrEmpty(txtStreetNameSearchSites.Text.Trim()) || !string.IsNullOrEmpty(txtPostalCodeSearchSites.Text.Trim()) || !string.IsNullOrEmpty(txtUnitNumSearchSites.Text.Trim()) ||
- !string.IsNullOrEmpty(txtCitySearchSites.Text.Trim()))
- {
- MessageBox.Show(Messages.Err0102220023);
- return false;
- }
- else
- return true;
- }
- //Validate if all fields are empty
- if (
- string.IsNullOrEmpty(txtLastNameSearchSites.Text.Trim()) &&
- string.IsNullOrEmpty(txtFirstNameSearchSites.Text.Trim()) &&
- string.IsNullOrEmpty(txtPhoneNumberSearchSites.Text.Trim()) &&
- string.IsNullOrEmpty(txtStreetNoSearchSites.Text.Trim()) &&
- string.IsNullOrEmpty(txtStreetNameSearchSites.Text.Trim()) &&
- string.IsNullOrEmpty(txtPostalCodeSearchSites.Text.Trim()) &&
- string.IsNullOrEmpty(txtUnitNumSearchSites.Text.Trim()) &&
- string.IsNullOrEmpty(txtCitySearchSites.Text.Trim()))
- {
- MessageBox.Show(Messages.Err0101050001);
- return false;
- }
- //If there is no street name/number in an Addr1 field, then it is not a valid address that CMS needs to search
- //Validate if there is a street number without street name in the search fields
- if (string.IsNullOrEmpty(txtStreetNameSearchSites.Text.Trim())
- && (!string.IsNullOrEmpty(txtStreetNoSearchSites.Text.Trim()) ||
- !string.IsNullOrEmpty(txtPostalCodeSearchSites.Text.Trim())
- ))
- {
- MessageBox.Show(Messages.Err0101050004);
- return false;
- }
- //Validate length of phone number
- if (!string.IsNullOrEmpty(txtPhoneNumberSearchSites.Text.Trim()) && txtPhoneNumberSearchSites.Text.Trim().Length < 3)
- {
- MessageBox.Show(Messages.Err0101050005);
- return false;
- }
- //Valid customer info.
- return true;
- }
- catch (Exception ex)
- {
- LogWrapper.LogError(ex);
- throw;
- }
- }
- /// <summary>
- /// Clear all text boxes having the same parent as the sent child
- /// </summary>
- /// <param name="child"></param>
- private static void ResetSearchSites(Control child)
- {
- try
- {
- //clear all text boxex in the same container as the sent control
- foreach (Control c in child.Parent.Controls)
- {
- if (c.GetType().Equals(typeof(TextBox)))
- {
- ((TextBox)c).Clear();
- }
- }
- }
- catch (Exception ex)
- {
- LogWrapper.LogError(ex);
- throw;
- }
- }
- /// <summary>
- /// search for a site with the current criteria
- /// </summary>
- private void searchSites()
- {
- try
- {
- //Log method start
- LogWrapper.LogMethodStart("searchSites()", null, null);
- if (!String.IsNullOrEmpty(txtServiceCallIdSearchSites.Text.Trim()))
- SearchSiteByServiceCallID();
- else
- {
- //Fill search results gridview with customers info.
- SiteSearchService.SiteReq rq = new SiteSearchService.SiteReq();
- rq.LastName = txtLastNameSearchSites.Text.Trim();
- rq.FirstName = txtFirstNameSearchSites.Text.Trim();
- rq.PhoneNumber = txtPhoneNumberSearchSites.Text.Trim();
- rq.StreetNumber = txtStreetNoSearchSites.Text.Trim();
- rq.PostalCode = txtPostalCodeSearchSites.Text.Trim();
- rq.StreetName = txtStreetNameSearchSites.Text.Trim();
- //rq.SuffixCode = txtSuffixSearchSites.Text.Trim();
- //rq.PostDirectionCode = txtPostDirSearchSites.Text.Trim();
- rq.UnitNum = txtUnitNumSearchSites.Text.Trim();
- rq.City = txtCitySearchSites.Text.Trim();
- // Read a configurable integer from config file;
- rq.MaxLimit = ConfigurationManager.AppSettings["MaxDisplayedRecords"];
- SiteSearchService.WcfService_Reliance_HVAC_CTI_IVRIntegration_OrchestrationsClient ws = new SiteSearchService.WcfService_Reliance_HVAC_CTI_IVRIntegration_OrchestrationsClient();
- SiteSearchService.SiteResp rsp = ws.GetSearchResults(rq);
- //Clear notification message label
- lblNoteMsgSearchSites.Text = string.Empty;
- List<SiteSearchService.SiteRespCustomerTable> lstSites = null;
- if (rsp.CustomerDataSet != null)
- lstSites = rsp.CustomerDataSet.ToList();
- //Display message "No data found" if no results returned
- if (lstSites == null || lstSites.Count == 0)
- {
- lblNoteMsgSearchSites.Text = Messages.Inf0101060001;
- }
- else
- {
- //Display only configurable no. of records from each type (Solomon, FSM) if they exceed the maximum
- //count multiplied by 2 because results are coming from both Solomon and FSM
- //If Solomon removed from the search results, remove multiplication by 2
- if (lstSites.Count() > Convert.ToInt32(ConfigurationManager.AppSettings["MaxDisplayedRecords"]) * 2)
- {
- //Display message "The number of search results exceeds the display maximum"
- lblNoteMsgSearchSites.Text = Messages.Inf0101060002;
- //Bind only the configured no. of records from each source
- lstSites =
- lstSites.Take(Convert.ToInt32(ConfigurationManager.AppSettings["MaxDisplayedRecords"]) * 2).ToList();
- }
- //Sort search results by customer name
- lstSites = lstSites.OrderBy(c => c.CustomerName).ToList();
- BindSearchSitesResults(lstSites);
- }
- //Log method End
- LogWrapper.LogMethodEnd("searchSites()", true);
- }
- }
- catch (Exception ex)
- {
- LogWrapper.LogError(ex);
- throw;
- }
- }
- private void SearchSiteByServiceCallID()
- {
- LogWrapper.LogMethodStart("SearchBySiteSearchServiceCallID()", null, null);
- SiteSearchService.SearchByServiceCallIDRequest req = new SiteSearchService.SearchByServiceCallIDRequest();
- req.ServiceCallID = txtServiceCallIdSearchSites.Text.Trim();
- SiteSearchService.WcfService_Reliance_HVAC_CTI_IVRIntegration_OrchestrationsClient ws = new SiteSearchService.WcfService_Reliance_HVAC_CTI_IVRIntegration_OrchestrationsClient();
- SiteSearchService.SearchByServiceCallIDResponse rsp = ws.SearchByServiceCallIDRequest(req);
- List<SiteSearchService.respCustomerTable> lstCustomers = null;
- List<SiteSearchService.SiteRespCustomerTable> lstSites = new List<SiteSearchService.SiteRespCustomerTable>();
- if (rsp.resp.CustomerDataSet != null)
- {
- lstCustomers = rsp.resp.CustomerDataSet.ToList();
- _SiteSearchserviceCallParams = new ServiceCallParams();
- _SiteSearchserviceCallParams.ServiceCallID = req.ServiceCallID;
- _SiteSearchserviceCallParams.ServiceCallStatus = rsp.ServiceCallStatus;
- }
- //Display message "No data found" if no results returned
- if (lstCustomers == null || lstCustomers.Count == 0)
- lblNoteMsgSearchSites.Text = Messages.Inf0101060001;
- else
- {
- foreach (var item in lstCustomers)
- {
- lstSites.Add(new SiteSearchService.SiteRespCustomerTable
- {
- Address1 = item.Address1,
- Address2 = string.IsNullOrEmpty(item.Address2) ? "" : item.Address2,
- CustomerCode = item.CustomerCode,
- CustomerName = item.CustomerName,
- CustomerStatus = item.CustomerStatus,
- PremiseCode = item.PremiseCode,
- CustomerType = item.CustomerType
- });
- }
- lblNoteMsgSearchSites.Text = string.Empty;
- BindSearchSitesResults(lstSites);
- }
- //Log method End
- LogWrapper.LogMethodEnd("SearchByServiceCallID()", true);
- }
- /// <summary>
- /// Bind search sites grid view
- /// </summary>
- /// <param name="lstSites"></param>
- private void BindSearchSitesResults(List<SiteSearchService.SiteRespCustomerTable> lstSites)
- {
- try
- {
- LogWrapper.LogMethodStart("BindSearchSitesResults(List<SearchSrv.respCustomerTable> resultSet)", new string[] { "lstSites" }, lstSites.ToArray<object>());
- //Display the no. of displayed recoeds as "Search Results ([N])"
- lblSearchResultsSearchSites.Text = "Search Results (" + lstSites.Count() + ")";
- dgvSearchResultSearchSites.DataSource = lstSites;
- //Log method End
- LogWrapper.LogMethodEnd("BindSearchSitesResults(List<SearchSrv.respCustomerTable> lstSites)", true);
- }
- catch (Exception ex)
- {
- LogWrapper.LogError(ex);
- throw;
- }
- }
- /// <summary>
- /// helper function to get the value of the clicked cell in a grid using it's column data proprty name
- /// </summary>
- /// <param name="grid">
- /// The grid to search in
- /// </param>
- /// <param name="rowIndex">
- /// The index of the cell's row
- /// </param>
- /// <param name="dataPropertName">
- /// The data property name of the cell's column
- /// </param>
- /// <returns></returns>
- private static string getGridViewCellValueByDataPropertyName(DataGridView grid, int rowIndex, string dataPropertName)
- {
- try
- {
- var cellValue = from DataGridViewColumn c in grid.Columns
- where c.DataPropertyName.Equals(dataPropertName, StringComparison.CurrentCultureIgnoreCase)
- select Convert.ToString(grid.Rows[rowIndex].Cells[c.Index].Value);
- return cellValue.FirstOrDefault();
- }
- catch (Exception ex)
- {
- LogWrapper.LogError(ex);
- throw;
- }
- }
- #endregion
- private void tbCustomersSearch_Click(object sender, EventArgs e)
- {
- }
- #endregion
- public class NoFocusCueButton : Button
- {
- protected override bool ShowFocusCues
- {
- get
- {
- return false;
- }
- }
- }
- void ShowHideNotesIcons(bool reload)
- {
- if (!DBConfigurations.ShowFloatingNotes)
- return;
- if (tcRelianceDesktop.SelectedIndex == 1 && !_isNewCustomer && !string.IsNullOrEmpty(_Customer.CrmGuID))
- {
- if (frmNotesIcons == null)
- {
- frmNotesIcons = new FrmNotesIcons();
- frmNotesIcons.StartPosition = FormStartPosition.Manual;
- SetIconsLocation();
- frmNotesIcons.CustomerCode = string.IsNullOrEmpty(_Customer.Cust) ? _Customer.SlmnID : _Customer.Cust;
- frmNotesIcons.PremiseCode = string.IsNullOrEmpty(_Customer.Cust) ? _Customer.SlmnSite : _Customer.Prem;
- frmNotesIcons.AccountId = string.IsNullOrEmpty(_Customer.Cust) ? _Customer.CrmGuID : string.Empty;
- frmNotesIcons.LoadData();
- frmNotesIcons.Show(this);
- }
- else
- {
- if (reload)
- {
- frmNotesIcons.CustomerCode = string.IsNullOrEmpty(_Customer.Cust) ? _Customer.SlmnID : _Customer.Cust;
- frmNotesIcons.PremiseCode = string.IsNullOrEmpty(_Customer.Cust) ? _Customer.SlmnSite : _Customer.Prem;
- frmNotesIcons.AccountId = string.IsNullOrEmpty(_Customer.Cust) ? _Customer.CrmGuID : string.Empty;
- frmNotesIcons.LoadData();
- }
- frmNotesIcons.Visible = true;
- }
- }
- else
- {
- if (frmNotesIcons != null)
- {
- if (reload)
- {
- frmNotesIcons.Visible = true;
- frmNotesIcons.CustomerCode = _Customer.SlmnID;
- frmNotesIcons.PremiseCode = _Customer.SlmnSite;
- frmNotesIcons.PremiseCode = _Customer.CrmGuID;
- frmNotesIcons.LoadData();
- }
- frmNotesIcons.Visible = false;
- if (frmNotesIcons.frmListing != null && frmNotesIcons.frmListing.Visible)
- frmNotesIcons.frmListing.Visible = false;
- if (frmNotesIcons.frmAdding != null && frmNotesIcons.frmAdding.Visible)
- frmNotesIcons.frmAdding.Visible = false;
- }
- }
- }
- private void FrmReliance_CMS_Activated(object sender, EventArgs e)
- {
- if (frmNotesIcons != null)
- {
- if (frmNotesIcons.frmListing != null && frmNotesIcons.frmListing.Visible)
- frmNotesIcons.frmListing.Visible = false;
- if (frmNotesIcons.frmAdding != null && frmNotesIcons.frmAdding.Visible && !frmNotesIcons.frmAdding.pageready)
- frmNotesIcons.frmAdding.Visible = false;
- }
- }
- private void FrmReliance_CMS_LocationChanged(object sender, EventArgs e)
- {
- SetIconsLocation();
- //SetIconsLocationOnSizeChange();
- }
- void SetIconsLocation()
- {
- if (frmNotesIcons != null)
- {
- frmNotesIcons.Location = new Point(this.Right - 88, this.Top + 290);
- }
- }
- void SetIconsLocationOnSizeChange()
- {
- if (frmNotesIcons != null)
- {
- frmNotesIcons.Location = new Point(this.Right - 88, frmNotesIcons.Location.Y);
- }
- }
- private void FrmReliance_CMS_SizeChanged(object sender, EventArgs e)
- {
- SetIconsLocation();
- //SetIconsLocationOnSizeChange();
- }
- bool hasOpenedSBWin;
- object openedWindow;
- private bool CheckOpenedServiceBookingWindow()
- {
- try
- {
- openedWindow = null;
- hasOpenedSBWin = false;
- var ifr1 = wbCRMSuperScreen.Document.GetElementById("contentIFrame");
- if (ifr1 != null)
- {
- if (ifr1.Document.Window.Frames.Count > 0)
- {
- var ifr2 = ifr1.Document.Window.Frames[0];
- if (ifr2 != null && ifr2.Frames != null && ifr2.Frames.Count > 0)
- {
- foreach (HtmlWindow ifr3 in ifr2.Frames)
- {
- if (ifr3.Url.AbsoluteUri.ToLower().Contains("customereligibleservices.htm"))
- {
- var hf = ifr3.Document.GetElementById("hfHasOpenedSBWindow");
- if (hf != null)
- {
- var hasOpenedWindow = hf.GetAttribute("value");
- if (hasOpenedWindow == "1")
- {
- hasOpenedSBWin = true;
- MessageBox.Show("Pending service order exists, please process or cancel");
- var obj = ifr3.Document.InvokeScript("GetSBWin");
- if (obj != null)
- {
- openedWindow = obj;
- }
- return true;
- }
- }
- }
- }
- }
- }
- }
- }
- catch
- {
- }
- return false;
- }
- private void SetHasOpenedSBWin()
- {
- try
- {
- var ifr1 = wbCRMSuperScreen.Document.GetElementById("contentIFrame");
- if (ifr1 != null)
- {
- if (ifr1.Document.Window.Frames.Count > 0)
- {
- var ifr2 = ifr1.Document.Window.Frames[0];
- if (ifr2 != null && ifr2.Frames != null && ifr2.Frames.Count > 0)
- {
- foreach (HtmlWindow ifr3 in ifr2.Frames)
- {
- if (ifr3.Url.AbsoluteUri.ToLower().Contains("customereligibleservices.htm"))
- {
- ifr3.Document.InvokeScript("SetOpenedWindow", new[] { openedWindow });
- }
- }
- }
- }
- }
- }
- catch
- {
- }
- }
- private void ActivateOpenedWindow()
- {
- try
- {
- var ifr1 = wbCRMSuperScreen.Document.GetElementById("contentIFrame");
- if (ifr1 != null)
- {
- if (ifr1.Document.Window.Frames.Count > 0)
- {
- var ifr2 = ifr1.Document.Window.Frames[0];
- if (ifr2 != null && ifr2.Frames != null && ifr2.Frames.Count > 0)
- {
- foreach (HtmlWindow ifr3 in ifr2.Frames)
- {
- if (ifr3.Url.AbsoluteUri.ToLower().Contains("customereligibleservices.htm"))
- {
- ifr3.Document.InvokeScript("ActivateSBWindow", null);
- }
- }
- }
- }
- }
- }
- catch
- {
- }
- }
- private void wbCRMSuperScreen_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
- {
- if (e.Url.AbsoluteUri.ToLower().Contains("customereligibleservices.htm"))
- {
- if (hasOpenedSBWin)
- {
- SetHasOpenedSBWin();
- }
- }
- }
- private void FrmReliance_CMS_FormClosing(object sender, FormClosingEventArgs e)
- {
- if (CheckOpenedServiceBookingWindow())
- {
- if (openedWindow != null)
- {
- ActivateOpenedWindow();
- }
- e.Cancel = true;
- return;
- }
- if (DBConfigurations.ShowFloatingNotes && frmNotesIcons != null)
- {
- frmNotesIcons.CheckUnSavedNote(true);
- }
- }
- private void webQASSearch_Navigated(object sender, WebBrowserNavigatedEventArgs e)
- {
- GetQASAddress();
- }
- private void GetQASAddress()
- {
- //var value = webQASSearch.Document.Url;
- //if (value != null && value.ToString().Length > 0)
- //{
- // var qry = value.Query;
- // var qrys = qry.Split('&');
- // foreach (var q in qrys)
- // {
- // var vs = q.Split('=');
- // if (vs.Length > 0)
- // {
- // if (vs[0] == "txtStreetName")
- // {
- // txtStreetName.Text = vs[1].Replace("+", " ");
- // }
- // }
- // }
- //}
- }
- private void ddlPreDir_KeyDown(object sender, KeyEventArgs e)
- {
- ddlPreDir.DroppedDown = false;
- }
- private void ddlSuffix_KeyDown(object sender, KeyEventArgs e)
- {
- ddlSuffix.DroppedDown = false;
- }
- private void ddlPostDir_KeyDown(object sender, KeyEventArgs e)
- {
- ddlPostDir.DroppedDown = false;
- }
- private void ddlUnitType_KeyDown(object sender, KeyEventArgs e)
- {
- ddlUnitType.DroppedDown = false;
- }
- private void ddlProvince_KeyDown(object sender, KeyEventArgs e)
- {
- ddlProvince.DroppedDown = false;
- }
- bool validFirstName = true, validLastName = true, ValidPhoneNo = true, validStreetNo = true, validPreDir = true, validStreetName = true, validSuffix = true, validPostDir = true, validUnitType = true, validUnitNum = true, validCity = true, validProvince = true, validPostalCode = true;
- private void ddlPreDir_Leave(object sender, EventArgs e)
- {
- if (!String.IsNullOrEmpty(ddlPreDir.Text))
- {
- foreach (var item in ddlPreDir.Items)
- {
- if (((System.Data.DataRowView)item).Row.ItemArray[0].ToString().ToLower() == ddlPreDir.Text.ToLower())
- {
- validPreDir = true;
- break;
- }
- else
- validPreDir = false;
- }
- if (!validPreDir)
- MessageBox.Show("Invalid Pre Direction.");
- }
- else
- validPreDir = true;
- }
- private void ddlSuffix_Leave(object sender, EventArgs e)
- {
- if (!String.IsNullOrEmpty(ddlSuffix.Text))
- {
- foreach (var item in ddlSuffix.Items)
- {
- if (((System.Data.DataRowView)item).Row.ItemArray[0].ToString().ToLower() == ddlSuffix.Text.ToLower())
- {
- validSuffix = true;
- break;
- }
- else
- validSuffix = false;
- }
- if (!validSuffix)
- MessageBox.Show("Invalid Suffix.");
- }
- else
- validSuffix = true;
- }
- private void ddlPostDir_Leave(object sender, EventArgs e)
- {
- if (!String.IsNullOrEmpty(ddlPostDir.Text))
- {
- foreach (var item in ddlPostDir.Items)
- {
- if (((System.Data.DataRowView)item).Row.ItemArray[0].ToString().ToLower() == ddlPostDir.Text.ToLower())
- {
- validPostDir = true;
- break;
- }
- else
- validPostDir = false;
- }
- if (!validPostDir)
- MessageBox.Show("Invalid Post Direction.");
- }
- else
- validPostDir = true;
- }
- private void ddlUnitType_Leave(object sender, EventArgs e)
- {
- if(!String.IsNullOrEmpty(ddlUnitType.Text))
- {
- foreach (var item in ddlUnitType.Items)
- {
- if (((System.Data.DataRowView)item).Row.ItemArray[0].ToString().ToLower() == ddlUnitType.Text.ToLower())
- {
- validUnitType = true;
- break;
- }
- else
- validUnitType = false;
- }
- if(!validUnitType)
- MessageBox.Show("Invalid Unit Type.");
- }
- else
- validUnitType=true;
- }
- private void ddlProvince_Leave(object sender, EventArgs e)
- {
- if (!String.IsNullOrEmpty(ddlProvince.Text))
- {
- foreach (var item in ddlProvince.Items)
- {
- if (((System.Data.DataRowView)item).Row.ItemArray[0].ToString().ToLower() == ddlProvince.Text.ToLower())
- {
- validProvince = true;
- break;
- }
- else validProvince = false;
- }
- if (!validProvince)
- MessageBox.Show("Invalid Province.");
- }
- else
- validProvince = true;
- }
- private void txtLastName_Leave(object sender, EventArgs e)
- {
- if (txtLastName.Text == "*")
- {
- MessageBox.Show("Please provide value with *.");
- validLastName = false;
- }
- else
- validLastName = true;
- }
- private void txtFirstName_Leave(object sender, EventArgs e)
- {
- if (txtFirstName.Text == "*")
- {
- MessageBox.Show("Please provide value with *.");
- validFirstName = false;
- }
- else
- validFirstName = true;
- }
- private void txtPhoneNo_Leave(object sender, EventArgs e)
- {
- if (txtPhoneNo.Text == "*")
- {
- MessageBox.Show("Please provide value with *.");
- ValidPhoneNo = false;
- }
- else
- ValidPhoneNo = true;
- }
- private void txtStreetNo_Leave(object sender, EventArgs e)
- {
- if (txtStreetNo.Text == "*")
- {
- MessageBox.Show("Please provide value with *.");
- validStreetNo = false;
- }
- else
- validStreetNo = true;
- }
- private void txtStreetName_Leave(object sender, EventArgs e)
- {
- if (txtStreetName.Text == "*")
- {
- MessageBox.Show("Please provide value with *.");
- validStreetName = false;
- }
- else
- validStreetName = true;
- }
- private void txtUnitNum_Leave(object sender, EventArgs e)
- {
- if (txtUnitNum.Text == "*")
- {
- MessageBox.Show("Please provide value with *.");
- validUnitNum = false;
- }
- else
- validUnitNum = true;
- }
- private void txtCity_Leave(object sender, EventArgs e)
- {
- if (txtCity.Text == "*")
- {
- MessageBox.Show("Please provide value with *.");
- validCity = false;
- }
- else
- validCity = true;
- }
- private void txtPostalCode_Leave(object sender, EventArgs e)
- {
- if (txtPostalCode.Text == "*")
- {
- MessageBox.Show("Please provide value with *.");
- validPostalCode = false;
- }
- else
- validPostalCode = true;
- }
- }
- }
[text] frmreliance
Viewer
*** This page was generated with the meta tag "noindex, nofollow". This happened because you selected this option before saving or the system detected it as spam. This means that this page will never get into the search engines and the search bot will not crawl it. There is nothing to worry about, you can still share it with anyone.
Editor
You can edit this paste and save as new:
File Description
- frmreliance
- Paste Code
- 26 Sep-2021
- 95.13 Kb
You can Share it: