private void button1_Click(object sender, EventArgs e) { using (EquipReDataContext dbContext = new EquipReDataContext()) { try { EquipmentReturn submitchanges = dbContext.EquipmentReturns.SingleOrDefault(X => X.IDText.Contains(RID)); submitchanges.EscalationAgent = comboBox1.Text; submitchanges.EscalationStatus = true; submitchanges.EscalationDate = DateTime.Now; submitchanges.Notes += "\r\n\r\nEmail of Escalation Supervisor: " + textBox2.Text; eemail = textBox2.Text; submitchanges.TicketStatus = 'C'; sendemail(submitchanges.TagID, textBox2.Text, submitchanges.Phone_Number.ToString(), submitchanges.Assignee.ToString(), comboBox1.Text); dbContext.SubmitChanges(); owner.Close(); this.Close(); } catch (Exception explanation) { MessageBox.Show("Error! Unable to connect to server\r\n\r\n" + explanation); } } }
private void button5_Click(object sender, EventArgs e) { using (EquipReDataContext dbContext = new EquipReDataContext()) { try { EquipmentReturn submitchanges = dbContext.EquipmentReturns.SingleOrDefault(X => X.IDText.Contains(RID)); //notes if (textBox3.Text != "" && submitchanges.AdditionalNotes == "") { submitchanges.AdditionalNotes += username + " (" + DateTime.Now.ToString() + "): " + textBox3.Text; } else if (textBox3.Text != "" && submitchanges.AdditionalNotes != "" && submitchanges.AdditionalNotes != textBox2.Text) { submitchanges.AdditionalNotes += "\r\n\r\n" + username + " (" + DateTime.Now.ToString() + "): " + textBox3.Text; } submitchanges.TicketStatus = 'F'; //level of priority if (comboBox1.SelectedIndex == 0) { submitchanges.Priority = 'H'; } if (comboBox1.SelectedIndex == 1) { submitchanges.Priority = 'M'; } if (comboBox1.SelectedIndex == 2) { submitchanges.Priority = 'L'; } if (submitchanges.AdditionalNotes == textBox3.Text || (textBox3.Text == "" && submitchanges.AdditionalNotes == "") || textBox3.Text == "") { MessageBox.Show("Error! Enter all details before continuing"); } else { //Status if (radioButton1.Checked == true) { submitchanges.TicketStatus = 'O'; } if (radioButton2.Checked == true) { email ReturnClosed = new email(); ReturnClosed.sendemail("Return Ticket Closed", "This is a notice that a ticket for equipment returns has been closed. \r\n\r\nDevice ID: " + submitchanges.TagID + "\r\nPhone Number Called: " + submitchanges.Phone_Number + "\r\nDevice Assigned to: " + submitchanges.Assignee, submitchanges.IDText, "*****@*****.**"); submitchanges.TicketStatus = 'C'; } if (radioButton3.Checked == true) { submitchanges.TicketStatus = 'P'; } if (radioButton4.Checked == true) { submitchanges.TicketStatus = 'F'; } dbContext.SubmitChanges(); this.Close(); } } catch { MessageBox.Show("Error Submiting Data. Please contact your Network Administrator or IT team."); } } }
private void button4_Click(object sender, EventArgs e) { //data holders string creator = ""; string DC = ""; string stat = ""; string priority = ""; string Device = ""; string type = ""; string notes = ""; string adnotes = ""; //people who have handled string fp = ""; string sp = ""; string tp = ""; string ep = ""; //dates of when handled string fd = ""; string sd = ""; string td = ""; string ed = ""; //escalation status string es = ""; //reason why returning string reason = ""; //Phone Number string phone = ""; //Assignee name string assigned = ""; //load Data EquipReDataContext db = new EquipReDataContext(); var r = from p in db.EquipmentReturns where p.IDText.Contains(RID) select p; foreach (var x in r) { creator = x.Ticketor; DC = x.DateCreated.ToString(); stat = "" + x.TicketStatus; if (stat == "F") { stat = "Follow-Up"; } if (stat == "C") { stat = "Closed"; } if (stat == "P") { stat = "Pending"; } if (stat == "O") { stat = "Open"; } priority = x.Priority + ""; if (priority == "L") { priority = "Low"; } if (priority == "M") { priority = "Medium"; } if (priority == "H") { priority = "High"; } phone = x.Phone_Number; Device = x.TagID; type = "Return"; notes = x.Notes; adnotes = x.AdditionalNotes; //contact people fp = x.FirstContactPerson; sp = x.SecondContactPerson; tp = x.ThirdContactperson; ep = x.EscalationAgent; assigned = x.Assignee; //contact dates if (x.FirstContactDate.ToString() != "01/01/1990 12:00:00 AM") { fp = x.FirstContactPerson; fd = x.FirstContactDate.ToString(); } else { fp = ""; fd = "No contact"; } if (x.SecondContactDate.ToString() != "01/01/1990 12:00:00 AM") { sp = x.SecondContactPerson; sd = x.SecondContactDate.ToString(); } else { sp = ""; sd = "No contact"; } if (x.ThirdContactDate.ToString() != "01/01/1990 12:00:00 AM") { tp = x.ThirdContactperson; td = x.ThirdContactDate.ToString(); } else { tp = ""; td = "No contact"; } reason = x.Reason; //escalation status if (x.EscalationStatus == true) { es = "Escalated"; ep = x.EscalationAgent; ed = x.EscalationDate.ToString(); } else { es = "Not Escalated"; ep = ""; ed = "No Contact"; } } //get a new class for printing PCPrint printer = new PCPrint(); //sent font printer.PrinterFont = new Font("Arial", 10); //set text printer.TextToPrint = " " + "CNS" + spacer(100, ' ') + "Ticket ID: " + RID + "\r\nIT Ticketing System" + "\r\n\r\n\r\n"; printer.TextToPrint += "Creator of ticket: " + creator + "\r\n"; printer.TextToPrint += "Date Created: " + DC + "\r\n"; printer.TextToPrint += "Status: " + stat + "\r\n"; printer.TextToPrint += "Priority: " + priority + "\r\n"; printer.TextToPrint += "Device ID: " + Device + "\r\n"; printer.TextToPrint += "Issue Type: " + type + "\r\n"; printer.TextToPrint += "Reason: " + reason + "\r\n"; printer.TextToPrint += "Device Assigned to: " + assigned + "\r\n"; printer.TextToPrint += "Phone Number Called: " + phone + "\r\n"; printer.TextToPrint += "First contact: " + fp + " (" + fd + ")\r\n"; printer.TextToPrint += "Second contact: " + sp + " (" + sd + ")\r\n"; printer.TextToPrint += "Third contact: " + tp + " (" + td + ")\r\n"; printer.TextToPrint += es + "\r\n"; printer.TextToPrint += "Escalation information: " + ep + " (" + ed + ")\r\n\r\n"; printer.TextToPrint += spacer(65, ' ') + "Notes:\r\n" + spacer(125, '-') + "\r\n" + notes + "\r\n" + spacer(125, '-') + "\r\n\r\n"; printer.TextToPrint += spacer(65, ' ') + "Additional Notes:\r\n" + spacer(125, '-') + "\r\n" + adnotes + "\r\n" + spacer(125, '-') + "\r\n\r\n"; //print printer.Print(); }
//loading of data private void ReturnData_Load(object sender, EventArgs e) { button1.Focus(); button2.Enabled = false; textBox1.Enabled = true; label2.Text = RID; EquipReDataContext edb = new EquipReDataContext(); var r = from p in edb.EquipmentReturns where p.IDText.Contains(RID) select p; foreach (var results in r) { label4.Text = results.Ticketor; label6.Text = results.DateCreated.ToString(); label8.Text = results.TagID; label10.Text = results.Reason; textBox3.Text = results.AdditionalNotes; if (results.Priority == 'H') { label25.Text = "High"; comboBox1.SelectedIndex = 0; } else if (results.Priority == 'M') { label25.Text = "Medium"; comboBox1.SelectedIndex = 1; } else if (results.Priority == 'L') { label25.Text = "Low"; comboBox1.SelectedIndex = 2; } if (results.TicketStatus == 'P') { label27.Text = "Pending Resolution"; radioButton3.Checked = true; } else if (results.TicketStatus == 'O') { label27.Text = "Open"; radioButton1.Checked = true; } else if (results.TicketStatus == 'F') { label27.Text = "Follow Up"; radioButton4.Checked = true; } else if (results.TicketStatus == 'C') { radioButton2.Checked = true; label27.Text = "Closed"; button1.Enabled = false; button2.Enabled = false; radioButton1.Enabled = false; button5.Enabled = false; radioButton2.Enabled = false; radioButton3.Enabled = false; radioButton4.Enabled = false; comboBox1.Enabled = false; textBox1.ReadOnly = true; textBox2.ReadOnly = true; } if (results.EscalationStatus == true) { label23.Text = "Yes"; label29.Text = results.EscalationAgent; label31.Text = results.EscalationDate.ToString(); button2.Enabled = false; } else if (results.EscalationStatus == false) { label23.Text = "No"; label28.Hide(); label29.Hide(); label30.Hide(); label31.Hide(); } label29.Text = results.EscalationAgent; label31.Text = results.EscalationDate.ToString(); label16.Text = results.FirstContactPerson; label17.Text = results.SecondContactPerson; label18.Text = results.ThirdContactperson; label19.Text = results.FirstContactDate.ToString(); label20.Text = results.SecondContactDate.ToString(); label21.Text = results.ThirdContactDate.ToString(); if (results.FirstContactPerson == "None") { label16.Text = "No Contact Made"; label14.Hide(); label15.Hide(); label17.Hide(); label18.Hide(); label20.Hide(); label21.Hide(); label19.Text = ""; } else if (results.SecondContactPerson == "None") { label17.Text = "No Contact Made"; label15.Hide(); label18.Hide(); label21.Hide(); label20.Text = ""; } else if (results.ThirdContactperson == "None") { label18.Text = "No Contact Made"; label21.Text = ""; } else { button1.Enabled = false; button5.Enabled = false; if (results.EscalationStatus == false) { button2.Enabled = true; textBox2.Enabled = false; textBox3.Enabled = false; } else { button2.Enabled = false; textBox2.Enabled = false; textBox3.Enabled = false; } } if (results.Phone_Number != "000-000-0000") { textBox1.Text = results.Phone_Number; textBox1.Enabled = false; } textBox2.Text = results.Notes; } }
private void button1_Click(object sender, EventArgs e) { if ((comboBox1.SelectedIndex == 4 && textBox2.Text == "") || textBox1.Text == "" || textBox3.Text == "") { MessageBox.Show("Please enter details in all fields"); } else { using (EquipReDataContext dbContext = new EquipReDataContext()) { DateTime blank = new DateTime(1990, 1, 1, 0, 0, 0); Random rnd = new Random(); string ID = "E" + long.Parse(DateTime.Now.ToString("MMddyyyyhhmm") + rnd.Next(1, 1000).ToString()); string reasons = ""; if (textBox2.Text != "") { reasons = comboBox1.Text + ": " + textBox2.Text; } else { reasons = comboBox1.Text; } EquipmentReturn returns = new EquipmentReturn() { Id = long.Parse(DateTime.Now.ToString("MMddyyyyhhmm") + rnd.Next(1, 1000).ToString()), IDText = ID, FirstContactPerson = "None", SecondContactPerson = "None", ThirdContactperson = "None", EscalationAgent = "None", EscalationStatus = false, FirstContactDate = blank, SecondContactDate = blank, ThirdContactDate = blank, EscalationDate = blank, Notes = "Device Assigned to: " + textBox3.Text + "\r\n", TicketStatus = 'P', Priority = 'L', Phone_Number = "000-000-0000", Assignee = textBox3.Text, Ticketor = username, DateCreated = DateTime.Now, Reason = reasons, TagID = textBox1.Text }; dbContext.EquipmentReturns.InsertOnSubmit(returns); try { dbContext.SubmitChanges(); } catch (Exception r) { MessageBox.Show("Error, unable to save to database. Check connection\r\n\r\n" + r.ToString()); } email ReturnSetup = new email(); ReturnSetup.sendemail("Return Ticket Created.", "A new Return ticket has been created.Please review this in the IT ticketing system for further information.\r\nThe ticket ID is: " + ID + "\r\nEquipmentID: " + textBox1.Text + "Assigned to: " + textBox3.Text, ID, "*****@*****.**"); this.Close(); } } }