Esempio n. 1
0
 private void OnControlLoad(object sender, EventArgs e)
 {
     //Event handler for control load event
     this.Cursor = Cursors.WaitCursor;
     try {
         if (!this.DesignMode)
         {
             if (this.cboClient.Items.Count == 0)
             {
                 this.mClientDS.Clear();
                 this.mClientDS.Merge(CRMGateway.GetCompanies());
                 OnClientChanged(null, EventArgs.Empty);
             }
             if (this.cboAgent.Items.Count == 0)
             {
                 this.mAgentDS.Clear();
                 this.mAgentDS.AgentTable.AddAgentTableRow("", "", "All", "", "", "", "", "", 0, "", "", "", "", "", "", "", "", "", "");
                 this.mAgentDS.Merge(CRMGateway.GetAgents());
                 if (this.cboAgent.Items.Count > 0)
                 {
                     this.cboAgent.SelectedIndex = 0;
                 }
                 OnAgentChanged(null, EventArgs.Empty);
             }
             this.dtpFrom.Value = DateTime.Today.AddDays(-90);
             this.dtpTo.Value   = DateTime.Today;
         }
     }
     catch (Exception ex) { App.ReportError(new ApplicationException(ex.Message, ex)); }
     finally { this.Cursor = Cursors.Default; }
 }
Esempio n. 2
0
        public long CreateIssue(Issue issue)
        {
            //Create a new issue
            long iid = 0;

            try {
                //Apply simple business rules

                //Create the TransactionScope to execute the commands, guaranteeing that both commands can commit or roll back as a single unit of work
                using (TransactionScope scope = new TransactionScope()) {
                    //
                    //Create issue
                    object io = new CRMGateway().CreateIssue(issue.TypeID, issue.Subject, issue.Contact, issue.CompanyID, issue.RegionNumber, issue.DistrictNumber, issue.AgentNumber, issue.StoreNumber);
                    iid = (long)io;

                    //Add the single 'Open' action
                    if (issue.Actions.Count == 0)
                    {
                        throw new ApplicationException("No action specified.");
                    }
                    ;
                    bool ok = new CRMGateway().CreateAction(issue.Actions[0].TypeID, iid, issue.Actions[0].UserID, issue.Actions[0].Comment);

                    //Commits the transaction; if an exception is thrown, Complete is not called and the transaction is rolled back
                    scope.Complete();
                }
            }
            catch (Exception ex) { throw new FaultException <CustomersFault>(new CustomersFault(ex.Message), "Service Error"); }
            return(iid);
        }
Esempio n. 3
0
 private void OnControlLoad(object sender, EventArgs e)
 {
     //Event handler for control load event
     this.Cursor = Cursors.WaitCursor;
     try {
         #region Grid customizations from normal layout (to support cell editing)
         this.grdDeliveries.DisplayLayout.Override.RowSelectors     = DefaultableBoolean.False;
         this.grdDeliveries.DisplayLayout.Override.SelectTypeRow    = SelectType.None;
         this.grdDeliveries.DisplayLayout.Override.SelectTypeCell   = SelectType.Single;
         this.grdDeliveries.DisplayLayout.TabNavigation             = TabNavigation.NextCell;
         this.grdDeliveries.DisplayLayout.Override.AllowAddNew      = AllowAddNew.No;
         this.grdDeliveries.DisplayLayout.Override.AllowDelete      = DefaultableBoolean.False;
         this.grdDeliveries.DisplayLayout.Override.AllowUpdate      = DefaultableBoolean.False;
         this.grdDeliveries.DisplayLayout.Override.CellClickAction  = CellClickAction.EditAndSelectText;
         this.grdDeliveries.DisplayLayout.Override.MaxSelectedCells = 1;
         this.grdDeliveries.DisplayLayout.Override.RowFilterMode    = RowFilterMode.AllRowsInBand;
         this.grdDeliveries.DisplayLayout.Override.RowFilterAction  = RowFilterAction.HideFilteredOutRows;
         //this.grdDeliveries.DisplayLayout.Bands[0].Columns["CBOL"].SortIndicator = SortIndicator.Descending;
         #endregion
         if (!this.DesignMode)
         {
             this.mClients.Merge(CRMGateway.GetCompanies());
             if (this.cboClient.Items.Count > 0)
             {
                 this.cboClient.SelectedIndex = 0;
             }
         }
         this.dtpFrom.Value = DateTime.Today.AddDays(-7);
         this.dtpTo.Value   = DateTime.Today;
     }
     catch (Exception ex) { App.ReportError(new ApplicationException(ex.Message)); }
     finally { this.Cursor = Cursors.Default; }
 }
