Beispiel #1
0
    public void SentMailToTechnicianForProblemCall(int problemid, int userid)
    {
        string      strYourSinscerely = Resources.MessageResource.strYourSinscerely.ToString();
        string      strContactNumber  = Resources.MessageResource.strContactNumber.ToString();
        Problem_mst objProblem        = new Problem_mst();

        objUser = objUser.Get_By_id(userid);
        ContactInfo_mst objCont_info = new ContactInfo_mst();

        objCont_info = objCont_info.Get_By_id(objUser.Userid);
        objProblem   = objProblem.Get_By_id(problemid);
        objPriority  = objPriority.Get_By_id(objProblem.Priorityid);
        UserLogin_mst objReq = new UserLogin_mst();

        objReq = objReq.Get_By_id(objProblem.Requesterid);
        ContactInfo_mst objReqCont = new ContactInfo_mst();

        objReqCont = objReqCont.Get_By_id(objReq.Userid);
        objSDE     = objSDE.Get_By_id(objProblem.CreatedByid);

        if (objCont_info.Emailid != null)
        {
            obj.To         = objCont_info.Emailid;
            obj.From       = Resources.MessageResource.strAdminEmail.ToString();
            obj.Subject    = " New Problem Call Assigned to you. Problem Id : " + problemid;
            obj.Body       = "Dear&nbsp;" + objUser.Username + "," + "<br/>  A Call with the following details have been assigned to you.<br/><br/><b>Problem Details : </b> <br/><br/><b>Problem Id&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:</b>" + objProblem.ProblemId + "<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;&nbsp;&nbsp;&nbsp;:</b>" + objProblem.title + " <br/><b>Logged Date & Time&nbsp;&nbsp;&nbsp;&nbsp;&nbsp&nbsp;&nbsp;&nbsp;:</b>" + objProblem.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;&nbsp;&nbsp;:</b>" + objProblem.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;&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;&nbsp;:</b>" + objReq.Username + "<br/><b>Mobile No.&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/>" + objReqCont.Mobile + "<br/><b>Landline No.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:<b/>" + objReqCont.Landline + "<br/><b>Mail Address&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:</b>" + objReqCont.Emailid + "<br/><b>Service Desk Executive&nbsp;&nbsp;&nbsp;:</b>" + objSDE.Username + "<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 = obj.SmtpServer = Resources.MessageResource.strSMTPServer.ToString();
            obj.SentMail();
        }
    }
Beispiel #2
0
 //function to check user exist or not
 protected void CheckUserExist()
 {
     lblerrmsg.Text = "";
     // BindDropSite();
     // BindDropDept();
     #region Find Userid of User who is Requesting to log a call
     objOrganization = objOrganization.Get_Organization();
     objUser         = objUser.Get_UserLogin_By_UserName(txtUsername.Text.Trim().ToString().Trim(), objOrganization.Orgid);
     int usrid    = Convert.ToInt16(objUser.Userid);
     int tempuser = 0;
     if (objUser.Userid == 0)
     {
         string myScript;
         tempuser = 1;
         myScript = "<script language=javascript>function __doPostBack(eventTarget, eventArgument){var theForm = document.forms['aspnetForm'];  if (theForm){  theForm.__EVENTTARGET.value = eventTarget;theForm.__EVENTARGUMENT.value = eventArgument;theForm.submit(); }} var Flag= confirm('User Does not Exist,Do You Want to Create User');if(Flag==true){ __doPostBack('callPostBack', 'create');}if(Flag==false){ __doPostBack('callPostBack', 'notcreate');}</script>";
         Page.RegisterClientScriptBlock("MyScript", myScript);
         Session["tempuser"] = tempuser;
         //txtassignasset.Text = "";
     }
     else
     {
         IncidentToAsset(usrid);
         ContactInfo_mst objConInfo = new ContactInfo_mst();
         objConInfo    = objConInfo.Get_By_id(usrid);
         txtEmail.Text = objConInfo.Emailid;
         //txtassignasset.Text = assetid.ToString();
         //txtassignasset.Text = compname;
         Session["assignassetid"] = assetid;
         Session["UserCreate"]    = "Exist";
     }
     string username1 = txtUsername.Text.Trim().ToString();
     Session["Username"] = username1;
     Session["Email"]    = txtEmail.Text;
     #endregion
 }
Beispiel #3
0
    protected void GetUserDetail()
    {
        string         userName = "";
        MembershipUser User     = Membership.GetUser();

        if (User != null)
        {
            userName         = User.UserName.ToString();
            txtUsername.Text = User.UserName.ToString();
        }
        if (userName != "")
        {
            int userid;
            objOrganization = objOrganization.Get_Organization();
            objUser         = objUser.Get_UserLogin_By_UserName(userName, objOrganization.Orgid);

            if (objUser.Userid != 0)
            {
                ContactInfo_mst objConInfo = new ContactInfo_mst();
                userid = objUser.Userid;
                IncidentToAsset(userid);
                objConInfo          = objConInfo.Get_By_id(userid);
                txtEmail.Text       = objConInfo.Emailid;
                txtassignasset.Text = compname;
            }
        }
    }
    protected void btnSolutionAdd_Click(object sender, EventArgs e)
    {///Add Exception handilng try catch change by vishal 21-05-2012
        try
        {
            string         userName;
            MembershipUser User = Membership.GetUser();
            userName = User.UserName.ToString();
            int userid;
            objOrganization = objOrganization.Get_Organization();
            objUser         = objUser.Get_UserLogin_By_UserName(userName, objOrganization.Orgid);

            int Solutionid;
            ObjSolution.Title    = txtTitle.Text.ToString();
            ObjSolution.Content  = Editor.Text.ToString();
            ObjSolution.Topicid  = Convert.ToInt32(drpTopic.SelectedValue);
            ObjSolution.Solution = drpSolutionType.SelectedValue;
            ObjSolution.Insert();
            Solutionid = ObjSolutionKeyword.Get_SolutionId();
            ObjSolutionKeyword.Keywords   = txtKeywords.Text.ToString();
            ObjSolutionKeyword.Solutionid = Solutionid;
            ObjSolutionKeyword.Insert();
            ObjSolutionCreator.Solutionid = Solutionid;
            ObjSolutionCreator.Createdby  = objUser.Userid;
            ObjSolutionCreator.Insert();
            objSentMailToUser.SentMailToPManager(Solutionid);
            Response.Redirect("ViewSolution.aspx?solutionid" + Solutionid);
        }
        catch (Exception ex)
        {
            string myScript;
            myScript = "<script language=javascript>alert('Exception - '" + ex + "');</script>";
            Page.RegisterClientScriptBlock("MyScript", myScript);
            return;
        }
    }
Beispiel #5
0
    protected void btnMapped_Click(object sender, EventArgs e)
    {
        //lblErrorMsg.Text = "";
        int flag = 0;

        foreach (GridViewRow gv in grdvwViewUser.Rows)
        {
            string      gvIDs;
            RadioButton selectonebutton = (RadioButton)gv.FindControl("selectone");
            if (selectonebutton.Checked)
            {
                flag    = 1;
                gvIDs   = ((Label)gv.FindControl("lblUserID")).Text.ToString();
                userid  = Convert.ToInt32(gvIDs);
                objUser = objUser.Get_By_id(userid);
                string username = objUser.Username.ToString();
                Session["username"] = username;
                Session["userid"]   = userid;
                Session["flag"]     = flag;
                Session["flag2"]    = flag;
                break;
            }
        }
        string myScript;

        myScript = "<script language=javascript>javascript:refreshParent(); javascript:window.close();</script>";
        Page.RegisterClientScriptBlock("MyScript", myScript);
    }
 protected void btnMapped_Click(object sender, EventArgs e)
 {
     //lblErrorMsg.Text = "";
     int flag = 0;
     foreach (GridViewRow gv in grdvwViewUser.Rows)
     {
         string gvIDs;
         RadioButton selectonebutton = (RadioButton)gv.FindControl("selectone");
         if (selectonebutton.Checked)
         {
             flag = 1;
             gvIDs = ((Label)gv.FindControl("lblUserID")).Text.ToString();
             userid = Convert.ToInt16(gvIDs);
             objUser = objUser.Get_By_id(userid);
             string username = objUser.Username.ToString();
             Session["username"] = username;
             Session["userid"] = userid;
             Session["flag"] = flag;
             Session["flag2"] = flag;
             break;
        }
        }
     string myScript;
     myScript = "<script language=javascript>javascript:refreshParent(); javascript:window.close();</script>";
     Page.RegisterClientScriptBlock("MyScript", myScript);
 }
Beispiel #7
0
    public void SentMailToPManager(int solutionid)
    {
        string          strYourSinscerely  = Resources.MessageResource.strYourSinscerely.ToString();
        string          strContactNumber   = Resources.MessageResource.strContactNumber.ToString();
        Solution_mst    objSolution        = new Solution_mst();
        SolutionCreator objSolutionCreator = new SolutionCreator();

        objSolution        = objSolution.Get_By_id(solutionid);
        objSolutionCreator = objSolutionCreator.Get_By_id(solutionid);
        UserLogin_mst objUserCreator = new UserLogin_mst();

        objUserCreator = objUserCreator.Get_By_id(objSolutionCreator.Createdby);
        int    FlagUser;
        string varRole = Resources.MessageResource.strPManagerRole.ToString();
        int    roleid;

        roleid  = objRole.Get_By_RoleName(varRole);
        colUser = objUser.Get_All_By_Role(roleid);
        foreach (UserLogin_mst objusr in colUser)
        {
            objC_info      = objC_info.Get_By_id(objusr.Userid);
            obj.From       = Resources.MessageResource.strAdminEmail.ToString();
            obj.To         = objC_info.Emailid;
            obj.Subject    = "New Solution Added. Solution Id : " + solutionid;
            obj.Body       = "Dear Sir/Madam,<br/>A New Solution has been Added.Please find the New Solution details .<br/><br/><b>Solution Details : </b> <br/><br/><b>Solution Id &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:</b>" + objSolution.Solutionid + "<br/><b>Title &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>" + objSolution.Title + " <br/><b>Added By &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:</b>" + objUserCreator.Username + "<br/><b>Created Date &nbsp;&nbsp;&nbsp;&nbsp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:</b>" + objSolutionCreator.CreateDatetime + "<br/><b>Content&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:</b>" + objSolution.Content + "<br/><br/>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();
        }
    }
Beispiel #8
0
    public void SentmailTechnician(int technicianid, int incidentid)
    {
        string strYourSinscerely = Resources.MessageResource.strYourSinscerely.ToString();
        string strContactNumber  = Resources.MessageResource.strContactNumber.ToString();

        objIncident       = objIncident.Get_By_id(incidentid);
        objSite           = objSite.Get_By_id(objIncident.Siteid);
        objIncidentStates = objIncidentStates.Get_By_id(incidentid);
        objPriority       = objPriority.Get_By_id(objIncidentStates.Priorityid);
        objUser           = objUser.Get_By_id(objIncident.Requesterid);
        objtech           = objtech.Get_By_id(technicianid);
        objSDE            = objSDE.Get_By_id(objIncident.Createdbyid);
        objC_info         = objC_info.Get_By_id(technicianid);
        objUserInfo       = objUserInfo.Get_By_id(objIncident.Requesterid);

        if (objC_info.Emailid != null)
        {
            obj.To         = objC_info.Emailid;
            obj.From       = Resources.MessageResource.strAdminEmail.ToString();
            obj.Subject    = " New Call Assigned to you. Ticket id : " + incidentid;
            obj.Body       = "Dear&nbsp;" + objtech.Username + "," + "<br/>  A Call with the following details have been assigned to you.<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;&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;&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;&nbsp;&nbsp;&nbsp;:</b>" + objSite.Sitename + "<br/><b>Logged Date & Time&nbsp;&nbsp;&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;&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;&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;&nbsp;:</b>" + objUser.Username + "<br/><b>Mobile No.&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/>" + objUserInfo.Mobile + "<br/><b>Landline No.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:<b/>" + objUserInfo.Landline + "<br/><b>Mail Address&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:</b>" + objC_info.Emailid + "<br/><b>Service Desk Executive&nbsp;&nbsp;&nbsp;:</b>" + objSDE.Username + "<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 = obj.SmtpServer = Resources.MessageResource.strSMTPServer.ToString();
            obj.SentMail();
        }
    }
Beispiel #9
0
 protected void txtUsername_TextChanged(object sender, EventArgs e)
 {
     #region Find Userid of User who is Requesting to log a call
     /////Add Exception handilng try catch change by vishal 21-05-2012
     try
     {
         objOrganization = objOrganization.Get_Organization();
         ObjUserLogin    = ObjUserLogin.Get_UserLogin_By_UserName(txtUsername.Text.ToString().Trim(), objOrganization.Orgid);
         if (ObjUserLogin.Userid == 0)
         {
             string myScript;
             myScript = "<script language=javascript>function __doPostBack(eventTarget, eventArgument){var theForm = document.forms['aspnetForm'];  if (theForm){  theForm.__EVENTTARGET.value = eventTarget;theForm.__EVENTARGUMENT.value = eventArgument;theForm.submit(); }} var Flag= confirm('User Does not Exist,Do You Want to Create User');if(Flag==true){ __doPostBack('callPostBack', 'create');}if(Flag==false){ __doPostBack('callPostBack', 'notcreate');}</script>";
             Page.RegisterClientScriptBlock("MyScript", myScript);
         }
         else
         {
             ViewState["UserCreate"] = "Exist";
             ContactInfo_mst objCont = new ContactInfo_mst();
             objCont       = objCont.Get_By_id(ObjUserLogin.Userid);
             txtEmail.Text = objCont.Emailid;
         }
     }
     catch (Exception ex)
     {
         string myScript;
         myScript = "<script language=javascript>alert('Exception - '" + ex + "');</script>";
         Page.RegisterClientScriptBlock("MyScript", myScript);
         return;
     }
     #endregion
 }
    protected void btnapprove_Click(object sender, EventArgs e)
    { /////Add Exception handilng try catch change by vishal 21-05-2012
        try
        {
            int userid     = 0;
            int incidentid = Convert.ToInt32(Session["incidentid"].ToString());
            if (incidentid != 0)
            {
                //objIncidentLog = objIncidentLog.Get_By_id(incidentid);
                //if (objIncidentLog.Incidentid != 0)
                //{
                //    objIncidentLog.Incidentid = incidentid;
                //    objIncidentLog.Incidentlog = txtcomments.Text;
                //    objIncidentLog.Update();

                //}
                //else
                //{
                //    objIncidentLog.Incidentid = incidentid;
                //    objIncidentLog.Incidentlog = txtcomments.Text;
                //    objIncidentLog.Insert();

                //}

                string         userName = "";
                MembershipUser User     = Membership.GetUser();
                if (User != null)
                {
                    userName = User.UserName.ToString();
                }


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

                objIncidentLog.Incidentid  = incidentid;
                objIncidentLog.Userid      = userid;
                objIncidentLog.Incidentlog = txtcomments.Text;
                objIncidentLog.Insert();

                string myScript;
                myScript = "<script language=javascript>javascript:refreshParent(); javascript:window.close();</script>";
                Page.RegisterClientScriptBlock("MyScript", myScript);
            }
        }
        catch (Exception ex)
        {
            string myScript;
            myScript = "<script language=javascript>alert('Exception - '" + ex + "');</script>";
            Page.RegisterClientScriptBlock("MyScript", myScript);
            return;
        }
    }
    protected void btnapprove_Click(object sender, EventArgs e)
    {
        int userid     = 0;
        int incidentid = Convert.ToInt16(Session["incidentid"].ToString());

        if (incidentid != 0)
        {
            string         userName = "";
            MembershipUser User     = Membership.GetUser();
            if (User != null)
            {
                userName = User.UserName.ToString();
            }


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

            objIncidentLog.Incidentid  = incidentid;
            objIncidentLog.Userid      = userid;
            objIncidentLog.Incidentlog = txtcomments.Text;
            objIncidentLog.Insert();

            string myScript;
            myScript = "<script language=javascript>javascript:window.close();</script>";
            Page.RegisterClientScriptBlock("MyScript", myScript);
        }
    }
    protected void btnSolutionAdd_Click(object sender, EventArgs e)
    {
        string userName;
        MembershipUser User = Membership.GetUser();
        userName = User.UserName.ToString();
        int userid;
        objOrganization = objOrganization.Get_Organization();
        objUser = objUser.Get_UserLogin_By_UserName(userName, objOrganization.Orgid);

        int Solutionid;
        ObjSolution.Title = txtTitle.Text.ToString();
        ObjSolution.Content=Editor.Text.ToString();
        ObjSolution.Topicid = Convert.ToInt16(drpTopic.SelectedValue);
        ObjSolution.Solution = drpSolutionType.SelectedValue;
        ObjSolution.Insert();
        Solutionid = ObjSolutionKeyword.Get_SolutionId();
        ObjSolutionKeyword.Keywords=txtKeywords.Text.ToString();
        ObjSolutionKeyword.Solutionid = Solutionid;
        ObjSolutionKeyword.Insert();
        ObjSolutionCreator.Solutionid = Solutionid;
        ObjSolutionCreator.Createdby = objUser.Userid;
        ObjSolutionCreator.Insert();
        objSentMailToUser.SentMailToPManager(Solutionid);
        Response.Redirect("ViewSolution.aspx?solutionid" + Solutionid);
    }
    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";
    }
    protected void btnSolutionAdd_Click(object sender, EventArgs e)
    {
        string         userName;
        MembershipUser User = Membership.GetUser();

        userName = User.UserName.ToString();
        int userid;

        objOrganization = objOrganization.Get_Organization();
        objUser         = objUser.Get_UserLogin_By_UserName(userName, objOrganization.Orgid);

        int Solutionid;

        ObjSolution.Title    = txtTitle.Text.ToString();
        ObjSolution.Content  = Editor.Text.ToString();
        ObjSolution.Topicid  = Convert.ToInt16(drpTopic.SelectedValue);
        ObjSolution.Solution = drpSolutionType.SelectedValue;
        ObjSolution.Insert();
        Solutionid = ObjSolutionKeyword.Get_SolutionId();
        ObjSolutionKeyword.Keywords   = txtKeywords.Text.ToString();
        ObjSolutionKeyword.Solutionid = Solutionid;
        ObjSolutionKeyword.Insert();
        ObjSolutionCreator.Solutionid = Solutionid;
        ObjSolutionCreator.Createdby  = objUser.Userid;
        ObjSolutionCreator.Insert();
        objSentMailToUser.SentMailToPManager(Solutionid);
        Response.Redirect("ViewSolution.aspx?solutionid" + Solutionid);
    }
    public void updatecomment()
    {
        string         userName;
        MembershipUser User = Membership.GetUser();

        solutionstatusid = Convert.ToInt16(Request.QueryString[0]);
        flag             = Convert.ToInt16(Request.QueryString[1]);
        int userid;

        if (flag == 3)
        {
            string seeionsid = Session["SolutionId"].ToString();

            string[] str = seeionsid.Split(new char[] { ',' });
            foreach (string s in str)
            {
                if (s == "")
                {
                    break;
                }
                int solid = Convert.ToInt16(s);
                ObjSolution                = ObjSolution.Get_By_id(solid);
                ObjSolution.Title          = ObjSolution.Title;
                ObjSolution.Topicid        = ObjSolution.Topicid;
                ObjSolution.Content        = ObjSolution.Content;
                ObjSolution.Comments       = txtcomments.Text;
                ObjSolution.SolutionStatus = solutionstatusid;
                ObjSolution.Update();

                userName = User.UserName.ToString();

                Objorganization = Objorganization.Get_Organization();
                objUser         = objUser.Get_UserLogin_By_UserName(userName, Objorganization.Orgid);
                ObjSolutionCreator.Solutionid   = solid;
                ObjSolutionCreator.LastUpdateBy = objUser.Userid;
                ObjSolutionCreator.Update();
            }
        }
        else
        {
            int solutionid = Convert.ToInt16(Request.QueryString[1]);

            ObjSolution                = ObjSolution.Get_By_id(solutionid);
            ObjSolution.Title          = ObjSolution.Title;
            ObjSolution.Topicid        = ObjSolution.Topicid;
            ObjSolution.Content        = ObjSolution.Content;
            ObjSolution.Comments       = txtcomments.Text;
            ObjSolution.SolutionStatus = solutionstatusid;
            ObjSolution.Update();

            userName = User.UserName.ToString();

            Objorganization = Objorganization.Get_Organization();
            objUser         = objUser.Get_UserLogin_By_UserName(userName, Objorganization.Orgid);
            ObjSolutionCreator.Solutionid   = solutionid;
            ObjSolutionCreator.LastUpdateBy = objUser.Userid;
            ObjSolutionCreator.Update();
        }
    }
