private void loadRegions() { //Load a list of region sslections try { LocationDS locationDS = new LocationDS(); LocationDS _ds = CustomerProxy.GetRegions(this.cboCompany.SelectedValue.ToString().PadLeft(6, '0').Substring(3, 3)); System.Collections.Hashtable table = new System.Collections.Hashtable(); for (int i = 0; i < _ds.LocationTable.Rows.Count; i++) { string region = _ds.LocationTable[i].Location.ToString().Trim(); if (region.Length == 0) { _ds.LocationTable[i].Delete(); } else { if (table.ContainsKey(region)) { _ds.LocationTable[i].Delete(); } else { table.Add(region, _ds.LocationTable[i].LocationName.ToString().Trim()); _ds.LocationTable[i].Location = region; _ds.LocationTable[i].LocationName = _ds.LocationTable[i].LocationName.ToString().Trim(); } } } locationDS.Merge(_ds, true); this.cboLocation.DisplayMember = "LocationTable.LocationName"; this.cboLocation.ValueMember = "LocationTable.Location"; this.cboLocation.DataSource = locationDS; } catch (Exception ex) { throw new ControlException("Unexpected error while loading company regions.", ex); } }
private void OnMenuClick(object sender, System.EventArgs e) { //Event handler fo menu item clicked try { ToolStripDropDownItem menu = (ToolStripDropDownItem)sender; switch (menu.Text) { case MNU_NEW: break; case MNU_OPEN: dlgContact dlg = new dlgContact(this.mContact); dlg.Font = this.Font; if (dlg.ShowDialog() == DialogResult.OK) { if (CustomerProxy.UpdateContact(this.mContact)) { this.ctxRefresh.PerformClick(); } } break; case MNU_REFRESH: this.Cursor = Cursors.WaitCursor; this.mContactDS.Clear(); this.mContactDS.Merge(CustomerProxy.GetContacts()); break; } } catch (Exception ex) { reportError(ex); } finally { setUserServices(); this.Cursor = Cursors.Default; } }
private void OnIssueCategorySelected(object sender, EventArgs e) { //Event handler for change in issue category this.mIssueTypes.Clear(); this.mIssueTypes.Merge(CustomerProxy.GetIssueTypes(this.cboIssueCategory.SelectedValue.ToString())); this.cboIssueType.SelectedIndex = -1; OnValidateForm(null, EventArgs.Empty); }
public void SearchAdvanced(object[] criteria) { try { this.mIssueSearch.Clear(); this.mIssueSearch.Merge(CustomerProxy.SearchIssuesAdvanced(criteria)); this.cboView.SelectedItem = "Search Results"; OnViewChanged(this.cboView, EventArgs.Empty); } catch (Exception ex) { reportError(ex); } }
private void OnFormLoad(object sender, EventArgs e) { //Event handler for form laod event this.Cursor = Cursors.WaitCursor; try { this.mContactDS.Merge(CustomerProxy.GetContacts()); this.grdContacts.DataBind(); } catch (Exception ex) { reportError(ex); } finally { setUserServices(); this.Cursor = Cursors.Default; } }
private void OnFormLoad(object sender, EventArgs e) { //Event handler for form load event this.Cursor = Cursors.WaitCursor; try { //Set initial service states this.Visible = true; this.mDeliveryDS.Merge(CustomerProxy.GetDeliveries(this.mCompanyID, this.mStoreNumber, this.mFrom, this.mTo)); } catch (Exception ex) { reportError(ex); } finally { OnValidateForm(null, EventArgs.Empty); this.Cursor = Cursors.Default; } }
private void OnMenuClick(object sender, EventArgs e) { //Event handler for mneu item clicked try { ToolStripDropDownItem menu = (ToolStripDropDownItem)sender; switch (menu.Text) { case MNU_NEW: Action action = new Action(); action.IssueID = this.mIssue.ID; action.TypeID = 0; action.UserID = Environment.UserName; action.Created = DateTime.Now; action.Comment = ""; action.Attachments = 0; dlgAction dlgNA = new dlgAction(action, this.mIssue); dlgNA.Font = this.Font; if (dlgNA.ShowDialog(this) == DialogResult.OK) { //Add the action to the issue CustomerProxy.CreateIssueAction(action.TypeID, action.IssueID, action.UserID, action.Comment); if (this.IssueChanged != null) { this.IssueChanged(this.mIssue, EventArgs.Empty); } loadActions(); } break; case MNU_PRINT: WinPrinter2 wp = new WinPrinter2("", this.txtAction.Font); string doc = "Issue Type: \t" + this.mIssue.Type + "\r\nSubject: \t\t" + this.mIssue.Subject + "\r\nContact: \t\t" + this.mIssue.ContactName + "\r\n" + "\r\nCompany: \t" + this.mIssue.CompanyName + "\r\nStore#: \t\t" + this.mIssue.StoreNumber.ToString() + "\r\nAgent#: \t" + this.mIssue.AgentNumber + "\r\nZone: \t\t" + this.mIssue.Zone; doc += "\r\n\r\n\r\n"; Action[] actions = CustomerProxy.GetIssueActions(this.mIssue.ID); for (int i = 0; i < actions.Length; i++) { doc += actions[i].Created.ToString("f") + " " + actions[i].UserID + ", " + actions[i].TypeName; doc += "\r\n\r\n"; doc += actions[i].Comment; doc += "\r\n"; doc += "".PadRight(75, '-'); doc += "\r\n"; } wp.Print(this.mIssue.Subject, doc, true); break; case MNU_REFRESH: Refresh(); break; case MNU_ARRANGEBYDATE: break; } } catch (Exception ex) { reportError(new ControlException("Unexpected error setting IssueInspector menu services.", ex)); } }
private void OnTabSelected(object sender, TabControlEventArgs e) { //Event handler for change in tab selection this.Cursor = Cursors.WaitCursor; try { if (this.mIssue == null) { return; } switch (e.TabPage.Name) { case "tabDetail": break; case "tabOSD": ScanDS osdscans = CustomerProxy.GetOSDScans(this.mIssue.PROID); this.oSDScanTableBindingSource.DataSource = osdscans; if (this.grdPOD.Selected.Rows.Count > 0) { long id = Convert.ToInt64(this.grdPOD.Selected.Rows[0].Cells["LabelSequenceNumber"].Value); for (int i = 0; i < this.grdOSD.Rows.Count; i++) { if (Convert.ToInt64(this.grdOSD.Rows[i].Cells["LabelSequenceNumber"].Value) == id) { this.grdOSD.Rows[0].Selected = true; break; } } } break; case "tabPOD": ScanDS podscans = CustomerProxy.GetPODScans(this.mIssue.PROID); this.pODScanTableBindingSource.DataSource = podscans; if (this.grdOSD.Selected.Rows.Count > 0) { long id = Convert.ToInt64(this.grdOSD.Selected.Rows[0].Cells["LabelSequenceNumber"].Value); for (int i = 0; i < this.grdPOD.Rows.Count; i++) { if (Convert.ToInt64(this.grdPOD.Rows[i].Cells["LabelSequenceNumber"].Value) == id) { this.grdPOD.Rows[0].Selected = true; break; } } } break; } } catch (Exception ex) { reportError(ex); } finally { setUserServices(); this.Cursor = Cursors.Default; } }
private void OnContactChanged(object source, ContactEventArgs e) { //Event handler for contact changed if (this.mIssue != null) { this.mIssue.ContactID = e.Contact.ID; CustomerProxy.UpdateIssue(this.mIssue); if (this.IssueChanged != null) { this.IssueChanged(this.mIssue, EventArgs.Empty); } } }
private void loadAgents() { //Load a list of agent selections try { AgentDS agentDS = new AgentDS(); AgentDS ds = CustomerProxy.GetAgents(this.cboCompany.SelectedValue.ToString().PadLeft(6, '0').Substring(3, 3)); agentDS.Merge(ds); this.cboLocation.DisplayMember = "AgentTable.AgentSummary"; this.cboLocation.ValueMember = "AgentTable.AgentNumber"; this.cboLocation.DataSource = agentDS; } catch (Exception ex) { throw new ControlException("Unexpected error while loading company agents.", ex); } }
private void OnDragDrop(object sender, System.Windows.Forms.DragEventArgs e) { //Event handler for dropping onto the listview try { DataObject data = (DataObject)e.Data; if (data.GetDataPresent(DataFormats.FileDrop)) { //Local file string[] names = (string[])data.GetData(DataFormats.FileDrop); if (names.Length > 0) { //Save attachment string name = new System.IO.FileInfo(names[0]).Name; System.IO.FileStream stream = new System.IO.FileStream(names[0], System.IO.FileMode.Open); byte[] bytes = new byte[stream.Length]; //stream.Position = 0; stream.Read(bytes, 0, (int)stream.Length); long actionID = Convert.ToInt64(this.lsvActions.SelectedItems[0].Name); CustomerProxy.CreateIssueAttachment(name, bytes, actionID); stream.Close(); loadActions(); } } else if (data.GetDataPresent("FileGroupDescriptor")) { //Outlook attachment //Set the position within the current stream to the beginning of the file name //return the file name in the fileName variable System.IO.MemoryStream stream = (System.IO.MemoryStream)data.GetData("FileGroupDescriptor"); stream.Seek(76, System.IO.SeekOrigin.Begin); byte[] fileName = new byte[256]; stream.Read(fileName, 0, 256); System.Text.Encoding encoding = System.Text.Encoding.ASCII; string name = encoding.GetString(fileName); name = name.TrimEnd('\0'); stream.Close(); //Save attachment stream = (System.IO.MemoryStream)e.Data.GetData("FileContents"); byte[] bytes = new byte[stream.Length]; //stream.Position = 0; stream.Read(bytes, 0, (int)stream.Length); long actionID = Convert.ToInt64(this.lsvActions.SelectedItems[0].Name); CustomerProxy.CreateIssueAttachment(name, bytes, actionID); stream.Close(); loadActions(); } } catch (Exception ex) { reportError(ex); } finally { setUserServices(); } }
private void OnAfterContactCreated(object source, ContactEventArgs e) { //Event handler for new contact created this.Cursor = Cursors.WaitCursor; try { //Persist the new contact int id = CustomerProxy.CreateContact(e.Contact); this.mContacts.Clear(); this.mContacts.Merge(CustomerProxy.GetContacts()); this.ctlContact.SelectedValue = id; } catch (Exception ex) { reportError(ex); } finally { this.Cursor = Cursors.Default; } }
protected void OnChangeView(object sender, CommandEventArgs e) { // switch (e.CommandName) { case "Search": this.mvPage.SetActiveView(this.vwIssues); break; case "Reset": this.mvPage.SetActiveView(this.vwSearch); break; case "Issues": this.mvPage.SetActiveView(this.vwIssues); break; case "Issue": Argix.Customers.Issue issue = new Argix.Customers.CustomerProxy().GetIssue(long.Parse(e.CommandArgument.ToString())); if (issue != null) { this.lblType.Text = issue.Type.Trim(); this.lblCompany.Text = ""; if (issue.CompanyName.Trim() != "All") { this.lblCompany.Text += issue.CompanyName.Trim(); if (issue.StoreNumber > 0) { this.lblCompany.Text += " #" + issue.StoreNumber.ToString(); } } else { if (issue.AgentNumber.Trim() != "All") { this.lblCompany.Text += ": Agent#" + issue.AgentNumber.Trim(); } else { this.lblCompany.Text += ": All Agents"; } } this.lblSubject.Text = issue.Subject.Trim(); } this.odsActions.SelectParameters["issueID"].DefaultValue = e.CommandArgument.ToString(); this.odsActions.DataBind(); this.mvPage.SetActiveView(this.vwIssue); break; } }
private void OnActionSelected(object sender, EventArgs e) { //Event handler for change in selected action try { this.txtAction.Text = ""; this.lsvAttachments.Items.Clear(); if (this.lsvActions.SelectedItems.Count > 0) { //Action long actionID = Convert.ToInt64(this.lsvActions.SelectedItems[0].Name); //Show the attachments Attachment[] attachments = CustomerProxy.GetAttachments(this.mIssue.ID, actionID); this.lsvAttachments.Items.Clear(); for (int i = 0; i < attachments.Length; i++) { this.lsvAttachments.Items.Add(attachments[i].ID.ToString(), attachments[i].Filename, -1); } this.lsvAttachments.View = View.List; //Show the selected action Action[] actions = this.mActions; int start = 0; bool go = false; for (int i = 0; i < actions.Length; i++) { Action action = actions[i]; if (!go && action.ID == actionID) { go = true; } if (go) { string header = action.Created.ToString("f") + " " + action.UserID + ", " + action.TypeName; this.txtAction.AppendText(header); this.txtAction.Select(start, header.Length); this.txtAction.SelectionFont = new Font(this.txtAction.Font, FontStyle.Bold); this.txtAction.AppendText("\r\n\r\n"); this.txtAction.AppendText(action.Comment); this.txtAction.AppendText("\r\n"); this.txtAction.AppendText("".PadRight(75, '-')); this.txtAction.AppendText("\r\n"); start = this.txtAction.Text.Length; } } } } catch (Exception ex) { reportError(new ControlException("Unexpected error on change of selected issue action in the IssueInspector control.", ex)); } finally { setUserServices(); }; }
private void OnSearch(object sender, KeyPressEventArgs e) { //Search try { this.mIssueSearch.Clear(); if (e.KeyChar == (char)Keys.Enter && this.cboSearch.Text.Trim().Length > 0) { //this.cboSearch.Items.Add(this.cboSearch.Text); this.mIssueSearch.Merge(CustomerProxy.SearchIssues(this.cboSearch.Text)); this.cboView.SelectedItem = "Search Results"; OnViewChanged(this.cboView, EventArgs.Empty); } } catch (Exception ex) { reportError(ex); } }
private void OnGridSelectionChanged(object sender, Infragistics.Win.UltraWinGrid.AfterSelectChangeEventArgs e) { //Event handler for after selection changes this.Cursor = Cursors.WaitCursor; try { //Update the selected contact this.mContact = null; if (this.grdContacts.Selected.Rows.Count > 0) { this.mContact = CustomerProxy.GetContact(Convert.ToInt32(this.grdContacts.Selected.Rows[0].Cells["ID"].Value)); } } catch { } finally { setUserServices(); this.Cursor = Cursors.Default; } }
private void OnGridSelectionChanged(object sender, Infragistics.Win.UltraWinGrid.AfterSelectChangeEventArgs e) { //Event handler for after selection changes this.Cursor = Cursors.WaitCursor; try { //Update the selected issue if not looking at another issue view this.mIssue = null; UltraGrid grid = (UltraGrid)sender; if (grid.Selected.Rows.Count > 0) { switch (this.cboView.Text) { case "Search Results": this.mIssue = CustomerProxy.GetIssue(Convert.ToInt32(grid.Selected.Rows[0].Cells["ID"].Value)); break; default: this.mIssue = CustomerProxy.GetIssue(Convert.ToInt32(grid.Selected.Rows[0].Cells["ID"].Value)); this.mIssueH = this.mIssue; break; } try { //Unbold viewed issues/actions grid.Selected.Rows[0].CellAppearance.FontData.Bold = DefaultableBoolean.False; int id = Convert.ToInt32(grid.Selected.Rows[0].Cells["ID"].Value); DateTime dt1 = Convert.ToDateTime(grid.Selected.Rows[0].Cells["LastActionCreated"].Value); if (this.mOldItems.ContainsKey(id)) { this.mOldItems[id] = dt1; } else { this.mOldItems.Add(id, dt1); } } catch { } } if (this.IssueSelected != null) { this.IssueSelected(this, EventArgs.Empty); } } catch { } finally { setUserServices(); this.Cursor = Cursors.Default; } }
private void loadDistricts() { //Load a list of district selections try { LocationDS locationDS = new LocationDS(); LocationDS _ds = CustomerProxy.GetDistricts(this.cboCompany.SelectedValue.ToString().PadLeft(6, '0').Substring(3, 3)); for (int i = 0; i < _ds.LocationTable.Rows.Count; i++) { _ds.LocationTable[i].Location = _ds.LocationTable[i].Location.ToString().Trim(); _ds.LocationTable[i].LocationName = _ds.LocationTable[i].LocationName.ToString().Trim(); } locationDS.Merge(_ds, true); this.cboLocation.DisplayMember = "LocationTable.LocationName"; this.cboLocation.ValueMember = "LocationTable.Location"; this.cboLocation.DataSource = locationDS; } catch (Exception ex) { throw new ControlException("Unexpected error while loading company districts.", ex); } }
private void OnFindPRONumber(object sender, EventArgs e) { //Event handler for change in selected company try { dlgDeliveries dlg = new dlgDeliveries(this.mIssue.CompanyID, Convert.ToInt32(this.mIssue.StoreNumber), this.dtpFrom.Value, this.dtpTo.Value); dlg.Font = this.Font; if (dlg.ShowDialog() == DialogResult.OK) { this.mIssue.ContactID = Convert.ToInt32(this.ctlContact.SelectedValue); this.mIssue.OFD1FromDate = this.dtpFrom.Value; this.mIssue.OFD1ToDate = this.dtpTo.Value; this.mIssue.PROID = dlg.PROID; CustomerProxy.UpdateIssue(this.mIssue); showDeliveryInfo(true); } } catch (Exception ex) { reportError(new ControlException("Unexpected error while determining delivery information in the IssueInspector control.", ex)); } }
//Interface protected void Page_Load(object sender, EventArgs e) { //Event handler for page load event if (!Page.IsPostBack) { //Get query params this.mIssueID = Convert.ToInt64(Request.QueryString["issueID"]); ViewState.Add("IssueID", this.mIssueID); this.Master.IssuesButtonFontColor = System.Drawing.Color.White; } else { this.mIssueID = (long)ViewState["IssueID"]; } Argix.Customers.Issue issue = new Argix.Customers.CustomerProxy().GetIssue(this.mIssueID); if (issue != null) { this.lblType.Text = issue.Type.Trim(); this.lblCompany.Text = ""; if (issue.CompanyName.Trim() != "All") { this.lblCompany.Text += issue.CompanyName.Trim(); if (issue.StoreNumber > 0) { this.lblCompany.Text += " #" + issue.StoreNumber.ToString(); } } else { if (issue.AgentNumber.Trim() != "All") { this.lblCompany.Text += ": Agent#" + issue.AgentNumber.Trim(); } else { this.lblCompany.Text += ": All Agents"; } } this.lblSubject.Text = issue.Subject.Trim(); } }
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.Merge(CustomerProxy.GetActionTypes(this.mIssue.ID)); this.cboActionType.SelectedIndex = -1; this.txtComment.Text = this.mAction.Comment; this.txtComments.Text = getAllActionComments(); this.chkRunning.Checked = true; OnRunningChecked(null, EventArgs.Empty); OnValidateForm(null, EventArgs.Empty); } catch (Exception ex) { reportError(ex); } finally { this.Cursor = Cursors.Default; } }
private void showDeliveryInfo(bool showCartons) { //Clear and validate this.grdDelivery.SelectedObject = null; if (this.mIssue != null) { //Display delivery info DeliveryDS delivery = CustomerProxy.GetDelivery(this.mIssue.CompanyID, this.mIssue.StoreNumber, this.mIssue.OFD1FromDate, this.mIssue.OFD1ToDate, this.mIssue.PROID); if (delivery.DeliveryTable.Rows.Count > 0) { this.grdDelivery.SelectedObject = new DeliveryInfo(delivery.DeliveryTable[0]); } if (showCartons) { ScanDS osdscans = CustomerProxy.GetOSDScans(this.mIssue.PROID); this.oSDScanTableBindingSource.DataSource = osdscans; ScanDS podscans = CustomerProxy.GetPODScans(this.mIssue.PROID); this.pODScanTableBindingSource.DataSource = podscans; } } }
private void showStoreDetail() { // this.mStoreDS = new StoreDS(); this.txtStoreDetail.Clear(); if (this.cboCompany.SelectedValue != null && this.txtStore.Text.Length > 0) { StoreDS ds = new StoreDS(); switch (this.cboScope.SelectedItem.ToString()) { case SCOPE_STORES: ds.Merge(CustomerProxy.GetStoreDetail(Convert.ToInt32(CompanySelectedValue), Convert.ToInt32(this.txtStore.Text))); break; case SCOPE_SUBSTORES: ds.Merge(CustomerProxy.GetStoreDetail(Convert.ToInt32(CompanySelectedValue), this.txtStore.Text)); break; } if (ds.StoreTable.Rows.Count > 0) { this.mStoreDS = ds; this.txtStoreDetail.Text = getStoreDetailString(); } } }
private void OnControlLoad(object sender, EventArgs e) { //Event handler for load event this.Cursor = Cursors.WaitCursor; try { if (this.mReadOnly) { this.mCompanyDS.Merge(CustomerProxy.GetCompanies()); } else { this.mCompanyDS.Merge(CustomerProxy.GetCompanies(true)); } this.cboCompany.Enabled = !this.mReadOnly && this.cboCompany.Items.Count > 0; this.cboScope.Enabled = this.cboLocation.Enabled = this.txtStore.Enabled = this.btnStoreDetail.Enabled = this.txtStoreDetail.Enabled = false; this.cboCompany.SelectedIndex = -1; this.cboLocation.DataSource = null; } catch (Exception ex) { reportError(new ControlException("Unexpected error while loading CompanyLocation control.", ex)); } finally { this.Cursor = Cursors.Default; } }
private string getAllActionComments() { //Get a running comment for this action string comments = ""; Action[] actions = CustomerProxy.GetIssueActions(this.mIssue.ID); for (int i = 0; i < actions.Length; i++) { Action action = actions[i]; if (i > 0) { comments += "\r\n\r\n"; comments += "".PadRight(75, '-'); comments += "\r\n"; } comments += action.Created.ToString("f") + ", " + action.UserID + ", " + action.TypeName; comments += "\r\n\r\n"; comments += action.Comment; } return(comments); }
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.cboIssueCategory.DataSource = this.mIssueCategorys; this.cboIssueCategory.DisplayMember = "IssueTypeTable.Category"; this.cboIssueCategory.ValueMember = "IssueTypeTable.Category"; this.mIssueCategorys.Merge(CustomerProxy.GetIssueCategorys()); this.cboIssueType.DataSource = this.mIssueTypes; this.cboIssueType.DisplayMember = "IssueTypeTable.Type"; this.cboIssueType.ValueMember = "IssueTypeTable.ID"; this.cboIssueCategory.SelectedIndex = 0; OnIssueCategorySelected(this.cboIssueCategory, EventArgs.Empty); this.ctlContact.DataSource = this.mContacts; this.mContacts.Merge(CustomerProxy.GetContacts()); this.txtTitle.Text = this.mIssue.Subject; } catch (Exception ex) { reportError(ex); } finally { this.btnOk.Enabled = false; this.Cursor = Cursors.Default; } }
private void loadActions() { //Event handler for change in actions collection //Load actions for this issue this.lsvActions.Groups.Clear(); this.lsvActions.Items.Clear(); if (this.mIssue != null) { //Create action listitems sorted by date/time Action[] actions = CustomerProxy.GetIssueActions(this.mIssue.ID); this.mActions = actions; for (int i = 0; i < actions.Length; i++) { //Add attachment symbol as required //Tag is used to enable attachement to newest action only Action action = actions[i]; ListViewItem item = this.lsvActions.Items.Add(action.ID.ToString(), action.UserID, (action.Attachments > 0 ? 0 : -1)); item.Tag = i.ToString(); //Assign to listitem group DateTime created = action.Created; bool useYesterday = DateTime.Today.DayOfWeek != DayOfWeek.Monday; if (created.CompareTo(DateTime.Today) >= 0) { this.lsvActions.Groups.Add("Today", "Today"); item.SubItems.Add(created.ToString("ddd HH:mm")); item.Group = this.lsvActions.Groups["Today"]; } else if (useYesterday && created.CompareTo(DateTime.Today.AddDays(-1)) >= 0) { this.lsvActions.Groups.Add("Yesterday", "Yesterday"); item.SubItems.Add(created.ToString("ddd HH:mm")); item.Group = this.lsvActions.Groups["Yesterday"]; } else if (created.CompareTo(DateTime.Today.AddDays(0 - DateTime.Today.DayOfWeek)) >= 0) { this.lsvActions.Groups.Add("This Week", "This Week"); item.SubItems.Add(created.ToString("ddd HH:mm")); item.Group = this.lsvActions.Groups["This Week"]; } else if (created.CompareTo(DateTime.Today.AddDays(0 - DateTime.Today.DayOfWeek - 7)) >= 0) { this.lsvActions.Groups.Add("Last Week", "Last Week"); item.SubItems.Add(created.ToString("ddd MM/dd HH:mm")); item.Group = this.lsvActions.Groups["Last Week"]; } else { this.lsvActions.Groups.Add("Other", "Other"); item.SubItems.Add(created.ToString("ddd MM/dd/yyyy HH:mm")); item.Group = this.lsvActions.Groups["Other"]; } } } if (this.lsvActions.Items.Count > 0) { this.lsvActions.Items[0].Selected = true; } else { OnActionSelected(null, EventArgs.Empty); } }
private void refreshContacts() { // this.mContactDS.Clear(); this.mContactDS.Merge(CustomerProxy.GetContacts()); }
private void OnToolbarItemClicked(object sender, ToolStripItemClickedEventArgs e) { //Toolbar handler - forward to main menu handler long actionID = 0; Action action = null; System.IO.FileStream fs = null; byte[] bytes = null; try { //Get the current action actionID = Convert.ToInt64(this.lsvActions.SelectedItems[0].Name); switch (e.ClickedItem.Name) { case "btnNew": this.ctxActionsNew.PerformClick(); break; case "btnPrint": this.ctxActionsPrint.PerformClick(); break; case "btnRefresh": this.ctxRefresh.PerformClick(); break; case "btnOpen": //Open the selected attachment int attachmentID = Convert.ToInt32(this.lsvAttachments.SelectedItems[0].Name); bytes = CustomerProxy.GetAttachment(attachmentID); string file = CustomerProxy.TempFolder + this.lsvAttachments.SelectedItems[0].Text.Trim(); fs = new System.IO.FileStream(file, System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.Write); System.IO.BinaryWriter writer = new System.IO.BinaryWriter(fs); writer.Write(bytes); writer.Flush(); writer.Close(); System.Diagnostics.Process.Start(file); break; case "btnAttach": //Save an attachment to the selected action OpenFileDialog dlgOpen = new OpenFileDialog(); dlgOpen.AddExtension = true; dlgOpen.Filter = "All Files (*.*) | *.*"; dlgOpen.FilterIndex = 0; dlgOpen.Title = "Select Attachment to Save..."; dlgOpen.FileName = ""; if (dlgOpen.ShowDialog(this) == DialogResult.OK) { string name = new System.IO.FileInfo(dlgOpen.FileName).Name; fs = new System.IO.FileStream(dlgOpen.FileName, System.IO.FileMode.Open, System.IO.FileAccess.Read); System.IO.BinaryReader reader = new System.IO.BinaryReader(fs); bytes = reader.ReadBytes((int)fs.Length); reader.Close(); bool created = CustomerProxy.CreateIssueAttachment(name, bytes, actionID); loadActions(); } break; case "btnSend": if (this.lsvActions.SelectedItems.Count > 0) { //Create new mail item if (OutlookApp == null) { return; } Outlook.MailItem item = (Outlook.MailItem)OutlookApp.CreateItem(Outlook.OlItemType.olMailItem); item.Subject = this.mIssue.Subject; item.Body = action.Comment; item.To = CustomerProxy.GetContact(this.mIssue.ContactID).Email; item.Display(false); } break; } } catch (Exception ex) { reportError(new ControlException("Unexpected error in IssueInspector.", ex)); } finally { if (fs != null) { fs.Close(); } } }
public void Save() { CustomerProxy.UpdateIssue(this.mIssue); }