Esempio n. 4
0
        private void OnIssueCategorySelected(object sender, EventArgs e)
        {
            //Event handler for change in issue category
            this.mIssueTypes.Clear();
            string issueCategory = this.cboIssueCategory.SelectedValue != null?this.cboIssueCategory.SelectedValue.ToString() : "";

            this.mIssueTypes.Merge(CRMGateway.GetIssueTypes(issueCategory));
            this.cboIssueType.SelectedIndex = -1;
            OnIssueTypeSelected(null, EventArgs.Empty);
        }
Esempio n. 5
0
 public byte[] GetAttachment(int id)
 {
     //Get an existing file attachment from database
     byte[] bytes = null;
     try {
         bytes = new CRMGateway().GetAttachment(id);
     }
     catch (Exception ex) { throw new FaultException <CustomersFault>(new CustomersFault(ex.Message), "Service Error"); }
     return(bytes);
 }
Esempio n. 6
0
        public DataSet SearchIssues(string searchText)
        {
            //Get issue search data
            DataSet ds = null;

            try {
                ds = new CRMGateway().SearchIssues(searchText);
            }
            catch (Exception ex) { throw new FaultException <CustomersFault>(new CustomersFault(ex.Message), "Service Error"); }
            return(ds);
        }
Esempio n. 7
0
        public DataSet ViewIssues(DateTime fromDate)
        {
            //Get issues
            DataSet ds = null;

            try {
                ds = new CRMGateway().ViewIssues(fromDate);
            }
            catch (Exception ex) { throw new FaultException <CustomersFault>(new CustomersFault(ex.Message), "Service Error"); }
            return(ds);
        }
Esempio n. 8
0
        private void OnScopeChanged(object sender, EventArgs e)
        {
            //Event handler for change in scope
            try {
                //Prepare a location selector for the specified scope
                string scope = this.cboScope.SelectedItem != null?this.cboScope.SelectedItem.ToString() : SCOPE_NONE;

                this.cboLocation.Visible = (scope == SCOPE_NONE || scope == SCOPE_DISTRICTS || scope == SCOPE_REGIONS || scope == SCOPE_AGENTS);
                this.txtStore.Visible    = (scope == SCOPE_STORES || scope == SCOPE_SUBSTORES);

                this.cboLocation.DataSource = null;
                CRMDataset locationDS = new CRMDataset();
                CRMDataset ds         = null;
                int        companyID  = int.Parse(this.cboCompany.SelectedValue.ToString());
                string     number     = this.cboCompany.SelectedValue.ToString().PadLeft(8, '0').Substring(5, 3);
                switch (scope)
                {
                case SCOPE_DISTRICTS:
                    ds = CRMGateway.GetDistricts(number);
                    this.cboLocation.DisplayMember = "LocationTable.LocationName";
                    this.cboLocation.ValueMember   = "LocationTable.Location";
                    break;

                case SCOPE_REGIONS:
                    ds = CRMGateway.GetRegions(number);
                    this.cboLocation.DisplayMember = "LocationTable.LocationName";
                    this.cboLocation.ValueMember   = "LocationTable.Location";
                    break;

                case SCOPE_STORES:
                case SCOPE_SUBSTORES:
                    this.txtStore.Text = "";
                    break;

                case SCOPE_AGENTS:
                    ds = CRMGateway.GetAgents(number);
                    this.cboLocation.DisplayMember = "AgentTable.AgentSummary";
                    this.cboLocation.ValueMember   = "AgentTable.AgentNumber";
                    break;
                }
                if (ds != null)
                {
                    locationDS.Merge(ds);
                    this.cboLocation.DataSource = locationDS;
                }
                this.cboLocation.Enabled = this.cboLocation.Items.Count > 0;
                if (this.cboLocation.Items.Count > 0)
                {
                    this.cboLocation.SelectedIndex = 0;
                }
                OnCompanyLocationChanged(null, EventArgs.Empty);
            }
            catch (Exception ex) { App.ReportError(new ApplicationException("Unexpected error when location scope changed.", ex)); }
        }