Beispiel #16
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();
    }
    public void updatecomment()
    {
        string userName;
        MembershipUser User = Membership.GetUser();

        solutionstatusid = Convert.ToInt32(Request.QueryString[0]);
        flag = Convert.ToInt32(Request.QueryString[1]);
        int userid;
        if (flag == 3)
        {
            string seeionsid = Session["SolutionId"].ToString();

            string[] str = seeionsid.Split(new char[] { ',' });
            foreach (string s in str)
            {
                if (s == "")
                {
                    break;
                }
                int solid = Convert.ToInt32(s);
                ObjSolution = ObjSolution.Get_By_id(solid);
                ObjSolution.Title = ObjSolution.Title;
                ObjSolution.Topicid = ObjSolution.Topicid;
                ObjSolution.Content = ObjSolution.Content;
                ObjSolution.Comments = txtcomments.Text;
                ObjSolution.SolutionStatus = solutionstatusid;
                ObjSolution.Update();

                userName = User.UserName.ToString();

                Objorganization = Objorganization.Get_Organization();
                objUser = objUser.Get_UserLogin_By_UserName(userName, Objorganization.Orgid);
                ObjSolutionCreator.Solutionid = solid;
                ObjSolutionCreator.LastUpdateBy = objUser.Userid;
                ObjSolutionCreator.Update();
            }
        }
        else
        {
            int solutionid = Convert.ToInt32(Request.QueryString[1]);

            ObjSolution = ObjSolution.Get_By_id(solutionid);
            ObjSolution.Title = ObjSolution.Title;
            ObjSolution.Topicid = ObjSolution.Topicid;
            ObjSolution.Content = ObjSolution.Content;
            ObjSolution.Comments = txtcomments.Text;
            ObjSolution.SolutionStatus = solutionstatusid;
            ObjSolution.Update();

            userName = User.UserName.ToString();

            Objorganization = Objorganization.Get_Organization();
            objUser = objUser.Get_UserLogin_By_UserName(userName, Objorganization.Orgid);
            ObjSolutionCreator.Solutionid = solutionid;
            ObjSolutionCreator.LastUpdateBy = objUser.Userid;
            ObjSolutionCreator.Update();
        }
    }
    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();
    }
Beispiel #19
0
 protected void IncidentToAsset(int userid)
 {
     objOrganization = objOrganization.Get_Organization();
     objUser         = objUser.Get_UserLogin_By_UserName(txtUsername.Text.Trim().ToString().Trim(), objOrganization.Orgid);
     userid          = Convert.ToInt16(objUser.Userid);
     assetid         = Convert.ToInt16(objusertoasset.Get_AssetId_By_UserId(userid));
     objassetmst     = objassetmst.Get_By_id(assetid);
     compname        = objassetmst.Computername;
 }
