protected void Showvalues()
    {
        int incidentid = Convert.ToInt32(Session["incidentid"]);

        ObjIncident       = ObjIncident.Get_By_id(incidentid);
        ObjIncidentStates = ObjIncidentStates.Get_By_id(incidentid);
        // drpTechnician.SelectedValue = ObjIncidentStates.Technicianid.ToString();
        drpCategory.SelectedValue = ObjIncidentStates.Categoryid.ToString();
        BindDropSubCategory();
        drpSubcategory.SelectedValue = ObjIncidentStates.Subcategoryid.ToString();

        // drpPriority.SelectedValue = ObjIncidentStates.Priorityid.ToString();
        txtTitle.Text = ObjIncident.Title.ToString();
        if (ObjIncident.Description != null)
        {
            txtDescription.Text = ObjIncident.Description.ToString();
        }

        UserLogin_mst   objUsr  = new UserLogin_mst();
        ContactInfo_mst objInfo = new ContactInfo_mst();

        objInfo                 = objInfo.Get_By_id(ObjIncident.Requesterid);
        objUsr                  = objUsr.Get_By_id(ObjIncident.Requesterid);
        txtUsername.Text        = objUsr.Username;
        txtEmail.Text           = objInfo.Emailid;
        ViewState["UserCreate"] = "Exist";
    }
示例#2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string strStatusClose = Resources.MessageResource.strStatusClose.ToString().Trim();
        string statusString   = "";
        int    incidentid     = Convert.ToInt16(Request.QueryString[0]);

        Objincident          = Objincident.Get_By_id(incidentid);
        Objincidentstate     = Objincidentstate.Get_By_id(incidentid);
        Objincidentresoution = Objincidentresoution.Get_By_id(incidentid);
        objstatus            = objstatus.Get_By_id(Objincidentstate.Statusid);
        statusString         = objstatus.Statusname.ToString();
        if (statusString.ToLower() == strStatusClose.ToLower())
        {
            lbltcktno.Text     = Objincident.Incidentid.ToString();
            lblcreatedate.Text = Objincident.Createdatetime.ToString();

            if (Objincidentstate.AssignedTime != null)
            {
                lblstarttime.Text = Objincidentstate.AssignedTime.ToString();
            }
            lblendtime.Text = Objincident.Completedtime.ToString();
            Objcategory     = Objcategory.Get_By_id(Objincidentstate.Categoryid);

            lblcomponenteffected.Text = Objcategory.CategoryName.ToString();
            lbldescription.Text       = Objincident.Title.ToString();
            string bb       = Objincidentresoution.Resolution.ToString();
            string stripped = Regex.Replace(bb, @"<(.|\n)*?>", string.Empty);
            lblresolution.Text = stripped.ToString();
            //bind data to data bound controls and do other stuff
            objUser           = objUser.Get_By_id(Objincident.Requesterid);
            lblcustomer.Text  = objUser.Username.ToString();
            objUser           = objUser.Get_By_id(Objincidentstate.Technicianid);
            lblengineer.Text  = objUser.Username.ToString();
            objstatus         = objstatus.Get_By_id(Objincidentstate.Statusid);
            lblrcaresult.Text = objstatus.Statusname.ToString();
        }
        Response.Clear();       //this clears the Response of any headers or previous output
        Response.Buffer = true; //make sure that the entire output is rendered simultaneously

        ///
        ///Set content type to MS Excel sheet
        ///Use "application/msword" for MS Word doc files
        ///"application/pdf" for PDF files
        ///

        Response.ContentType = "application/vnd.ms-excel";
        StringWriter stringWriter = new StringWriter(); //System.IO namespace should be used

        HtmlTextWriter htmlTextWriter = new HtmlTextWriter(stringWriter);

        ///
        ///Render the entire Page control in the HtmlTextWriter object
        ///We can render individual controls also, like a DataGrid to be
        ///exported in custom format (excel, word etc)
        ///
        this.RenderControl(htmlTextWriter);
        Response.Write(stringWriter.ToString());
        Response.End();
    }