Esempio n. 9
0
        public DataSet SearchIssuesAdvanced(object[] criteria)
        {
            //Get issue search data
            DataSet ds = null;

            try {
                ds = new CRMGateway().SearchIssuesAdvanced(criteria);
            }
            catch (Exception ex) { throw new FaultException <CustomersFault>(new CustomersFault(ex.Message), "Service Error"); }
            return(ds);
        }
Esempio n. 10
0
        public bool UpdateIssueType(int id, string description, int isactive)
        {
            //Update an existing issue type
            bool updated = false;

            try {
                //
                updated = new CRMGateway().UpdateIssueType(id, description, isactive);
            }
            catch (Exception ex) { throw new FaultException <CustomersFault>(new CustomersFault(ex.Message), "Service Error"); }
            return(updated);
        }
Esempio n. 11
0
        public bool CreateIssueType(string type, string category, string description)
        {
            //Create a new issue type
            bool created = false;

            try {
                //
                created = new CRMGateway().CreateIssueType(type, category, description);
            }
            catch (Exception ex) { throw new FaultException <CustomersFault>(new CustomersFault(ex.Message), "Service Error"); }
            return(created);
        }
Esempio n. 12
0
 private void OnView(object sender, EventArgs e)
 {
     //
     this.Cursor = Cursors.WaitCursor;
     try {
         this.mDeliveries.Clear();
         if (this.cboClient.SelectedValue != null && this.mskStoreNumber.Text.Trim().Length > 0)
         {
             this.grdDeliveries.DataSource = CRMGateway.GetDeliveries(int.Parse(this.cboClient.SelectedValue.ToString()), int.Parse(this.mskStoreNumber.Text), this.dtpFrom.Value, this.dtpTo.Value);
         }
     }
     catch (Exception ex) { App.ReportError(new ApplicationException(ex.Message)); }
     finally { this.Cursor = Cursors.Default; }
 }
Esempio n. 13
0
        private void OnStoreKeyUp(object sender, KeyEventArgs e)
        {
            //Event handler for store textbox key up event
            try {
                if (e.KeyCode == Keys.Enter)
                {
                    this.txtStoreName.Text = this.txtStoreAddress.Text = this.txtStoreDetail.Text = "";
                    if (this.cboClient.SelectedValue != null && this.mskStore.Text.Trim().Length > 0)
                    {
                        CRMDataset ds = new CRMDataset();
                        ds.Merge(CRMGateway.GetStoreDetail(int.Parse(this.cboClient.SelectedValue.ToString()), int.Parse(this.mskStore.Text)));
                        if (ds.StoreTable.Rows.Count > 0)
                        {
                            CRMDataset.StoreTableRow store = ds.StoreTable[0];
                            this.txtStoreName.Text = store.StoreName.Trim() + " (store #" + store.StoreNumber.ToString() + "; substore #" + store.SubStoreNumber.Trim() + ")";

                            StringBuilder address = new StringBuilder();
                            address.AppendLine((!store.IsStoreAddressline1Null() ? store.StoreAddressline1.Trim() : ""));
                            address.AppendLine((!store.IsStoreAddressline2Null() ? store.StoreAddressline2.Trim() : ""));
                            address.AppendLine((!store.IsStoreCityNull() ? store.StoreCity.Trim() : "") + ", " +
                                               (!store.IsStoreStateNull() ? store.StoreState.Trim() : "") + " " +
                                               (!store.IsStoreZipNull() ? store.StoreZip.Trim() : ""));
                            this.txtStoreAddress.Text = address.ToString();

                            StringBuilder detail = new StringBuilder();
                            detail.AppendLine((!store.IsRegionDescriptionNull() ? store.RegionDescription.Trim() : "") +
                                              " (" + (!store.IsRegionNull() ? store.Region.Trim() : "") + "), " +
                                              (!store.IsDistrictNameNull() ? store.DistrictName.Trim() : "") +
                                              " (" + (!store.IsDistrictNull() ? store.District.Trim() : "") + ")");
                            detail.AppendLine("Zone " + (!store.IsZoneNull() ? store.Zone.Trim() : "") + ", " +
                                              "Agent " + (!store.IsAgentNumberNull() ? store.AgentNumber.Trim() : "") + " " +
                                              (!store.IsAgentNameNull() ? store.AgentName.Trim() : ""));
                            detail.AppendLine("Window " + (!store.IsWindowTimeStartNull() ? store.WindowTimeStart.ToString("HH:mm") : "") + " - " +
                                              (!store.IsWindowTimeEndNull() ? store.WindowTimeEnd.ToString("HH:mm") : "") + ", " +
                                              "Del Days " + getDeliveryDays(store) + ", " +
                                              (!store.IsScanStatusDescrptionNull() ? store.ScanStatusDescrption.Trim() : ""));
                            detail.AppendLine("JA Transit " + (!store.IsStandardTransitNull() ? store.StandardTransit.ToString() : "") + ", " + "OFD " + getOFD(store));
                            detail.AppendLine("Special Inst: " + (!store.IsSpecialInstructionsNull() ? store.SpecialInstructions.Trim() : ""));
                            this.txtStoreDetail.Text = detail.ToString();
                        }
                    }
                    refreshReports();
                }
            }
            catch (Exception ex) { App.ReportError(new ApplicationException("Unexpected error when store keyed in.", ex)); }
        }
