private void BindHistory()
 {
     TicketHistory history = new TicketHistory();
     history.GetAllHistoryTicketsByTicketID(TicketID);
     uiGridViewHistory.DataSource = history.DefaultView;
     uiGridViewHistory.DataBind();
 }
        protected void uiLinkButtonReply_Click(object sender, EventArgs e)
        {
            Pricing.BLL.Tickets ticket = new Pricing.BLL.Tickets();
            ticket.LoadByPrimaryKey(TicketID);

            TicketHistory history = new TicketHistory();
            history.AddNew();
            history.TicketID = TicketID;
            history.ResponseDate = DateTime.Now;
            history.ResponseText = uiTextBoxResponse.Text;
            if (ticket.TicketStatusID == 4) // need more info
                history.TicketStatusID = 5; // need more info / complete
            //history.TicketStatusID = Convert.ToInt32(uiDropDownListStatus.SelectedValue);

            string filepath = "";
            if (uiFileUploadAttach.HasFile)
            {

                filepath = "/Attachments/TicketHistory/" + DateTime.Now.ToString("ddMMyyyyhhmmss_") + uiFileUploadAttach.FileName;
                uiFileUploadAttach.SaveAs(Server.MapPath("~" + filepath));
                history.FileAttachement = filepath;
            }
            history.Save();

            if (ticket.TicketStatusID == 4) // need more info
                ticket.TicketStatusID = 5;  // need more info / complete
            //ticket.TicketStatusID = Convert.ToInt32(uiDropDownListStatus.SelectedValue);
            ticket.Save();

            if (ticket.TicketStatusID == 4)
            {
                uiPanelResponse.Visible = true;
            }
            else
            {
                uiPanelResponse.Visible = false;
            }

            uiTextBoxResponse.Text = "";
            uiDropDownListStatus.SelectedIndex = 0;

            BindHistory();
        }
        protected void uiLinkButtonReply_Click(object sender, EventArgs e)
        {
            if (uiDropDownListStatus.SelectedItem.Text == "Closed" && uiTextBoxResponse.Text=="")
            {
                lblCloseTicketValidation.Text = "You must write a comment before close the ticket !";
                return;
            }

            // Admin only can change the status if it was closed
            Pricing.BLL.Tickets objTicket = new Pricing.BLL.Tickets();
            objTicket.LoadByPrimaryKey(TicketID);
            if (CodeGlobal.LogedInUser.s_Privaledge != "admin" && objTicket.TicketStatusID == 2)
            {
                lblCloseTicketValidation.Text = "System Admin only who can change the status now !";
                return;
            }

            TicketHistory history = new TicketHistory();
            history.AddNew();
            history.TicketID = TicketID;
            history.ResponseDate = DateTime.Now;
            history.ResponseText = uiTextBoxResponse.Text;
            history.TicketStatusID = Convert.ToInt32(uiDropDownListStatus.SelectedValue);
            string filepath = "";
            if (uiFileUploadAttach.HasFile)
            {

                filepath = "/Attachments/TicketHistory/" + DateTime.Now.ToString("ddMMyyyyhhmmss_") + uiFileUploadAttach.FileName;
                uiFileUploadAttach.SaveAs(Server.MapPath("~" + filepath));
                history.FileAttachement = filepath;
            }
            history.Save();

            Pricing.BLL.Tickets ticket = new Pricing.BLL.Tickets();
            ticket.LoadByPrimaryKey(TicketID);
            ticket.TicketStatusID = Convert.ToInt32(uiDropDownListStatus.SelectedValue);
            ticket.Save();

            if (ticket.TicketStatusID == 4)
            {
                uiPanelResponse.Visible = false;
            }
            else
            {
                uiPanelResponse.Visible = true;
            }

            uiTextBoxResponse.Text = "";
            uiDropDownListStatus.SelectedIndex = 0;

            BindHistory();
            LoadDDl();
        }