示例#3
0
    protected void BindIncidentToProblem()
    {
        if (Session["IncidentToProblem"] != null)
        {
            int incidentid = Convert.ToInt32(Session["IncidentToProblem"].ToString());

            Incident_mst   objIncident       = new Incident_mst();
            IncidentStates objIncidentStates = new IncidentStates();
            objIncident       = objIncident.Get_By_id(incidentid);
            objIncidentStates = objIncidentStates.Get_By_id(incidentid);
            objuser           = objuser.Get_By_id(objIncident.Requesterid);
            if (objIncidentStates.Priorityid != 0)
            {
                drpPriority.SelectedValue = Convert.ToString(objIncidentStates.Priorityid);
            }
            if (objIncidentStates.Categoryid != 0)
            {
                drpCategory.SelectedValue = Convert.ToString(objIncidentStates.Categoryid);
                BindDropSubCategory();
            }


            if (objIncidentStates.Subcategoryid != 0)
            {
                drpSubcategory.SelectedValue = Convert.ToString(objIncidentStates.Subcategoryid);
            }
            if (objIncidentStates.Technicianid != 0)
            {
                drpTechnician.SelectedValue = Convert.ToString(objIncidentStates.Technicianid);
            }
            txtDescription.Text = objIncident.Description;
            txtTitle.Text       = objIncident.Title;
            if (objuser.Userid != 0)
            {
                ContactInfo_mst objInfo = new ContactInfo_mst();
                objInfo                 = objInfo.Get_By_id(objuser.Userid);
                txtUsername.Text        = objuser.Username;
                txtEmail.Text           = objInfo.Emailid;
                ViewState["UserCreate"] = "Exist";
            }
        }
    }
    protected void BindIncidentToProblem()
    {
        if (Session["IncidentToProblem"] != null)
        {
            int incidentid = Convert.ToInt16(Session["IncidentToProblem"].ToString());

            Incident_mst objIncident = new Incident_mst();
            IncidentStates objIncidentStates = new IncidentStates();
            objIncident = objIncident.Get_By_id(incidentid);
            objIncidentStates = objIncidentStates.Get_By_id(incidentid);
            objuser = objuser.Get_By_id(objIncident.Requesterid);
            if (objIncidentStates.Priorityid != 0)
            {
                drpPriority.SelectedValue = Convert.ToString(objIncidentStates.Priorityid);

            }
            if (objIncidentStates.Categoryid != 0)
            {
                drpCategory.SelectedValue = Convert.ToString(objIncidentStates.Categoryid);
                BindDropSubCategory();

            }

            if (objIncidentStates.Subcategoryid  != 0)
            {

                drpSubcategory.SelectedValue = Convert.ToString(objIncidentStates.Subcategoryid);
            }
            if (objIncidentStates.Technicianid  != 0)
            {
                drpTechnician.SelectedValue = Convert.ToString(objIncidentStates.Technicianid);

            }
            txtDescription.Text = objIncident.Description;
            txtTitle.Text  = objIncident.Title;
            if (objuser.Userid != 0)
            {
                ContactInfo_mst objInfo = new ContactInfo_mst();
                objInfo = objInfo.Get_By_id(objuser.Userid);
                txtUsername.Text = objuser.Username;
                txtEmail.Text = objInfo.Emailid;
                ViewState["UserCreate"] = "Exist";
            }

        }
    }
    protected void grdvwRequest_RowDataBound(Object sender, GridViewRowEventArgs e)
    {
        /////Add Exception handilng try catch change by vishal 21-05-2012
        try
        {
            System.Drawing.ColorConverter colConvert = new ColorConverter();
            BLLCollection<ColorScheme_mst> colColor = new BLLCollection<ColorScheme_mst>();
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                #region Autogenerate Serial number
                Label lblSerial = (Label)e.Row.FindControl("lblSerial");
                lblSerial.Text = i.ToString();
                i++;
                #endregion

                int TotalTimeSpentonCall;
                int TotalResolutionTime;

                int varIncidentid = Convert.ToInt32(((Label)e.Row.FindControl("incidentid")).Text.ToString());
                string varCreateDatetime = e.Row.Cells[9].Text;
                string varStatusOpen = Resources.MessageResource.strStatusOpen.ToString();
                string varStatusClose = Resources.MessageResource.strStatusClose.ToString();
                string varStatusOnHold = Resources.MessageResource.strStatusOnHold.ToString();

                string varStatusResolved = Resources.MessageResource.strStatusResolved.ToString();

                #region Bind Data Row at Run time with requesterid to Requester name
                int requesterid = Convert.ToInt32(e.Row.Cells[3].Text);
                //objUser = objUser.Get_By_id(requesterid);
                objContactmst = objContactmst.Get_By_id(requesterid);
                //if (objUser.Userid != 0)
                //{
                //    e.Row.Cells[3].Text = objUser.Username.ToString();
                //    //e.Row.Cells[3].Text = objContactmst.Firstname.ToString();
                //}
                //else { e.Row.Cells[3].Text = ""; }
                //if (objUser.Userid != 0)
                //{
                //e.Row.Cells[3].Text = objUser.Username.ToString();
                if (objContactmst.Firstname != null)
                {
                    e.Row.Cells[3].Text = objContactmst.Firstname.ToString();
                }
                // }else { e.Row.Cells[3].Text = ""; }
                #endregion

                #region Bind Datarow at Run Time with Createdbyid to Created by name
                int createdbyid = Convert.ToInt32(e.Row.Cells[4].Text);
                objUser = objUser.Get_By_id(createdbyid);
                if (objUser.Userid != 0)
                {
                    e.Row.Cells[4].Text = objUser.Username.ToString();
                }
                else { e.Row.Cells[4].Text = ""; }
                #endregion

                #region Bind Datarow at Run Time with technicianid to technician name
                int technicianid = Convert.ToInt32(e.Row.Cells[5].Text);
                objUser = objUser.Get_By_id(technicianid);
                if (objUser.Userid != 0)
                {
                    e.Row.Cells[5].Text = objUser.Username.ToString();
                }
                else { e.Row.Cells[5].Text = ""; }
                #endregion

                #region Bind Datarow at run time with Statusid to Status
                int statusid = Convert.ToInt32(e.Row.Cells[6].Text);
                objStatus = objStatus.Get_By_id(statusid);
                if (objStatus.Statusid != 0)
                {

                    e.Row.Cells[6].Text = objStatus.Statusname.ToString();

                }
                else { e.Row.Cells[6].Text = ""; }
                #endregion

                #region Bind Datarow at run time with Priorityid to Priority
                int priorityid = Convert.ToInt32(e.Row.Cells[7].Text);
                objPriority = objPriority.Get_By_id(priorityid);
                if (objPriority.Priorityid != 0)
                { e.Row.Cells[7].Text = objPriority.Name.ToString(); }
                else { e.Row.Cells[7].Text = ""; }
                #endregion

                #region Bind Datarow at run time with Siteid to Site
                int siteid = Convert.ToInt32(e.Row.Cells[8].Text);
                objSite = objSite.Get_By_id(siteid);
                if (objSite.Siteid != 0)
                {
                    string custSiteName;
                    int custid = 0;
                    colCustToSite = objCustToSite.Get_All_By_siteid(objSite.Siteid);
                    foreach (CustomerToSiteMapping objCuToSite in colCustToSite)
                    {
                        custid = objCuToSite.Custid;

                    }
                    objCustomer = objCustomer.Get_By_id(custid);

                    e.Row.Cells[8].Text = objCustomer.Customer_name + "/" + objSite.Sitename.ToString();

                }
                else { e.Row.Cells[8].Text = ""; }
                #endregion

                #region Apply Color Coding to Open Calls,According to define SLA
                if (varStatusOpen.ToLower() == objStatus.Statusname.ToString().ToLower())
                {

                    Incident_mst obj = new Incident_mst();
                    obj = obj.Get_By_id(varIncidentid);
                    if (obj.Incidentid != 0)
                    {
                        if (obj.Slaid != 0)
                        {
                            #region Declare local variables,and objects of various classes
                            int percent;

                            ProcessEscalateEmail objPro = new ProcessEscalateEmail();
                            #endregion
                            #region Get Total Resolution time define for particular SLA and Time Spent on Request
                            TotalResolutionTime = objPro.GetResolutionTimeInMins(obj.Slaid);
                            TotalTimeSpentonCall = objIncident.Get_TimeSpentonRequest(varIncidentid, siteid, varCreateDatetime, DateTime.Now.ToString());
                            if (TotalTimeSpentonCall < 0)
                            {
                                TotalTimeSpentonCall = 0;
                            }
                            #endregion
                            #region Calculate Percent
                            if (TotalResolutionTime != 0)
                            {
                                percent = (TotalTimeSpentonCall * 100) / TotalResolutionTime;
                            }
                            else
                            {
                                percent = 0;
                            }

                            #endregion

                            ColorScheme_mst objColor = new ColorScheme_mst();
                            colColor = objColor.Get_All_By_CallStatus(varStatusOpen);

                            foreach (ColorScheme_mst objCol in colColor)
                            {
                                if (objCol.Percnt_to != 0)
                                {
                                    if (percent >= objCol.Percnt && percent <= objCol.Percnt_to)
                                    {
                                        e.Row.BackColor = (System.Drawing.Color)colConvert.ConvertFromString(objCol.Colorname);
                                    }
                                }
                                else
                                {
                                    if (percent >= objCol.Percnt)
                                    {
                                        e.Row.BackColor = (System.Drawing.Color)colConvert.ConvertFromString(objCol.Colorname);
                                    }

                                }

                            }

                        }
                        else
                        {
                            ColorScheme_mst objColor = new ColorScheme_mst();
                            colColor = objColor.Get_All_By_CallStatus("NonSLA");

                            foreach (ColorScheme_mst objCol in colColor)
                            {

                                e.Row.BackColor = (System.Drawing.Color)colConvert.ConvertFromString(objCol.Colorname);
                            }

                        }
                    }

                }
                #endregion

                #region Apply Color Coding to Close Calls
                if (varStatusClose.ToLower() == objStatus.Statusname.ToString().ToLower())
                {
                    ColorScheme_mst objColor = new ColorScheme_mst();
                    colColor = objColor.Get_All_By_CallStatus(varStatusClose);
                    foreach (ColorScheme_mst obj in colColor)
                    {
                        try { e.Row.BackColor = (System.Drawing.Color)colConvert.ConvertFromString(obj.Colorname); }
                        catch (Exception ex)
                        { e.Row.BackColor = (System.Drawing.Color)colConvert.ConvertFromString("White"); }

                    }

                }
                #endregion

                #region Apply Color Coding to On Hold Calls
                if (varStatusOnHold.ToLower() == objStatus.Statusname.ToString().ToLower())
                {
                    ColorScheme_mst objColor = new ColorScheme_mst();
                    colColor = objColor.Get_All_By_CallStatus(varStatusOnHold);
                    foreach (ColorScheme_mst obj in colColor)
                    {
                        e.Row.BackColor = (System.Drawing.Color)colConvert.ConvertFromString(obj.Colorname);

                    }

                }
                #endregion

                #region Apply Color Coding to Resolved Calls
                if (varStatusResolved.ToLower() == objStatus.Statusname.ToString().ToLower())
                {
                    ColorScheme_mst objColor = new ColorScheme_mst();
                    colColor = objColor.Get_All_By_CallStatus(varStatusResolved);
                    foreach (ColorScheme_mst obj in colColor)
                    {
                        e.Row.BackColor = (System.Drawing.Color)colConvert.ConvertFromString(obj.Colorname);

                    }

                }
                #endregion

            }
        }
        catch (Exception ex)
        {
            string myScript;
            myScript = "<script language=javascript>alert('Exception - '" + ex + "');</script>";
            Page.RegisterClientScriptBlock("MyScript", myScript);
            return;
        }
    }