Esempio n. 14
0
 private void OnAgentChanged(object sender, EventArgs e)
 {
     //Event handler for change in selected agent
     try {
         this.mTerminals.Clear();
         if (this.cboAgent.SelectedValue != null)
         {
             this.mTerminals.Merge(CRMGateway.GetAgentTerminals(this.cboAgent.SelectedValue.ToString()));
             if (this.cboTerminal.Items.Count > 0)
             {
                 this.cboTerminal.SelectedIndex = 0;
             }
             OnAgentTerminalChanged(null, EventArgs.Empty);
         }
     }
     catch (Exception ex) { App.ReportError(new ApplicationException("Unexpected error on agent selection.", ex)); }
 }
Esempio n. 15
0
        public bool AddAction(Action action)
        {
            //Add a new action to an existing issue
            bool added = false;

            try {
                //Apply simple business rules

                //Create the TransactionScope to execute the commands, guaranteeing that both commands can commit or roll back as a single unit of work
                using (TransactionScope scope = new TransactionScope()) {
                    //
                    added = new CRMGateway().CreateAction(action.TypeID, action.IssueID, action.UserID, action.Comment);

                    //Commits the transaction; if an exception is thrown, Complete is not called and the transaction is rolled back
                    scope.Complete();
                }
            }
            catch (Exception ex) { throw new FaultException <CustomersFault>(new CustomersFault(ex.Message), "Service Error"); }
            return(added);
        }
Esempio n. 16
0
        public bool AddAttachment(Attachment attachment)
        {
            //Create a new issue
            bool added = false;

            try {
                //Apply simple business rules

                //Create the TransactionScope to execute the commands, guaranteeing that both commands can commit or roll back as a single unit of work
                using (TransactionScope scope = new TransactionScope()) {
                    //
                    added = new CRMGateway().CreateAttachment(attachment.Filename, attachment.File, attachment.ActionID);

                    //Commits the transaction; if an exception is thrown, Complete is not called and the transaction is rolled back
                    scope.Complete();
                }
            }
            catch (Exception ex) { throw new FaultException <CustomersFault>(new CustomersFault(ex.Message), "Service Error"); }
            return(added);
        }
Esempio n. 17
0
        private void OnFormLoad(object sender, EventArgs e)
        {
            //Event handler for form load event
            this.Cursor = Cursors.WaitCursor;
            try {
                this.mToolTip            = new ToolTip();
                this.mToolTip.ShowAlways = true;
                this.mToolTip.SetToolTip(this.cboActionType, "Select an action type.");

                this.mActionsDS.Clear(); this.mActionsDS.Merge(CRMGateway.GetActionTypes(this.mIssue.ID));

                this.cboActionType.SelectedValue = this.mAction.TypeID;
                this.txtComment.Text             = this.mAction.Comment;
                this.txtComments.Text            = showAllActions(this.mIssue.Actions);
                this.chkShowAll.Checked          = true;
                OnShowAllCheckedChanged(null, EventArgs.Empty);
            }
            catch (Exception ex) { App.ReportError(ex); }
            finally { OnValidateForm(null, EventArgs.Empty); this.Cursor = Cursors.Default; }
        }