Beispiel #20
0
    string GetUsername(int userid)
    {
        string username = "";

        objUser = objUser.Get_By_id(userid);
        if (objUser.Userid != 0)
        {
            username = objUser.Username;
        }
        return(username);
    }
    protected void BindDropSite()
    {
        string userName = "";
        MembershipUser User = Membership.GetUser();
        if (User != null)
        {
            userName = User.UserName.ToString();
        }

        if (userName != "")
        {
            int userid;
            objOrganization = objOrganization.Get_Organization();
            objUser = objUser.Get_UserLogin_By_UserName(userName, objOrganization.Orgid);
            if (objUser.Userid != 0)
            {
                userid = objUser.Userid;
                colUserToSite = ObjUserToSite.Get_All_By_userid(userid);
                foreach (UserToSiteMapping obj in colUserToSite)
                {
                    int siteid;
                    Site_mst objSite1 = new Site_mst();
                    siteid = obj.Siteid;
                    objSite1 = objSite1.Get_By_id(siteid);
                    if (objSite1.Siteid != 0)
                    {
                        colSite.Add(objSite1);
                    }

                }

            }
            drpSite.DataTextField = "sitename";
            drpSite.DataValueField = "siteid";
            drpSite.DataSource = colSite;
            drpSite.DataBind();
            ListItem item = new ListItem();
            item.Text = "-------------Select-------------";
            item.Value = "0";
            drpSite.Items.Add(item);
            drpSite.SelectedValue = "0";

            //drpSite1.DataTextField = "sitename";
            //drpSite1.DataValueField = "siteid";
            //drpSite1.DataSource = colSite;
            //drpSite1.DataBind();
            //ListItem item1= new ListItem();
            //item1.Text = "-------------Select-------------";
            //item1.Value = "0";
            //drpSite1.Items.Add(item1);
            //drpSite1.SelectedValue = "0";

        }
    }
    protected void btnapprove_Click(object sender, EventArgs e)
    {
        int userid=0;
        int incidentid = Convert.ToInt16(Session["incidentid"].ToString());
        if (incidentid != 0)
        {

            //objIncidentLog = objIncidentLog.Get_By_id(incidentid);
            //if (objIncidentLog.Incidentid != 0)
            //{
            //    objIncidentLog.Incidentid = incidentid;
            //    objIncidentLog.Incidentlog = txtcomments.Text;
            //    objIncidentLog.Update();

            //}
            //else
            //{
            //    objIncidentLog.Incidentid = incidentid;
            //    objIncidentLog.Incidentlog = txtcomments.Text;
            //    objIncidentLog.Insert();

            //}

        string userName="";
        MembershipUser User = Membership.GetUser();
        if (User != null)
        {
            userName = User.UserName.ToString();
        }

        if (userName != "")
        {

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

            objIncidentLog.Incidentid = incidentid;
            objIncidentLog.Userid = userid;
            objIncidentLog.Incidentlog = txtcomments.Text;
            objIncidentLog.Insert();

            string myScript;
            myScript = "<script language=javascript>javascript:refreshParent(); javascript:window.close();</script>";
            Page.RegisterClientScriptBlock("MyScript", myScript);

        }
    }
Beispiel #23
0
    protected void BindDropSite()
    {
        string         userName = "";
        MembershipUser User     = Membership.GetUser();

        if (User != null)
        {
            userName = User.UserName.ToString();
        }


        if (userName != "")
        {
            int userid;
            objOrganization = objOrganization.Get_Organization();
            objUser         = objUser.Get_UserLogin_By_UserName(userName, objOrganization.Orgid);
            if (objUser.Userid != 0)
            {
                userid        = objUser.Userid;
                colUserToSite = ObjUserToSite.Get_All_By_userid(userid);
                foreach (UserToSiteMapping obj in colUserToSite)
                {
                    int      siteid;
                    Site_mst objSite1 = new Site_mst();
                    siteid   = obj.Siteid;
                    objSite1 = objSite1.Get_By_id(siteid);
                    if (objSite1.Siteid != 0)
                    {
                        int custid = Convert.ToInt16(drpCustomer.SelectedValue);
                        int flag   = objCustToSite.Get_By_Id(custid, objSite1.Siteid);
                        if (flag == 1)
                        {
                            colSite.Add(objSite1);
                        }
                    }
                }
            }
            drpSite.DataTextField  = "sitename";
            drpSite.DataValueField = "siteid";
            drpSite.DataSource     = colSite;
            drpSite.DataBind();

            if (colSite.Count == 0)
            {
                ListItem item = new ListItem();
                item.Text  = "-------------Select-------------";
                item.Value = "0";
                drpSite.Items.Add(item);
            }
        }
    }
Beispiel #24
0
    protected void GetUserDetail()
    {
        string         userName = "";
        MembershipUser User     = Membership.GetUser();

        if (User != null)
        {
            userName         = User.UserName.ToString();
            txtUsername.Text = User.UserName.ToString();
        }
        if (userName != "")
        {
            int userid;
            objOrganization = objOrganization.Get_Organization();
            objUser         = objUser.Get_UserLogin_By_UserName(userName, objOrganization.Orgid);
            //objRole = objRole.Get_By_id(roleid);
            if (objUser.Userid != 0)
            {
                ContactInfo_mst objConInfo = new ContactInfo_mst();
                userid = objUser.Userid;
                IncidentToAsset(userid);
                objConInfo          = objConInfo.Get_By_id(userid);
                txtEmail.Text       = objConInfo.Emailid;
                txtassignasset.Text = compname;
                //priorityid = Convert.ToInt32(objConInfo.userpriority);
                //BindDropPriority(int priorityid);

                //ContactInfo_mst objcnt = new ContactInfo_mst();
                //if (objRole.roleid != 1)
                //{

                if (objConInfo.userpriority == 1)
                {
                    priorityid = objPriority.Get_By_PriorityName("High");
                }
                else
                {
                    priorityid = objPriority.Get_By_PriorityName("Medium");
                }
                //}
                Priority_mst objP = new Priority_mst();
                objP = objPriority.Get_By_id(priorityid);
                colPriority.Add(objP);
                drpPriority.DataTextField  = "name";
                drpPriority.DataValueField = "priorityid";
                drpPriority.DataSource     = colPriority;
                drpPriority.DataBind();
            }
        }
    }
    protected void Showvalues()
    {
        int problemid = Convert.ToInt16(Session["problemid"]);

        ObjProblem = ObjProblem.Get_By_id(problemid);
        drpTechnician.SelectedValue = ObjProblem.Technicianid.ToString();
        drpCategory.SelectedValue   = ObjProblem.Categoryid.ToString();
        BindDropSubCategory();
        drpSubcategory.SelectedValue = ObjProblem.Subcategoryid.ToString();
        drpPriority.SelectedValue    = ObjProblem.Priorityid.ToString();
        txtTitle.Text       = ObjProblem.title.ToString();
        txtDescription.Text = ObjProblem.Description.ToString();
        ObjUserLogin        = ObjUserLogin.Get_By_id(ObjProblem.Requesterid);
    }
    // Event handler btnShow_Click , To Bind Sites to Grid View on the Selected Username and Region
    protected void btnShow_Click(object sender, EventArgs e)
    {
        // Declare local Variable gvIDs,Username,organizationId and FlagStatus
        string gvIDs;
        string Username;
        int    organizationId;
        int    FlagStatus;

        lblErrorMsg.Text = "";
        // To get the Object of Organization ,to find the organization id
        objOrganization = objOrganization.Get_Organization();
        // Assign Organization Id to local variable organizationId
        organizationId = objOrganization.Orgid;
        // Assign Username from textbox to local variable Username
        Username = txtUserName.Text.ToString().Trim();
        // Get Object of UserLogin_mst Class on the basis of username and OrganizationId
        objUser = objUser.Get_UserLogin_By_UserName(Username, organizationId);
        // If Userid is not equal to Zero ,then user Exist
        if (objUser.Userid != 0)
        {
            // Bind Grid of Sites
            BindGrid();
            // To check row by row of gridview ,how many sites have been mapped to this user from table UserToSiteMapping
            foreach (GridViewRow gv in grdvwSite.Rows)
            {
                // Declare local variable deleteChkBxItem of Checkbox type to get the Checkbox Instance of Grid Row
                CheckBox deleteChkBxItem = (CheckBox)gv.FindControl("deleteRec");
                // Get the Site Id from variable of Label type declare in GridView of grdvwSite
                gvIDs = ((Label)gv.FindControl("SiteID")).Text.ToString();
                // Check if gvIDs is not null
                if (gvIDs != "")
                {
                    // Declare local variable userid and siteid to get userid and SiteId
                    int userid;
                    int siteid;
                    userid = Convert.ToInt16(objUser.Userid);
                    siteid = Convert.ToInt16(gvIDs);
                    // To Find Current Site to this User is Mapped by Calling Function objUserToSite.Get_By_Id()
                    FlagStatus = objUserToSite.Get_By_Id(userid, siteid);
                    // If FlagStatus is not zero then site is mapped to this user
                    if (FlagStatus != 0)
                    {
                        //Checked checkbox to show site is mapped to this user
                        deleteChkBxItem.Checked = true;
                    }
                }
            }
        }
    }
    protected void btnapprove_Click(object sender, EventArgs e)
    {
        /////Add Exception handilng try catch change by vishal 21-05-2012
        try
        {
            int userid = 0;
            int incidentid = Convert.ToInt32(Session["incidentid"].ToString());
            if (incidentid != 0)
            {

                string userName = "";
                MembershipUser User = Membership.GetUser();
                if (User != null)
                {
                    userName = User.UserName.ToString();
                }

                if (userName != "")
                {

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

                objIncidentLog.Incidentid = incidentid;
                objIncidentLog.Userid = userid;
                objIncidentLog.Incidentlog = txtcomments.Text;
                objIncidentLog.Insert();

                string myScript;
                myScript = "<script language=javascript>javascript:window.close();</script>";
                Page.RegisterClientScriptBlock("MyScript", myScript);

            }
        }
        catch (Exception ex)
        {
            string myScript;
            myScript = "<script language=javascript>alert('Exception - '" + ex + "');</script>";
            Page.RegisterClientScriptBlock("MyScript", myScript);
            return;
        }
    }
    protected void txtUsername_TextChanged(object sender, EventArgs e)
    {
        #region Find Userid of User who is Requesting to log a call
        objOrganization = objOrganization.Get_Organization();
        ObjUserLogin    = ObjUserLogin.Get_UserLogin_By_UserName(txtUsername.Text.ToString().Trim(), objOrganization.Orgid);
        if (ObjUserLogin.Userid == 0)
        {
            string myScript;
            myScript = "<script language=javascript>function __doPostBack(eventTarget, eventArgument){var theForm = document.forms['aspnetForm'];  if (theForm){  theForm.__EVENTTARGET.value = eventTarget;theForm.__EVENTARGUMENT.value = eventArgument;theForm.submit(); }} var Flag= confirm('User Does not Exist,Do You Want to Create User');if(Flag==true){ __doPostBack('callPostBack', 'create');}if(Flag==false){ __doPostBack('callPostBack', 'notcreate');}</script>";
            Page.RegisterClientScriptBlock("MyScript", myScript);
        }
        else
        {
            ViewState["UserCreate"] = "Exist";
        }

        #endregion
    }
Beispiel #29
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 grdvwUser_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        // Hndling GridView RowDeleting Event for deleting Row for selected UserId
        int userid;

        userid = Convert.ToInt16(grdvwUser.Rows[e.RowIndex].Cells[0].Text);
        UserLogin_mst obj = new UserLogin_mst();

        obj = ObjUserlogin.Get_By_id(userid);
        if (obj.Userid != 0)
        {
            Membership.DeleteUser(obj.Username, true);
        }

        Objcontactinfo.Delete(userid);
        ObjUserlogin.Delete(userid);

        // Bind GridView
        BindGrid();
    }
Beispiel #31
0
    public void SentMailToChangeCommittee(int changeid, int changetypeid)
    {
        string  strYourSinscerely = Resources.MessageResource.strYourSinscerely.ToString();
        string  strContactNumber  = Resources.MessageResource.strContactNumber.ToString();
        Cab_mst Objcabmember      = new Cab_mst();

        ObjChange = ObjChange.Get_By_id(changeid);

        BLLCollection <Cab_mst> colmembers     = new BLLCollection <Cab_mst>();
        UserLogin_mst           objUserCreator = new UserLogin_mst();

        int FlagUser;

        int    roleid;
        string varServerName;

        varServerName = Resources.MessageResource.serverNameForChangePage.ToString();
        // varServerName = "10.80.0.15";
        string url11;

        url11 = "http://" + varServerName + "/BEST/LoginPageAccess/ApproveorRejectChangeRequest.aspx?changeid=" + changeid;

        colmembers = Objcabmember.Get_All_By_ChangeTypeid(changetypeid);



        string url;

        foreach (Cab_mst objmember in colmembers)
        {
            url = "<a  href=" + url11 + "&userid=" + objmember.Membername + " ' onclick=window.open()>Click Here For Approval</a>";

            obj.From = Resources.MessageResource.strAdminEmail.ToString();

            obj.To         = objmember.Emailid;
            obj.Subject    = "New Change Added. Change Id : " + changeid;
            obj.Body       = "Dear Sir/Madam,<br/>A New Change has been requested.Please.<br/><br/><b>Solution Details : </b> <br/><br/><b>Changeid Id &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:</b>" + ObjChange.Changeid + "<br/><b>Title &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>" + ObjChange.Title + " <br/><b>Added By &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:</b>" + ObjChange.CreatedByID + "<br/><b>Created Date &nbsp;&nbsp;&nbsp;&nbsp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:</b>" + ObjChange.Createdtime + "<br/><b>Content&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:</b>" + ObjChange.Description + "<br/><br/>This is an auto generated mail. Please do not reply.</b><br/><br/></b><br/><b>Kindly Click the following link to Aprove or Reject the Change Request. <br></br>" + url + " <b><br/><br/><b>Yours sincerely,</b><br/> <b>" + strYourSinscerely + "</b>";
            obj.SmtpServer = Resources.MessageResource.strSMTPServer.ToString();
            obj.SentMail();
        }
    }
Beispiel #32
0
    public void SentMailToSDM(int siteid, int incidentid, int requesterid)
    {
        string strYourSinscerely = Resources.MessageResource.strYourSinscerely.ToString();
        string strContactNumber  = Resources.MessageResource.strContactNumber.ToString();
        int    FlagUser;
        string varRole = Resources.MessageResource.strSDMRole.ToString();
        int    roleid;

        roleid  = objRole.Get_By_RoleName(varRole);
        colUser = objUser.Get_All_By_Role(roleid);
        foreach (UserLogin_mst objusr in colUser)
        {
            FlagUser = objUserToSiteMapping.Get_By_Id(objusr.Userid, siteid);
            if (FlagUser != 0)
            {
                objIncident       = objIncident.Get_By_id(incidentid);
                objSite           = objSite.Get_By_id(objIncident.Siteid);
                objIncidentStates = objIncidentStates.Get_By_id(incidentid);
                objPriority       = objPriority.Get_By_id(objIncidentStates.Priorityid);

                UserLogin_mst obju   = new UserLogin_mst();
                UserLogin_mst objReq = new UserLogin_mst();
                obju      = obju.Get_By_id(objUserToSiteMapping.Userid);
                objC_info = objC_info.Get_By_id(objusr.Userid);
                objReq    = objReq.Get_By_id(requesterid);
                ContactInfo_mst objReqContInfo = new ContactInfo_mst();
                objReqContInfo = objReqContInfo.Get_By_id(objReq.Userid);

                obj.From       = Resources.MessageResource.strAdminEmail.ToString();
                obj.To         = objC_info.Emailid;
                obj.Subject    = "High Priority Call. Ticket Id: " + incidentid;
                obj.Body       = "Dear Sir/Madam,<br/>High Priority Call has been logged, please find below the Complaint  details .<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>" + objReq.Username + "<br/><b>Mail Address&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:</b>" + objReqContInfo.Emailid + "<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();
            }
        }
    }
    protected void btnSolutionAdd_Click(object sender, EventArgs e)
    {
        ///Add Exception handilng try catch change by vishal 21-05-2012
        try
        {
        string userName;
        MembershipUser User = Membership.GetUser();
        userName = User.UserName.ToString();
        int userid;
        objOrganization = objOrganization.Get_Organization();
        objUser = objUser.Get_UserLogin_By_UserName(userName, objOrganization.Orgid);

        int Solutionid;
        ObjSolution.Title = txtTitle.Text.ToString();
        ObjSolution.Content=Editor.Text.ToString();
        ObjSolution.Topicid = Convert.ToInt32(drpTopic.SelectedValue);
        ObjSolution.Solution = drpSolutionType.SelectedValue;
        ObjSolution.Insert();
        Solutionid = ObjSolutionKeyword.Get_SolutionId();
        ObjSolutionKeyword.Keywords=txtKeywords.Text.ToString();
        ObjSolutionKeyword.Solutionid = Solutionid;
        ObjSolutionKeyword.Insert();
        ObjSolutionCreator.Solutionid = Solutionid;
        ObjSolutionCreator.Createdby = objUser.Userid;
        ObjSolutionCreator.Insert();
        objSentMailToUser.SentMailToPManager(Solutionid);
        Response.Redirect("ViewSolution.aspx?solutionid" + Solutionid);
         }
        catch (Exception ex)
        {
            string myScript;
            myScript = "<script language=javascript>alert('Exception - '" + ex + "');</script>";
            Page.RegisterClientScriptBlock("MyScript", myScript);
            return;
        }
    }
Beispiel #34
0
    protected void Bindgrid()
    {
        #region Declaration of localvariable and table Variable
        int       filterId;
        DataTable dtTable = new DataTable();
        dtTable = CreateDataTable();
        string userName         = "";
        int    varTechnicianId  = 0;
        string varSortParameter = "createdatetime";

        #endregion

        #region Get Current User and his Role
        MembershipUser User              = Membership.GetUser();
        string         varUserRole       = "";
        string         varRoleTechnician = "";
        if (User != null)
        {
            userName = User.UserName.ToString();
            string[] arrUserRole = Roles.GetRolesForUser();
            varUserRole       = arrUserRole[0].ToString();
            varRoleTechnician = Resources.MessageResource.strTechnicianRole.ToString();
        }
        #endregion

        #region Get User object  by Calling Function Get_UserLogin_By_UserName() via passing parameter username and organizationid
        objOrganization = objOrganization.Get_Organization();
        objUser         = objUser.Get_UserLogin_By_UserName(userName, objOrganization.Orgid);
        #endregion


        #region If User Exist
        if (objUser.Userid != 0)
        {
            string fromdate = null;
            string todate   = null;

            #region Find how many sites have been mapped to current user by calling function Get_All_By_userid() via passing parameter userid
            int userid = objUser.Userid;
            colUserToSite = ObjUserToSite.Get_All_By_userid(userid);
            #endregion
            #region Fetch each object from Collection of UserToSiteMapping
            foreach (UserToSiteMapping obj in colUserToSite)
            {
                #region Declare Local Variables and Collection of Incident_mst Type
                string Status;
                BLLCollection <Incident_mst> col = new BLLCollection <Incident_mst>();
                int siteid;
                #endregion
                #region Get the Siteid and Filter Parameter
                siteid   = obj.Siteid;
                filterId = 0;
                #endregion

                #region If Role of User is Technician



                #region If Filter Variable is All
                if (filterId == 0)
                {
                    col = objIncident.Get_All_By_Siteid_Requesterid(siteid, objUser.Userid, fromdate, todate, varSortParameter);
                }
                #endregion



                #endregion



                #region Fetch Each object of type Incident_mst from Collection Incident_mst
                foreach (Incident_mst objInc in col)
                {
                    #region Create Table row and assign value to it
                    DataRow row;
                    row = dtTable.NewRow();
                    row["incidentid"]     = Convert.ToString(objInc.Incidentid);
                    row["title"]          = objInc.Title;
                    row["requesterid"]    = Convert.ToString(objInc.Requesterid);
                    row["createdbyid"]    = Convert.ToString(objInc.Createdbyid);
                    row["siteid"]         = Convert.ToString(objInc.Siteid);
                    row["createdatetime"] = Convert.ToString(objInc.Createdatetime);
                    objIncidentStates     = objIncidentStates.Get_By_id(objInc.Incidentid);
                    row["statusid"]       = objIncidentStates.Statusid;
                    row["technicianid"]   = objIncidentStates.Technicianid;
                    row["priorityid"]     = objIncidentStates.Priorityid;
                    dtTable.Rows.Add(row);
                    #endregion
                }
                #endregion
            }
            #endregion
            #region Bind Grid from datasource dtTable
            DataView dvData        = new DataView(dtTable);
            string   sortFormat    = "{0} {1}";
            String   sortDirection = "DESC";
            if (varSortParameter == "createdatetime")
            {
                varSortParameter = "incidentid";
            }
            dvData.Sort = String.Format(sortFormat, varSortParameter, sortDirection);



            grdvwRequest.DataSource = dvData;
            grdvwRequest.DataBind();
            #endregion
        }
        #endregion
    }
    //#region Handle Button btnAssigned Click Event
    //protected void btnAssigned_Click(object sender, EventArgs e)
    //{
    //    #region Fetch Each Row from GridView,and Check Which Check Box is Selected
    //    foreach (GridViewRow gv in grdvwRequest.Rows)
    //    {
    //        string gvIDs;
    //        #region Declare local variable deleteChkBxItem of Checkbox type to get the Checkbox Instance of Grid Row
    //         CheckBox deleteChkBxItem = (CheckBox)gv.FindControl("deleteRec");
    //        #endregion
    //        #region If deleteChkBxItem is Checked then ,mapped Current site to this user
    //         if (deleteChkBxItem.Checked)
    //        {
    //            #region Declare local Variables
    //            int incidentid;
    //            int varSiteid;
    //            int oldtechnicianvalue;
    //            #endregion
    //            #region Get the Incident Id from variable of Label type declare in GridView of grdvwSite
    //              gvIDs = ((Label)gv.FindControl("incidentid")).Text.ToString();
    //            #endregion
    //            #region Convert to incident id into integer
    //              incidentid = Convert.ToInt32(gvIDs);
    //              #endregion
    //            #region If Incident id in Not Null
    //            if (gvIDs != "")
    //            {
    //                Incident_mst objInc = new Incident_mst();
    //                IncidentStates objIncSta = new IncidentStates();
    //                objIncSta = objIncSta.Get_By_id(incidentid);
    //                if (objIncSta.Incidentid != 0)
    //                {
    //                    oldtechnicianvalue = objIncSta.Technicianid;
    //                    int technicianid=Convert.ToInt32(drpTechnician1.SelectedValue);
    //                    if(technicianid!=0)
    //                    {
    //                     int userid = Convert.ToInt32(ViewState["Userid"].ToString());
    //                    #region Update into IncidentStates Table
    //                     objIncidentStates.Incidentid = incidentid;
    //                    objIncidentStates.Technicianid = technicianid;
    //                    objIncidentStates.Subcategoryid = objIncSta.Subcategoryid;
    //                    objIncidentStates.Statusid = objIncSta.Statusid;
    //                    objIncidentStates.Requesttypeid = objIncSta.Requesttypeid;
    //                    objIncidentStates.Priorityid = objIncSta.Priorityid;
    //                    objIncidentStates.Categoryid = objIncSta.Categoryid;
    //                    objIncidentStates.AssignedTime = objIncSta.AssignedTime;
    //                    objIncidentStates.Update();
    //                     #endregion
    //                    #region Insert into IncidentHistory Table
    //                    objIncidentHistory.Incidentid = incidentid;
    //                    objIncidentHistory.Operationownerid = userid;
    //                    objIncidentHistory.Operation = "update";
    //                    objIncidentHistory.Insert();
    //                    #endregion
    //                    #region Get the Current historyid by calling function Get_Current_IncidentHistoryid()
    //                    int  historyid = objIncidentHistory.Get_Current_IncidentHistoryid();
    //                    #endregion
    //                   #region If technician value is changed,Insert into IncidentHistoryDiff table
    //                    #region Declare Local variables
    //                        string columnName;
    //                        string prev_value;
    //                        string curnt_value;
    //                    #endregion
    //                    #region Get Column Name from MessageResource File
    //                        columnName = Resources.MessageResource.strColumnTechnicianid.ToString();
    //                        #endregion
    //                       prev_value = Convert.ToString(oldtechnicianvalue);
    //                       curnt_value = Convert.ToString(drpTechnician1.SelectedValue);
    //                       objIncidentHistoryDiff.Historyid = historyid;
    //                       objIncidentHistoryDiff.Columnname = columnName;
    //                       objIncidentHistoryDiff.Current_value = curnt_value;
    //                       objIncidentHistoryDiff.Prev_value = prev_value;
    //                       objIncidentHistoryDiff.Insert();
    //                       if (objIncSta.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 = objIncSta.AssignedTime;
    //                           curnt_value = DateTime.Now.ToString();
    //                           objIncidentHistoryDiff.Historyid = historyid;
    //                           objIncidentHistoryDiff.Columnname = columnName;
    //                           objIncidentHistoryDiff.Current_value = curnt_value;
    //                           objIncidentHistoryDiff.Prev_value = prev_value;
    //                           objIncidentHistoryDiff.Insert();
    //                       }
    //                   #endregion
    //                       objInc = objIncident.Get_By_id(incidentid);
    //                       if (objInc.Siteid != Convert.ToInt32(drpSite1.SelectedValue))
    //                       {
    //                           int oldsiteid = objInc.Siteid;
    //                           int oldslaid = objInc.Slaid;
    //                           objInc.Siteid = Convert.ToInt32(drpSite1.SelectedValue);
    //                           int SLAid = objIncident.Get_By_SLAid(Convert.ToInt32(drpSite1.SelectedValue), objIncSta.Priorityid );
    //                           int requesttypeid = Convert.ToInt32(Resources.MessageResource.strRequestTypeId.ToString());
    //                           if (requesttypeid == Convert.ToInt32(objIncSta.Requesttypeid ))
    //                           {
    //                               SLAid = 0;
    //                           }
    //                           objInc.Slaid = SLAid;
    //                           objInc.Active = true;
    //                           objInc.Update();
    //                           #region If site value is changed,Insert into IncidentHistoryDiff table
    //                           columnName = Resources.MessageResource.strColumnSiteid.ToString();
    //                           prev_value = Convert.ToString(oldsiteid);
    //                           curnt_value = drpSite1.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
    //                           columnName = Resources.MessageResource.strColumnSLAid.ToString();
    //                           prev_value = Convert.ToString(oldslaid);
    //                           curnt_value = Convert.ToString(SLAid);
    //                           objIncidentHistoryDiff.Historyid = historyid;
    //                           objIncidentHistoryDiff.Columnname = columnName;
    //                           objIncidentHistoryDiff.Current_value = curnt_value;
    //                           objIncidentHistoryDiff.Prev_value = prev_value;
    //                           objIncidentHistoryDiff.Insert();
    //                           #endregion
    //                       }
    //                    }
    //                }
    //                varSiteid = Convert.ToInt32(drpSite.SelectedValue);
    //                if (varSiteid == 0)
    //                { BindGridForAllParameter(); }
    //                else { BindGridForSelectedParameter(); }
    //            }
    //            #endregion
    //        }
    //         #endregion
    //    }
    //    #endregion
    //}
    //#endregion
    protected void BindSelectedFilter()
    {
        string keyword = Session["keyword"].ToString();
        string Filterid = Session["Filterid"].ToString();
        string userName = "";
        MembershipUser User = Membership.GetUser();
        if (User != null)
        {
            userName = User.UserName.ToString();
        }
        objOrganization = objOrganization.Get_Organization();
        objUser = objUser.Get_UserLogin_By_UserName(userName, objOrganization.Orgid);
        string Uid = objUser.Userid.ToString();

        #region Declaration of localvariable and table Variable
        DataTable dtTable = new DataTable();
        dtTable = CreateDataTable();

        #endregion
        BLLCollection<Incident_mst> col = new BLLCollection<Incident_mst>();
        col = objIncident.Get_All_Incidentid_By_SearchParameter(Filterid, keyword,Uid);
        #region Create Table row and assign value to it
        foreach (Incident_mst obj in col)
        {
            IncidentStates objS = new IncidentStates();
            DataRow row;
            row = dtTable.NewRow();
            row["incidentid"] = Convert.ToString(obj.Incidentid);
            row["title"] = obj.Title;
            row["requesterid"] = Convert.ToString(obj.Requesterid);
            row["createdbyid"] = Convert.ToString(obj.Createdbyid);
            row["siteid"] = Convert.ToString(obj.Siteid);
            row["createdatetime"] = Convert.ToString(obj.Createdatetime);
            objS = objS.Get_By_id(obj.Incidentid);
            row["statusid"] = objS.Statusid;
            row["technicianid"] = objS.Technicianid;
            row["priorityid"] = objS.Priorityid;
            dtTable.Rows.Add(row);
        }
        #endregion

        grdvwRequest.DataSource = dtTable;
        grdvwRequest.DataBind();
        Session.Remove("Filterid");
        Session.Remove("keyword");
        ViewState["keyword"] = keyword;
        ViewState["Filterid"] = Filterid;
    }
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        bool FlagUserStatus = true;
        #region Find Userid of User who is Requesting to log a call

        #region If User Already Exist
        if (ViewState["UserCreate"].ToString() == "Exist")
        {
            objOrganization = objOrganization.Get_Organization();
            ObjUserLogin = ObjUserLogin.Get_UserLogin_By_UserName(txtUsername.Text.ToString().Trim(), objOrganization.Orgid);
            if (ObjUserLogin.Userid != 0)
            {
                requesterid = ObjUserLogin.Userid;
            }
        }
        #endregion
        #region If New User is to be Created
        else if (ViewState["UserCreate"].ToString() == "create")
        {
            string varEmail = "";
            string varRoleName = Resources.MessageResource.BasicUserRole.ToString();
            if (txtEmail.Text == "")
            {
                varEmail = Resources.MessageResource.errMemshipCreateUserEmail.ToString();
            }
            else
            {
                varEmail = txtEmail.Text;
            }

            int roleid = objRole.Get_By_RoleName(varRoleName);
            int status;
            objOrganization = objOrganization.Get_Organization();

            objuser.Username = txtUsername.Text.ToString();
            objuser.Password = Resources.MessageResource.strDefaultPassword.ToString();
            objuser.Roleid = roleid;
            objuser.Orgid = objOrganization.Orgid;
            objuser.ADEnable = false;
            objuser.Enable = true;
            objuser.Createdatetime = DateTime.Now.ToString();
            status = objuser.Insert();
            if (status == 1)
            {
                // Create Mstatus field to send in Membership.CreateUser function as Out Variable for creating Membership User database
                MembershipCreateStatus Mstatus = default(MembershipCreateStatus);
                // Call Membership.CreateUser function to create Membership user
                Membership.CreateUser(txtUsername.Text.ToString().Trim(), Resources.MessageResource.strDefaultPassword.ToString(), varEmail, "Project Name", "Helpdesk", true, out Mstatus);
                // Call Roles.AddUserToRole Function to Add User To Role
                Roles.AddUserToRole(txtUsername.Text.ToString().Trim(), varRoleName);
                // Declare Local Variable Userid to fetch userid of newly created user

                // Create Object objUserLogin of UserLogin_mst()Class
                objuser = new UserLogin_mst();
                // Fetch userid of Newly created user and assign to local variable userid by calling function objUserLogin.Get_By_UserName
                requesterid = objuser.Get_By_UserName(txtUsername.Text.ToString().Trim(), objOrganization.Orgid);
                // If userid not equal to 0 then we get userid of Newly created user otherwise error Occured

                ContactInfo_mst objContactInfo = new ContactInfo_mst();
                objContactInfo.Userid = requesterid;
                objContactInfo.Emailid = varEmail;
                objContactInfo.Firstname = txtUsername.Text.ToString();
                objContactInfo.Lastname = txtUsername.Text.ToString();
                objContactInfo.Insert();

            }
        }
        #endregion
        #region If User is Not to be Created
        else if (ViewState["UserCreate"].ToString() == "notcreate")
        {
            FlagUserStatus = false;

        }
        #endregion

        #endregion

        MembershipUser User = Membership.GetUser();
        string userName;
        userName = User.UserName.ToString();
        if (FlagUserStatus == true)
        {

            objOrganization = objOrganization.Get_Organization();
            objuser = objuser.Get_UserLogin_By_UserName(userName, objOrganization.Orgid);
            ObjProblem.CreatedByid = objuser.Userid;
            ObjProblem.Requesterid = requesterid;
            ObjProblem.Categoryid = Convert.ToInt16(drpCategory.SelectedValue);
            ObjProblem.Subcategoryid = Convert.ToInt16(drpSubcategory.SelectedValue);

            ObjProblem.Priorityid = Convert.ToInt16(drpPriority.SelectedValue);
            ObjProblem.Statusid = Convert.ToInt16(drpStatus.SelectedValue);
            ObjProblem.Technicianid = Convert.ToInt16(drpTechnician.SelectedValue);
            ObjProblem.title = txtTitle.Text;
            ObjProblem.Description = txtDescription.Text;
            if (Convert.ToInt16(drpTechnician.SelectedValue) != 0)
            {
                ObjProblem.AssginedTime = DateTime.Now.ToString();
            }

            ObjProblem.Insert();
            int problemid = ObjProblem.Get_Current_Problemid();

            ObjProblemHistory.Operationtime = DateTime.Now.ToString();
            ObjProblemHistory.Problemid = problemid;
            ObjProblemHistory.Operation = "create";
            ObjProblemHistory.Operationownerid = objuser.Userid;
            if (Session["IncidentToProblem"] != null)
            {
                int incidentid = Convert.ToInt16(Session["IncidentToProblem"].ToString());
                Incident_To_Problem objIncToprob = new Incident_To_Problem();
                objIncToprob.Incidentid = incidentid;
                objIncToprob.Problemid = problemid;
                objIncToprob.Insert();

            }
            if (Convert.ToInt16(drpTechnician.SelectedValue) != 0)
            {
                objSentMailToUser.SentMailToTechnicianForProblemCall(problemid, Convert.ToInt16(drpTechnician.SelectedValue));

            }

            ObjProblemHistory.Insert();
            //ResetControls();

            string myScript;
            myScript = "<script language=javascript>javascript:window.close();</script>";
            Page.RegisterClientScriptBlock("MyScript", myScript);

        }
    }
