Example #1
0
        private void closeBtnSave_Click(object sender, EventArgs e)
        {
            string status;

            if (closeTxtMessage.Text == "")
            {
                MessageBox.Show("Please provide a message");
            }
            else
            {
                if (closeRadClose.Checked == true)
                {
                    status = "Closed";
                }
                else
                {
                    status = "Escalated";
                }
                string callStatus = status;
                string callDateResolved;
                string ticketNum     = closeComboUnikNo.Text;
                string escalatedTo   = clsEscalatedTo.Text;
                string callType      = closeTxtType.Text;
                string closureReason = closeTxtMessage.Text;

                if (status == "Closed")
                {
                    callDateResolved = DateTime.Now.ToString();
                }
                else
                {
                    callDateResolved = "Still in progress";
                }
                using (SqlConnection conn = new SqlConnection(DatabaseConnection.connectionStr))
                {
                    conn.Open();
                    using (SqlCommand cmd = new SqlCommand("update Tickets set Status= @callStatus , ClosedDate= @ClosedDate ,EscalatedTo= @escalatedTo,ClosureReason=@ClosureReason where TicketNumber = '" + ticketNum + "'", conn))
                    {
                        SendEmail sendE    = new SendEmail();
                        string    emailMsg = "The ticket has been " + callStatus;
                        void threadStart()
                        {
                            sendE.sendEmail(Global.Staff.Email,
                                            escalatedTo, "*****@*****.**", "",
                                            closureReason, ticketNum, callType, "Name",
                                            callStatus, "", emailMsg);
                        }

                        Thread thread = new Thread(threadStart);
                        thread.Start();

                        cmd.Parameters.AddWithValue("@callStatus", callStatus);
                        cmd.Parameters.AddWithValue("@ClosedDate", callDateResolved);
                        cmd.Parameters.AddWithValue("@escalatedTo", escalatedTo);
                        cmd.Parameters.AddWithValue("@ClosureReason", closureReason);

                        cmd.ExecuteNonQuery();
                    }
                }

                MessageBox.Show("Call sucessfully " + status + "!");
            }
        }
Example #2
0
        //private void recBtnSearch_Click(object sender, EventArgs e)
        //{
        //    string refNum = recComboUnikNo.Text;
        //    int i;
        //    try
        //    {
        //        if ((refNum.ToString().Length > 2))
        //        {
        //            if (int.TryParse(refNum, out i))
        //            {
        //                int id = Convert.ToInt32(refNum);
        //                using (SqlConnection conn = new SqlConnection(DatabaseConnection.connectionStr))
        //                {
        //                    conn.Open();
        //                    try
        //                    {
        //                        using (SqlCommand cmd = new SqlCommand("SELECT * from Staff where StaffID = '" + id + "'", conn))
        //                        {
        //                            SqlDataReader reader = cmd.ExecuteReader();
        //                            reader.Read();
        //                            recTxtName.Text = reader["Name"].ToString();
        //                            recTxtSurname.Text = reader["Surname"].ToString();
        //                            recTxtEmail.Text = reader["Email"].ToString();
        //                            recTxtDept.Text = reader["Department"].ToString();
        //                            recTxtUnit.Text = reader["Unit"].ToString();
        //                            recTxtBuilding.Text = reader["Building"].ToString();
        //                            recTxtFloorNo.Text = reader["Floor"].ToString();

        //                            reader.Close();
        //                        }
        //                    }
        //                    catch (Exception ex)
        //                    {
        //                        MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
        //                        new LogWriter(ex);
        //                        this.Close();
        //                    }

        //                }
        //            }
        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
        //        new LogWriter(ex);
        //        this.Close();
        //    }
        //}

        private void RecBtnSave_Click(object sender, EventArgs e)
        {
            string callType         = "";
            string callPriority     = recComboPriority.Text;
            string callStatus       = "Opened";
            string callAssignedTo   = recComboAssignedTo.Text;
            string callDateLogged   = DateTime.Now.ToString();
            string callDateResolved = "Still in progress";
            string callAssignedBy   = staffNames.Text;
            string callDescription  = recTxtCallDescription.Text;
            string callSubmitedBy   = recComboUnikNo.Text;
            string callName         = recTxtTicketName.Text;

            string techEmail = recComboAssignedTo.Text;
            //string clientEmail = recTxtEmail.Text;
            //string clientNames = recTxtSurname.Text + " " + recTxtName.Text;
            string callDesc = recTxtCallDescription.Text;
            string refNum   = recComboUnikNo.Text;

            string emailMsg = "You have been assigned a new Ticket!";
            GenerateTicketNumber genTicket = new GenerateTicketNumber();
            string TicketNum = genTicket.getTicketNumber();

            try
            {
                if (recRadIncident.Checked == true)
                {
                    callType  = "Incident";
                    TicketNum = "I" + genTicket.getTicketNumber();
                }
                else
                {
                    callType  = "Request";
                    TicketNum = "R" + genTicket.getTicketNumber();
                }

                if ((recTxtCallDescription.Text == "") || (recComboUnikNo.Text == "") || (recComboAssignedTo.Text == "Choose") || (recComboPriority.Text == "Choose") ||
                    (recComboAssignedTo.Text == "") || (recComboPriority.Text == ""))
                {
                    MessageBox.Show("Please fill in all the fields with the correct information");
                }
                else
                {
                    using (SqlConnection conn = new SqlConnection(DatabaseConnection.connectionStr))
                    {
                        conn.Open();
                        using (SqlCommand cmd = new SqlCommand("INSERT INTO Tickets(TicketNumber,TicketName,Type,CreatedBy,Priority,Description,CreatedDate,Status,ClosedDate,AssignedTo,SubmitedBy) " +
                                                               "VALUES(@TicketNumber,@TicketName,@Type,@CreatedBy,@Priority,@Description,@CreatedDate,@Status,@ClosedDate,@AssignedTo,@SubmitedBy) ", conn))
                        {
                            cmd.Parameters.AddWithValue("@TicketNumber", TicketNum);
                            cmd.Parameters.AddWithValue("@TicketName", callName);
                            cmd.Parameters.AddWithValue("@Type", callType);
                            cmd.Parameters.AddWithValue("@AssignedTo", callAssignedTo);
                            cmd.Parameters.AddWithValue("@CreatedBy", callAssignedBy);
                            cmd.Parameters.AddWithValue("@Priority", callPriority);
                            cmd.Parameters.AddWithValue("@Description", callDescription);
                            cmd.Parameters.AddWithValue("@CreatedDate", callDateLogged);
                            cmd.Parameters.AddWithValue("@Status", callStatus);
                            cmd.Parameters.AddWithValue("@ClosedDate", callDateResolved);
                            cmd.Parameters.AddWithValue("@SubmitedBy", callSubmitedBy);

                            cmd.ExecuteNonQuery();

                            SendEmail sendE = new SendEmail();
                            void threadStart()
                            {
                                sendE.sendEmail(Global.Staff.Email,
                                                "*****@*****.**", "*****@*****.**", "Rugamba Cedric",
                                                "Ticket", TicketNum, callType, callName,
                                                callStatus, callPriority, emailMsg);
                            }
                            Thread thread = new Thread(threadStart);
                            thread.Start();
                        }
                    }
                    LoadCalls();
                    //string techEmail = recComboAssignedTo.Text;
                    //string clientEmail = recTxtEmail.Text;
                    //string clientNames = recTxtSurname.Text + " " + recTxtName.Text;
                    //string callDesc = recTxtCallDescription.Text;
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                new LogWriter(ex);
                this.Close();
            }
        }