Esempio n. 18
0
        private void OnAgentTerminalChanged(object sender, EventArgs e)
        {
            //Event handler for change in agent terminal
            try {
                this.txtTerminalName.Text = this.txtTerminalAddress.Text = this.txtTermainlDetail.Text = "";
                if (this.cboTerminal.SelectedValue != null)
                {
                    CRMDataset ds = new CRMDataset();
                    ds.Merge(CRMGateway.GetAgentTerminalDetail(this.cboTerminal.SelectedValue.ToString()));
                    if (ds.AgentTable.Rows.Count > 0)
                    {
                        CRMDataset.AgentTableRow agent = ds.AgentTable[0];
                        this.txtTerminalName.Text = agent.AgentNumber.ToString() + " - " + agent.AgentName.Trim();

                        StringBuilder address = new StringBuilder();
                        address.AppendLine((!agent.IsAddressLine1Null() ? agent.AddressLine1.Trim() : ""));
                        address.AppendLine((!agent.IsAddressLine2Null() ? agent.AddressLine2.Trim() : ""));
                        address.AppendLine((!agent.IsCityNull() ? agent.City.Trim() : "") + ", " +
                                           (!agent.IsStateNull() ? agent.State.Trim() : "") + " " +
                                           (!agent.IsZipNull() ? agent.Zip.Trim() : ""));
                        this.txtTerminalAddress.Text = address.ToString();

                        StringBuilder detail = new StringBuilder();
                        detail.AppendLine("Contact: " + (!agent.IsContactNull() ? agent.Contact.Trim() : ""));
                        detail.AppendLine("Phone: " + (!agent.IsPhoneNull() ? agent.Phone.Trim() : ""));
                        detail.AppendLine("Coordinator: " + (!agent.IsCoordinatorNull() ? agent.Coordinator.Trim() : ""));
                        detail.AppendLine("Agent Type: " + (!agent.IsTypeNull() ? agent.Type.Trim() : ""));
                        detail.AppendLine(
                            ("Main Zone: " + (!agent.IsMainZoneNull() ? agent.MainZone.Trim() : "")) + ", " +
                            ("Type= " + (!agent.IsZoneTypeNull() ? agent.ZoneType.Trim() : "")) + ", " +
                            ("Status= " + (!agent.IsZoneStatusNull() ? agent.ZoneStatus.Trim() : "")) + ", " +
                            ("Is Main= " + (!agent.IsIsMainZoneNull() ? agent.IsMainZone.ToString() : ""))
                            );
                        this.txtTermainlDetail.Text = detail.ToString();
                    }
                    refreshReports();
                }
            }
            catch (Exception ex) { App.ReportError(new ApplicationException("Unexpected error on agent selection.", ex)); }
        }
Esempio n. 19
0
        public DataSet GetIssueTypes(string issueCategory)
        {
            //Issue types- all or filtered by category
            DataSet issueTypes = new DataSet();

            try {
                DataSet ds = new CRMGateway().GetIssueTypes();
                if (ds != null && ds.Tables["IssueTypeTable"] != null && ds.Tables["IssueTypeTable"].Rows.Count > 0)
                {
                    if (issueCategory != null && issueCategory.Trim().Length > 0)
                    {
                        issueTypes.Merge(ds.Tables["IssueTypeTable"].Select("Category='" + issueCategory + "'"));
                    }
                    else
                    {
                        issueTypes.Merge(ds);
                    }
                }
            }
            catch (Exception ex) { throw new ApplicationException(ex.Message, ex); }
            return(issueTypes);
        }
Esempio n. 20
0
        private void showStoreDetail()
        {
            //
            this.txtStoreDetail.Clear();
            if (this.cboCompany.SelectedValue != null && this.txtStore.Text.Length > 0)
            {
                CRMDataset ds = new CRMDataset();
                switch (this.cboScope.SelectedItem.ToString())
                {
                case SCOPE_STORES:
                    ds.Merge(CRMGateway.GetStoreDetail(int.Parse(this.cboCompany.SelectedValue.ToString()), int.Parse(this.txtStore.Text)));
                    break;

                case SCOPE_SUBSTORES:
                    ds.Merge(CRMGateway.GetStoreDetail(int.Parse(this.cboCompany.SelectedValue.ToString()), this.txtStore.Text));
                    break;
                }
                if (ds.StoreTable.Rows.Count > 0)
                {
                    this.txtStoreDetail.Text = getStoreDetailString(ds.StoreTable[0]);
                }
            }
        }