Beispiel #37
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
        }
    }
 string GetUsername(int userid)
 {
     string username = "";
     objUser = objUser.Get_By_id(userid);
     if (objUser.Userid != 0)
     {
         username = objUser.Username;
     }
     return username;
 }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        // Save User to Database on Button Save click Event
        // Start
        objOrganization = objOrganization.Get_Organization();
            //Declare Local Variables - Flag,varRolename,FlagMembership
              int Flag;
              string varRoleName;
              bool FlagMembership;
              // Use Asp.Net Membership Validator Control Membership.ValidateUser to check User Exist in aspnet Database
                 FlagMembership = Membership.ValidateUser(txtUserName.Text.ToString().Trim(), txtPassword.Text.ToString().Trim());

             //  Create Object of UserLogin_mst Class to Check User Exist in Database UserLogin_mst table
                  UserLogin_mst objUserLogin = new UserLogin_mst();
             //  Declare local Variable Flag to Check Status User Exist in databse
                  Flag = objUserLogin.Get_By_UserName(txtUserName.Text.ToString().Trim(), objOrganization.Orgid );
             //  If User Does'nt exist in Database and in aspnet databse then flag value will 0 and FlagMembership value will be False
                 if (Flag == 0 && FlagMembership==false)
                {
                    // Declare status local variable
                    int status;
                    // Create Object objUserLogin of UserLogin_mst() Class to insert record in table
                    objUserLogin = new UserLogin_mst();
                    objUserLogin.Username = txtUserName.Text.ToString().Trim();
                    objUserLogin.Password = txtPassword.Text.ToString().Trim();
                    objUserLogin.Roleid = Convert.ToInt16(dropRole.SelectedValue);
                    objUserLogin.Orgid = objOrganization.Orgid ;
                    objUserLogin.ADEnable = false;
                    objUserLogin.Enable = true;
                    objUserLogin.Createdatetime = DateTime.Now.ToString();
                    // Call Insert function to insert record in UserLogin_mst table
                    // Check status whether Record inserted Successfully or Not,If status=1 then Success otherwise Operation Fail
                       status = objUserLogin.Insert();
                       if (status == 1)
                       {
                           // Declare local variable varEmail to fetch email of user from textbox
                              string varEmail;
                           //If Email field is Not Empty then Assign value to varEmail Local Variable
                           if (txtEmailId.Text != "")
                           {
                               varEmail = txtEmailId.Text.Trim();
                           }
                           // Else Assign value define in MessagesResources.resx file in errMemshipCreateUserEmail field
                           else
                           {
                               varEmail = Resources.MessageResource.errMemshipCreateUserEmail.ToString();
                           }
                           // Assign selected text from droprole down to  local variable field varRoleName
                           varRoleName = dropRole.SelectedItem.Text.ToString().Trim();
                           // Create Mstatus field to send in Membership.CreateUser function as Out Variable for creating Membership User database
                              MembershipCreateStatus Mstatus = default(MembershipCreateStatus);
                              // Call Membership.CreateUser function to create Membership user
                                 Membership.CreateUser(txtUserName.Text.ToString().Trim(), txtPassword.Text.ToString().Trim(), varEmail, "Project Name", "Helpdesk", true, out Mstatus);
                                // Call Roles.AddUserToRole Function to Add User To Role
                                Roles.AddUserToRole(txtUserName.Text.ToString().Trim(), varRoleName);
                                // Declare Local Variable Userid to fetch userid of newly created user
                                int userid;
                                // Create Object objUserLogin of UserLogin_mst()Class
                                  objUserLogin = new UserLogin_mst();
                                  // Fetch userid of Newly created user and assign to local variable userid by calling function objUserLogin.Get_By_UserName
                                  userid = objUserLogin.Get_By_UserName(txtUserName.Text.ToString().Trim(), objOrganization.Orgid );
                                  // If userid not equal to 0 then we get userid of Newly created user otherwise error Occured
                                    UserToSiteMapping objusertositemapping = new UserToSiteMapping();
                                    if (userid != 0)
                                    {
                                        // Create Object objContactInfo of ContactInfo_mst class to Store User Contact Information in Contact_info table
                                        ContactInfo_mst objContactInfo = new ContactInfo_mst();
                                        objContactInfo.Userid = userid;
                                        objContactInfo.Firstname = txtFname.Text.ToString().Trim();
                                        objContactInfo.Lastname = txtLname.Text.ToString().Trim();
                                        objContactInfo.Description = txtDesc.Text.ToString().Trim();
                                        objContactInfo.Empid = txtEmpId.Text;
                                        objContactInfo.Emailid = txtEmailId.Text.ToString().Trim();
                                        objContactInfo.Landline = txtLandline.Text.ToString().Trim();
                                        objContactInfo.Mobile = txtMobile.Text.ToString().Trim();
                                        objContactInfo.Siteid = Convert.ToInt16(DrpSite.SelectedValue);

                                        //if (DrpDepartment.SelectedItem.ToString() != null)
                                        //{
                                            objContactInfo.Deptid = Convert.ToInt16(DrpDepartment.SelectedValue);
                                        //}

                                        // Call objContactInfo.Insert function to Insert record in Contact_info table
                                        objContactInfo.Insert();
                                        // Show Message Operation perform successfully
                                           //lblMessage.Text = Resources.MessageResource.errDataSave.ToString();
                                        // Calling Function Clear() to Clear all controls on Form
                                           objusertositemapping.Userid = userid;
                                           objusertositemapping.Siteid = Convert.ToInt16(DrpSite.SelectedValue);
                                           objusertositemapping.Insert();
                                          Clear();
                                          Response.Redirect("~/admin/ViewUser.aspx");

                                    }
                                    else
                                    {
                                        // Show Message Error Occured due to some Reason
                                        lblMessage.Text = Resources.MessageResource.errOccured.ToString();
                                    }

                       }
                       else
                       {
                           // Show Message Error Occured due to some Reason
                           lblMessage.Text = Resources.MessageResource.errOccured.ToString();
                       }

               }
              else
               {
                   // Show Message User Already Exist
                lblMessage.Text = Resources.MessageResource.errUserExist.ToString();

               }

           // End Save button Click
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        //Add Exception handilng try catch change by vishal 21-05-2012
        try
        {
            string strStatusClose = Resources.MessageResource.strStatusClose.ToString().Trim();
            string statusString = "";
            int problemid = Convert.ToInt32(Request.QueryString[0]);
            ObjProbelm = ObjProbelm.Get_By_id(problemid);
            objrootcause = objrootcause.Get_By_id(problemid);
            objimpact = objimpact.Get_By_id(problemid);
            objstatus = objstatus.Get_By_id(ObjProbelm.Statusid);
            statusString = objstatus.Statusname.ToString();
            if (statusString.ToLower() == strStatusClose.ToLower())
            {

                string ii = objimpact.Description.ToString();
                string stripped4 = Regex.Replace(ii, @"<(.|\n)*?>", string.Empty);
                lblserviceeffected.Text = objimpact.Description.ToString();
                string rr = objrootcause.Description.ToString();
                string stripped1 = Regex.Replace(rr, @"<(.|\n)*?>", string.Empty);
                lblcause.Text = stripped1.ToString();
                objproblemsysmptom = objproblemsysmptom.Get_By_id(problemid);
                string ss = objproblemsysmptom.Description.ToString();
                string stripped3 = Regex.Replace(ss, @"<(.|\n)*?>", string.Empty);
                lblsymptom.Text = stripped3.ToString();
                lbltcktno.Text = ObjProbelm.ProblemId.ToString();
                lblcreatedate.Text = ObjProbelm.CreateDatetime.ToString();
                if (ObjProbelm.AssginedTime != null)
                {
                    lblstarttime.Text = ObjProbelm.AssginedTime.ToString();
                }
                lblendtime.Text = ObjProbelm.Closedatetime.ToString();
                Objcategory = Objcategory.Get_By_id(ObjProbelm.Categoryid);

                lblcomponenteffected.Text = Objcategory.CategoryName.ToString();
                lbldescription.Text = ObjProbelm.title.ToString();
                objproblemtosolution = objproblemtosolution.Get_By_id(ObjProbelm.ProblemId);
                Objsolution = Objsolution.Get_By_id(objproblemtosolution.Solutionid);
                string bb = Objsolution.Solution.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(ObjProbelm.Requesterid);
                lblcustomer.Text = objUser.Username.ToString();
                objUser = objUser.Get_By_id(ObjProbelm.Technicianid);
                lblengineer.Text = objUser.Username.ToString();
                lblrcaresult.Text = "Completed";
            }
            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();

        }
        catch (Exception ex)
        {
            string myScript;
            myScript = "<script language=javascript>alert('Exception - '" + ex + "');</script>";
            Page.RegisterClientScriptBlock("MyScript", myScript);
            return;
        }
    }
    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;
        }
    }
    //protected void btngetuser_Click(object sender, EventArgs e)
    //{
    //    lblErrorMsg.Text = "";
    //    string Username = txtusername.Text.ToString().Trim();
    //    objUser = objUser.Get_UserLogin_By_UserName_Like(Username);
    //    if (objUser.Userid != 0)
    //    {
    //        txtusername.Text = objUser.Username.ToString().Trim();
    //        userid = objUser.Userid;
    //    }
    //    else
    //    {
    //        txtusername.Text = "";
    //    }
    //}
    //protected void btnshow_Click(object sender, EventArgs e)
    //{
    //    lblErrorMsg.Text = "";
    //    string Username = txtusername.Text.ToString().Trim();
    //    objUser = objUser.Get_UserLogin_By_UserName_Like(Username);
    //    userid = objUser.Userid;
    //    int assid=Convert.ToInt32(objusertoasset.Get_AssetId_By_UserId(userid));
    //    int usercount = objusertoasset.Get_UserId_From_UserToAssetMap(userid);
    //    col = ObjAsset.Get_Assetdetails_By_Assetid(assid);
    //    grdvwViewAsset.DataSource = col;
    //    grdvwViewAsset.DataBind();
    //    foreach (GridViewRow gv in grdvwViewAsset.Rows)
    //    {
    //        RadioButton selectonebutton = (RadioButton)gv.FindControl("selectone");
    //        selectonebutton.Checked = true;
    //    }
    //}
    protected void btnMapped_Click(object sender, EventArgs e)
    {
        /////Add Exception handilng try catch change by vishal 21-05-2012
        try
        {
            lblErrorMsg.Text = "";
            int flag = 0;

            foreach (GridViewRow gv in grdvwViewAsset.Rows)
            {
                string gvIDs;
                RadioButton selectonebutton = (RadioButton)gv.FindControl("selectone");
                if (selectonebutton.Checked)
                {
                    flag = 1;
                    int assetid;
                    gvIDs = ((Label)gv.FindControl("lblAssetID")).Text.ToString();
                    assetid = Convert.ToInt32(gvIDs);

                    string Username = txtusername.Text.ToString().Trim();
                    objUser = objUser.Get_UserLogin_By_UserName_Like(Username);
                    //objcontactinfo = objcontactinfo.Get_By_id(objUser.Userid); //added by lalit 24 feb 2012
                    userid = objUser.Userid;
                    if (txtusername.Text == "")
                    {
                        lblErrorMsg.Text = "Enter the user name for mapped a particular Asset";
                        break;
                    }
                    else if (userid == 0)
                    {
                        lblErrorMsg.Text = "User Name doesn't  exist";
                        break;
                    }
                    else
                    {
                        assetcount = objusertoasset.Get_AssetId_From_UserToAssetMap(assetid);
                        usercount = objusertoasset.Get_UserId_From_UserToAssetMap(userid);
                        assetlocation = objUser.City;  //added by lalit 24 feb 2012
                        companyname = objUser.Company;
                        if (assetcount == 0)
                        {
                            if (usercount == 0)
                            {
                                objusertoasset.Insert(userid, assetid, assetlocation, companyname);  //added a new field siteid on 24 feb.
                                lblErrorMsg.Text = "Asset Mapped Successfully to the Current User";
                                break;
                            }
                            else
                            {
                                int oldassetid = Convert.ToInt32(objusertoasset.Get_AssetId_By_UserId(userid));
                                objusertoasset.Update_Assetid(oldassetid, assetid, assetlocation, companyname);
                                lblErrorMsg.Text = "Asset Mapped Successfully to the Current User";
                                break;
                            }
                        }
                        else
                        {
                            lblErrorMsg.Text = "Asset already Mapped";
                            break;
                        }
                    }
                }

            }
            if (flag == 0)
            {
                lblErrorMsg.Text = "Select Asset for mapping";
            }
        }
        catch (Exception ex)
        {
            string myScript;
            myScript = "<script language=javascript>alert('Exception - '" + ex + "');</script>";
            Page.RegisterClientScriptBlock("MyScript", myScript);
            return;
        }
    }
    protected void BindDropTechnician()
    {
        objRole = objRole.Get_RoleInfo_By_RoleName("technician");
        if (objRole.Roleid != 0)
        {
            int siteid = 0;
            int roleid;
            if (drpSite.SelectedValue != "") { siteid = Convert.ToInt32(drpSite.SelectedValue); }

            roleid = objRole.Roleid;
            if (siteid != 0 && roleid != 0)
            {
                colUser = objUser.Get_All_By_Role_Site(roleid, siteid);
                //meenakshi
                for (int i = 0; i < colUser.Count; i++)
                {
                    for (int j = i; j < colUser.Count; j++)
                    {

                        if (String.Compare(colUser[i].Username, colUser[j].Username) > 0)
                        {
                            UserLogin_mst obj = new UserLogin_mst();
                            obj = colUser[i];
                            colUser[i] = colUser[j];
                            colUser[j] = obj;

                        }
                    }

                }
                //end
                drpTechnician.DataTextField = "username";
                drpTechnician.DataValueField = "userid";
                drpTechnician.DataSource = colUser;
                drpTechnician.DataBind();
                ListItem item = new ListItem();
                item.Text = "All";
                item.Value = "0";
                drpTechnician.Items.Add(item);
                //item.Text = "-----------Select-----------";
                //item.Value = "0";
                //drpTechnician.Items.Add(item);
                drpTechnician.SelectedValue = "0";

            }
            else
            {

                colUser = objUser.Get_All_By_Role_Site(roleid, siteid);
                //meenakshi
                for (int i = 0; i < colUser.Count; i++)
                {
                    for (int j = i; j < colUser.Count; j++)
                    {

                        if (String.Compare(colUser[i].Username, colUser[j].Username) > 0)
                        {
                            UserLogin_mst obj = new UserLogin_mst();
                            obj = colUser[i];
                            colUser[i] = colUser[j];
                            colUser[j] = obj;

                        }
                    }

                }
                //end
                drpTechnician.DataTextField = "username";
                drpTechnician.DataValueField = "userid";
                drpTechnician.DataSource = colUser;
                drpTechnician.DataBind();
                ListItem item = new ListItem();
                item.Text = "All";
                item.Value = "0";
                drpTechnician.Items.Add(item);
                //item.Text = "-----------Select-----------";
                //item.Value = "0";
                //drpTechnician.Items.Add(item);
                drpTechnician.SelectedValue = "0";

            }

        }
    }
    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();
    }
    protected void BindGridForAllParameter()
    {
        #region Declaration of localvariable and table Variable
        int filterId;
        DataTable dtTable = new DataTable();
        dtTable = CreateDataTable();
        string userName = "";
        int varTechnicianId = 0;
        if (drpTechnician.SelectedValue != "") { varTechnicianId = Convert.ToInt32(drpTechnician.SelectedValue); }

        string varSortParameter = "";
        varSortParameter = drpSort.SelectedValue;
        if (varSortParameter == "0")
        { varSortParameter = "createdatetime"; }
        #endregion
        #region Get Current User and his Role
        MembershipUser User = Membership.GetUser();
        string varUserRole = "";
        string varRoleTechnician = "";
        if (User != null)
        {
            userName = User.UserName.ToString();

            string[] arrUserRole = Roles.GetRolesForUser();
            varUserRole = arrUserRole[0].ToString();
            varRoleTechnician = Resources.MessageResource.strTechnicianRole.ToString();

        }
        #endregion
        #region Get User object  by Calling Function Get_UserLogin_By_UserName() via passing parameter username and organizationid
        objOrganization = objOrganization.Get_Organization();
        objUser = objUser.Get_UserLogin_By_UserName(userName, objOrganization.Orgid);
        #endregion
        #region if UserExist
        if (objUser.Userid != 0)
        {
            ViewState["Userid"] = objUser.Userid;
            string fromdate = null;
            string todate = null;
            if (ViewState["fromdate"] != null)
            {
                fromdate = ViewState["fromdate"].ToString();
            }
            if (ViewState["todate"] != null)
            {
                todate = ViewState["todate"].ToString();
            }
            if (fromdate == "")
            { fromdate = null; }
            if (todate == "")
            { todate = null; }
            #region Declare Local Variables and Collection of Incident_mst Type
            string Status;

            //            int siteid;
            #endregion
            #region Get the Siteid and Filter Parameter
            //siteid = obj.Siteid;
            filterId = Convert.ToInt32(drpFilter.SelectedValue);
            #endregion
            #region If Role of User is Technician
            if (varUserRole == varRoleTechnician)
            {
                lblTechnician.Visible = false;
                drpTechnician.Visible = false;
                //lblTechnician1.Visible = false;
                //drpTechnician1.Visible = false;
                //btnAssigned.Visible = false;
                #region If Filter Variable is All
                if (filterId == 0)
                {
                    //  col = objIncident.Get_All_By_Siteid_Technicianid(siteid, objUser.Userid, fromdate, todate, varSortParameter);

                }
                #endregion
                #region If Filter Variable is Requested
                else if (filterId == 1)
                {

                    Status = Resources.MessageResource.strChangestatusrequested.ToString();
                    int statusid;

                    statusid = ObjChangeStatus.Get_By_StatusName(Status);

                    col = ObjChange.Get_All_By_Statusid_technicianid(statusid, objUser.Userid, fromdate, todate, varSortParameter);
                }

                #endregion
                #region If Filter Variable is Approval
                else if (filterId == 2)
                {

                    Status = Resources.MessageResource.StrApproval.ToString();
                    int statusid;

                    statusid = ObjChangeStatus.Get_By_StatusName(Status);

                    col = ObjChange.Get_All_By_Statusid_technicianid(statusid, objUser.Userid, fromdate, todate, varSortParameter);
                }

                #endregion
                #region If Filter Variable is Approval
                else if (filterId == 3)
                {

                    Status = Resources.MessageResource.StrApproved.ToString();
                    int statusid;

                    statusid = ObjChangeStatus.Get_By_StatusName(Status);

                    col = ObjChange.Get_All_By_Statusid_technicianid(statusid, objUser.Userid, fromdate, todate, varSortParameter);
                }

                #endregion
                #region If Filter Variable is Rejected
                else if (filterId == 4)
                {

                    Status = Resources.MessageResource.StrRejected.ToString();
                    int statusid;

                    statusid = ObjChangeStatus.Get_By_StatusName(Status);

                    col = ObjChange.Get_All_By_Statusid_technicianid(statusid, objUser.Userid, fromdate, todate, varSortParameter);
                }

                #endregion
                #region If Filter Variable is Planning
                else if (filterId == 5)
                {

                    Status = Resources.MessageResource.StrPlanning.ToString();
                    int statusid;

                    statusid = ObjChangeStatus.Get_By_StatusName(Status);

                    col = ObjChange.Get_All_By_Statusid_technicianid(statusid, objUser.Userid, fromdate, todate, varSortParameter);
                }

                #endregion
                #region If Filter Variable is Testing
                else if (filterId == 6)
                {

                    Status = Resources.MessageResource.StrTesting.ToString();
                    int statusid;

                    statusid = ObjChangeStatus.Get_By_StatusName(Status);

                    col = ObjChange.Get_All_By_Statusid_technicianid(statusid, objUser.Userid, fromdate, todate, varSortParameter);
                }

                #endregion
                #region If Filter Variable is Release
                else if (filterId == 7)
                {

                    Status = Resources.MessageResource.StrRelease.ToString();
                    int statusid;

                    statusid = ObjChangeStatus.Get_By_StatusName(Status);

                    col = ObjChange.Get_All_By_Statusid_technicianid(statusid, objUser.Userid, fromdate, todate, varSortParameter);
                }

                #endregion
                #region If Filter Variable is Implemented
                else if (filterId == 8)
                {

                    Status = Resources.MessageResource.StrImplemented.ToString();
                    int statusid;

                    statusid = ObjChangeStatus.Get_By_StatusName(Status);

                    col = ObjChange.Get_All_By_Statusid_technicianid(statusid, objUser.Userid, fromdate, todate, varSortParameter);
                }

                #endregion
                #region If Filter Variable is Completed
                else if (filterId == 9)
                {

                    Status = Resources.MessageResource.StrCompleted.ToString();
                    int statusid;

                    statusid = ObjChangeStatus.Get_By_StatusName(Status);

                    col = ObjChange.Get_All_By_Statusid_technicianid(statusid, objUser.Userid, fromdate, todate, varSortParameter);
                }

                #endregion
            }
            #endregion
            #region If User Role is other then technician
            else
            {
                #region If Filter Variable is All
                if (filterId == 0)
                {
                    //  col = objIncident.Get_All_By_Siteid_Technicianid(siteid, objUser.Userid, fromdate, todate, varSortParameter);

                }
                #endregion
                #region If Filter Variable is Requested
                else if (filterId == 1)
                {

                    Status = Resources.MessageResource.strChangestatusrequested.ToString();
                    int statusid;

                    statusid = ObjChangeStatus.Get_By_StatusName(Status);

                    col = ObjChange.Get_All_By_Statusid(statusid, fromdate, todate, varTechnicianId, varSortParameter);
                }

                #endregion
                #region If Filter Variable is Approval
                else if (filterId == 2)
                {

                    Status = Resources.MessageResource.StrApproval.ToString();
                    int statusid;

                    statusid = ObjChangeStatus.Get_By_StatusName(Status);

                    col = ObjChange.Get_All_By_Statusid(statusid, fromdate, todate, varTechnicianId, varSortParameter);
                }

                #endregion
                #region If Filter Variable is Approval
                else if (filterId == 3)
                {

                    Status = Resources.MessageResource.StrApproved.ToString();
                    int statusid;

                    statusid = ObjChangeStatus.Get_By_StatusName(Status);

                    col = ObjChange.Get_All_By_Statusid(statusid, fromdate, todate, varTechnicianId, varSortParameter);
                }

                #endregion
                #region If Filter Variable is Rejected
                else if (filterId == 4)
                {

                    Status = Resources.MessageResource.StrRejected.ToString();
                    int statusid;

                    statusid = ObjChangeStatus.Get_By_StatusName(Status);

                    col = ObjChange.Get_All_By_Statusid(statusid, fromdate, todate, varTechnicianId, varSortParameter);
                }

                #endregion
                #region If Filter Variable is Planning
                else if (filterId == 5)
                {

                    Status = Resources.MessageResource.StrPlanning.ToString();
                    int statusid;

                    statusid = ObjChangeStatus.Get_By_StatusName(Status);

                    col = ObjChange.Get_All_By_Statusid(statusid, fromdate, todate, varTechnicianId, varSortParameter);
                }

                #endregion
                #region If Filter Variable is Testing
                else if (filterId == 6)
                {

                    Status = Resources.MessageResource.StrTesting.ToString();
                    int statusid;

                    statusid = ObjChangeStatus.Get_By_StatusName(Status);

                    col = ObjChange.Get_All_By_Statusid(statusid, fromdate, todate, varTechnicianId, varSortParameter);
                }

                #endregion
                #region If Filter Variable is Release
                else if (filterId == 7)
                {

                    Status = Resources.MessageResource.StrRelease.ToString();
                    int statusid;

                    statusid = ObjChangeStatus.Get_By_StatusName(Status);

                    col = ObjChange.Get_All_By_Statusid(statusid, fromdate, todate, varTechnicianId, varSortParameter);
                }

                #endregion
                #region If Filter Variable is Implemented
                else if (filterId == 8)
                {

                    Status = Resources.MessageResource.StrImplemented.ToString();
                    int statusid;

                    statusid = ObjChangeStatus.Get_By_StatusName(Status);

                    col = ObjChange.Get_All_By_Statusid(statusid, fromdate, todate, varTechnicianId, varSortParameter);
                }

                #endregion
                #region If Filter Variable is Completed
                else if (filterId == 9)
                {

                    Status = Resources.MessageResource.StrCompleted.ToString();
                    int statusid;

                    statusid = ObjChangeStatus.Get_By_StatusName(Status);

                    col = ObjChange.Get_All_By_Statusid(statusid, fromdate, todate, varTechnicianId, varSortParameter);
                }

                #endregion
            }
            #endregion

        }
        #endregion
        #region Fetch Each object of type Change_mst from Collection Change_mst
        foreach (Change_mst obj in col)
        {

            #region Create Table row and assign value to it
            DataRow row;
            row = dtTable.NewRow();
            row["Changeid"] = Convert.ToString(obj.Changeid);
            row["title"] = obj.Title;
            row["Requestedby"] = Convert.ToString(obj.Requestedby);
            row["CreatedByid"] = Convert.ToString(obj.CreatedByID);
            row["Technician"] = Convert.ToString(obj.Technician);
            row["Statusid"] = obj.Statusid;
            row["Priority"] = obj.Priority;
            row["Createdtime"] = obj.Createdtime;
            dtTable.Rows.Add(row);
            #endregion

        }
        //}
        #endregion
        #region Bind Grid from datasource dtTable
        grdvwChange.DataSource = dtTable;
        grdvwChange.DataBind();

        #endregion
    }
    protected void grdvwChange_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)
            {
                //if(col.Count!=0)
                //{

                #region Autogenerate Serial number
                //Label lblSerial = (Label)e.Row.FindControl("lblSerial");
                //lblSerial.Text = i.ToString();
                //i++;
                #endregion

                int TotalTimeSpentonCall;
                int TotalResolutionTime;

                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[2].Text);
                objUser = objUser.Get_By_id(requesterid);

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

                #region Bind Datarow at Run Time with Createdbyid to Created by name
                int createdbyid = Convert.ToInt32(e.Row.Cells[3].Text);
                objUser = objUser.Get_By_id(createdbyid);
                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 technicianid to technician name
                int technicianid = Convert.ToInt32(e.Row.Cells[4].Text);
                objUser = objUser.Get_By_id(technicianid);
                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 Statusid to Status
                int statusid = Convert.ToInt32(e.Row.Cells[5].Text);

                ObjChangeStatus = ObjChangeStatus.Get_By_id(statusid);
                if (ObjChangeStatus.ChangeStatusid != 0)
                {

                    e.Row.Cells[5].Text = ObjChangeStatus.Statusname.ToString();

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

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

            }
        }
        catch (Exception ex)
        {
            string myScript;
            myScript = "<script language=javascript>alert('Exception - '" + ex + "');</script>";
            Page.RegisterClientScriptBlock("MyScript", myScript);
            return;
        }
    }
    protected void ShowResolution()
    {
        IncidentResolution objIncidentResolution = new IncidentResolution();
        #region Declaration of Dynamic Table,and Placeholder
        PlaceHolderResolution.Controls.Clear();
        Table tbl = new Table();
        PlaceHolderResolution.Controls.Add(tbl);
        int hdwidth = 1500;
        int height = 5;
        #endregion

        int incidentid = Convert.ToInt32(Session["incidentid"].ToString());

        #region Get Collection of Log From IncidentLog table via incidentid
        colIncidentResolution = objIncidentResolution.Get_All_By_incidentid(incidentid);
        if (colIncidentResolution.Count == 0)
        {

            TableRow tabRow3 = new TableRow();
            TableCell tbCell3 = new TableCell();
            tbCell3.Width = hdwidth;
            tbCell3.Height = height;
            Label lbl3 = new Label();
            lbl3.Text = "No Record Found";
            lbl3.Font.Size = FontUnit.Smaller;
            tbCell3.Controls.Add(lbl3);
            tabRow3.Cells.Add(tbCell3);
            tbl.Rows.Add(tabRow3);

        }
        foreach (IncidentResolution obj in colIncidentResolution)
        {

            #region Fetch Username on the basis of Operationownerid,by calling Get_By_id() function of Userlogin_mst Instance
            string username;
            objUser = objUser.Get_By_id(obj.Userid);
            username = objUser.Username.ToString();
            #endregion
            #region Declaration of Tablerow,TableCell and lable object
            TableRow tabRow = new TableRow();
            TableCell tbCell = new TableCell();
            tbCell.Width = hdwidth;
            Label lbl = new Label();
            #endregion
            #region Print Each Operation Performed by User
            lbl.Font.Bold = true;
            lbl.Text = "&nbsp;&nbsp;" + username + "&nbsp;&nbsp;&nbsp;&nbsp;said on&nbsp;&nbsp;&nbsp;&nbsp;" + obj.Lastupdatetime.ToString();
            #endregion
            #region Fix background color of Row

            tabRow.BackColor = System.Drawing.Color.Lavender;

            #endregion
            #region Add label,cell,and Row to tabel
            tbCell.Controls.Add(lbl);
            tabRow.Cells.Add(tbCell);
            tbl.Rows.Add(tabRow);
            #endregion

            #region Declaration of local variables,tablerow,tablecell and label
            TableRow tabRowInner = new TableRow();
            TableCell tbCellInner = new TableCell();
            tbCellInner.Width = hdwidth;
            Label lblinner = new Label();
            lblinner.Font.Size = FontUnit.Smaller;
            #endregion

            #region Print Each Operation Performed by User
            lblinner.Font.Bold = true;
            lblinner.Text = "&nbsp;&nbsp;&nbsp;&nbsp;" + obj.Resolution.ToString();
            #endregion

            #region Label,cells and rows to Tabel of inner loop
            tabRowInner.BackColor = System.Drawing.Color.White;
            tbCellInner.Controls.Add(lblinner);
            tabRowInner.Cells.Add(tbCellInner);
            tbl.Rows.Add(tabRowInner);
            #endregion

        }

        #endregion
    }
    protected void BindGridForAllParameter()
    {
        #region Declaration of localvariable and table Variable
        int filterId;
        DataTable dtTable = new DataTable();
        dtTable = CreateDataTable();
        string userName = "";
        int varTechnicianId = 0;
        if (drpTechnician.SelectedValue != "") { varTechnicianId = Convert.ToInt32(drpTechnician.SelectedValue); }

        string varSortParameter = "";
        varSortParameter = drpSort.SelectedValue;
        if (varSortParameter == "0")
        { varSortParameter = "createdatetime"; }
        #endregion

        #region Get Current User and his Role
        MembershipUser User = Membership.GetUser();
        string varUserRole = "";
        string varRoleTechnician = "";
        if (User != null)
        {
            userName = User.UserName.ToString();

            string[] arrUserRole = Roles.GetRolesForUser();
            varUserRole = arrUserRole[0].ToString();
            varRoleTechnician = Resources.MessageResource.strTechnicianRole.ToString();

        }
        #endregion

        #region Get User object  by Calling Function Get_UserLogin_By_UserName() via passing parameter username and organizationid
        objOrganization = objOrganization.Get_Organization();
        objUser = objUser.Get_UserLogin_By_UserName(userName, objOrganization.Orgid);
        #endregion

        #region If User Exist
        if (objUser.Userid != 0)
        {
            ViewState["Userid"] = objUser.Userid;
            string fromdate = null;
            string todate = null;
            if (ViewState["fromdate"] != null)
            {
                fromdate = ViewState["fromdate"].ToString();
            }
            if (ViewState["todate"] != null)
            {
                todate = ViewState["todate"].ToString();
            }
            if (fromdate == "")
            { fromdate = null; }
            if (todate == "")
            { todate = null; }

            #region Declare Local Variables and Collection of Incident_mst Type
              string Status;

        //            int siteid;
                #endregion
            #region Get the Siteid and Filter Parameter
                //siteid = obj.Siteid;
                filterId = Convert.ToInt32(drpFilter.SelectedValue);
                #endregion

            #region If Role of User is Technician
               if (varUserRole == varRoleTechnician)
                {

                    lblTechnician.Visible = false;
                    drpTechnician.Visible = false;

                    btnCancell.Visible = false;
                    #region If Filter Variable is All
                    if (filterId == 0)
                    {
                      //  col = objIncident.Get_All_By_Siteid_Technicianid(siteid, objUser.Userid, fromdate, todate, varSortParameter);

                    }
                    #endregion
                    #region If Filter Variable is Open
                    else if (filterId == 1)
                    {
                        Status = Resources.MessageResource.strStatusOpen.ToString();
                        int statusid;
                        statusid = objStatus.Get_By_StatusName(Status);
                        col=ObjProblem.Get_All_By_Statusid_technicianid(statusid, objUser.Userid, fromdate, todate, varSortParameter);

                    }
                    #endregion
                    #region If Filter variable is Onhold
                    else if (filterId == 2)
                    {
                        Status = Resources.MessageResource.strStatusOnHold.ToString();
                        int statusid;
                        statusid = objStatus.Get_By_StatusName(Status);
                       col=ObjProblem.Get_All_By_Statusid_technicianid(statusid, objUser.Userid, fromdate, todate, varSortParameter);

                    }
                    #endregion
                    #region If Filter Variable is Close
                    else if (filterId == 3)
                    {
                        Status = Resources.MessageResource.strStatusClose.ToString();
                        int statusid;
                        statusid = objStatus.Get_By_StatusName(Status);
                       col=ObjProblem.Get_All_By_Statusid_technicianid(statusid, objUser.Userid, fromdate, todate, varSortParameter);
                    }
                    #endregion
                    #region If filter variable is resolved
                    else if (filterId == 4)
                    {
                        Status = Resources.MessageResource.strStatusResolved.ToString();
                        int statusid;
                        statusid = objStatus.Get_By_StatusName(Status);
                       col=ObjProblem.Get_All_By_Statusid_technicianid(statusid, objUser.Userid, fromdate, todate, varSortParameter);
                    }
                    #endregion

                }
           #endregion
            #region If User Role is other than Technician
        else
        {
                    #region If Filter Variable is All
               if (filterId == 0)
                    {
                        //varSortParameter

                   col=ObjProblem.Get_All_By_Createdbyid(fromdate, todate, varTechnicianId, varSortParameter);
                    }
        #endregion
                    #region If Filter Variable is Open
                    else if (filterId == 1)
                    {
                        Status = Resources.MessageResource.strStatusOpen.ToString();
                        int statusid;
                        statusid = objStatus.Get_By_StatusName(Status);

                        col=ObjProblem.Get_All_By_Statusid(statusid, fromdate, todate, varTechnicianId, varSortParameter);
                    }
                    #endregion
                    #region If Filter variable is Onhold
                    else if (filterId == 2)
                    {
                        Status = Resources.MessageResource.strStatusOnHold.ToString();
                        int statusid;
                        statusid = objStatus.Get_By_StatusName(Status);
                         col=ObjProblem.Get_All_By_Statusid(statusid, fromdate, todate, varTechnicianId, varSortParameter);
                    }
                    #endregion
                    #region If Filter Variable is Close
                    else if (filterId == 3)
                    {
                        Status = Resources.MessageResource.strStatusClose.ToString();
                        int statusid;
                        statusid = objStatus.Get_By_StatusName(Status);
                        col=ObjProblem.Get_All_By_Statusid(statusid, fromdate, todate, varTechnicianId, varSortParameter);
                    }
                    #endregion
                    #region If filter variable is resolved
                    else if (filterId == 4)
                    {
                        Status = Resources.MessageResource.strStatusResolved.ToString();
                        int statusid;
                        statusid = objStatus.Get_By_StatusName(Status);

                        col=ObjProblem.Get_All_By_Statusid( statusid, fromdate, todate, varTechnicianId, varSortParameter);
                    }
                    #endregion
                    #region If filter variable is UnAssigned
                    else if (filterId == 5)
                    {
                        Status = Resources.MessageResource.strStatusOpen.ToString();
                        int statusid;
                        statusid = objStatus.Get_By_StatusName(Status);

                        col=ObjProblem.Get_All_By_Statusid_Unassigned(statusid, fromdate, todate, varSortParameter);

                    }
                    #endregion
                    #region If filter variable is Assigned
                    else if (filterId == 6)
                    {

                        col=ObjProblem.Get_All_By_Assigned(fromdate, todate, varSortParameter);
                    }
                    #endregion
                    #region Else Condition will call using Filter variable all
                    else
                    {

                        col=ObjProblem.Get_All_By_Createdbyid(fromdate, todate, varTechnicianId, varSortParameter);
                    }
                    #endregion

                }
                #endregion

            }

        #region Fetch Each object of type Incident_mst from Collection Incident_mst
            foreach (Problem_mst obj in col)
            {

                #region Create Table row and assign value to it
                DataRow row;
                row = dtTable.NewRow();
                row["ProblemId"] = Convert.ToString(obj.ProblemId);
                row["title"] = obj.title;
                row["Requesterid"] = Convert.ToString(obj.Requesterid);
                row["CreatedByid"] = Convert.ToString(obj.CreatedByid);
                row["Technicianid"] = Convert.ToString(obj.Technicianid);
                row["Statusid"] = obj.Statusid;
                row["Priorityid"] = obj.Priorityid;
                row["CreateDatetime"] = obj.CreateDatetime;
                dtTable.Rows.Add(row);
                #endregion

            }
        //}
        #endregion
        #region Bind Grid from datasource dtTable
        grdvwProblem.DataSource = dtTable;
        grdvwProblem.DataBind();

            #endregion
        #endregion
        if (varUserRole == varRoleTechnician)
        {
           ///RoleTechnician();
        }
    }