示例#6
0
    protected void grdvwRequest_RowDataBound(Object sender, GridViewRowEventArgs e)
    {
        System.Drawing.ColorConverter   colConvert = new ColorConverter();
        BLLCollection <ColorScheme_mst> colColor   = new BLLCollection <ColorScheme_mst>();

        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            #region Autogenerate Serial number
            Label lblSerial = (Label)e.Row.FindControl("lblSerial");
            lblSerial.Text = i.ToString();
            i++;
            #endregion

            int TotalTimeSpentonCall;
            int TotalResolutionTime;


            int    varIncidentid     = Convert.ToInt16(((Label)e.Row.FindControl("incidentid")).Text.ToString());
            string varCreateDatetime = e.Row.Cells[9].Text;
            string varStatusOpen     = Resources.MessageResource.strStatusOpen.ToString();
            string varStatusClose    = Resources.MessageResource.strStatusClose.ToString();
            string varStatusOnHold   = Resources.MessageResource.strStatusOnHold.ToString();
            string varStatusResolved = Resources.MessageResource.strStatusResolved.ToString();

            #region Bind Data Row at Run time with requesterid to Requester name
            int requesterid = Convert.ToInt16(e.Row.Cells[3].Text);
            objUser = objUser.Get_By_id(requesterid);

            if (objUser.Userid != 0)
            {
                e.Row.Cells[3].Text = objUser.Username.ToString();
            }
            else
            {
                e.Row.Cells[3].Text = "";
            }
            #endregion

            #region Bind Datarow at Run Time with Createdbyid to Created by name
            int createdbyid = Convert.ToInt16(e.Row.Cells[4].Text);
            objUser = objUser.Get_By_id(createdbyid);
            if (objUser.Userid != 0)
            {
                e.Row.Cells[4].Text = objUser.Username.ToString();
            }
            else
            {
                e.Row.Cells[4].Text = "";
            }
            #endregion

            #region Bind Datarow at Run Time with technicianid to technician name
            int technicianid = Convert.ToInt16(e.Row.Cells[5].Text);
            objUser = objUser.Get_By_id(technicianid);
            if (objUser.Userid != 0)
            {
                e.Row.Cells[5].Text = objUser.Username.ToString();
            }
            else
            {
                e.Row.Cells[5].Text = "";
            }
            #endregion

            #region Bind Datarow at run time with Statusid to Status
            int statusid = Convert.ToInt16(e.Row.Cells[6].Text);
            objStatus = objStatus.Get_By_id(statusid);
            if (objStatus.Statusid != 0)
            {
                e.Row.Cells[6].Text = objStatus.Statusname.ToString();
            }
            else
            {
                e.Row.Cells[6].Text = "";
            }
            #endregion

            #region Bind Datarow at run time with Priorityid to Priority
            int priorityid = Convert.ToInt16(e.Row.Cells[7].Text);
            objPriority = objPriority.Get_By_id(priorityid);
            if (objPriority.Priorityid != 0)
            {
                e.Row.Cells[7].Text = objPriority.Name.ToString();
            }
            else
            {
                e.Row.Cells[7].Text = "";
            }
            #endregion


            #region Bind Datarow at run time with Siteid to Site
            int siteid = Convert.ToInt16(e.Row.Cells[8].Text);
            objSite = objSite.Get_By_id(siteid);
            if (objSite.Siteid != 0)
            {
                string custSiteName;
                int    custid = 0;
                colCustToSite = objCustToSite.Get_All_By_siteid(objSite.Siteid);
                foreach (CustomerToSiteMapping objCuToSite in colCustToSite)
                {
                    custid = objCuToSite.Custid;
                }
                objCustomer = objCustomer.Get_By_id(custid);

                e.Row.Cells[8].Text = objCustomer.Customer_name + "/" + objSite.Sitename.ToString();
            }
            else
            {
                e.Row.Cells[8].Text = "";
            }
            #endregion

            #region Apply Color Coding to Open Calls,According to define SLA
            if (varStatusOpen.ToLower() == objStatus.Statusname.ToString().ToLower())
            {
                Incident_mst obj = new Incident_mst();
                obj = obj.Get_By_id(varIncidentid);
                if (obj.Incidentid != 0)
                {
                    if (obj.Slaid != 0)
                    {
                        #region Declare local variables,and objects of various classes
                        int percent;

                        ProcessEscalateEmail objPro = new ProcessEscalateEmail();
                        #endregion
                        #region Get Total Resolution time define for particular SLA and Time Spent on Request
                        TotalResolutionTime  = objPro.GetResolutionTimeInMins(obj.Slaid);
                        TotalTimeSpentonCall = objIncident.Get_TimeSpentonRequest(varIncidentid, siteid, varCreateDatetime, DateTime.Now.ToString());
                        if (TotalTimeSpentonCall < 0)
                        {
                            TotalTimeSpentonCall = 0;
                        }
                        #endregion
                        #region Calculate Percent
                        percent = (TotalTimeSpentonCall * 100) / TotalResolutionTime;

                        #endregion

                        ColorScheme_mst objColor = new ColorScheme_mst();
                        colColor = objColor.Get_All_By_CallStatus(varStatusOpen);


                        foreach (ColorScheme_mst objCol in colColor)
                        {
                            if (objCol.Percnt_to != 0)
                            {
                                if (percent >= objCol.Percnt && percent <= objCol.Percnt_to)
                                {
                                    e.Row.BackColor = (System.Drawing.Color)colConvert.ConvertFromString(objCol.Colorname);
                                }
                            }
                            else
                            {
                                if (percent >= objCol.Percnt)
                                {
                                    e.Row.BackColor = (System.Drawing.Color)colConvert.ConvertFromString(objCol.Colorname);
                                }
                            }
                        }
                    }
                    else
                    {
                        ColorScheme_mst objColor = new ColorScheme_mst();
                        colColor = objColor.Get_All_By_CallStatus("NonSLA");


                        foreach (ColorScheme_mst objCol in colColor)
                        {
                            e.Row.BackColor = (System.Drawing.Color)colConvert.ConvertFromString(objCol.Colorname);
                        }
                    }
                }
            }
            #endregion

            #region Apply Color Coding to Close Calls
            if (varStatusClose.ToLower() == objStatus.Statusname.ToString().ToLower())
            {
                ColorScheme_mst objColor = new ColorScheme_mst();
                colColor = objColor.Get_All_By_CallStatus(varStatusClose);
                foreach (ColorScheme_mst obj in colColor)
                {
                    try { e.Row.BackColor = (System.Drawing.Color)colConvert.ConvertFromString(obj.Colorname); }
                    catch (Exception ex)
                    { e.Row.BackColor = (System.Drawing.Color)colConvert.ConvertFromString("White"); }
                }
            }
            #endregion

            #region Apply Color Coding to On Hold Calls
            if (varStatusOnHold.ToLower() == objStatus.Statusname.ToString().ToLower())
            {
                ColorScheme_mst objColor = new ColorScheme_mst();
                colColor = objColor.Get_All_By_CallStatus(varStatusOnHold);
                foreach (ColorScheme_mst obj in colColor)
                {
                    e.Row.BackColor = (System.Drawing.Color)colConvert.ConvertFromString(obj.Colorname);
                }
            }
            #endregion

            #region Apply Color Coding to Resolved Calls
            if (varStatusResolved.ToLower() == objStatus.Statusname.ToString().ToLower())
            {
                ColorScheme_mst objColor = new ColorScheme_mst();
                colColor = objColor.Get_All_By_CallStatus(varStatusResolved);
                foreach (ColorScheme_mst obj in colColor)
                {
                    e.Row.BackColor = (System.Drawing.Color)colConvert.ConvertFromString(obj.Colorname);
                }
            }
            #endregion
        }
    }