Esempio n. 21
0
 private static void OnDoWork(object sender, DoWorkEventArgs e)
 {
     //
     try { e.Result = CRMGateway.GetIssues(); }
     catch { }
 }
Esempio n. 22
0
        private void OnFormLoad(object sender, EventArgs e)
        {
            //Event handler for form load event
            this.Cursor = Cursors.WaitCursor;
            try {
                this.mToolTip            = new System.Windows.Forms.ToolTip();
                this.mToolTip.ShowAlways = true;
                this.mToolTip.SetToolTip(this.cboIssueType, "Select an issue type.");

                this.mCompanyDS.Clear(); this.mCompanyDS.Merge(CRMGateway.GetCompanies());
                this.mIssueCategorys.Clear(); this.mIssueCategorys.Merge(CRMGateway.GetIssueCategories());
                this.mActionsDS.Clear(); this.mActionsDS.Merge(CRMGateway.GetActionTypes(this.mIssue.ID));

                if (this.mIssue.ID == 0 && this.mIssue.CompanyID == -1)
                {
                    this.cboCompany.SelectedIndex = -1;
                }
                else
                {
                    this.cboCompany.SelectedValue = this.mIssue.CompanyID;
                }
                OnCompanySelected(null, EventArgs.Empty);
                if (this.mIssue.DistrictNumber != null)
                {
                    this.cboScope.SelectedItem     = SCOPE_DISTRICTS; OnScopeChanged(null, EventArgs.Empty);
                    this.cboLocation.SelectedValue = this.mIssue.DistrictNumber;
                }
                else if (this.mIssue.RegionNumber != null)
                {
                    this.cboScope.SelectedItem     = SCOPE_REGIONS; OnScopeChanged(null, EventArgs.Empty);
                    this.cboLocation.SelectedValue = this.mIssue.RegionNumber;
                }
                else if (this.mIssue.AgentNumber != null)
                {
                    this.cboScope.SelectedItem     = SCOPE_AGENTS; OnScopeChanged(null, EventArgs.Empty);
                    this.cboLocation.SelectedValue = this.mIssue.AgentNumber;
                }
                else if (this.mIssue.StoreNumber > -1)
                {
                    this.cboScope.SelectedItem = SCOPE_STORES; OnScopeChanged(null, EventArgs.Empty);
                    this.txtStore.Text         = this.mIssue.StoreNumber.ToString();
                    showStoreDetail();
                }
                else
                {
                    this.cboLocation.DataSource = null;
                }
                this.cboIssueCategory.SelectedIndex = -1;
                OnIssueCategorySelected(this.cboIssueCategory, EventArgs.Empty);
                if (this.mIssue.TypeID > -1)
                {
                    this.cboIssueType.SelectedValue = this.mIssue.TypeID;
                }
                this.txtContact.Text = this.mIssue.Contact;
                this.txtSubject.Text = this.mIssue.Subject;

                this.cboActionType.SelectedIndex = -1;  // this.mIssue.ID == 0 ? 0 : -1;
                this.txtComments.Text            = getAllActionComments();
                this.chkShowAll.Checked          = this.mIssue.ID > 0;
                OnShowAllCheckedChanged(null, EventArgs.Empty);

                this.cboCompany.Enabled       = this.mIssue.ID == 0 && this.cboCompany.Items.Count > 0;
                this.cboScope.Enabled         = this.mIssue.ID == 0;
                this.cboLocation.Enabled      = this.txtStore.Enabled = this.mIssue.ID == 0;
                this.cboIssueCategory.Enabled = this.cboIssueType.Enabled = this.mIssue.ID == 0;
                this.txtContact.Enabled       = this.mIssue.ID == 0;
                this.txtSubject.Enabled       = this.mIssue.ID == 0;
                this.chkShowAll.Enabled       = this.mIssue.ID > 0 && this.mIssue.Actions.Count > 0;
            }
            catch (Exception ex) { App.ReportError(ex); }
            finally { OnValidateForm(null, EventArgs.Empty); this.Cursor = Cursors.Default; }
        }