Beispiel #49
0
    protected void buttonadd_click(object sender, EventArgs e)
    {
        /////Add Exception handilng try catch change by vishal 21-05-2012
        try
        {
            #region Find Userid of User who is Requesting to log a call

            #region If User Already Exist
            if (ViewState["UserCreate"].ToString() == "Exist")
            {
                objOrganization = objOrganization.Get_Organization();
                ObjUserLogin    = ObjUserLogin.Get_UserLogin_By_UserName(txtUsername.Text.ToString().Trim(), objOrganization.Orgid);
                if (ObjUserLogin.Userid != 0)
                {
                    requesterid = ObjUserLogin.Userid;
                }
            }
            #endregion
            #region If New User is to be Created
            else if (ViewState["UserCreate"].ToString() == "create")
            {
                string varEmail    = "";
                string varRoleName = Resources.MessageResource.BasicUserRole.ToString();
                if (txtEmail.Text == "")
                {
                    varEmail = Resources.MessageResource.errMemshipCreateUserEmail.ToString();
                }
                else
                {
                    varEmail = txtEmail.Text;
                }


                int roleid = objRole.Get_By_RoleName(varRoleName);
                int status;
                objOrganization = objOrganization.Get_Organization();

                objuser.Username       = txtUsername.Text.ToString();
                objuser.Password       = Resources.MessageResource.strDefaultPassword.ToString();
                objuser.Roleid         = roleid;
                objuser.Orgid          = objOrganization.Orgid;
                objuser.ADEnable       = false;
                objuser.Enable         = true;
                objuser.Createdatetime = DateTime.Now.ToString();
                status = objuser.Insert();
                if (status == 1)
                {
                    // Create Mstatus field to send in Membership.CreateUser function as Out Variable for creating Membership User database
                    MembershipCreateStatus Mstatus = default(MembershipCreateStatus);
                    // Call Membership.CreateUser function to create Membership user
                    Membership.CreateUser(txtUsername.Text.ToString().Trim(), Resources.MessageResource.strDefaultPassword.ToString(), varEmail, "Project Name", "Helpdesk", true, out Mstatus);
                    // Call Roles.AddUserToRole Function to Add User To Role
                    Roles.AddUserToRole(txtUsername.Text.ToString().Trim(), varRoleName);
                    // Declare Local Variable Userid to fetch userid of newly created user

                    // Create Object objUserLogin of UserLogin_mst()Class
                    objuser = new UserLogin_mst();
                    // Fetch userid of Newly created user and assign to local variable userid by calling function objUserLogin.Get_By_UserName
                    requesterid = objuser.Get_By_UserName(txtUsername.Text.ToString().Trim(), objOrganization.Orgid);
                    // If userid not equal to 0 then we get userid of Newly created user otherwise error Occured

                    ContactInfo_mst objContactInfo = new ContactInfo_mst();
                    objContactInfo.Userid    = requesterid;
                    objContactInfo.Emailid   = varEmail;
                    objContactInfo.Firstname = txtUsername.Text.ToString();
                    objContactInfo.Lastname  = txtUsername.Text.ToString();
                    objContactInfo.Insert();
                }
            }
            #endregion
            #region If User is Not to be Created
            else if (ViewState["UserCreate"].ToString() == "notcreate")
            {
                // FlagUserStatus = false;
            }
            #endregion

            #endregion
            ObjChange.Active = true;

            ObjChange.Statusid      = Convert.ToInt32(drpStatus.SelectedValue);
            ObjChange.Categoryid    = Convert.ToInt32(drpCategory.SelectedValue);
            ObjChange.Subcategoryid = Convert.ToInt32(drpSubcategory.SelectedValue);
            // ObjChange.Technician =Convert.ToInt32(drpTechnician.SelectedValue);
            ObjChange.Title          = txtTitle.Text;
            ObjChange.Description    = txtDescription.Text;
            ObjChange.Createdtime    = DateTime.Now.ToString();
            ObjChange.Changetype     = Convert.ToInt32(drpchangetype.SelectedValue);
            ObjChange.Approvalstatus = "Send For Approval";
            MembershipUser user     = Membership.GetUser();
            string         username = user.UserName.ToString();
            objOrganization = objOrganization.Get_Organization();
            ObjUserLogin    = ObjUserLogin.Get_UserLogin_By_UserName(username, objOrganization.Orgid);
            int userid = Convert.ToInt32(ObjUserLogin.Userid);
            ObjChange.CreatedByID = userid;
            ObjUserLogin          = ObjUserLogin.Get_UserLogin_By_UserName(txtUsername.Text, objOrganization.Orgid);
            ObjChange.Requestedby = ObjUserLogin.Userid;
            // ObjChange.Priority = Convert.ToInt32(drpPriority.SelectedValue);
            ObjChange.Insert();
            int changeid = ObjChange.Get_Current_Changeid();
            for (int i = ListAsset.Items.Count - 1; i >= 0; i--)
            {
                if (ListAsset.Items[i].Selected == true)
                {
                    Objincludeaasetchange.Assetid  = Convert.ToInt32(ListAsset.Items[i].Value);
                    Objincludeaasetchange.Changeid = changeid;
                    Objincludeaasetchange.Insert();
                }
            }
            ObjChangeHistory.Changeid = changeid;
            // ObjChangeHistory.Description = "create";
            ObjChangeHistory.Operation        = "create";
            ObjChangeHistory.Operationownerid = ObjUserLogin.Userid;
            ObjChangeHistory.Insert();
            int changetype = Convert.ToInt32(drpchangetype.SelectedValue);

            objSentEmailToChange.SentMailToChangeCommittee(changeid, changetype);

            Response.Redirect("~/Change/EditChange.aspx?" + changeid + " ");
        }
        catch (Exception ex)
        {
            string myScript;
            myScript = "<script language=javascript>alert('Exception - '" + ex + "');</script>";
            Page.RegisterClientScriptBlock("MyScript", myScript);
            return;
        }
    }
    //protected void btngetuser_Click(object sender, EventArgs e)
    //{
    //    lblErrorMsg.Text = "";
    //    string Username = txtusername.Text.ToString().Trim();
    //    objUser = objUser.Get_UserLogin_By_UserName_Like(Username);
    //    if (objUser.Userid != 0)
    //    {
    //        txtusername.Text = objUser.Username.ToString().Trim();
    //        userid = objUser.Userid;
    //    }
    //    else
    //    {
    //        txtusername.Text = "";

    //    }
    //}

    //protected void btnshow_Click(object sender, EventArgs e)
    //{
    //    lblErrorMsg.Text = "";
    //    string Username = txtusername.Text.ToString().Trim();
    //    objUser = objUser.Get_UserLogin_By_UserName_Like(Username);
    //    userid = objUser.Userid;
    //    int assid=Convert.ToInt32(objusertoasset.Get_AssetId_By_UserId(userid));
    //    int usercount = objusertoasset.Get_UserId_From_UserToAssetMap(userid);
    //    col = ObjAsset.Get_Assetdetails_By_Assetid(assid);
    //    grdvwViewAsset.DataSource = col;
    //    grdvwViewAsset.DataBind();
    //    foreach (GridViewRow gv in grdvwViewAsset.Rows)
    //    {
    //        RadioButton selectonebutton = (RadioButton)gv.FindControl("selectone");
    //        selectonebutton.Checked = true;
    //    }
    //}

    protected void btnMapped_Click(object sender, EventArgs e)
    {
/////Add Exception handilng try catch change by vishal 21-05-2012
        try
        {
            lblErrorMsg.Text = "";
            int flag = 0;

            foreach (GridViewRow gv in grdvwViewAsset.Rows)
            {
                string      gvIDs;
                RadioButton selectonebutton = (RadioButton)gv.FindControl("selectone");
                if (selectonebutton.Checked)
                {
                    flag = 1;
                    int assetid;
                    gvIDs   = ((Label)gv.FindControl("lblAssetID")).Text.ToString();
                    assetid = Convert.ToInt32(gvIDs);

                    string Username = txtusername.Text.ToString().Trim();
                    objUser = objUser.Get_UserLogin_By_UserName_Like(Username);
                    //objcontactinfo = objcontactinfo.Get_By_id(objUser.Userid); //added by lalit 24 feb 2012
                    userid = objUser.Userid;
                    if (txtusername.Text == "")
                    {
                        lblErrorMsg.Text = "Enter the user name for mapped a particular Asset";
                        break;
                    }
                    else if (userid == 0)
                    {
                        lblErrorMsg.Text = "User Name doesn't  exist";
                        break;
                    }
                    else
                    {
                        assetcount    = objusertoasset.Get_AssetId_From_UserToAssetMap(assetid);
                        usercount     = objusertoasset.Get_UserId_From_UserToAssetMap(userid);
                        assetlocation = objUser.City;  //added by lalit 24 feb 2012
                        companyname   = objUser.Company;
                        if (assetcount == 0)
                        {
                            if (usercount == 0)
                            {
                                objusertoasset.Insert(userid, assetid, assetlocation, companyname);  //added a new field siteid on 24 feb.
                                lblErrorMsg.Text = "Asset Mapped Successfully to the Current User";
                                break;
                            }
                            else
                            {
                                int oldassetid = Convert.ToInt32(objusertoasset.Get_AssetId_By_UserId(userid));
                                objusertoasset.Update_Assetid(oldassetid, assetid, assetlocation, companyname);
                                lblErrorMsg.Text = "Asset Mapped Successfully to the Current User";
                                break;
                            }
                        }
                        else
                        {
                            lblErrorMsg.Text = "Asset already Mapped";
                            break;
                        }
                    }
                }
            }
            if (flag == 0)
            {
                lblErrorMsg.Text = "Select Asset for mapping";
            }
        }
        catch (Exception ex)
        {
            string myScript;
            myScript = "<script language=javascript>alert('Exception - '" + ex + "');</script>";
            Page.RegisterClientScriptBlock("MyScript", myScript);
            return;
        }
    }
    protected void BindGridForSelectedParameter()
    {
        #region Declaration of localvariable and table Variable
        int filterId;
        DataTable dtTable = new DataTable();
        dtTable = CreateDataTable();
        string userName = "";
        int varTechnicianId = Convert.ToInt32(drpTechnician.SelectedValue);
        string varSortParameter = "";
        varSortParameter = drpSort.SelectedValue;
        if (varSortParameter == "0")
        { varSortParameter = "createdatetime"; }
        #endregion

        #region Get Current User and his Role
        MembershipUser User = Membership.GetUser();
        string varUserRole = "";
        string varRoleTechnician = "";
        if (User != null)
        {
            userName = User.UserName.ToString();

            string[] arrUserRole = Roles.GetRolesForUser();
            varUserRole = arrUserRole[0].ToString();
            varRoleTechnician = Resources.MessageResource.strTechnicianRole.ToString();

        }
        #endregion

        #region Get User object  by Calling Function Get_UserLogin_By_UserName() via passing parameter username and organizationid
        objOrganization = objOrganization.Get_Organization();
        objUser = objUser.Get_UserLogin_By_UserName(userName, objOrganization.Orgid);
        #endregion

        #region If User Exist
        if (objUser.Userid != 0)
        {
            string fromdate = null;
            string todate = null;
            if (ViewState["fromdate"] != null)
            {
                fromdate = ViewState["fromdate"].ToString();
            }
            if (ViewState["todate"] != null)
            {
                todate = ViewState["todate"].ToString();
            }
            if (fromdate == "")
            { fromdate = null; }
            if (todate == "")
            { todate = null; }

            #region Declare Local Variables and Collection of Incident_mst Type
            string Status;
            BLLCollection<Incident_mst> col = new BLLCollection<Incident_mst>();
            int siteid;
            #endregion
            #region Get the Siteid and Filter Parameter
            siteid = Convert.ToInt32(drpSite.SelectedValue);
            filterId = Convert.ToInt32(drpFilter.SelectedValue);
            #endregion

            #region If Role of User is Technician
            if (varUserRole == varRoleTechnician)
            {

                lblTechnician.Visible = false;
                drpTechnician.Visible = false;
                #region If Filter Variable is All
                if (filterId == 0)
                {
                    col = objIncident.Get_All_By_Siteid_Technicianid(siteid, objUser.Userid, fromdate, todate, varSortParameter);
                }
                #endregion
                #region If Filter Variable is Open
                else if (filterId == 1)
                {
                    Status = Resources.MessageResource.strStatusOpen.ToString();
                    int statusid;
                    statusid = objStatus.Get_By_StatusName(Status);
                    col = objIncident.Get_All_By_Siteid_Statusid_technicianid(siteid, statusid, objUser.Userid, fromdate, todate, varSortParameter);
                }
                #endregion
                #region If Filter variable is Onhold
                else if (filterId == 2)
                {
                    Status = Resources.MessageResource.strStatusOnHold.ToString();
                    int statusid;
                    statusid = objStatus.Get_By_StatusName(Status);
                    col = objIncident.Get_All_By_Siteid_Statusid_technicianid(siteid, statusid, objUser.Userid, fromdate, todate, varSortParameter);
                }
                #endregion
                #region If Filter Variable is Close
                else if (filterId == 3)
                {
                    Status = Resources.MessageResource.strStatusClose.ToString();
                    int statusid;
                    statusid = objStatus.Get_By_StatusName(Status);
                    col = objIncident.Get_All_By_Siteid_Statusid_technicianid(siteid, statusid, objUser.Userid, fromdate, todate, varSortParameter);
                }
                #endregion
                #region If filter variable is resolved
                else if (filterId == 4)
                {
                    Status = Resources.MessageResource.strStatusResolved.ToString();
                    int statusid;
                    statusid = objStatus.Get_By_StatusName(Status);
                    col = objIncident.Get_All_By_Siteid_Statusid_technicianid(siteid, statusid, objUser.Userid, fromdate, todate, varSortParameter);
                }
                #endregion

            }
            #endregion
            #region If User Role is other than Technician
            else
            {
                #region If Filter Variable is All
                if (filterId == 0)
                {

                    col = objIncident.Get_All_By_Siteid_Createdbyid(siteid, fromdate, todate, varTechnicianId, varSortParameter);
                }
                #endregion
                #region If Filter Variable is Open
                else if (filterId == 1)
                {
                    Status = Resources.MessageResource.strStatusOpen.ToString();
                    int statusid;
                    statusid = objStatus.Get_By_StatusName(Status);
                    col = objIncident.Get_All_By_Siteid_Statusid(siteid, statusid, fromdate, todate, varTechnicianId, varSortParameter);
                }
                #endregion
                #region If Filter variable is Onhold
                else if (filterId == 2)
                {
                    Status = Resources.MessageResource.strStatusOnHold.ToString();
                    int statusid;
                    statusid = objStatus.Get_By_StatusName(Status);
                    col = objIncident.Get_All_By_Siteid_Statusid(siteid, statusid, fromdate, todate, varTechnicianId, varSortParameter);
                }
                #endregion
                #region If Filter Variable is Close
                else if (filterId == 3)
                {
                    Status = Resources.MessageResource.strStatusClose.ToString();
                    int statusid;
                    statusid = objStatus.Get_By_StatusName(Status);
                    col = objIncident.Get_All_By_Siteid_Statusid(siteid, statusid, fromdate, todate, varTechnicianId, varSortParameter);
                }
                #endregion
                #region If filter variable is resolved
                else if (filterId == 4)
                {
                    Status = Resources.MessageResource.strStatusResolved.ToString();
                    int statusid;
                    statusid = objStatus.Get_By_StatusName(Status);
                    col = objIncident.Get_All_By_Siteid_Statusid(siteid, statusid, fromdate, todate, varTechnicianId, varSortParameter);
                }
                #endregion
                #region If filter variable is UnAssigned
                else if (filterId == 5)
                {
                    Status = Resources.MessageResource.strStatusOpen.ToString();
                    int statusid;
                    statusid = objStatus.Get_By_StatusName(Status);
                    col = objIncident.Get_All_By_Siteid_Statusid_Unassigned(siteid, statusid, fromdate, todate, varSortParameter);
                }

                #endregion
                #region If filter variable is Assigned
                else if (filterId == 6)
                {

                    col = objIncident.Get_All_By_Siteid_Assigned(siteid, fromdate, todate, varSortParameter);
                }
                #endregion
                #region Else Condition will call using Filter variable all
                else { col = objIncident.Get_All_By_Siteid_Createdbyid(siteid, fromdate, todate, varTechnicianId, varSortParameter); }
                #endregion

            }
            #endregion

            #region Fetch Each object of type Incident_mst from Collection Incident_mst
            foreach (Incident_mst objInc in col)
            {

                #region Create Table row and assign value to it
                DataRow row;
                row = dtTable.NewRow();
                row["incidentid"] = Convert.ToString(objInc.Incidentid);
                row["title"] = objInc.Title;
                row["requesterid"] = Convert.ToString(objInc.Requesterid);
                row["createdbyid"] = Convert.ToString(objInc.Createdbyid);
                row["siteid"] = Convert.ToString(objInc.Siteid);
                row["createdatetime"] = Convert.ToString(objInc.Createdatetime);
                objIncidentStates = objIncidentStates.Get_By_id(objInc.Incidentid);
                row["statusid"] = objIncidentStates.Statusid;
                row["technicianid"] = objIncidentStates.Technicianid;
                row["priorityid"] = objIncidentStates.Priorityid;
                dtTable.Rows.Add(row);
                #endregion

            }
            #endregion

        }
        #endregion

        #region Bind Grid from datasource dtTable
        DataView dvData = new DataView(dtTable);
        string sortFormat = "{0} {1}";
        String sortDirection = "DESC";
        if (varSortParameter == "createdatetime")
        {
            //varSortParameter = "incidentid";
        }
        if (varSortParameter == "incidentid")
        {
        }
        dvData.Sort = String.Format(sortFormat, varSortParameter, sortDirection);
        grdvwRequest.DataSource = null;
        grdvwRequest.DataBind();

        grdvwRequest.DataSource = dvData;
        grdvwRequest.DataBind();

        #endregion

        if (varUserRole == varRoleTechnician)
        {
            RoleTechnician();
        }
    }