示例#7
0
    public void SentmailUser(int userid, int incidentid, string status)
    {
        objIncident = objIncident.Get_By_id(incidentid);
        //added by lalit 02 nov to get resolution and show it to user when call closed mail goes to user
        objIncidentResolution = objIncidentResolution.Get_By_id(incidentid);
        //end
        objSite           = objSite.Get_By_id(objIncident.Siteid);
        objAreaManager    = objAreaManager.Get_By_id(objSite.Siteid);
        objIncidentStates = objIncidentStates.Get_By_id(incidentid);
        objPriority       = objPriority.Get_By_id(objIncidentStates.Priorityid);
        objUser           = objUser.Get_By_id(objIncident.Requesterid);
        objC_info         = objC_info.Get_By_id(userid);
        objtech           = objtech.Get_By_id(objIncidentStates.Technicianid);
        colemailid        = objemail.Get_All_userid(userid);
        string strStatusOpen     = Resources.MessageResource.strStatusOpen.ToString();
        string strStatusClose    = Resources.MessageResource.strStatusClose.ToString();
        string strYourSinscerely = Resources.MessageResource.strYourSinscerely.ToString();
        string strContactNumber  = Resources.MessageResource.strContactNumber.ToString();

        if (strStatusOpen.ToLower() == status.ToLower())
        {
            foreach (UserEmail obj1 in colemailid)
            {
                if (obj1.Emailid != null)
                {
                    obj.From    = Resources.MessageResource.strAdminEmail.ToString();
                    obj.To      = obj1.Emailid;
                    obj.CC      = objAreaManager.Email;
                    obj.Subject = "Call Logged. Ticket Id : " + incidentid;
                    obj.Body    = "Dear " + objC_info.Firstname + ",<br/><br/> Thank you for contacting IT Service desk, please find below the new Ticket Id details for your future reference.<br/><br/><b>Incident Details : </b> <br/><br/><b>Ticket Id&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:</b> "
                                  + incidentid + "<br/><b>Site&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:</b> "
                                  + objSite.Sitename + "<br/><b>Logged Date & Time&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:</b> "
                                  + objIncident.Createdatetime + "<br/><b>Description&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:</b> "
                                  + objIncident.Description + "<br/><b>Priority&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:</b> "
                                  + objPriority.Name + "<br/><b>Username&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:</b> "
                                  + objUser.Username + "<br/><b>EstimatedResolutionTime&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:</b> "
                                  + GetResolutionTimeInHours(objIncident.Slaid)
                                  + "<br/><b>Email Address&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:</b> "

                                  + objC_info.Emailid + "<br/><br/> For any other support, kindly get in touch with us at " + strContactNumber + ".<br/><br/> <b>This is an auto generated mail. Please do not reply.</b><br/><br/><b>Yours sincerely,</b><br/><br/> <b> " + strYourSinscerely + "</b>";
                    obj.SmtpServer = Resources.MessageResource.strSMTPServer.ToString();
                    obj.SentMail();
                    string varPriority = Resources.MessageResource.strPriorityHigh.ToString();
                    if (objPriority.Priorityid != 0)
                    {
                        if (objPriority.Name.ToLower() == varPriority.ToLower())
                        {
                            SentMailToSDM(objSite.Siteid, incidentid, objUser.Userid);
                        }
                    }
                }
            }
            //if (objC_info.Emailid != null)
            //{
            //    obj.From = Resources.MessageResource.strAdminEmail.ToString();
            //    obj.To = objC_info.Emailid;
            //    obj.Subject = " New Call Logged. Ticket Id : " + incidentid;
            //    obj.Body = "Dear User,<br/> Thank you for contacting Service desk, please find below the Ticket Id details for your future reference.<br/><br/><b>Complaints Details : </b> <br/><br/><b>Ticket Id&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:</b>" + incidentid + "<br/><b>Title of Call&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:</b>" + objIncident.Title + " <br/><b>Site&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:</b>" + objSite.Sitename + "<br/><b>Logged Date & Time&nbsp;&nbsp&nbsp;&nbsp;&nbsp;:</b>" + objIncident.Createdatetime + "<br/><b>Description&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:</b>" + objIncident.Description + "<br/><b>Priority&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:</b> " + objPriority.Name + "<br/><b>UserName&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:</b>" + objUser.Username + "<br/><b>Mail Address&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:</b>" + objC_info.Emailid + "<br/><br/> For any other support kindly get in touch with us at <b>" + strContactNumber + "</b>.<br/><br/> <b>This is an auto generated mail. Please do not reply.</b><br/><br/><b>Yours sincerely,</b><br/> <b>" + strYourSinscerely + "</b>";
            //    obj.SmtpServer = Resources.MessageResource.strSMTPServer.ToString();
            //   //obj.SentMail();
            //    string varPriority = Resources.MessageResource.strPriorityHigh.ToString();
            //    if (objPriority.Priorityid != 0)
            //    {
            //        if (objPriority.Name.ToLower() == varPriority.ToLower())
            //        {
            //            SentMailToSDM(objSite.Siteid, incidentid, objUser.Userid);
            //        }
            //    }
            //}
        }
        if (strStatusClose.ToLower() == status.ToLower())
        {
            foreach (UserEmail obj1 in colemailid)
            {
                if (obj1.Emailid != null)
                {
                    int    id = Convert.ToInt16(objIncident.Incidentid);
                    string varServerName1;
                    string varfeedbackmode;
                    varServerName1 = Resources.MessageResource.serverNameForChangePage.ToString();
                    //added by lalit to check feedback mode. feedback should add in mail or not.
                    //fetching value from resouce file which is from appsettting page.
                    varfeedbackmode = Resources.MessageResource.UserFeedbackmode.ToString();
                    string url11;
                    url11 = "http://" + varServerName1 + "/" + getpath() + "/LoginPageAccess/CustomerFeedback.aspx?userid=" + userid + "&Clid=" + objIncident.Incidentid;
                    //url11 = "../LoginPageAccess/CustomerFeedback.aspx?userid=" + userid + "&Clid=" + objIncident.Incidentid;
                    if (objC_info.Emailid != null)
                    {
                        // string url;
                        //    url = "<a  href=" + url11 + "&userid=" + objC_info.Firstname + " ' onclick=window.open()>Your Feedback</a>";
                        string url = "<a  href=" + url11 + " ' onclick=window.open()>Your Feedback</a>";
                        obj.From    = Resources.MessageResource.strAdminEmail.ToString();
                        obj.To      = obj1.Emailid;
                        obj.CC      = objAreaManager.Email;
                        obj.Subject = "Call Closed Ticket id : " + incidentid;
                        //added by lalit
                        if (varfeedbackmode == "0") //0 means default mode where user will not recieve link in mail to give feedback
                        {
                            obj.Body = "Dear " + objC_info.Firstname
                                       + ",<br/><br/> <b>Incident Status:</b> Issue Resolved and call closed by&nbsp;<b>"
                                       + objtech.Username + "</b>&nbsp;on&nbsp;<b>"
                                       + objIncident.Completedtime + ".<br/><br/></b>We are pleased to confirm that the Service Call reported by you has been attended and resolved, should there be any further questions or queries, please do not hesitate to contact the Service Desk." + "<br/><br/><b>Incident Details : </b> <br/><br/><b>Ticket Id&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:</b> "
                                       + incidentid + "<br/><b>Site&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:</b> "
                                       + objSite.Sitename + "<br/><b>Logged Date & Time&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;:</b> "
                                       + objIncident.Createdatetime + "<br/><b>Closed Date & Time&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:</b> "
                                       + objIncident.Completedtime + "<br/><b>Description&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:</b> "
                                       + objIncident.Description + "<br/><b>Resolution&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:</b> "
                                       + objIncidentResolution.Resolution + "<br/><b>Priority&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:</b> "
                                       + objPriority.Name + "<br/><b>Username&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:</b> "
                                       + objUser.Username + "<br/><b>Email Address&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:</b> "
                                       + objC_info.Emailid + "<br/><br/> For any other support, kindly get in touch with us at "
                                       + strContactNumber + ".<br/><br/> <b>This is an auto generated mail. Please do not reply.</b><br/><br/><b>Yours sincerely,</b><br/><br/> <b>"
                                       + strYourSinscerely + "</b>";
                        }
                        else
                        {
                            obj.Body = "Dear " + objC_info.Firstname
                                       + ",<br/><br/> <b>Incident Status:</b> Issue Resolved and call closed by&nbsp;<b>"
                                       + objtech.Username + "</b>&nbsp;on&nbsp;<b>"
                                       + objIncident.Completedtime + ".<br/><br/></b>We are pleased to confirm that the Service Call reported by you has been attended and resolved, should there be any further questions or queries, please do not hesitate to contact the Service Desk." + "<br/><br/><b>Incident Details : </b> <br/><br/><b>Ticket Id&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:</b> "
                                       + incidentid + "<br/><b>Site&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:</b> "
                                       + objSite.Sitename + "<br/><b>Logged Date & Time&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;:</b> "
                                       + objIncident.Createdatetime + "<br/><b>Closed Date & Time&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:</b> "
                                       + objIncident.Completedtime + "<br/><b>Description&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:</b> "
                                       + objIncident.Description + "<br/><b>Resolution&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:</b> "
                                       + objIncidentResolution.Resolution + "<br/><b>Priority&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:</b> "
                                       + objPriority.Name + "<br/><b>Username&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:</b> "
                                       + objUser.Username + "<br/><b>Email Address&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:</b> "
                                       + objC_info.Emailid + "<br/><br/> For any other support, kindly get in touch with us at "
                                       + strContactNumber + ".<br/><br/>To give feedback click on "
                                       + url + ".<br/><br/> <b>This is an auto generated mail. Please do not reply.</b><br/><br/><b>Yours sincerely,</b><br/><br/> <b>"
                                       + strYourSinscerely + "</b>";
                        }
                        obj.SmtpServer = Resources.MessageResource.strSMTPServer.ToString();
                        obj.SentMail();
                    }
                }
            }
            //int id = Convert.ToInt16(objIncident.Incidentid);
            //string varServerName1;
            //varServerName1 = Resources.MessageResource.serverNameForChangePage.ToString();
            //// varServerName = "10.80.0.15";
            //string url11;
            //url11 = "http://" + varServerName1 + "/BESTN/LoginPageAccess/CustomerFeedback.aspx?incident=" + id;
            //if (objC_info.Emailid != null)
            //{
            //    string url;
            //    url = "<a  href=" + url11 + "&userid=" + objC_info.Firstname + " ' onclick=window.open()>Your Feedback</a>";
            //    obj.From = Resources.MessageResource.strAdminEmail.ToString();
            //    obj.To = objC_info.Emailid;
            //    obj.Subject = "Call Closed Ticket id : " + incidentid;
            //    obj.Body = "Dear User,<br/> <b>Complaint Status:</b>Problem solved and call closed by&nbsp;<b>" + objtech.Username + "</b>&nbsp;on&nbsp;<b>" + objIncident.Completedtime + "</b>.We are pleased to inform you that your reported Service Call has been attended and problem solved as informed by our engineer.<br/>Should there be any further questions or queries, please do not hesitate to contact the Service Desk on 0120 4393941, quoting your Ticket Reference Number.   " + "<br/><br/><b>Complaints Details : </b> <br/><br/><b>Ticket Id&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:</b>" + incidentid + "<br/><b>Title of Call&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:</b>" + objIncident.Title + " <br/><b>Site&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:</b>" + objSite.Sitename + "</br><b>Logged Date & Time&nbsp;&nbsp&nbsp;&nbsp;&nbsp;:</b>" + objIncident.Createdatetime + "<br/><b>Description&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:</b>" + objIncident.Description + "<br/><b>Priority&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:</b> " + objPriority.Name + "<br/><b>UserName&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:</b>" + objUser.Username + "<br/><b>Mail Address&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:</b>" + objC_info.Emailid + "<br/><br/> For any other support kindly get in touch with us at <b>" + strContactNumber + "</b>.<br/><br/> <b>This is an auto generated mail. Please do not reply.</b><br/><br/><b>Your Feedback</b><br/><br/>" + url + "<br/><br/><b>Yours sincerely,</b><br/> <b>" + strYourSinscerely + "</b>";
            //    obj.SmtpServer = obj.SmtpServer = Resources.MessageResource.strSMTPServer.ToString();
            //   // obj.SentMail();
            //}
        }
    }
    protected void SendEmail(int incidentid, int level, int slaid)
    {
        SentEmail objEmail = new SentEmail();

        #region Sent Mail for Level 1 Escalation
        if (level == 1)
        {
            objLevel1 = objLevel1.Get_By_Slaid(slaid);
            if (objLevel1 != null)
            {
                string   varemail    = objLevel1.Emailid;
                string[] arrEmail    = varemail.Split(',');
                int      lengthCount = Convert.ToInt32(arrEmail.Length.ToString());
                for (int i = 0; i < lengthCount - 1; i++)
                {
                    string emailId = arrEmail[i].ToString();
                    if (emailId != "," && emailId != "")
                    {
                        objIncident = objIncident.Get_By_id(incidentid);
                        if (objIncident != null)
                        {
                            objCheckLevel1 = objCheckLevel1.Get_By_id(incidentid);
                            if (objCheckLevel1.Incidentid == 0)
                            {
                                CheckLevel1Escalate obj = new CheckLevel1Escalate();
                                obj.Incidentid     = incidentid;
                                obj.Level1escalate = true;
                                obj.Insert();
                                objEmail.To         = emailId;
                                objEmail.From       = Resources.MessageResource.strEmailFromLevel1Escalate.ToString();
                                objEmail.Subject    = "Problem Not Resolve for Call -" + objIncident.Title;
                                objEmail.Body       = "Dear Sir, The Current Request is not Solved whose Incident Id is " + objIncident.Incidentid + " and Title of Call is " + objIncident.Title + " Thanks & Regards Admin";
                                objEmail.SmtpServer = Resources.MessageResource.strMailServer.ToString();
                                objEmail.SentMail();
                            }
                        }
                    }
                }
            }
        }
        #endregion
        #region Sent Mail for Level 2 Escalation
        if (level == 2)
        {
            objLevel2 = objLevel2.Get_By_Slaid(slaid);
            if (objLevel2.Slaid != 0)
            {
                string   varemail    = objLevel2.Emailid;
                string[] arrEmail    = varemail.Split(',');
                int      lengthCount = Convert.ToInt32(arrEmail.Length.ToString());
                for (int i = 0; i < lengthCount - 1; i++)
                {
                    string emailId = arrEmail[i].ToString();
                    if (emailId != "," && emailId != "")
                    {
                        objIncident = objIncident.Get_By_id(incidentid);
                        if (objIncident != null)
                        {
                            objCheckLevel2 = objCheckLevel2.Get_By_id(incidentid);
                            if (objCheckLevel2.Incidentid == 0)
                            {
                                CheckLevel2Escalate obj = new CheckLevel2Escalate();
                                obj.Incidentid     = incidentid;
                                obj.Level2escalate = true;
                                obj.Insert();
                                objEmail.To         = emailId;
                                objEmail.From       = Resources.MessageResource.strEmailFromLevel2Escalate.ToString();
                                objEmail.Subject    = "Problem Not Resolve for Call -" + objIncident.Title;
                                objEmail.Body       = "Dear Sir, The Current Request is not Solved whose Incident Id is " + objIncident.Incidentid + " and Title of Call is " + objIncident.Title + " Thanks & Regards <br/> Admin";
                                objEmail.SmtpServer = Resources.MessageResource.strMailServer.ToString();
                                objEmail.SentMail();
                            }
                        }
                    }
                }
            }
        }
        #endregion
        #region Sent Mail for Level 3 Escalation
        if (level == 3)
        {
            objLevel3 = objLevel3.Get_By_Slaid(slaid);
            if (objLevel3.Slaid != 0)
            {
                string   varemail    = objLevel3.Emailid;
                string[] arrEmail    = varemail.Split(',');
                int      lengthCount = Convert.ToInt32(arrEmail.Length.ToString());
                for (int i = 0; i < lengthCount - 1; i++)
                {
                    string emailId = arrEmail[i].ToString();
                    if (emailId != "," && emailId != "")
                    {
                        objIncident = objIncident.Get_By_id(incidentid);
                        if (objIncident != null)
                        {
                            objCheckLevel3 = objCheckLevel3.Get_By_id(incidentid);
                            if (objCheckLevel3.Incidentid == 0)
                            {
                                CheckLevel3Escalate obj = new CheckLevel3Escalate();
                                obj.Incidentid     = incidentid;
                                obj.Level3escalate = true;
                                obj.Insert();

                                objEmail.To         = emailId;
                                objEmail.From       = Resources.MessageResource.strEmailFromLevel3Escalate.ToString();
                                objEmail.Subject    = "Problem Not Resolve for Call -" + objIncident.Title;
                                objEmail.Body       = "Dear Sir, The Current Request is not Solved whose Incident Id is " + objIncident.Incidentid + " and Title of Call is " + objIncident.Title + "  Thanks & Regards  Admin";
                                objEmail.SmtpServer = Resources.MessageResource.strMailServer.ToString();
                                objEmail.SentMail();
                            }
                        }
                    }
                }
            }
        }
        #endregion
    }
    protected void FunctionUpdate()
    {
        #region Get incidentid from QueryString
        int incidentid = Convert.ToInt32(Request.QueryString[0]);
        #endregion

        #region Declare Local Variable
        // Declare local Variable
        int historyid;
        int varTotalTimeSpentonCall = 0;
        int SLAid;
        string userName;
        int userid = 0;
        string strCreateDatetime = "";
        string statusString;
        string strStatusOpen;
        string strStatusClose;
        string strStatusResolved;
        string strStatusOnHold;
        bool FlagTechnicianId;
        bool FlagCloseStatus;
        int requesttypeid;
        string OldStatusString;
        FlagTechnicianId = false;
        FlagCloseStatus = false;
        string oldCompletedTime = "";
        Incident_mst objIncidentOld = new Incident_mst();
        IncidentStates objIncidentStatesOld = new IncidentStates();

        bool FlagClosedStatus = true;
        string VarResolutionAdded = "";
        #endregion

        #region Fetch Current User
        // Fetch Current User and assign to local variable userName
        MembershipUser User = Membership.GetUser();
        userName = User.UserName.ToString();
        #endregion

        #region Fetch Data from MessageResource file and assign to Local Variable

        statusString = GetStatusString(Convert.ToInt32(drpStatus.SelectedValue));
        strStatusOpen = Resources.MessageResource.strStatusOpen.ToString().Trim();
        strStatusClose = Resources.MessageResource.strStatusClose.ToString().Trim();
        strStatusResolved = Resources.MessageResource.strStatusResolved.ToString().Trim();
        strStatusOnHold = Resources.MessageResource.strStatusOnHold.ToString().Trim();

        #endregion

        # region Get SLAid by Calling Function Get_By_SLAid() ,via Passing Parameter siteid and priorityid

        SLAid = objIncident.Get_By_SLAid(Convert.ToInt32(drpSite.SelectedValue), Convert.ToInt32(drpPriority.SelectedValue));
        requesttypeid = Convert.ToInt32(Resources.MessageResource.strRequestTypeId.ToString());
        if (requesttypeid == Convert.ToInt32(drpRequestType.SelectedValue))
        {
            SLAid = 0;
        }
        #endregion

        #region On the basis of Username ,get Userid by calling Function Get_UserLogin_By_UserName(),via passing parameter Username and organizationid

        if (userName != "")
        {
            objOrganization = objOrganization.Get_Organization();
            objUser = objUser.Get_UserLogin_By_UserName(userName, objOrganization.Orgid);
            if (objUser.Userid != 0)
            {
                userid = objUser.Userid;
            }
        }
        #endregion

        //#region Insert value in IncidentHistory Table ,for every update of Page

        //if (statusString.ToLower() == strStatusClose.ToLower())
        //{
        //    if (Session["ResolutionAdded"] != null)
        //    {
        //        VarResolutionAdded = Session["ResolutionAdded"].ToString();
        //    }

        //    if (VarResolutionAdded == "true")
        //    {
        //        objIncidentHistory.Incidentid = incidentid;
        //        objIncidentHistory.Operationownerid = userid;
        //        objIncidentHistory.Operation = "closed";
        //        objIncidentHistory.Insert();
        //        Session["ResolutionAdded"] = "false";
        //    }
        //    else { FlagClosedStatus = false; }
        //}
        //else if (statusString.ToLower() == strStatusResolved.ToLower())
        //{

        //    objIncidentHistory.Incidentid = incidentid;
        //    objIncidentHistory.Operationownerid = userid;
        //    objIncidentHistory.Operation = "resolved";
        //    objIncidentHistory.Insert();
        //}
        //else
        //{

        //    objIncidentHistory.Incidentid = incidentid;
        //    objIncidentHistory.Operationownerid = userid;
        //    objIncidentHistory.Operation = "update";
        //    objIncidentHistory.Insert();

        //}
        //#endregion
        #region Insert value in IncidentHistory Table ,for every update of Page
        if (statusString.ToLower() == strStatusClose.ToLower())
        {
            objIncidentHistory.Incidentid = incidentid;
            objIncidentHistory.Operationownerid = userid;
            objIncidentHistory.Operation = "closed";
            objIncidentHistory.Insert();
        }
        else if (statusString.ToLower() == strStatusResolved.ToLower())
        {
            if (Session["ResolutionAdded"] != null)
            {
                VarResolutionAdded = Session["ResolutionAdded"].ToString();
            }

            if (VarResolutionAdded == "true")
            {
                objIncidentHistory.Incidentid = incidentid;
                objIncidentHistory.Operationownerid = userid;
                objIncidentHistory.Operation = "resolved";
                objIncidentHistory.Insert();
                Session["ResolutionAdded"] = "false";
            }
            else { FlagClosedStatus = false; }
            //objIncidentHistory.Incidentid = incidentid;
            //objIncidentHistory.Operationownerid = userid;
            //objIncidentHistory.Operation = "resolved";
            //objIncidentHistory.Insert();
        }
        else
        {

            objIncidentHistory.Incidentid = incidentid;
            objIncidentHistory.Operationownerid = userid;
            objIncidentHistory.Operation = "update";
            objIncidentHistory.Insert();
        }
        #endregion

        #region Get the Current historyid by calling function Get_Current_IncidentHistoryid()
        historyid = objIncidentHistory.Get_Current_IncidentHistoryid();
        #endregion

        #region Find Current value of Incident and IncidentStates object ,By Calling Function Get_By_id(),via passing incidentid
        objIncidentOld = objIncidentOld.Get_By_id(incidentid);
        objIncidentStatesOld = objIncidentStatesOld.Get_By_id(incidentid);
        #endregion

        if (FlagClosedStatus == true)
        {
            #region Insert into IncidentHistoryDiff table ,By Comparing Current value and Updated Values

            if (objIncidentOld.Incidentid != 0 && objIncidentStatesOld.Incidentid != 0)
            {
                #region Declare local variable
                string columnName;
                string prev_value;
                string curnt_value;
                #endregion

                #region If site value is changed,Insert into IncidentHistoryDiff table
                if (objIncidentOld.Siteid != Convert.ToInt32(drpSite.SelectedValue))
                {
                    columnName = Resources.MessageResource.strColumnSiteid.ToString();
                    prev_value = Convert.ToString(objIncidentOld.Siteid);
                    curnt_value = drpSite.SelectedValue;
                    objIncidentHistoryDiff.Historyid = historyid;
                    objIncidentHistoryDiff.Columnname = columnName;
                    objIncidentHistoryDiff.Current_value = curnt_value;
                    objIncidentHistoryDiff.Prev_value = prev_value;
                    objIncidentHistoryDiff.Insert();
                }
                #endregion
                #region If Department value is changed,Insert into IncidentHistoryDiff table
                if (objIncidentOld.Deptid != Convert.ToInt32(drpDepartment.SelectedValue))
                {
                    columnName = Resources.MessageResource.strColumnDeptid.ToString();
                    prev_value = Convert.ToString(objIncidentOld.Deptid);
                    curnt_value = drpDepartment.SelectedValue;
                    objIncidentHistoryDiff.Historyid = historyid;
                    objIncidentHistoryDiff.Columnname = columnName;
                    objIncidentHistoryDiff.Current_value = curnt_value;
                    objIncidentHistoryDiff.Prev_value = prev_value;
                    objIncidentHistoryDiff.Insert();
                }
                #endregion
                #region If Mode value is changed,Insert into IncidentHistoryDiff table
                if (objIncidentOld.Modeid != Convert.ToInt32(drpMode.SelectedValue))
                {
                    columnName = Resources.MessageResource.strColumnModeid.ToString();
                    prev_value = Convert.ToString(objIncidentOld.Modeid);
                    curnt_value = drpMode.SelectedValue;
                    objIncidentHistoryDiff.Historyid = historyid;
                    objIncidentHistoryDiff.Columnname = columnName;
                    objIncidentHistoryDiff.Current_value = curnt_value;
                    objIncidentHistoryDiff.Prev_value = prev_value;
                    objIncidentHistoryDiff.Insert();
                }
                #endregion
                #region If SLA value is changed,Insert into IncidentHistoryDiff table

                if (objIncidentOld.Slaid != SLAid)
                {
                    columnName = Resources.MessageResource.strColumnSLAid.ToString();
                    prev_value = Convert.ToString(objIncidentOld.Slaid);
                    curnt_value = Convert.ToString(SLAid);
                    objIncidentHistoryDiff.Historyid = historyid;
                    objIncidentHistoryDiff.Columnname = columnName;
                    objIncidentHistoryDiff.Current_value = curnt_value;
                    objIncidentHistoryDiff.Prev_value = prev_value;
                    objIncidentHistoryDiff.Insert();
                }
                #endregion
                #region If Requesttype value is changed,Insert into IncidentHistoryDiff table

                if (objIncidentStatesOld.Requesttypeid != Convert.ToInt32(drpRequestType.SelectedValue))
                {
                    columnName = Resources.MessageResource.strColumnRequesttypeid.ToString();
                    prev_value = Convert.ToString(objIncidentStatesOld.Requesttypeid);
                    curnt_value = Convert.ToString(drpRequestType.SelectedValue);
                    objIncidentHistoryDiff.Historyid = historyid;
                    objIncidentHistoryDiff.Columnname = columnName;
                    objIncidentHistoryDiff.Current_value = curnt_value;
                    objIncidentHistoryDiff.Prev_value = prev_value;
                    objIncidentHistoryDiff.Insert();
                }
                #endregion

                #region If Priority value is changed,Insert into IncidentHistoryDiff table

                if (objIncidentStatesOld.Priorityid != Convert.ToInt32(drpPriority.SelectedValue))
                {
                    columnName = Resources.MessageResource.strColumnPriorityid.ToString();
                    prev_value = Convert.ToString(objIncidentStatesOld.Priorityid);
                    curnt_value = Convert.ToString(drpPriority.SelectedValue);
                    objIncidentHistoryDiff.Historyid = historyid;
                    objIncidentHistoryDiff.Columnname = columnName;
                    objIncidentHistoryDiff.Current_value = curnt_value;
                    objIncidentHistoryDiff.Prev_value = prev_value;
                    objIncidentHistoryDiff.Insert();
                }
                #endregion
                #region If Category value is changed,Insert into IncidentHistoryDiff table
                if (objIncidentStatesOld.Categoryid != Convert.ToInt32(drpCategory.SelectedValue))
                {
                    columnName = Resources.MessageResource.strColumnCategoryid.ToString();
                    prev_value = Convert.ToString(objIncidentStatesOld.Categoryid);
                    curnt_value = Convert.ToString(drpCategory.SelectedValue);
                    objIncidentHistoryDiff.Historyid = historyid;
                    objIncidentHistoryDiff.Columnname = columnName;
                    objIncidentHistoryDiff.Current_value = curnt_value;
                    objIncidentHistoryDiff.Prev_value = prev_value;
                    objIncidentHistoryDiff.Insert();
                }
                #endregion
                #region If SubCategory value is changed,Insert into IncidentHistoryDiff table
                if (objIncidentStatesOld.Subcategoryid != Convert.ToInt32(drpSubcategory.SelectedValue))
                {
                    columnName = Resources.MessageResource.strColumnSubcategoryid.ToString();
                    prev_value = Convert.ToString(objIncidentStatesOld.Subcategoryid);
                    curnt_value = Convert.ToString(drpSubcategory.SelectedValue);
                    objIncidentHistoryDiff.Historyid = historyid;
                    objIncidentHistoryDiff.Columnname = columnName;
                    objIncidentHistoryDiff.Current_value = curnt_value;
                    objIncidentHistoryDiff.Prev_value = prev_value;
                    objIncidentHistoryDiff.Insert();
                }
                #endregion

                #region If Status value is changed,Insert into IncidentHistoryDiff table

                if (objIncidentStatesOld.Statusid != Convert.ToInt32(drpStatus.SelectedValue))
                {
                    string Statusprev;
                    string StatusCurrent;
                    columnName = Resources.MessageResource.strColumnstatusid.ToString();
                    prev_value = Convert.ToString(objIncidentStatesOld.Statusid);
                    curnt_value = Convert.ToString(drpStatus.SelectedValue);
                    objIncidentHistoryDiff.Historyid = historyid;
                    objIncidentHistoryDiff.Columnname = columnName;
                    objIncidentHistoryDiff.Current_value = curnt_value;
                    objIncidentHistoryDiff.Prev_value = prev_value;
                    objIncidentHistoryDiff.Insert();
                    Statusprev = GetStatusString(Convert.ToInt32(objIncidentStatesOld.Statusid));
                    StatusCurrent = GetStatusString(Convert.ToInt32(drpStatus.SelectedValue));
                    if (Statusprev.ToLower() == strStatusOpen.ToLower() && StatusCurrent.ToLower() == strStatusOnHold.ToLower())
                    {
                        columnName = Resources.MessageResource.strColumnStarttime.ToString();
                        prev_value = "0";
                        curnt_value = DateTime.Now.ToString();
                        objIncidentHistoryDiff.Historyid = historyid;
                        objIncidentHistoryDiff.Columnname = columnName;
                        objIncidentHistoryDiff.Current_value = curnt_value;
                        objIncidentHistoryDiff.Prev_value = prev_value;
                        objIncidentHistoryDiff.Insert();
                    }

                    if (Statusprev.ToLower() == strStatusOnHold.ToLower() && StatusCurrent.ToLower() != strStatusOnHold.ToLower())
                    {
                        columnName = Resources.MessageResource.srColumnEndtime.ToString();
                        prev_value = "0";
                        curnt_value = DateTime.Now.ToString();
                        objIncidentHistoryDiff.Historyid = historyid;
                        objIncidentHistoryDiff.Columnname = columnName;
                        objIncidentHistoryDiff.Current_value = curnt_value;
                        objIncidentHistoryDiff.Prev_value = prev_value;
                        objIncidentHistoryDiff.Insert();
                    }
                    //Added by lalit
                    //if current techncian is wintel and current status is closed then
                    string prev_valuetechid = Convert.ToString(objIncidentStatesOld.Technicianid);
                    if (StatusCurrent == "Closed")
                    {
                        // if (prev_valuetechid == "11740")
                        if (IsSLANeedsToBeStopped(prev_valuetechid) == 1)
                        {
                            columnName = Resources.MessageResource.srColumnEndtime.ToString();
                            prev_value = "0";
                            curnt_value = DateTime.Now.ToString();
                            objIncidentHistoryDiff.Historyid = historyid;
                            objIncidentHistoryDiff.Columnname = columnName;
                            objIncidentHistoryDiff.Current_value = curnt_value;
                            objIncidentHistoryDiff.Prev_value = prev_value;
                            objIncidentHistoryDiff.Insert();
                        }
                    }
                    //end
                    //end lalit
                }
                #endregion

                #region If technician value is changed,Insert into IncidentHistoryDiff table
                if (objIncidentStatesOld.Technicianid != Convert.ToInt32(drpTechnician.SelectedValue))
                {
                    string columnNametechid = Resources.MessageResource.strColumnTechnicianid.ToString();
                    string prev_valuetechid = Convert.ToString(objIncidentStatesOld.Technicianid);
                    string curnt_valuetechid = Convert.ToString(drpTechnician.SelectedValue);
                    // string Id = "";

                    //if (curnt_valuetechid == "11740" && prev_valuetechid!="11740")
                    if (IsSLANeedsToBeStopped(curnt_valuetechid) == 1 && IsSLANeedsToBeStopped(prev_valuetechid) == 0)
                    {
                        string StatusCurrent = GetStatusString(Convert.ToInt32(drpStatus.SelectedValue));
                        if (StatusCurrent.ToLower() != strStatusOnHold.ToLower())
                        {
                            //insert start time

                            if (StatusCurrent.ToLower() != strStatusOnHold.ToLower())
                            {
                                columnName = Resources.MessageResource.strColumnStarttime.ToString();
                                prev_value = "0";
                                curnt_value = DateTime.Now.ToString();
                                objIncidentHistoryDiff.Historyid = historyid;
                                objIncidentHistoryDiff.Columnname = columnName;
                                objIncidentHistoryDiff.Current_value = curnt_value;
                                objIncidentHistoryDiff.Prev_value = prev_value;
                                objIncidentHistoryDiff.Insert();
                                //end
                            }
                            //insert techcianid
                            objIncidentHistoryDiff.Historyid = historyid;
                            objIncidentHistoryDiff.Columnname = columnNametechid;
                            objIncidentHistoryDiff.Current_value = curnt_valuetechid;
                            objIncidentHistoryDiff.Prev_value = prev_valuetechid;
                            objIncidentHistoryDiff.Insert();
                            //end
                            //insert assigntime
                            if (objIncidentStatesOld.AssignedTime == null)
                            {
                                columnName = Resources.MessageResource.strColumnAssignedTime.ToString();
                                prev_value = "0";
                                curnt_value = DateTime.Now.ToString();
                                objIncidentHistoryDiff.Historyid = historyid;
                                objIncidentHistoryDiff.Columnname = columnName;
                                objIncidentHistoryDiff.Current_value = curnt_value;
                                objIncidentHistoryDiff.Prev_value = prev_value;
                                objIncidentHistoryDiff.Insert();
                            }
                            else
                            {
                                columnName = "AssignedTime";
                                prev_value = objIncidentStatesOld.AssignedTime;
                                curnt_value = DateTime.Now.ToString();
                                objIncidentHistoryDiff.Historyid = historyid;
                                objIncidentHistoryDiff.Columnname = columnName;
                                objIncidentHistoryDiff.Current_value = curnt_value;
                                objIncidentHistoryDiff.Prev_value = prev_value;
                                objIncidentHistoryDiff.Insert();
                            }
                            //end
                        }
                    }

                    else
                    {
                        //if prev value- progress eng
                        columnName = Resources.MessageResource.strColumnTechnicianid.ToString();
                        prev_value = Convert.ToString(objIncidentStatesOld.Technicianid);
                        curnt_value = Convert.ToString(drpTechnician.SelectedValue);
                        objIncidentHistoryDiff.Historyid = historyid;
                        objIncidentHistoryDiff.Columnname = columnName;
                        objIncidentHistoryDiff.Current_value = curnt_value;
                        objIncidentHistoryDiff.Prev_value = prev_value;
                        objIncidentHistoryDiff.Insert();

                        if (objIncidentStatesOld.AssignedTime == null)
                        {
                            columnName = Resources.MessageResource.strColumnAssignedTime.ToString();
                            prev_value = "0";
                            curnt_value = DateTime.Now.ToString();
                            objIncidentHistoryDiff.Historyid = historyid;
                            objIncidentHistoryDiff.Columnname = columnName;
                            objIncidentHistoryDiff.Current_value = curnt_value;
                            objIncidentHistoryDiff.Prev_value = prev_value;
                            objIncidentHistoryDiff.Insert();
                        }
                        else
                        {
                            columnName = "AssignedTime";
                            prev_value = objIncidentStatesOld.AssignedTime;
                            curnt_value = DateTime.Now.ToString();
                            objIncidentHistoryDiff.Historyid = historyid;
                            objIncidentHistoryDiff.Columnname = columnName;
                            objIncidentHistoryDiff.Current_value = curnt_value;
                            objIncidentHistoryDiff.Prev_value = prev_value;
                            objIncidentHistoryDiff.Insert();
                        }
                        // if (prev_valuetechid == "11740")
                        if (IsSLANeedsToBeStopped(prev_valuetechid) == 1)
                        {
                            string StatusCurrent = GetStatusString(Convert.ToInt32(drpStatus.SelectedValue));
                            if (StatusCurrent.ToLower() != strStatusOnHold.ToLower())
                            {
                                columnName = Resources.MessageResource.srColumnEndtime.ToString();
                                prev_value = "0";
                                curnt_value = DateTime.Now.ToString();
                                objIncidentHistoryDiff.Historyid = historyid;
                                objIncidentHistoryDiff.Columnname = columnName;
                                objIncidentHistoryDiff.Current_value = curnt_value;
                                objIncidentHistoryDiff.Prev_value = prev_value;
                                objIncidentHistoryDiff.Insert();
                            }
                            //end
                        }
                        //then insert end time 0
                        //end
                        //else
                        //end
                    }

                    if (Convert.ToInt32(drpTechnician.SelectedValue) != 0)
                    {
                        objSentMailtoUser.SentmailTechnician(Convert.ToInt32(drpTechnician.SelectedValue), objIncidentOld.Incidentid);
                    }
                    FlagTechnicianId = true;
                }
                #endregion

                #region If External Ticket value is changed,Insert into IncidentHistoryDiff table
                if (objIncidentOld.ExternalTicketNo == null)
                { objIncidentOld.ExternalTicketNo = " "; }

                if (objIncidentOld.ExternalTicketNo.ToString().Trim() != txtExternalTicket.Text.ToString().Trim())
                {
                    //////////////////////////////////////////////////change done by meenakshi
                     int flag = Convert.ToInt32(Session["flag"]);
                     if (flag == 1)
                     {
                         columnName = Resources.MessageResource.strColumnExternalTicket.ToString();
                         prev_value = objIncidentOld.ExternalTicketNo.ToString().Trim();
                         txtExternalTicket.Text = (string)Session["compname"];
                         curnt_value = txtExternalTicket.Text.ToString().Trim();
                         //curnt_value =(string) Session["compname"];
                         objIncidentHistoryDiff.Historyid = historyid;
                         objIncidentHistoryDiff.Columnname = columnName;
                         objIncidentHistoryDiff.Current_value = curnt_value;
                         objIncidentHistoryDiff.Prev_value = prev_value;
                         objIncidentHistoryDiff.Insert();
                     }
                }
                #endregion

                #region If Vendor  value is changed,Insert into IncidentHistoryDiff table
                if (objIncidentOld.VendorId == null)
                { objIncidentOld.ExternalTicketNo = "0"; }

                if (objIncidentOld.VendorId != Convert.ToInt32(drpVendor.SelectedValue))
                {
                    columnName = Resources.MessageResource.strColumnVendorId.ToString();
                    prev_value = Convert.ToString(objIncidentOld.VendorId);
                    curnt_value = Convert.ToString(drpVendor.SelectedValue);
                    objIncidentHistoryDiff.Historyid = historyid;
                    objIncidentHistoryDiff.Columnname = columnName;
                    objIncidentHistoryDiff.Current_value = curnt_value;
                    objIncidentHistoryDiff.Prev_value = prev_value;
                    objIncidentHistoryDiff.Insert();
                }
                #endregion

                #region Check  Old status is closed and current status is closed,then Assign value to localvariable FlagCloseStatus=true and used later
                OldStatusString = GetStatusString(objIncidentStatesOld.Statusid);
                strCreateDatetime = objIncidentOld.Createdatetime;
                if (strStatusClose.ToLower() == OldStatusString.ToLower() && statusString.ToLower() == strStatusClose.ToLower())
                {
                    FlagCloseStatus = true;
                    oldCompletedTime = objIncidentOld.Completedtime;
                }
                #endregion

            }
            #endregion
        }

        if (FlagClosedStatus == true)
        {
            #region Update values in Incident Table
            objIncident.Incidentid = incidentid;
            objIncident.Siteid = Convert.ToInt32(drpSite.SelectedValue);
            objIncident.Deptid = Convert.ToInt32(drpDepartment.SelectedValue);
            objIncident.Title = lblTitle.Text;
            objIncident.Description = lblDescription.Text;
            objIncident.Modeid = Convert.ToInt32(drpMode.SelectedValue);
            objIncident.Slaid = SLAid;
            objIncident.Active = true;
            if (drpAMCCall.Text.ToUpper() == "YES")
            {
                objIncident.AMCCall = true;
            }
            else if (drpAMCCall.Text.ToUpper() == "NO")
            {
                objIncident.AMCCall = false;
            }
        /////////////////////////////////////////////////////////////////change done by meenakshi/////////////////////////
            //objIncident.ExternalTicketNo = txtExternalTicket.Text.ToString().Trim();
            objIncident.ExternalTicketNo = (string)(Session["compname"]);
        /////////////////////////////////////////////////////////////////end/////////////////////////////////
            objIncident.VendorId = Convert.ToInt32(drpVendor.SelectedValue);
            //#region If Current status is closed,then Assign Completed time
            #region If Current status is resolved,then Assign Completed time
            if (statusString.ToLower() == strStatusResolved.ToLower())
            {
                #region If FlagCloseStatus=flase ie Currrent status is closed ,and old status is not Closed
                if (FlagCloseStatus == false)
                {
                    objIncident.Completedtime = DateTime.Now.ToString();
                    varTotalTimeSpentonCall = objIncident.Get_TimeSpentonRequest(incidentid, Convert.ToInt32(drpSite.SelectedValue), strCreateDatetime, DateTime.Now.ToString());
                }
                else
                {
                    objIncident.Completedtime = oldCompletedTime;
                    varTotalTimeSpentonCall = objIncident.Get_TimeSpentonRequest(incidentid, Convert.ToInt32(drpSite.SelectedValue), strCreateDatetime, oldCompletedTime);
                }
                #endregion
            }
            //added by lalit 27 march
            if (statusString.ToLower() == strStatusClose.ToLower())
            {
                #region If FlagCloseStatus=flase ie Currrent status is closed ,and old status is not Closed
                varTotalTimeSpentonCall = objIncident.Timespentonreq;
                objIncident.Completedtime = oldCompletedTime;
                #endregion
            }
            //end lalit
            if (varTotalTimeSpentonCall <= 0)
            {
                varTotalTimeSpentonCall = 0;
            }

            if (lblextension.Text != "")
            {

                objIncident.Extension = Convert.ToInt64(lblextension.Text);
            }
            //if (lblAMCcall.Text != "")
            //{

            //    objIncident.AMCCall = Convert.ToInt32(lblAMCcall.Text);
            //}
            objIncident.Timespentonreq = varTotalTimeSpentonCall;
            objIncident.Update();
            //if (statusString.ToLower() == strStatusClose.ToLower() && FlagClosedStatus == true)
            if (statusString.ToLower() == strStatusResolved.ToLower() && FlagClosedStatus == true)
            {
                objSentMailtoUser.SentmailUser(objIncidentOld.Requesterid, objIncidentOld.Incidentid, "closed");
            }
            #endregion
            #endregion
        }
        if (FlagClosedStatus == true)
        {
            #region Update Values in IncidentStates
            objIncidentStates.Incidentid = incidentid;
            objIncidentStates.Categoryid = Convert.ToInt32(drpCategory.SelectedValue);
            objIncidentStates.Subcategoryid = Convert.ToInt32(drpSubcategory.SelectedValue);
            objIncidentStates.Technicianid = Convert.ToInt32(drpTechnician.SelectedValue);
            if (FlagTechnicianId == true)
            {
                objIncidentStates.AssignedTime = DateTime.Now.ToString();

            }
            objIncidentStates.Statusid = Convert.ToInt32(drpStatus.SelectedValue);
            objIncidentStates.Priorityid = Convert.ToInt32(drpPriority.SelectedValue);
            objIncidentStates.Requesttypeid = Convert.ToInt32(drpRequestType.SelectedValue);
            objIncidentStates.Update();
            #endregion
        }
            #region Callint Updatepanel1() function to display value in Non Editable Mode
        UpdatePanel1();
        #endregion
        HistoryUpdatePanel();
    }