Beispiel #52
0
    protected void btnAdd_Click(object sender, EventArgs e)
    {//Add Exception handilng try catch change by vishal 21-05-2012
        try
        {
            bool FlagUserStatus = true;
            #region Find Userid of User who is Requesting to log a call

            #region If User Already Exist
            if (ViewState["UserCreate"].ToString() == "Exist")
            {
                objOrganization = objOrganization.Get_Organization();
                ObjUserLogin    = ObjUserLogin.Get_UserLogin_By_UserName(txtUsername.Text.ToString().Trim(), objOrganization.Orgid);
                if (ObjUserLogin.Userid != 0)
                {
                    requesterid = ObjUserLogin.Userid;
                }
            }
            #endregion
            #region If New User is to be Created
            else if (ViewState["UserCreate"].ToString() == "create")
            {
                string varEmail    = "";
                string varRoleName = Resources.MessageResource.BasicUserRole.ToString();
                if (txtEmail.Text == "")
                {
                    varEmail = Resources.MessageResource.errMemshipCreateUserEmail.ToString();
                }
                else
                {
                    varEmail = txtEmail.Text;
                }


                int roleid = objRole.Get_By_RoleName(varRoleName);
                int status;
                objOrganization = objOrganization.Get_Organization();

                objuser.Username       = txtUsername.Text.ToString();
                objuser.Password       = Resources.MessageResource.strDefaultPassword.ToString();
                objuser.Roleid         = roleid;
                objuser.Orgid          = objOrganization.Orgid;
                objuser.ADEnable       = false;
                objuser.Enable         = true;
                objuser.Createdatetime = DateTime.Now.ToString();
                status = objuser.Insert();
                if (status == 1)
                {
                    // Create Mstatus field to send in Membership.CreateUser function as Out Variable for creating Membership User database
                    MembershipCreateStatus Mstatus = default(MembershipCreateStatus);
                    // Call Membership.CreateUser function to create Membership user
                    Membership.CreateUser(txtUsername.Text.ToString().Trim(), Resources.MessageResource.strDefaultPassword.ToString(), varEmail, "Project Name", "Helpdesk", true, out Mstatus);
                    // Call Roles.AddUserToRole Function to Add User To Role
                    Roles.AddUserToRole(txtUsername.Text.ToString().Trim(), varRoleName);
                    // Declare Local Variable Userid to fetch userid of newly created user

                    // Create Object objUserLogin of UserLogin_mst()Class
                    objuser = new UserLogin_mst();
                    // Fetch userid of Newly created user and assign to local variable userid by calling function objUserLogin.Get_By_UserName
                    requesterid = objuser.Get_By_UserName(txtUsername.Text.ToString().Trim(), objOrganization.Orgid);
                    // If userid not equal to 0 then we get userid of Newly created user otherwise error Occured

                    ContactInfo_mst objContactInfo = new ContactInfo_mst();
                    objContactInfo.Userid    = requesterid;
                    objContactInfo.Emailid   = varEmail;
                    objContactInfo.Firstname = txtUsername.Text.ToString();
                    objContactInfo.Lastname  = txtUsername.Text.ToString();
                    objContactInfo.Insert();
                }
            }
            #endregion
            #region If User is Not to be Created
            else if (ViewState["UserCreate"].ToString() == "notcreate")
            {
                FlagUserStatus = false;
            }
            #endregion

            #endregion

            MembershipUser User = Membership.GetUser();
            string         userName;
            userName = User.UserName.ToString();
            if (FlagUserStatus == true)
            {
                objOrganization          = objOrganization.Get_Organization();
                objuser                  = objuser.Get_UserLogin_By_UserName(userName, objOrganization.Orgid);
                ObjProblem.CreatedByid   = objuser.Userid;
                ObjProblem.Requesterid   = requesterid;
                ObjProblem.Categoryid    = Convert.ToInt32(drpCategory.SelectedValue);
                ObjProblem.Subcategoryid = Convert.ToInt32(drpSubcategory.SelectedValue);

                ObjProblem.Priorityid   = Convert.ToInt32(drpPriority.SelectedValue);
                ObjProblem.Statusid     = Convert.ToInt32(drpStatus.SelectedValue);
                ObjProblem.Technicianid = Convert.ToInt32(drpTechnician.SelectedValue);
                ObjProblem.title        = txtTitle.Text;
                ObjProblem.Description  = txtDescription.Text;
                if (Convert.ToInt32(drpTechnician.SelectedValue) != 0)
                {
                    ObjProblem.AssginedTime = DateTime.Now.ToString();
                }

                ObjProblem.Insert();
                int problemid = ObjProblem.Get_Current_Problemid();

                ObjProblemHistory.Operationtime    = DateTime.Now.ToString();
                ObjProblemHistory.Problemid        = problemid;
                ObjProblemHistory.Operation        = "create";
                ObjProblemHistory.Operationownerid = objuser.Userid;
                if (Session["IncidentToProblem"] != null)
                {
                    int incidentid = Convert.ToInt32(Session["IncidentToProblem"].ToString());
                    Incident_To_Problem objIncToprob = new Incident_To_Problem();
                    objIncToprob.Incidentid = incidentid;
                    objIncToprob.Problemid  = problemid;
                    objIncToprob.Insert();
                }
                if (Convert.ToInt32(drpTechnician.SelectedValue) != 0)
                {
                    objSentMailToUser.SentMailToTechnicianForProblemCall(problemid, Convert.ToInt32(drpTechnician.SelectedValue));
                }

                ObjProblemHistory.Insert();
                //ResetControls();

                string myScript;
                myScript = "<script language=javascript>javascript:window.close();</script>";
                Page.RegisterClientScriptBlock("MyScript", myScript);
            }
        }
        catch (Exception ex)
        {
            string myScript;
            myScript = "<script language=javascript>alert('Exception - '" + ex + "');</script>";
            Page.RegisterClientScriptBlock("MyScript", myScript);
            return;
        }
    }
    protected void btnResolution_Click(object sender, EventArgs e)
    {
        /////Add Exception handilng try catch change by vishal 21-05-2012
        try
        {
            int userid = 0;
            string userName;
            MembershipUser User = Membership.GetUser();
            userName = User.UserName.ToString();

            if (userName != "")
            {

                objOrganization = objOrganization.Get_Organization();
                objUser = objUser.Get_UserLogin_By_UserName(userName, objOrganization.Orgid);
                if (objUser.Userid != 0)
                {
                    userid = objUser.Userid;
                }
            }
            IncidentResolution objIncidentResolution = new IncidentResolution();
            #region Get incidentid from QueryString
            int incidentid = Convert.ToInt32(Request.QueryString[0]);
            #endregion
            #region Check Is Resolution Exist in Database
            objIncidentResolution = objIncidentResolution.Get_By_id(incidentid);
            #endregion
            #region Add Resolution  in Database

            string varResolution;
            varResolution = Editor.Text;
            objIncidentResolution.Incidentid = incidentid;
            objIncidentResolution.Lastupdatetime = DateTime.Now.ToString();
            objIncidentResolution.Resolution = varResolution;
            objIncidentResolution.Userid = userid;
            objIncidentResolution.Insert();
            Editor.Text = "";
            ShowResolution();

            #endregion
        }
        catch (Exception ex)
        {
            string myScript;
            myScript = "<script language=javascript>alert('Exception - '" + ex + "');</script>";
            Page.RegisterClientScriptBlock("MyScript", myScript);
            return;
        }
    }
    protected void Bindgrid()
    {
        #region Declaration of localvariable and table Variable
        int filterId;
        DataTable dtTable = new DataTable();
        dtTable = CreateDataTable();
        string userName = "";
        int varTechnicianId = 0;
        string varSortParameter = "createdatetime";

        #endregion

        #region Get Current User and his Role
        MembershipUser User = Membership.GetUser();
        string varUserRole = "";
        string varRoleTechnician = "";
        if (User != null)
        {
            userName = User.UserName.ToString();
            string[] arrUserRole = Roles.GetRolesForUser();
            varUserRole = arrUserRole[0].ToString();
            varRoleTechnician = Resources.MessageResource.strTechnicianRole.ToString();
        }
        #endregion

        #region Get User object  by Calling Function Get_UserLogin_By_UserName() via passing parameter username and organizationid
        objOrganization = objOrganization.Get_Organization();
        objUser = objUser.Get_UserLogin_By_UserName(userName, objOrganization.Orgid);
        #endregion

        #region If User Exist
        if (objUser.Userid != 0)
        {
            string fromdate = null;
            string todate = null;

            #region Find how many sites have been mapped to current user by calling function Get_All_By_userid() via passing parameter userid
            int userid = objUser.Userid;
            colUserToSite = ObjUserToSite.Get_All_By_userid(userid);
            #endregion
            #region Fetch each object from Collection of UserToSiteMapping
            foreach (UserToSiteMapping obj in colUserToSite)
            {
                #region Declare Local Variables and Collection of Incident_mst Type
                string Status;
                BLLCollection<Incident_mst> col = new BLLCollection<Incident_mst>();
                int siteid;
                #endregion
                #region Get the Siteid and Filter Parameter
                siteid = obj.Siteid;
                filterId = 0;
                #endregion

                #region If Role of User is Technician

                #region If Filter Variable is All
                if (filterId == 0)
                {
                    col = objIncident.Get_All_By_Siteid_Requesterid(siteid, objUser.Userid, fromdate, todate, varSortParameter);
                }
                #endregion

                #endregion

                #region Fetch Each object of type Incident_mst from Collection Incident_mst
                foreach (Incident_mst objInc in col)
                {

                    #region Create Table row and assign value to it
                    DataRow row;
                    row = dtTable.NewRow();
                    row["incidentid"] = Convert.ToString(objInc.Incidentid);
                    row["title"] = objInc.Title;
                    row["requesterid"] = Convert.ToString(objInc.Requesterid);
                    row["createdbyid"] = Convert.ToString(objInc.Createdbyid);
                    row["siteid"] = Convert.ToString(objInc.Siteid);
                    row["createdatetime"] = Convert.ToString(objInc.Createdatetime);
                    objIncidentStates = objIncidentStates.Get_By_id(objInc.Incidentid);
                    row["statusid"] = objIncidentStates.Statusid;
                    row["technicianid"] = objIncidentStates.Technicianid;
                    row["priorityid"] = objIncidentStates.Priorityid;
                    dtTable.Rows.Add(row);
                    #endregion

                }
                #endregion
            }
            #endregion
            #region Bind Grid from datasource dtTable
            DataView dvData = new DataView(dtTable);
            string sortFormat = "{0} {1}";
            String sortDirection = "DESC";
            if (varSortParameter == "createdatetime")
            {
                varSortParameter = "incidentid";
            }
            dvData.Sort = String.Format(sortFormat, varSortParameter, sortDirection);

            grdvwRequest.DataSource = dvData;
            grdvwRequest.DataBind();
            #endregion

        }
        #endregion
    }
    protected void btnUpdate_Click(object sender, EventArgs e)
    {
        //Add Exception handilng try catch change by vishal 21-05-2012
        try
        {
            # region Declare Local Variable
            string StrStatusRequested;
            string StrStatusRejected;
            string StrStatusApproval;
            string StrStatusApproved;
            string StrStatusPlanning;
            string StrStatusTesting;
            string StrStatusRelease;
            string StrStatusImplemented;
            string StrStatusCompleted;
            string StrStatusString = "";
            int userid = 0;
            int changeid = Convert.ToInt32(Request.QueryString[0]);
            string userName = "";
            #endregion
            #region Fetch the Status Value from Resource File
            StrStatusString = GetChangeStatusString(Convert.ToInt32(drpStatus.SelectedValue));
            StrStatusRejected = Resources.MessageResource.StrRejected.ToString();
            StrStatusApproval = Resources.MessageResource.StrApproval.ToString();
            StrStatusRequested = Resources.MessageResource.StrRequested.ToString();
            StrStatusApproved = Resources.MessageResource.StrApproved.ToString();
            StrStatusPlanning = Resources.MessageResource.StrPlanning.ToString();
            StrStatusTesting = Resources.MessageResource.StrTesting.ToString();
            StrStatusRelease = Resources.MessageResource.StrRelease.ToString();
            StrStatusImplemented = Resources.MessageResource.StrImplemented.ToString();
            StrStatusCompleted = Resources.MessageResource.StrCompleted.ToString();

            #endregion
            MembershipUser User = Membership.GetUser();
            userName = User.UserName.ToString();

            #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 Historyvalue in Change History Table
            int result = String.Compare(StrStatusString, StrStatusRequested, true);
            if (result == 0)
            {
                ObjChangeHistory.Changeid = changeid;
                ObjChangeHistory.Operationownerid = userid;
                ObjChangeHistory.Operation = "Requested";
                ObjChangeHistory.Insert();
            }
            result = String.Compare(StrStatusString, StrStatusRejected, true);
            if (result == 0)
            {
                ObjChangeHistory.Changeid = changeid;
                ObjChangeHistory.Operationownerid = userid;
                ObjChangeHistory.Operation = "Rejected";
                ObjChangeHistory.Insert();
            }
            result = String.Compare(StrStatusString, StrStatusApproval, true);
            if (result == 0)
            {
                ObjChangeHistory.Changeid = changeid;
                ObjChangeHistory.Operationownerid = userid;
                ObjChangeHistory.Operation = "Approval";
                ObjChangeHistory.Insert();
            }
            result = String.Compare(StrStatusString, StrStatusApproved, true);
            if (result == 0)
            {
                ObjChangeHistory.Changeid = changeid;
                ObjChangeHistory.Operationownerid = userid;
                ObjChangeHistory.Operation = "Approved";
                ObjChangeHistory.Insert();
            }
            result = String.Compare(StrStatusString, StrStatusPlanning, true);
            if (result == 0)
            {
                ObjChangeHistory.Changeid = changeid;
                ObjChangeHistory.Operationownerid = userid;
                ObjChangeHistory.Operation = "Planning";
                ObjChangeHistory.Insert();
            }
            result = String.Compare(StrStatusString, StrStatusTesting, true);
            if (result == 0)
            {
                ObjChangeHistory.Changeid = changeid;
                ObjChangeHistory.Operationownerid = userid;
                ObjChangeHistory.Operation = "Testing";
                ObjChangeHistory.Insert();
            }
            result = String.Compare(StrStatusString, StrStatusRelease, true);
            if (result == 0)
            {
                ObjChangeHistory.Changeid = changeid;
                ObjChangeHistory.Operationownerid = userid;
                ObjChangeHistory.Operation = "Release";
                ObjChangeHistory.Insert();
            }
            result = String.Compare(StrStatusString, StrStatusImplemented, true);
            if (result == 0)
            {
                ObjChangeHistory.Changeid = changeid;
                ObjChangeHistory.Operationownerid = userid;
                ObjChangeHistory.Operation = "Implemented";
                ObjChangeHistory.Insert();
            }
            result = String.Compare(StrStatusString, StrStatusCompleted, true);
            if (result == 0)
            {
                ObjChangeHistory.Changeid = changeid;
                ObjChangeHistory.Operationownerid = userid;
                ObjChangeHistory.Operation = "Completed";
                ObjChangeHistory.Insert();
            }
            #endregion
            #region Get the Current historyid by calling function Get_Current_ProblemHistoryid()

            int historyid = ObjChangeHistory.Get_Current_ChangeHistoryid();
            #endregion
            #region Find Current value of Problem aBy Calling Function Get_By_id(),via passing problemid

            ObjChange = ObjChange.Get_By_id(changeid);

            #endregion
            #region Insert into ChangeHistoryDiff table ,By Comparing Current value and Updated Values
            if (ObjChange.Changeid != 0)
            {
                #region Declare local variable
                string columnName;
                string prev_value;
                string curnt_value;
                #endregion
                #region If Priority value is changed,Insert into ChangeHistoryDiff table

                if (ObjChange.Priority != Convert.ToInt32(drpPriority.SelectedValue))
                {
                    columnName = Resources.MessageResource.strColumnPriorityid.ToString();
                    prev_value = Convert.ToString(ObjChange.Priority);
                    curnt_value = Convert.ToString(drpPriority.SelectedValue);
                    ObjChangeHistoryDiff.Historyid = historyid;
                    ObjChangeHistoryDiff.Columnname = columnName;
                    ObjChangeHistoryDiff.Current_value = curnt_value;
                    ObjChangeHistoryDiff.Prev_value = prev_value;
                    ObjChangeHistoryDiff.Insert();
                }
                #endregion
                #region If Technician value is changed,Insert into ChangeHistoryDiff table
                if (ObjChange.Technician != Convert.ToInt32(drpTechnician.SelectedValue))
                {
                    columnName = Resources.MessageResource.strColumnTechnicianid.ToString();
                    prev_value = Convert.ToString(ObjChange.Technician);
                    curnt_value = Convert.ToString(drpTechnician.SelectedValue);
                    ObjChangeHistoryDiff.Historyid = historyid;
                    ObjChangeHistoryDiff.Columnname = columnName;
                    ObjChangeHistoryDiff.Current_value = curnt_value;
                    ObjChangeHistoryDiff.Prev_value = prev_value;
                    ObjChangeHistoryDiff.Insert();

                }
                #endregion
                #region If category value is changed,Insert into ChangeHistoryDiff table

                if (ObjChange.Categoryid != Convert.ToInt32(drpCategory.SelectedValue))
                {
                    columnName = Resources.MessageResource.strColumnCategoryid.ToString();
                    prev_value = Convert.ToString(ObjChange.Categoryid);
                    curnt_value = Convert.ToString(drpCategory.SelectedValue);
                    ObjChangeHistoryDiff.Historyid = historyid;
                    ObjChangeHistoryDiff.Columnname = columnName;
                    ObjChangeHistoryDiff.Current_value = curnt_value;
                    ObjChangeHistoryDiff.Prev_value = prev_value;
                    ObjChangeHistoryDiff.Insert();
                }
                #endregion
                #region If Subcategory value is changed,Insert into ChangeHistoryDiff table

                if (ObjChange.Subcategoryid != Convert.ToInt32(drpSubcategory.SelectedValue))
                {
                    columnName = Resources.MessageResource.strColumnSubcategoryid.ToString();
                    prev_value = Convert.ToString(ObjChange.Subcategoryid);
                    curnt_value = Convert.ToString(drpSubcategory.SelectedValue);
                    ObjChangeHistoryDiff.Historyid = historyid;
                    ObjChangeHistoryDiff.Columnname = columnName;
                    ObjChangeHistoryDiff.Current_value = curnt_value;
                    ObjChangeHistoryDiff.Prev_value = prev_value;
                    ObjChangeHistoryDiff.Insert();
                }
                #endregion
                #region If Changetype value is changed,Insert into ChangeHistoryDiff table

                if (ObjChange.Changetype != Convert.ToInt32(drpchangetype.SelectedValue))
                {
                    columnName = Resources.MessageResource.strColumnChangeType.ToString();
                    prev_value = Convert.ToString(ObjChange.Changetype);
                    curnt_value = Convert.ToString(drpchangetype.SelectedValue);
                    ObjChangeHistoryDiff.Historyid = historyid;
                    ObjChangeHistoryDiff.Columnname = columnName;
                    ObjChangeHistoryDiff.Current_value = curnt_value;
                    ObjChangeHistoryDiff.Prev_value = prev_value;
                    ObjChangeHistoryDiff.Insert();
                }
                #endregion
                #region If Changestatus value is changed,Insert into ChangeHistoryDiff table

                if (ObjChange.Changetype != Convert.ToInt32(drpStatus.SelectedValue))
                {
                    columnName = Resources.MessageResource.strColumnstatusid.ToString();
                    prev_value = Convert.ToString(ObjChange.Statusid);
                    curnt_value = Convert.ToString(drpStatus.SelectedValue);
                    ObjChangeHistoryDiff.Historyid = historyid;
                    ObjChangeHistoryDiff.Columnname = columnName;
                    ObjChangeHistoryDiff.Current_value = curnt_value;
                    ObjChangeHistoryDiff.Prev_value = prev_value;
                    ObjChangeHistoryDiff.Insert();
                }
                #endregion

            }
            #endregion
            #region Update the completed status

            #endregion
            #region update the data in change_mst table

            ObjChange.Technician = Convert.ToInt32(drpTechnician.SelectedValue);
            ObjChange.Categoryid = Convert.ToInt32(drpCategory.SelectedValue);
            ObjChange.Subcategoryid = Convert.ToInt32(drpSubcategory.SelectedValue);
            ObjChange.Priority = Convert.ToInt32(drpPriority.SelectedValue);
            ObjChange.Changetype = Convert.ToInt32(drpchangetype.SelectedValue);
            ObjChange.Statusid = Convert.ToInt32(drpStatus.SelectedValue);
            ObjChange.Changeid = Convert.ToInt32(Request.QueryString[0]);
            ObjChange.Active = true;
            #region If Current status is closed,then Assign Completed time
            result = String.Compare(StrStatusString, StrStatusCompleted, true);
            if (result == 0)
            {
                BLLCollection<Incident_To_Change> colincidentchnage = new BLLCollection<Incident_To_Change>();
                colincidentchnage = Objincidenttochange.Get_All_By_Changeid(changeid);
                int id = 0;
                foreach (Incident_To_Change objitoc in colincidentchnage)
                {
                    id = Convert.ToInt32(objitoc.Incidentid);
                }

                IncidentStates objstate = new IncidentStates();
                objstate = objstate.Get_By_id(id);
                Status_mst objincidentstats = new Status_mst();

                objincidentstats = objincidentstats.Get_By_id(objstate.Statusid);
                string currentincidentstatus = objincidentstats.Statusname.ToString();
                int comparestatus = String.Compare(currentincidentstatus, Resources.MessageResource.strStatusClose.ToString(), true);
                if (comparestatus == 0)
                {
                    ObjChange.Completedtime = DateTime.Now.ToString();
                    Change_mst Objcurrentchange = new Change_mst();
                    ChangeStatus_mst Objchangestatus = new ChangeStatus_mst();
                    Objcurrentchange = Objcurrentchange.Get_By_id(changeid);
                    Objchangestatus = Objchangestatus.Get_By_id(Objcurrentchange.Statusid);
                    string status = Objchangestatus.Statusname.ToString();

                    int result1 = String.Compare(status, StrStatusCompleted, true);
                    if (result1 == 0)
                    {
                        ObjChange.Completedtime = Objcurrentchange.Completedtime;
                        ObjChange.Update();

                    }
                    else
                    {
                        ObjChange.Completedtime = DateTime.Now.ToString();
                        ObjChange.Update();

                    }
                }

                else
                {
                    string myScript;
                    //myScript = "<script language=javascript>javascript:alert('Please Close All the Attached Incident');</script>";
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "Javascript:alert('Please Close Alll the attached incident');", "Javascript:alert('Please Close Alll the attached incident');", true);
                    ///'''Page.RegisterClientScriptBlock("MyScript", myScript);
                }

            }
            else
            {

            #endregion

                ObjChange.Update();

            }

            #endregion
            //   #region Update Include Assets in Change value in IncludedAssetinchange

            //objincludeasset.Delete(changeid);
            //for (int i = lstassetupdate.Items.Count - 1; i >= 0; i--)
            //{
            //    if (lstassetupdate.Items[i].Selected == true)
            //    {
            //        objincludeasset.Assetid = Convert.ToInt32(lstassetupdate.Items[i].Value);
            //        objincludeasset.Changeid = changeid;
            //        objincludeasset.Insert();

            //    }
            //}

            //#endregion
            Showchangeinfo();
            btnUpdate.Visible = false;
            btnCancel.Visible = false;
        }
    protected void grdvwProblem_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;

                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[2].Text);
                objUser = objUser.Get_By_id(requesterid);

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

                #region Bind Datarow at Run Time with Createdbyid to Created by name
                int createdbyid = Convert.ToInt32(e.Row.Cells[3].Text);
                objUser = objUser.Get_By_id(createdbyid);
                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 technicianid to technician name
                int technicianid = Convert.ToInt32(e.Row.Cells[4].Text);
                objUser = objUser.Get_By_id(technicianid);
                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 Statusid to Status
                int statusid = Convert.ToInt32(e.Row.Cells[5].Text);
                objStatus = objStatus.Get_By_id(statusid);
                if (objStatus.Statusid != 0)
                {

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

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

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

            }
    }
    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 buttonadd_click(object sender, EventArgs e)
    {
        /////Add Exception handilng try catch change by vishal 21-05-2012
        try
        {
            #region Find Userid of User who is Requesting to log a call

            #region If User Already Exist
            if (ViewState["UserCreate"].ToString() == "Exist")
            {
                objOrganization = objOrganization.Get_Organization();
                ObjUserLogin = ObjUserLogin.Get_UserLogin_By_UserName(txtUsername.Text.ToString().Trim(), objOrganization.Orgid);
                if (ObjUserLogin.Userid != 0)
                {
                    requesterid = ObjUserLogin.Userid;
                }
            }
            #endregion
            #region If New User is to be Created
            else if (ViewState["UserCreate"].ToString() == "create")
            {
                string varEmail = "";
                string varRoleName = Resources.MessageResource.BasicUserRole.ToString();
                if (txtEmail.Text == "")
                {
                    varEmail = Resources.MessageResource.errMemshipCreateUserEmail.ToString();
                }
                else
                {
                    varEmail = txtEmail.Text;
                }

                int roleid = objRole.Get_By_RoleName(varRoleName);
                int status;
                objOrganization = objOrganization.Get_Organization();

                objuser.Username = txtUsername.Text.ToString();
                objuser.Password = Resources.MessageResource.strDefaultPassword.ToString();
                objuser.Roleid = roleid;
                objuser.Orgid = objOrganization.Orgid;
                objuser.ADEnable = false;
                objuser.Enable = true;
                objuser.Createdatetime = DateTime.Now.ToString();
                status = objuser.Insert();
                if (status == 1)
                {
                    // Create Mstatus field to send in Membership.CreateUser function as Out Variable for creating Membership User database
                    MembershipCreateStatus Mstatus = default(MembershipCreateStatus);
                    // Call Membership.CreateUser function to create Membership user
                    Membership.CreateUser(txtUsername.Text.ToString().Trim(), Resources.MessageResource.strDefaultPassword.ToString(), varEmail, "Project Name", "Helpdesk", true, out Mstatus);
                    // Call Roles.AddUserToRole Function to Add User To Role
                    Roles.AddUserToRole(txtUsername.Text.ToString().Trim(), varRoleName);
                    // Declare Local Variable Userid to fetch userid of newly created user

                    // Create Object objUserLogin of UserLogin_mst()Class
                    objuser = new UserLogin_mst();
                    // Fetch userid of Newly created user and assign to local variable userid by calling function objUserLogin.Get_By_UserName
                    requesterid = objuser.Get_By_UserName(txtUsername.Text.ToString().Trim(), objOrganization.Orgid);
                    // If userid not equal to 0 then we get userid of Newly created user otherwise error Occured

                    ContactInfo_mst objContactInfo = new ContactInfo_mst();
                    objContactInfo.Userid = requesterid;
                    objContactInfo.Emailid = varEmail;
                    objContactInfo.Firstname = txtUsername.Text.ToString();
                    objContactInfo.Lastname = txtUsername.Text.ToString();
                    objContactInfo.Insert();

                }
            }
            #endregion
            #region If User is Not to be Created
            else if (ViewState["UserCreate"].ToString() == "notcreate")
            {
                // FlagUserStatus = false;

            }
            #endregion

            #endregion
            ObjChange.Active = true;

            ObjChange.Statusid = Convert.ToInt32(drpStatus.SelectedValue);
            ObjChange.Categoryid = Convert.ToInt32(drpCategory.SelectedValue);
            ObjChange.Subcategoryid = Convert.ToInt32(drpSubcategory.SelectedValue);
            ///ObjChange.Technician = "";
            ObjChange.Title = txtTitle.Text;
            ObjChange.Description = txtDescription.Text;
            ObjChange.Createdtime = DateTime.Now.ToString();
            ObjChange.Changetype = Convert.ToInt32(drpchangetype.SelectedValue);
            ObjChange.Approvalstatus = "Send For Approval";
            MembershipUser user = Membership.GetUser();
            string username = user.UserName.ToString();
            objOrganization = objOrganization.Get_Organization();
            ObjUserLogin = ObjUserLogin.Get_UserLogin_By_UserName(username, objOrganization.Orgid);
            int userid = Convert.ToInt32(ObjUserLogin.Userid);
            ObjChange.CreatedByID = userid;
            //////////change doneby meenakshi

            objservice = objservice.Get_By_id(Convert.ToInt32(drpservices.SelectedValue));
            if (objservice.servicename != null)
            {
                ObjChange.servicename = objservice.servicename;
            }
            else
            {
                ObjChange.servicename = "";
            }
            ////////end
            ObjUserLogin = ObjUserLogin.Get_UserLogin_By_UserName(txtUsername.Text, objOrganization.Orgid);
            ObjChange.Requestedby = ObjUserLogin.Userid;
            //ObjChange.Priority = Convert.ToInt32(drpPriority.SelectedValue);
            ObjChange.Insert();
            int changeid = ObjChange.Get_Current_Changeid();
            for (int i = ListAsset.Items.Count - 1; i >= 0; i--)
            {
                if (ListAsset.Items[i].Selected == true)
                {
                    Objincludeaasetchange.Assetid = Convert.ToInt32(ListAsset.Items[i].Value);
                    Objincludeaasetchange.Changeid = changeid;
                    Objincludeaasetchange.Insert();

                }
            }
            objIncidentToChange.Changeid = changeid;
            objIncidentToChange.Incidentid = Convert.ToInt32(Session["incidentid"]);

            objIncidentToChange.Insert();
            int changetype = Convert.ToInt32(ObjChange.Changetype);
            objSentEmailToChange.SentMailToChangeCommittee(changeid, changetype);
            ScriptManager.RegisterStartupScript(this, this.GetType(), "Close()", "Close();", true);
        }
        catch (Exception ex)
        {
            string myScript;
            myScript = "<script language=javascript>alert('Exception - '" + ex + "');</script>";
            Page.RegisterClientScriptBlock("MyScript", myScript);
            return;
        }
    }
    protected void txtUsername_TextChanged(object sender, EventArgs e)
    {
        #region Find Userid of User who is Requesting to log a call
        objOrganization = objOrganization.Get_Organization();
        ObjUserLogin = ObjUserLogin.Get_UserLogin_By_UserName(txtUsername.Text.ToString().Trim(), objOrganization.Orgid);
        if (ObjUserLogin.Userid == 0)
        {
            string myScript;
            myScript = "<script language=javascript>function __doPostBack(eventTarget, eventArgument){var theForm = document.forms['aspnetForm'];  if (theForm){  theForm.__EVENTTARGET.value = eventTarget;theForm.__EVENTARGUMENT.value = eventArgument;theForm.submit(); }} var Flag= confirm('User Does not Exist,Do You Want to Create User');if(Flag==true){ __doPostBack('callPostBack', 'create');}if(Flag==false){ __doPostBack('callPostBack', 'notcreate');}</script>";
            Page.RegisterClientScriptBlock("MyScript", myScript);

        }
        else { ViewState["UserCreate"] = "Exist"; }

        #endregion
    }
    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";
    }