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;
            }
        }
    }
Beispiel #2
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
 }
    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 #4
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();
            }
        }
    }
    // 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 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 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)
    {///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;
        }
    }
    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 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 #11
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 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;
        }
    }
Beispiel #13
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        //Add Exception handilng try catch change by vishal 21-05-2012
        try
        {
            //if (dt.Rows.Count > 0)
            //{
            #region match keys with given keys
            // Create Local variable varOrganizationId to hold the Organization id from Organization_mst table
            int varOrganizationId;
            //  Call function objOrganization.Get_Organization(), to get Object of Organization_mst Class
            objOrganization = objOrganization.Get_Organization();
            // Assign Organization Id to variable varOrganizationId
            varOrganizationId = objOrganization.Orgid;
            // Call Function objUserLogin.Get_UserLogin_By_UserName ,to get Object of UserLogin_mst Class by passing parameter username and organization id
            objUserLogin = objUserLogin.Get_UserLogin_By_UserName(txtUserName.Text.ToString().Trim(), varOrganizationId);
            // Create local Variable varDomainName to get the value of domain name

            #region if user is AD user
            // Check whether User is from Active Directory User or Normal User,  if objUserLogin.ADEnable == true ie user is Active Directory User
            if (objUserLogin.ADEnable == true)
            {
                //string varDomainName = objUserLogin.DomainName;
                // Create local Variable FlagStatus ,to hold the status of whether user have valid credentials against Active Directory

                // Call get DomainName from DB                  //added by lalit joshi
                string domainname = getdomain();
                bool   FlagStatus;
                // Call Function Authenticate to validate user credentials by passing parameters Username,Password and DomainName and store Status in variable FlagStatus
                FlagStatus = Authenticate(txtUserName.Text.ToString().Trim(), txtPassword.Text.ToString().Trim(), getdomain());

                // If FlagStatus is True ,ie  User Credentials are Valid and it's Cookie Ticket Will be Generated
                if (FlagStatus == true)
                {
                    // Cookie Ticket is  Generated and redirected to the default page
                    FormsAuthentication.SetAuthCookie(txtUserName.Text.ToString().Trim(), false);

                    #region find last row of Key table
                    DataTable dt = Authenticate();
                    #endregion

                    if (dt.Rows.Count > 0)
                    {
                        string decrytkey = Decrypt(dt.Rows[0]["Lkey"].ToString(), "pipl?123");
                        string keystatus = Encrypt("InActive", "pipl?123");

                        if (decrytkey == "bu$$1ne$$@2011" || decrytkey == "educ0mp#1nch1n@" || decrytkey == "c1v1l$0c1at@" || decrytkey == "11$1n2011" || decrytkey == "1nsp1r@t10n" || decrytkey == "c1rcum1nst@nce5" || decrytkey == "pipl$prog#" || decrytkey == "$1lverl1ghtc01n" || decrytkey == "A@B#Z123$*" || decrytkey == "Z001nP0lyt1c$" || decrytkey == "DUU3MY1$FG")
                        {
                            string decryptstatus = Decrypt(dt.Rows[0]["status"].ToString(), "pipl?123");
                            if (decryptstatus == "Active")
                            {
                                string   dtvalid      = dt.Rows[0]["validdate"].ToString();
                                string   dtvaliddecry = Decrypt(dt.Rows[0]["validdate"].ToString(), "pipl?123");
                                DateTime dtvaliddecr  = DateTime.Parse(dtvaliddecry);
                                DateTime dttoday      = DateTime.Now;
                                #region if today date is exceeding expiry date
                                if (DateTime.Compare(dttoday, dtvaliddecr) >= 0)
                                {
                                    string sql = "update Loginkey set status='" + keystatus + "' where status='" + dt.Rows[0]["status"].ToString() + "'";
                                    UpdateRecord(sql);
                                    Response.Redirect("~/Admin/Activate.aspx");
                                }
                                #endregion

                                if (Roles.IsUserInRole(txtUserName.Text.ToString().Trim(), "PManager"))
                                {
                                    Response.Redirect("~/KEDB/ViewSolution.aspx");
                                }
                                else if (Roles.IsUserInRole(txtUserName.Text.ToString().Trim(), "User"))
                                {
                                    Response.Redirect("~/Login/Usercall.aspx");
                                }
                                else
                                {
                                    Response.Redirect("~/Login/Default.aspx");
                                }
                            }
                            else
                            {
                                Response.Redirect("~/admin/Activate.aspx");
                            }
                        }
                    }
                    else
                    {
                        DateTime date        = System.DateTime.Now;
                        DateTime dateto30    = System.DateTime.Now.AddMonths(1);
                        string   keyen       = Encrypt("bu$$1ne$$@2011", "pipl?123");
                        string   keydate     = Encrypt(date.ToString(), "pipl?123");
                        string   keydateto30 = Encrypt(dateto30.ToString(), "pipl?123");
                        string   keystatus   = Encrypt("Active", "pipl?123");

                        string sql = "insert into LoginKey(Lkey,currentdate,validdate,status)values('" + keyen + "','" + keydate + "','" + keydateto30 + "','" + keystatus + "')";
                        Insert(sql);
                        if (Roles.IsUserInRole(txtUserName.Text.ToString().Trim(), "PManager"))
                        {
                            Response.Redirect("~/KEDB/ViewSolution.aspx");
                        }
                        else if (Roles.IsUserInRole(txtUserName.Text.ToString().Trim(), "User"))
                        {
                            Response.Redirect("~/Login/Usercall.aspx");
                        }
                        else
                        {
                            Response.Redirect("~/Login/Default.aspx");
                        }
                    }
                }
                else
                {
                    // If User Credentials is not valid against active directory,display message Either Username or Password is not Valid
                    lblErrorMsg.Text = Resources.MessageResource.errUserNotVaild.ToString();
                }
            }
            #endregion

            else
            {
                int userid = objUserLogin.Get_By_UserName(txtUserName.Text.Trim(), varOrganizationId);
                // Check User Credentials Against Database,We Use Membership Function Membership.ValidateUser to check User Credentials against aspnet database
                // If it's Returns True,ie user has valid Credentials and it's Cookir ticket wiil be generated
                if (Membership.ValidateUser(txtUserName.Text.ToString().Trim(), txtPassword.Text.ToString().Trim()) || AuthenticateFromDB(userid, txtPassword.Text.Trim()))
                {
                    // Cookie Ticket is  Generated and redirected to the default page
                    FormsAuthentication.SetAuthCookie(txtUserName.Text.ToString().Trim(), false);

                    #region find last row of Key table
                    DataTable dt = Authenticate();
                    #endregion

                    if (dt.Rows.Count > 0)
                    {
                        string decrytkey = Decrypt(dt.Rows[0]["Lkey"].ToString(), "pipl?123");
                        string keystatus = Encrypt("InActive", "pipl?123");

                        if (decrytkey == "bu$$1ne$$@2011" || decrytkey == "educ0mp#1nch1n@" || decrytkey == "c1v1l$0c1at@" || decrytkey == "11$1n2011" || decrytkey == "1nsp1r@t10n" || decrytkey == "c1rcum1nst@nce5" || decrytkey == "pipl$prog#" || decrytkey == "$1lverl1ghtc01n" || decrytkey == "A@B#Z123$*" || decrytkey == "Z001nP0lyt1c$" || decrytkey == "DUU3MY1$FG" || decrytkey == "M@UU37Y1$FG")
                        {
                            string decryptstatus = Decrypt(dt.Rows[0]["status"].ToString(), "pipl?123");
                            if (decryptstatus == "Active")
                            {
                                string   dtvalid      = dt.Rows[0]["validdate"].ToString();
                                string   dtvaliddecry = Decrypt(dt.Rows[0]["validdate"].ToString(), "pipl?123");
                                DateTime dtvaliddecr  = DateTime.Parse(dtvaliddecry);
                                DateTime dttoday      = DateTime.Now;
                                #region if today date is exceeding expiry date
                                if (DateTime.Compare(dttoday, dtvaliddecr) >= 0)
                                {
                                    string sql = "update Loginkey set status='" + keystatus + "' where status='" + dt.Rows[0]["status"].ToString() + "'";
                                    UpdateRecord(sql);
                                    Response.Redirect("~/Admin/Activate.aspx");
                                }
                                #endregion

                                if (Roles.IsUserInRole(txtUserName.Text.ToString().Trim(), "PManager"))
                                {
                                    Response.Redirect("~/KEDB/ViewSolution.aspx");
                                }
                                else if (Roles.IsUserInRole(txtUserName.Text.ToString().Trim(), "User"))
                                {
                                    Response.Redirect("~/Login/Usercall.aspx");
                                }
                                else
                                {
                                    Response.Redirect("~/Login/Default.aspx");
                                }
                            }
                            else
                            {
                                Response.Redirect("~/admin/Activate.aspx");
                            }
                        }
                    }
                    else
                    {
                        DateTime date        = System.DateTime.Now;
                        DateTime dateto30    = System.DateTime.Now.AddMonths(1);
                        string   keyen       = Encrypt("bu$$1ne$$@2011", "pipl?123");
                        string   keydate     = Encrypt(date.ToString(), "pipl?123");
                        string   keydateto30 = Encrypt(dateto30.ToString(), "pipl?123");
                        string   keystatus   = Encrypt("Active", "pipl?123");

                        string sql = "insert into LoginKey(Lkey,currentdate,validdate,status)values('" + keyen + "','" + keydate + "','" + keydateto30 + "','" + keystatus + "')";
                        Insert(sql);
                        if (Roles.IsUserInRole(txtUserName.Text.ToString().Trim(), "PManager"))
                        {
                            Response.Redirect("~/KEDB/ViewSolution.aspx");
                        }
                        else if (Roles.IsUserInRole(txtUserName.Text.ToString().Trim(), "User"))
                        {
                            Response.Redirect("~/Login/Usercall.aspx");
                        }
                        else
                        {
                            Response.Redirect("~/Login/Default.aspx");
                        }
                    }
                }
                else
                {
                    // If User Credentials is not valid against databse,display message Either Username or Password is not Valid
                    lblErrorMsg.Text = Resources.MessageResource.errUserNotVaild.ToString();
                }

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

        #region Fetch Current User
        // Fetch Current User and assign to local variable userName
        MembershipUser User = Membership.GetUser();
        userName = User.UserName.ToString();
        #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

        //objIncidentHistory.Incidentid = incidentid;
        //objIncidentHistory.Operationownerid = userid;
        //objIncidentHistory.Operation = "update";
        //objIncidentHistory.Insert();
        //#region Get the Current historyid by calling function Get_Current_IncidentHistoryid()
        //int historyid = objIncidentHistory.Get_Current_IncidentHistoryid();
        //#endregion

        //#region Insert into IncidentHistoryDiff table ,By Comparing Current value and Updated Values
        //#region Declare local variable
        //string columnName;
        //string prev_value;
        //string curnt_value;
        //#endregion

        //columnName = "Resolution";
        //prev_value = "";
        //curnt_value = Editor.Text ;
        //objIncidentHistoryDiff.Historyid = historyid;
        //objIncidentHistoryDiff.Columnname = columnName;
        //objIncidentHistoryDiff.Current_value = curnt_value;
        //objIncidentHistoryDiff.Prev_value = prev_value;
        //objIncidentHistoryDiff.Insert();


        //#endregion
        Session["ResolutionAdded"]           = "true";
        objIncidentResolution.Incidentid     = incidentid;
        objIncidentResolution.Lastupdatetime = DateTime.Now.ToString();
        objIncidentResolution.Resolution     = Editor.Text;
        objIncidentResolution.Userid         = userid;
        Editor.Text = "";
        objIncidentResolution.Insert();
        //ShowResolution();

        string myScript;
        myScript = "<script language=javascript>javascript:window.close();</script>";
        Page.RegisterClientScriptBlock("MyScript", myScript);
    }
Beispiel #15
0
    protected void btnSolutionAdd_Click(object sender, EventArgs e)
    {//Add Exception handilng try catch change by vishal 21-05-2012
        try
        {
            string Prev_value   = "";
            string Curr_value   = "";
            int    SolutionType = Convert.ToInt32(Request.QueryString[0]);
            int    problemid    = Convert.ToInt32(Request.QueryString[1]);
            if (SolutionType != 0)
            {
                if (SolutionType == 1)
                {
                    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 = "WorkAround";
                    ObjSolution.Insert();
                    Solutionid = ObjSolutionKeyword.Get_SolutionId();
                    ObjproblemToSolution.Problemid    = problemid;
                    ObjproblemToSolution.Solutionid   = Solutionid;
                    ObjproblemToSolution.Solutiontype = "WorkAround";
                    ObjproblemToSolution.Insert();
                    ObjSolutionKeyword.Keywords   = txtKeywords.Text.ToString();
                    ObjSolutionKeyword.Solutionid = Solutionid;
                    ObjSolutionKeyword.Insert();
                    ObjSolutionCreator.Solutionid = Solutionid;
                    ObjSolutionCreator.Createdby  = objUser.Userid;
                    ObjSolutionCreator.Insert();
                    objSentMailToUser.SentMailToPManager(Solutionid);
                }
                if (SolutionType == 4)
                {
                    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);
                    problemid       = Convert.ToInt32(Request.QueryString[1]);
                    colproblems     = ObjproblemToSolution.Get_All_Problemid(problemid);
                    foreach (ProblemToSolution obj in colproblems)
                    {
                        if (obj.Solutiontype == "WorkAround")
                        {
                            ObjSolution.Solutionid = obj.Solutionid;
                        }
                    }

                    ObjSolution.Solution = "WorkAround";
                    ObjSolution.Content  = Editor.Text.ToString();
                    ObjSolution.Title    = txtTitle.Text.ToString();
                    ObjSolution.Topicid  = Convert.ToInt32(drpTopic.SelectedValue);
                    ObjSolution.Update();
                    ObjSolutionKeyword.Keywords   = txtKeywords.Text.ToString();
                    ObjSolutionKeyword.Solutionid = Convert.ToInt32(ObjSolution.Solutionid);
                    ObjSolutionKeyword.Update();
                    ObjSolutionCreator.LastUpdateBy = objUser.Userid;
                    ObjSolutionCreator.LastUpdateon = DateTime.Now.ToString();
                    ObjSolutionCreator.Update();
                }



                if (SolutionType == 3)
                {
                    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);
                    problemid       = Convert.ToInt32(Request.QueryString[1]);
                    colproblems     = ObjproblemToSolution.Get_All_Problemid(problemid);
                    foreach (ProblemToSolution obj in colproblems)
                    {
                        if (obj.Solutiontype == "Solution")
                        {
                            ObjSolution.Solutionid = obj.Solutionid;
                        }
                    }

                    ObjSolution.Solution = "Solution";
                    ObjSolution.Content  = Editor.Text.ToString();
                    ObjSolution.Title    = txtTitle.Text.ToString();
                    ObjSolution.Topicid  = Convert.ToInt32(drpTopic.SelectedValue);
                    ObjSolution.Update();
                    ObjSolutionKeyword.Keywords   = txtKeywords.Text.ToString();
                    ObjSolutionKeyword.Solutionid = Convert.ToInt32(ObjSolution.Solutionid);
                    ObjSolutionKeyword.Update();
                    ObjSolutionCreator.LastUpdateBy = objUser.Userid;
                    ObjSolutionCreator.LastUpdateon = DateTime.Now.ToString();
                    ObjSolutionCreator.Update();
                }
                if (SolutionType == 2)
                {
                    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);

                    // ObjproblemToSolution = ObjproblemToSolution.Get_All_Problemid(problemid);
                    int Solutionid;
                    ObjSolution.Title    = txtTitle.Text.ToString();
                    ObjSolution.Content  = Editor.Text.ToString();
                    ObjSolution.Topicid  = Convert.ToInt32(drpTopic.SelectedValue);
                    ObjSolution.Solution = "Solution";
                    ObjSolution.Insert();
                    Solutionid = ObjSolutionKeyword.Get_SolutionId();
                    ObjproblemToSolution.Problemid    = problemid;
                    ObjproblemToSolution.Solutionid   = Solutionid;
                    ObjproblemToSolution.Solutiontype = "Solution";
                    ObjproblemToSolution.Insert();
                    ObjSolutionKeyword.Keywords   = txtKeywords.Text.ToString();
                    ObjSolutionKeyword.Solutionid = Solutionid;
                    ObjSolutionKeyword.Insert();
                    ObjSolutionCreator.Solutionid = Solutionid;
                    ObjSolutionCreator.Createdby  = objUser.Userid;
                    ObjSolutionCreator.Insert();
                    objSentMailToUser.SentMailToPManager(Solutionid);
                }
            }

            string myScript;
            myScript = "<script language=javascript>refreshParent();</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 BindDropCustomer()
    //{
    //    BLLCollection<Customer_mst> colCtS = new BLLCollection<Customer_mst>();
    //    string userName = "";
    //    MembershipUser User = Membership.GetUser();
    //    if (User != null)
    //    {
    //        userName = User.UserName.ToString();
    //    }
    //    if (userName != "")
    //    {
    //        int userid;
    //        int Flagcount = 0;
    //        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)
    //                {
    //                    colCustToSite=objCustToSite.Get_All_By_siteid(objSite1.Siteid);
    //                    foreach (CustomerToSiteMapping objcts in colCustToSite)
    //                    {
    //                        Customer_mst objC = new Customer_mst();
    //                        int FlagStatus = 0;
    //                        objC = objC.Get_By_id(objcts.Custid);
    //                        if (Flagcount == 0)
    //                        {
    //                            colCtS.Add(objC);
    //                        }
    //                        else
    //                        {
    //                            foreach (Customer_mst objCus in colCtS)
    //                            {
    //                                if (objC.Custid == objCus.Custid)
    //                                {
    //                                    FlagStatus = 1;
    //                                }
    //                            }
    //                            if (FlagStatus==0)
    //                            {
    //                                colCtS.Add(objC);
    //                            }
    //                        }
    //                        Flagcount = Flagcount + 1;
    //                    }
    //                }
    //            }
    //        }
    //    }
    //    drpCustomer.DataTextField = "Customer_Name";
    //    drpCustomer.DataValueField = "CustId";
    //    drpCustomer.DataSource = colCtS;
    //    drpCustomer.DataBind();
    //    if (colCtS.Count  == 0)
    //    {
    //        ListItem item = new ListItem();
    //        item.Text = "-------------Select-------------";
    //        item.Value = "0";
    //        drpCustomer.Items.Add(item);
    //    }
    //}
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        //Add Exception handilng try catch change by vishal 21-05-2012
        try
        {
            Session["UserCreate"] = "Exist";

            #region Declaration of Local Variables
            int siteid, priorityid;
            int SLAid = 0;
            int createdbyid = 0;
            int requesterid = 0;
            int FlagInsert;
            int requesttypeid;
            string userName;
            bool FlagUserStatus;
            FlagUserStatus = true;
            FlagInsert = 0;
            #endregion

            #region Fetch Current User
            MembershipUser User = Membership.GetUser();
            userName = User.UserName.ToString();
            #endregion
            #region Get Current Site and Priority id
            siteid = Convert.ToInt32(drpSite.SelectedValue);
            priorityid = Convert.ToInt32(drpPriority.SelectedValue);
            #endregion

            #region Get SLAid on the basis of siteid and Priority id

            if (siteid != 0 && priorityid != 0)
            {
                SLAid = objIncident.Get_By_SLAid(siteid, priorityid);
                requesttypeid = Convert.ToInt32(Resources.MessageResource.strRequestTypeId.ToString());
                if (requesttypeid == Convert.ToInt32(drpRequestType.SelectedValue))
                {
                    SLAid = 0;
                }
            }
            #endregion
            if (userName != "")
            {
                #region Find Userid of User who Created this Request
                objOrganization = objOrganization.Get_Organization();
                objUser = objUser.Get_UserLogin_By_UserName(userName, objOrganization.Orgid);
                if (objUser.Userid != 0)
                {
                    createdbyid = objUser.Userid;
                }

                #endregion

                #region Find Userid of User who is Requesting to log a call

                #region If User Already Exist
                if (Session["UserCreate"].ToString() == "Exist")
                {
                    objUser = objUser.Get_UserLogin_By_UserName(txtUsername.Text.ToString().Trim(), objOrganization.Orgid);
                    if (objUser.Userid != 0)
                    {
                        requesterid = objUser.Userid;
                    }
                }
                #endregion

                #endregion

            }

            //added by lalit
            objIncident.Reporteddatetime =DBNull.Value.ToString();
            objIncident.AMCCall = false;
            //end
            objIncident.Title = txtTitle.Text.ToString().Trim() + "-" + TxtExtension.Text.Trim();
            objIncident.Slaid = SLAid;
            objIncident.Createdbyid = createdbyid;
            objIncident.Requesterid = requesterid;
            objIncident.Siteid = siteid;
            objIncident.Description = txtDescription.Text.ToString().Trim();
            objIncident.Deptid = 0;
            objIncident.Createdatetime = DateTime.Now.ToString();
            objIncident.Modeid = Convert.ToInt32(drpMode.SelectedValue);
            UserToSiteMapping objUserToSite = new UserToSiteMapping();

            if (FlagUserStatus == true)
            {
                FlagInsert = objIncident.Insert();

                #region Save Assetid and incident id in incidenttoassetmaaping

                objOrganization = objOrganization.Get_Organization();
                objUser = objUser.Get_UserLogin_By_UserName(txtUsername.Text.ToString().Trim(), objOrganization.Orgid);
                int userid = Convert.ToInt32(objUser.Userid);
                int tempuser1 = Convert.ToInt32(Session["tempuser1"]);
                if (tempuser1 == 1)
                {
                    assetid = Convert.ToInt32(Session["assetid"]);
                }
                else
                {
                    assetid = Convert.ToInt32(objusertoasset.Get_AssetId_By_UserId(userid));
                }
                int incid = Convert.ToInt32(objIncident.Get_TopIncidentId());
                if (txtassignasset.Text != "")
                {
                    //assetid = Convert.ToInt32(txtassignasset.Text);
                    if (assetid != 0)
                    {
                        objincidenttoasset.Insert(incid, assetid);
                        objusertoasset.Insert(userid, assetid, objUser.City, objUser.Company);    //added a new column siteid
                        Session.Abandon();
                    }
                }

                #endregion

            }

            if (FlagInsert == 1)
            {
                int FlagIncdStatesInsert;
                int incidentid;
                incidentid = objIncident.Get_Current_Incidentid();
                objIncidentStates.Incidentid = incidentid;
                objIncidentStates.Priorityid = Convert.ToInt32(drpPriority.SelectedValue);
                objIncidentStates.Categoryid = Convert.ToInt32(drpCategory.SelectedValue);
                objIncidentStates.Statusid = Convert.ToInt32(drpStatus.SelectedValue);
                objIncidentStates.Subcategoryid = Convert.ToInt32(drpSubcategory.SelectedValue);
                objIncidentStates.Technicianid = 0;

                objIncidentStates.Requesttypeid = Convert.ToInt32(drpRequestType.SelectedValue);
                FlagIncdStatesInsert = objIncidentStates.Insert();
                if (FlagIncdStatesInsert == 1)
                {
                    objIncidentHistory.Incidentid = incidentid;
                    objIncidentHistory.Operation = "create";
                    objIncidentHistory.Operationownerid = createdbyid;
                    objIncidentHistory.Insert();
                    objSentmailtoUser.SentmailUser(requesterid, incidentid, "open");
                    // change code/////////////////////////////////////////////////////////////////
                    if (FileUpload1.HasFile)
                    {
                        string filepath = Server.MapPath("~/FileAttach/");
                        string[] filenameupd = FileUpload1.FileName.Split(new char[] { '.' });
                        string filenew = Convert.ToString(incidentid) + "." + filenameupd[1];
                        FileUpload1.PostedFile.SaveAs(filepath + filenew);
                    }
                    ///////////////////////////////////////////////////////////////////////////////
                    ////////change code on 27 march///
                    #region Map Site to user
                    //FlagInsert=0;
                    int FlagDelete = 0;
                    int FlagStatus = 0;
                    //string Username;
                    //string gvIDs;
                    int organizationId;
                    //string gv;
                    // Get object of Organization to get organization id and assign to local variable organizationId
                    objOrganization = objOrganization.Get_Organization();
                    organizationId = objOrganization.Orgid;
                    // Get username from textbox and assign to local variable Username
                    //Username = txtUserName.Text.ToString().Trim();
                    // Find User Exist ,by calling function Get_UserLogin_By_UserName()
                    //objUser = objUser.Get_UserLogin_By_UserName(Username, organizationId);
                    // If Userid is not zero ,then user exist in database
                    if (objUser.Userid != 0)
                    {
                        //'Navigate through each row in the GridView for checkbox items
                        //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");
                        // If deleteChkBxItem is Checked then ,mapped Current site to this user
                        //if (deleteChkBxItem.Checked)
                        //{
                        // 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;

                        userid = Convert.ToInt32(objUser.Userid);
                        //siteid = Convert.ToInt32(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  zero then site is not  mapped to this user
                        if (FlagStatus == 0)
                        {
                            objUserToSite.Siteid = siteid;
                            objUserToSite.Userid = userid;
                            // Mapped Current Site to this User by calling function objUserToSite.Insert()
                            FlagInsert = objUserToSite.Insert();
                        }
                        //}
                    }
                    // If deleteChkBxItem is Un Checked then ,Un mapped Current site to this user
                    else
                    {
                        // 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;

                        userid = Convert.ToInt32(objUser.Userid);
                        //siteid = Convert.ToInt32(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)
                        {
                            // Un Mapped Current Site to this User by calling function objUserToSite.Delete()
                            FlagDelete = objUserToSite.Delete(userid, siteid);
                        }
                        //}
                    }
                    //}
                    #endregion

                    /////////////end/////////////////

                    Response.Redirect("../Login/AllUserCall.aspx");

                }

            }

        }
        catch (Exception ex)
        {
            string myScript;
            myScript = "<script language=javascript>alert('Exception - '" + ex + "');</script>";
            Page.RegisterClientScriptBlock("MyScript", myScript);
            return;
        }
    }
Beispiel #17
0
    //Added by Lalit
    public void BindDropCustomer()
    {
        BLLCollection <Customer_mst> colCtS = new BLLCollection <Customer_mst>();
        string         userName             = "";
        MembershipUser User = Membership.GetUser();

        if (User != null)
        {
            userName = User.UserName.ToString();
        }
        if (userName != "")
        {
            int userid;
            int Flagcount = 0;
            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)
                    {
                        colCustToSite = objCustToSite.Get_All_By_siteid(objSite1.Siteid);


                        foreach (CustomerToSiteMapping objcts in colCustToSite)
                        {
                            Customer_mst objC       = new Customer_mst();
                            int          FlagStatus = 0;
                            objC = objC.Get_By_id(objcts.Custid);
                            if (Flagcount == 0)
                            {
                                colCtS.Add(objC);
                            }
                            else
                            {
                                foreach (Customer_mst objCus in colCtS)
                                {
                                    if (objC.Custid == objCus.Custid)
                                    {
                                        FlagStatus = 1;
                                    }
                                }
                                if (FlagStatus == 0)
                                {
                                    colCtS.Add(objC);
                                }
                            }
                            Flagcount = Flagcount + 1;
                        }
                    }
                }
            }
            //}

            //DdlStock.DataBind();
            //   DdlOwner.DataTextField = "Customer_Name";
            //  DdlOwner.DataValueField = "CustId";
            //  DdlOwner.DataSource = colCtS;
            //  DdlOwner.DataBind();

            //if (colCtS.Count == 0)
            //{
            ListItem item = new ListItem();
            item.Text = "Other";
            //item.Value = "1";
            //   DdlOwner.Items.Add(item);


            //}
        }
    }
Beispiel #18
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
    }
    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 #20
0
    //protected void BindDropCustomer()
    //{
    //    BLLCollection<Customer_mst> colCtS = new BLLCollection<Customer_mst>();

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


    //    if (userName != "")
    //    {
    //        int userid;
    //        int Flagcount = 0;
    //        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)
    //                {
    //                    colCustToSite=objCustToSite.Get_All_By_siteid(objSite1.Siteid);


    //                    foreach (CustomerToSiteMapping objcts in colCustToSite)
    //                    {
    //                        Customer_mst objC = new Customer_mst();
    //                        int FlagStatus = 0;
    //                        objC = objC.Get_By_id(objcts.Custid);
    //                        if (Flagcount == 0)
    //                        {
    //                            colCtS.Add(objC);
    //                        }
    //                        else
    //                        {
    //                            foreach (Customer_mst objCus in colCtS)
    //                            {
    //                                if (objC.Custid == objCus.Custid)
    //                                {
    //                                    FlagStatus = 1;
    //                                }

    //                            }
    //                            if (FlagStatus==0)
    //                            {
    //                                colCtS.Add(objC);
    //                            }

    //                        }

    //                        Flagcount = Flagcount + 1;

    //                    }

    //                }

    //            }


    //        }


    //    }

    //    drpCustomer.DataTextField = "Customer_Name";
    //    drpCustomer.DataValueField = "CustId";
    //    drpCustomer.DataSource = colCtS;
    //    drpCustomer.DataBind();
    //    if (colCtS.Count  == 0)
    //    {
    //        ListItem item = new ListItem();
    //        item.Text = "-------------Select-------------";
    //        item.Value = "0";
    //        drpCustomer.Items.Add(item);

    //    }



    //}
    protected void btnAdd_Click(object sender, EventArgs e)
    {//Add Exception handilng try catch change by vishal 21-05-2012
        try
        {
            Session["UserCreate"] = "Exist";

            #region Declaration of Local Variables
            int    siteid, priorityid;
            int    SLAid       = 0;
            int    createdbyid = 0;
            int    requesterid = 0;
            int    FlagInsert;
            int    requesttypeid;
            string userName;
            bool   FlagUserStatus;
            FlagUserStatus = true;
            FlagInsert     = 0;
            #endregion

            #region Fetch Current User
            MembershipUser User = Membership.GetUser();
            userName = User.UserName.ToString();
            #endregion
            #region Get Current Site and Priority id
            siteid     = Convert.ToInt32(drpSite.SelectedValue);
            priorityid = Convert.ToInt32(drpPriority.SelectedValue);
            #endregion


            #region Get SLAid on the basis of siteid and Priority id

            if (siteid != 0 && priorityid != 0)
            {
                SLAid         = objIncident.Get_By_SLAid(siteid, priorityid);
                requesttypeid = Convert.ToInt32(Resources.MessageResource.strRequestTypeId.ToString());
                if (requesttypeid == Convert.ToInt32(drpRequestType.SelectedValue))
                {
                    SLAid = 0;
                }
            }
            #endregion
            if (userName != "")
            {
                #region Find Userid of User who Created this Request
                objOrganization = objOrganization.Get_Organization();
                objUser         = objUser.Get_UserLogin_By_UserName(userName, objOrganization.Orgid);
                if (objUser.Userid != 0)
                {
                    createdbyid = objUser.Userid;
                }

                #endregion



                #region Find Userid of User who is Requesting to log a call

                #region If User Already Exist
                if (Session["UserCreate"].ToString() == "Exist")
                {
                    objUser = objUser.Get_UserLogin_By_UserName(txtUsername.Text.ToString().Trim(), objOrganization.Orgid);
                    if (objUser.Userid != 0)
                    {
                        requesterid = objUser.Userid;
                    }
                }
                #endregion



                #endregion
            }

            //added by lalit
            objIncident.Reporteddatetime = DBNull.Value.ToString();
            objIncident.AMCCall          = false;
            //end
            objIncident.Title          = txtTitle.Text.ToString().Trim() + "-" + TxtExtension.Text.Trim();
            objIncident.Slaid          = SLAid;
            objIncident.Createdbyid    = createdbyid;
            objIncident.Requesterid    = requesterid;
            objIncident.Siteid         = siteid;
            objIncident.Description    = txtDescription.Text.ToString().Trim();
            objIncident.Deptid         = 0;
            objIncident.Createdatetime = DateTime.Now.ToString();
            objIncident.Modeid         = Convert.ToInt32(drpMode.SelectedValue);
            UserToSiteMapping objUserToSite = new UserToSiteMapping();

            if (FlagUserStatus == true)
            {
                FlagInsert = objIncident.Insert();

                #region Save Assetid and incident id in incidenttoassetmaaping


                objOrganization = objOrganization.Get_Organization();
                objUser         = objUser.Get_UserLogin_By_UserName(txtUsername.Text.ToString().Trim(), objOrganization.Orgid);
                int userid    = Convert.ToInt32(objUser.Userid);
                int tempuser1 = Convert.ToInt32(Session["tempuser1"]);
                if (tempuser1 == 1)
                {
                    assetid = Convert.ToInt32(Session["assetid"]);
                }
                else
                {
                    assetid = Convert.ToInt32(objusertoasset.Get_AssetId_By_UserId(userid));
                }
                int incid = Convert.ToInt32(objIncident.Get_TopIncidentId());
                if (txtassignasset.Text != "")
                {
                    //assetid = Convert.ToInt32(txtassignasset.Text);
                    if (assetid != 0)
                    {
                        objincidenttoasset.Insert(incid, assetid);
                        objusertoasset.Insert(userid, assetid, objUser.City, objUser.Company);    //added a new column siteid
                        Session.Abandon();
                    }
                }

                #endregion
            }

            if (FlagInsert == 1)
            {
                int FlagIncdStatesInsert;
                int incidentid;
                incidentid = objIncident.Get_Current_Incidentid();
                objIncidentStates.Incidentid    = incidentid;
                objIncidentStates.Priorityid    = Convert.ToInt32(drpPriority.SelectedValue);
                objIncidentStates.Categoryid    = Convert.ToInt32(drpCategory.SelectedValue);
                objIncidentStates.Statusid      = Convert.ToInt32(drpStatus.SelectedValue);
                objIncidentStates.Subcategoryid = Convert.ToInt32(drpSubcategory.SelectedValue);
                objIncidentStates.Technicianid  = 0;

                objIncidentStates.Requesttypeid = Convert.ToInt32(drpRequestType.SelectedValue);
                FlagIncdStatesInsert            = objIncidentStates.Insert();
                if (FlagIncdStatesInsert == 1)
                {
                    objIncidentHistory.Incidentid       = incidentid;
                    objIncidentHistory.Operation        = "create";
                    objIncidentHistory.Operationownerid = createdbyid;
                    objIncidentHistory.Insert();
                    objSentmailtoUser.SentmailUser(requesterid, incidentid, "open");
                    // change code/////////////////////////////////////////////////////////////////
                    if (FileUpload1.HasFile)
                    {
                        string   filepath    = Server.MapPath("~/FileAttach/");
                        string[] filenameupd = FileUpload1.FileName.Split(new char[] { '.' });
                        string   filenew     = Convert.ToString(incidentid) + "." + filenameupd[1];
                        FileUpload1.PostedFile.SaveAs(filepath + filenew);
                    }
                    ///////////////////////////////////////////////////////////////////////////////
                    ////////change code on 27 march///
                    #region Map Site to user
                    //FlagInsert=0;
                    int FlagDelete = 0;
                    int FlagStatus = 0;
                    //string Username;
                    //string gvIDs;
                    int organizationId;
                    //string gv;
                    // Get object of Organization to get organization id and assign to local variable organizationId
                    objOrganization = objOrganization.Get_Organization();
                    organizationId  = objOrganization.Orgid;
                    // Get username from textbox and assign to local variable Username
                    //Username = txtUserName.Text.ToString().Trim();
                    // Find User Exist ,by calling function Get_UserLogin_By_UserName()
                    //objUser = objUser.Get_UserLogin_By_UserName(Username, organizationId);
                    // If Userid is not zero ,then user exist in database
                    if (objUser.Userid != 0)
                    {
                        //'Navigate through each row in the GridView for checkbox items
                        //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");
                        // If deleteChkBxItem is Checked then ,mapped Current site to this user
                        //if (deleteChkBxItem.Checked)
                        //{
                        // 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;

                        userid = Convert.ToInt32(objUser.Userid);
                        //siteid = Convert.ToInt32(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  zero then site is not  mapped to this user
                        if (FlagStatus == 0)
                        {
                            objUserToSite.Siteid = siteid;
                            objUserToSite.Userid = userid;
                            // Mapped Current Site to this User by calling function objUserToSite.Insert()
                            FlagInsert = objUserToSite.Insert();
                        }
                        //}
                    }
                    // If deleteChkBxItem is Un Checked then ,Un mapped Current site to this user
                    else
                    {
                        // 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;

                        userid = Convert.ToInt32(objUser.Userid);
                        //siteid = Convert.ToInt32(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)
                        {
                            // Un Mapped Current Site to this User by calling function objUserToSite.Delete()
                            FlagDelete = objUserToSite.Delete(userid, siteid);
                        }
                        //}
                    }
                    //}
                    #endregion

                    /////////////end/////////////////


                    Response.Redirect("../Login/AllUserCall.aspx");
                }
            }
        }
        catch (Exception ex)
        {
            string myScript;
            myScript = "<script language=javascript>alert('Exception - '" + ex + "');</script>";
            Page.RegisterClientScriptBlock("MyScript", myScript);
            return;
        }
    }
Beispiel #21
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 buttonadd_click(object sender, EventArgs e)
    {
        #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.ToInt16(drpStatus.SelectedValue);
        ObjChange.Categoryid     = Convert.ToInt16(drpCategory.SelectedValue);
        ObjChange.Subcategoryid  = Convert.ToInt16(drpSubcategory.SelectedValue);
        ObjChange.Technician     = Convert.ToInt16(drpTechnician.SelectedValue);
        ObjChange.Title          = txtTitle.Text;
        ObjChange.Description    = txtDescription.Text;
        ObjChange.Createdtime    = DateTime.Now.ToString();
        ObjChange.Changetype     = Convert.ToInt16(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.ToInt16(ObjUserLogin.Userid);
        ObjChange.CreatedByID = userid;
        ObjUserLogin          = ObjUserLogin.Get_UserLogin_By_UserName(txtUsername.Text, objOrganization.Orgid);
        ObjChange.Requestedby = ObjUserLogin.Userid;
        ObjChange.Priority    = Convert.ToInt16(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.ToInt16(ListAsset.Items[i].Value);
                Objincludeaasetchange.Changeid = changeid;
                Objincludeaasetchange.Insert();
            }
        }
        ObjProblemToChange.Changeid  = changeid;
        ObjProblemToChange.Problemid = Convert.ToInt16(Session["problemid"]);
        ObjProblemToChange.Insert();
        ScriptManager.RegisterStartupScript(this, this.GetType(), "Close()", "Close();", true);
    }
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        #region Declaration of Local Variables
        int siteid, priorityid;
        int SLAid = 0;
        int createdbyid = 0;
        int requesterid = 0;
        int FlagInsert;
        int requesttypeid;
        string userName;
        bool FlagUserStatus;
        FlagUserStatus = true;
        FlagInsert = 0;
        #endregion
        #region Fetch Current User
        MembershipUser User = Membership.GetUser();
        userName = User.UserName.ToString();
        #endregion
        #region Get Current Site and Priority id
        siteid = Convert.ToInt16(drpSite.SelectedValue);
        priorityid = Convert.ToInt16(drpPriority.SelectedValue);
        #endregion
        #region Get SLAid on the basis of siteid and Priority id

        if (siteid != 0 && priorityid != 0)
        {

            SLAid = objIncident.Get_By_SLAid(siteid, priorityid);
            requesttypeid = Convert.ToInt16(Resources.MessageResource.strRequestTypeId.ToString());
            if (requesttypeid == Convert.ToInt16(drpRequestType.SelectedValue))
            {
                SLAid = 0;
            }
        }
        #endregion
        if (userName != "")
        {
            #region Find Userid of User who Created this Request
            objOrganization = objOrganization.Get_Organization();
            objUser = objUser.Get_UserLogin_By_UserName(userName, objOrganization.Orgid);
            if (objUser.Userid != 0)
            {
                createdbyid = objUser.Userid;
            }

            #endregion
            #region Find Userid of User who is Requesting to log a call
            #region If User Already Exist
            if (Session["UserCreate"].ToString() == "Exist")
            {
                objUser = objUser.Get_UserLogin_By_UserName(txtUsername.Text.ToString().Trim(), objOrganization.Orgid);
                if (objUser.Userid != 0)
                {
                    requesterid = objUser.Userid;
                }
            }
            #endregion
            #region If New User is to be Created
            else if (Session["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();
                UserLogin_mst objUserLogin = new UserLogin_mst();
                objUserLogin.Username = txtUsername.Text.Trim().ToString();
                objUserLogin.Password = Resources.MessageResource.strDefaultPassword.ToString();
                objUserLogin.Roleid = roleid;
                objUserLogin.Orgid = objOrganization.Orgid;
                objUserLogin.ADEnable = false;
                objUserLogin.Enable = true;
                objUserLogin.Createdatetime = DateTime.Now.ToString();
                status = objUserLogin.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
                    objUserLogin = new UserLogin_mst();
                    // Fetch userid of Newly created user and assign to local variable userid by calling function objUserLogin.Get_By_UserName
                    requesterid = 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

                    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 (Session["UserCreate"].ToString() == "notcreate")
            {
                FlagUserStatus = false;

            }
            #endregion

            #endregion

        }

        objIncident.Title = txtTitle.Text.Trim();
        //objIncident.Title = drpTitle.SelectedItem.Text;
        objIncident.Slaid = SLAid;
        objIncident.Createdbyid = createdbyid;
        objIncident.Requesterid = requesterid;
        objIncident.Siteid = siteid;
        objIncident.Description = txtDescription.Text.ToString().Trim();
        objIncident.Deptid = Convert.ToInt16(drpDepartment.SelectedValue);
        objIncident.Createdatetime = DateTime.Now.ToString();
        IFormatProvider provider = new System.Globalization.CultureInfo("en-CA", true);
        String datetime = txtReportedDate.Text.Trim();

        DateTime dt = DateTime.Parse(datetime, provider, System.Globalization.DateTimeStyles.NoCurrentDateDefault);
        //changed by prachi

        //objIncident.Reporteddatetime = dt.ToShortDateString() + " " + DateTime.Now.ToShortTimeString();
        DateTime dtNowForTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, Convert.ToInt32(drpTimeHours.SelectedItem.Text), Convert.ToInt32(drpTimeMin.SelectedItem.Text), 0);
        //end prachi

        objIncident.Reporteddatetime = dt.ToShortDateString() + " " + dtNowForTime.ToShortTimeString();
        objIncident.Modeid = Convert.ToInt16(drpMode.SelectedValue);
        //objIncident.ExternalTicketNo = txtExternalTicket.Text.ToString().Trim();
        if (FlagUserStatus == true)
        {
            FlagInsert = objIncident.Insert();
            #region Save Assetid and incident id in incidenttoassetmaaping
            // Get Asset and Incident Id for incidenttoassetmaaping
            objOrganization = objOrganization.Get_Organization();
            objUser = objUser.Get_UserLogin_By_UserName(txtUsername.Text.Trim().ToString().Trim(), objOrganization.Orgid);
            int userid = Convert.ToInt16(objUser.Userid);
            int tempuser1 = Convert.ToInt16(Session["tempuser1"]);
            if (tempuser1 == 1)
            {
                assetid = Convert.ToInt16(Session["assetid"]);
            }
            else
            {
                assetid = Convert.ToInt16(objusertoasset.Get_AssetId_By_UserId(userid));
            }
            int incid = Convert.ToInt16(objIncident.Get_TopIncidentId());
            //if (txtassignasset.Text != "")
            {
                //assetid = Convert.ToInt16(txtassignasset.Text);
                if (assetid != 0)
                {
                    objincidenttoasset.Insert(incid, assetid);
                    objusertoasset.Insert(userid, assetid);
                    Session.Abandon();

                }
            }

            #endregion

        }

        if (FlagInsert == 1)
        {
            int FlagIncdStatesInsert;
            int incidentid;
            incidentid = objIncident.Get_Current_Incidentid();
            objIncidentStates.Incidentid = incidentid;
            objIncidentStates.Priorityid = Convert.ToInt16(drpPriority.SelectedValue);
            objIncidentStates.Categoryid = Convert.ToInt16(drpCategory.SelectedValue);
            objIncidentStates.Statusid = Convert.ToInt16(drpStatus.SelectedValue);
            objIncidentStates.Subcategoryid = Convert.ToInt16(drpSubcategory.SelectedValue);
            objIncidentStates.Technicianid = Convert.ToInt16(drpTechnician.SelectedValue);
            if (Convert.ToInt16(drpTechnician.SelectedValue) != 0)
            {
                objIncidentStates.AssignedTime = DateTime.Now.ToString();
            }
            objIncidentStates.Requesttypeid = Convert.ToInt16(drpRequestType.SelectedValue);
            FlagIncdStatesInsert = objIncidentStates.Insert();
            if (FlagIncdStatesInsert == 1)
            {

                objIncidentHistory.Incidentid = incidentid;
                objIncidentHistory.Operation = "create";
                objIncidentHistory.Operationownerid = createdbyid;
                objIncidentHistory.Insert();

                objSentmailtoUser.SentmailUser(requesterid, incidentid, "open");
                if (Convert.ToInt16(drpTechnician.SelectedValue) != 0)
                {
                    objSentmailtoUser.SentmailTechnician(Convert.ToInt16(drpTechnician.SelectedValue), incidentid);
                }
                ////////////////////Added by lalit 28nov to /////////////////////////////////////////////////////
                if (Session["id"] != null)
                {
                    int id = Convert.ToInt32(Session["id"].ToString());
                    SqlConnection con;
                    SqlCommand cmd;
                    string connection = ConfigurationManager.ConnectionStrings["CSM_DB"].ConnectionString;
                    con = new SqlConnection(connection);
                    cmd = new SqlCommand();
                    con.Open();
                    cmd.Connection = con;
                    cmd.CommandText = "update storemail set IsActive=2 where id='" + id + "'";
                    cmd.ExecuteNonQuery();
                }

                Response.Redirect("~/Incident/IncidentRequestUpdate.aspx?" + incidentid + "");

            }

        }
    }
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        Session["UserCreate"] = "Exist";

        #region Declaration of Local Variables
        int siteid, priorityid;
        int SLAid = 0;
        int createdbyid = 0;
        int requesterid = 0;
        int FlagInsert;
        int requesttypeid;
        string userName;
        bool FlagUserStatus;
        FlagUserStatus = true;
        FlagInsert = 0;
        #endregion

        #region Fetch Current User
        MembershipUser User = Membership.GetUser();
        userName = User.UserName.ToString();
        #endregion
        #region Get Current Site and Priority id
        siteid = Convert.ToInt16(drpSite.SelectedValue);
        priorityid = Convert.ToInt16(drpPriority.SelectedValue);
        #endregion

        #region Get SLAid on the basis of siteid and Priority id

        if (siteid != 0 && priorityid != 0)
        {
            SLAid = objIncident.Get_By_SLAid(siteid, priorityid);
            requesttypeid = Convert.ToInt16(Resources.MessageResource.strRequestTypeId.ToString());
            if (requesttypeid == Convert.ToInt16(drpRequestType.SelectedValue))
            {
                SLAid = 0;
            }
        }
        #endregion
        if (userName != "")
        {
            #region Find Userid of User who Created this Request
            objOrganization = objOrganization.Get_Organization();
            objUser = objUser.Get_UserLogin_By_UserName(userName, objOrganization.Orgid);
            if (objUser.Userid != 0)
            {
                createdbyid = objUser.Userid;
            }

            #endregion

            #region Find Userid of User who is Requesting to log a call

            #region If User Already Exist
            if (Session["UserCreate"].ToString() == "Exist")
            {
                objUser = objUser.Get_UserLogin_By_UserName(txtUsername.Text.ToString().Trim(), objOrganization.Orgid);
                if (objUser.Userid != 0)
                {
                    requesterid = objUser.Userid;
                }
            }
            #endregion

            #endregion

        }

        objIncident.Title = txtTitle.Text.ToString().Trim();
        objIncident.Slaid = SLAid;
        objIncident.Createdbyid = createdbyid;
        objIncident.Requesterid = requesterid;
        objIncident.Siteid = siteid;
        objIncident.Description = txtDescription.Text.ToString().Trim();
        objIncident.Deptid = 0;
        objIncident.Createdatetime = DateTime.Now.ToString();
        objIncident.Modeid = Convert.ToInt16(drpMode.SelectedValue);

        if (FlagUserStatus == true)
        {
            FlagInsert = objIncident.Insert();

            #region Save Assetid and incident id in incidenttoassetmaaping

            objOrganization = objOrganization.Get_Organization();
            objUser = objUser.Get_UserLogin_By_UserName(txtUsername.Text.ToString().Trim(), objOrganization.Orgid);
            int userid = Convert.ToInt16(objUser.Userid);
            int tempuser1 = Convert.ToInt16(Session["tempuser1"]);
            if (tempuser1 == 1)
            {
                assetid = Convert.ToInt16(Session["assetid"]);
            }
            else
            {
                assetid = Convert.ToInt16(objusertoasset.Get_AssetId_By_UserId(userid));
            }
            int incid = Convert.ToInt16(objIncident.Get_TopIncidentId());
            if (txtassignasset.Text != "")
            {
                //assetid = Convert.ToInt16(txtassignasset.Text);
                if (assetid != 0)
                {
                    objincidenttoasset.Insert(incid, assetid);
                    objusertoasset.Insert(userid, assetid);
                    Session.Abandon();

                }
            }

            #endregion

        }

        if (FlagInsert == 1)
        {
            int FlagIncdStatesInsert;
            int incidentid;
            incidentid = objIncident.Get_Current_Incidentid();
            objIncidentStates.Incidentid = incidentid;
            objIncidentStates.Priorityid = Convert.ToInt16(drpPriority.SelectedValue);
            objIncidentStates.Categoryid = Convert.ToInt16(drpCategory.SelectedValue);
            objIncidentStates.Statusid = Convert.ToInt16(drpStatus.SelectedValue);
            objIncidentStates.Subcategoryid = Convert.ToInt16(drpSubcategory.SelectedValue);
            objIncidentStates.Technicianid = 0;

            objIncidentStates.Requesttypeid = Convert.ToInt16(drpRequestType.SelectedValue);
            FlagIncdStatesInsert = objIncidentStates.Insert();
            if (FlagIncdStatesInsert == 1)
            {
                objIncidentHistory.Incidentid = incidentid;
                objIncidentHistory.Operation = "create";
                objIncidentHistory.Operationownerid = createdbyid;
                objIncidentHistory.Insert();
                objSentmailtoUser.SentmailUser(requesterid, incidentid, "open");
                // change code/////////////////////////////////////////////////////////////////

                if (FileUpload1.HasFile)
                {
                    string filepath = Server.MapPath("~/FileAttach/");
                    string[] filenameupd = FileUpload1.FileName.Split(new char[] { '.' });
                    string filenew = Convert.ToString(incidentid) + "." + filenameupd[1];
                    FileUpload1.PostedFile.SaveAs(filepath + filenew);
                }
                ///////////////////////////////////////////////////////////////////////////////
                Response.Redirect("../Login/AllUserCall.aspx");

            }

        }
    }
Beispiel #25
0
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        #region Declaration of Local Variables
        int    siteid, priorityid;
        int    SLAid       = 0;
        int    createdbyid = 0;
        int    requesterid = 0;
        int    FlagInsert;
        int    requesttypeid;
        string userName;
        bool   FlagUserStatus;
        FlagUserStatus = true;
        FlagInsert     = 0;
        #endregion
        #region Fetch Current User
        MembershipUser User = Membership.GetUser();
        userName = User.UserName.ToString();
        #endregion
        #region Get Current Site and Priority id
        siteid     = Convert.ToInt16(drpSite.SelectedValue);
        priorityid = Convert.ToInt16(drpPriority.SelectedValue);
        #endregion
        #region Get SLAid on the basis of siteid and Priority id

        if (siteid != 0 && priorityid != 0)
        {
            SLAid         = objIncident.Get_By_SLAid(siteid, priorityid);
            requesttypeid = Convert.ToInt16(Resources.MessageResource.strRequestTypeId.ToString());
            if (requesttypeid == Convert.ToInt16(drpRequestType.SelectedValue))
            {
                SLAid = 0;
            }
        }
        #endregion
        if (userName != "")
        {
            #region Find Userid of User who Created this Request
            objOrganization = objOrganization.Get_Organization();
            objUser         = objUser.Get_UserLogin_By_UserName(userName, objOrganization.Orgid);
            if (objUser.Userid != 0)
            {
                createdbyid = objUser.Userid;
            }

            #endregion
            #region Find Userid of User who is Requesting to log a call
            #region If User Already Exist
            if (Session["UserCreate"].ToString() == "Exist")
            {
                objUser = objUser.Get_UserLogin_By_UserName(txtUsername.Text.ToString().Trim(), objOrganization.Orgid);
                if (objUser.Userid != 0)
                {
                    requesterid = objUser.Userid;
                }
            }
            #endregion
            #region If New User is to be Created
            else if (Session["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();
                UserLogin_mst objUserLogin = new UserLogin_mst();
                objUserLogin.Username       = txtUsername.Text.Trim().ToString();
                objUserLogin.Password       = Resources.MessageResource.strDefaultPassword.ToString();
                objUserLogin.Roleid         = roleid;
                objUserLogin.Orgid          = objOrganization.Orgid;
                objUserLogin.ADEnable       = false;
                objUserLogin.Enable         = true;
                objUserLogin.Createdatetime = DateTime.Now.ToString();
                status = objUserLogin.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
                    objUserLogin = new UserLogin_mst();
                    // Fetch userid of Newly created user and assign to local variable userid by calling function objUserLogin.Get_By_UserName
                    requesterid = 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

                    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 (Session["UserCreate"].ToString() == "notcreate")
            {
                FlagUserStatus = false;
            }
            #endregion

            #endregion
        }

        objIncident.Title = txtTitle.Text.Trim();
        //objIncident.Title = drpTitle.SelectedItem.Text;
        objIncident.Slaid          = SLAid;
        objIncident.Createdbyid    = createdbyid;
        objIncident.Requesterid    = requesterid;
        objIncident.Siteid         = siteid;
        objIncident.Description    = txtDescription.Text.ToString().Trim();
        objIncident.Deptid         = Convert.ToInt16(drpDepartment.SelectedValue);
        objIncident.Createdatetime = DateTime.Now.ToString();
        IFormatProvider provider = new System.Globalization.CultureInfo("en-CA", true);
        String          datetime = txtReportedDate.Text.Trim();

        DateTime dt = DateTime.Parse(datetime, provider, System.Globalization.DateTimeStyles.NoCurrentDateDefault);
        //changed by prachi

        //objIncident.Reporteddatetime = dt.ToShortDateString() + " " + DateTime.Now.ToShortTimeString();
        DateTime dtNowForTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, Convert.ToInt32(drpTimeHours.SelectedItem.Text), Convert.ToInt32(drpTimeMin.SelectedItem.Text), 0);
        //end prachi

        objIncident.Reporteddatetime = dt.ToShortDateString() + " " + dtNowForTime.ToShortTimeString();
        objIncident.Modeid           = Convert.ToInt16(drpMode.SelectedValue);
        //objIncident.ExternalTicketNo = txtExternalTicket.Text.ToString().Trim();
        if (FlagUserStatus == true)
        {
            FlagInsert = objIncident.Insert();
            #region Save Assetid and incident id in incidenttoassetmaaping
            // Get Asset and Incident Id for incidenttoassetmaaping
            objOrganization = objOrganization.Get_Organization();
            objUser         = objUser.Get_UserLogin_By_UserName(txtUsername.Text.Trim().ToString().Trim(), objOrganization.Orgid);
            int userid    = Convert.ToInt16(objUser.Userid);
            int tempuser1 = Convert.ToInt16(Session["tempuser1"]);
            if (tempuser1 == 1)
            {
                assetid = Convert.ToInt16(Session["assetid"]);
            }
            else
            {
                assetid = Convert.ToInt16(objusertoasset.Get_AssetId_By_UserId(userid));
            }
            int incid = Convert.ToInt16(objIncident.Get_TopIncidentId());
            //if (txtassignasset.Text != "")
            {
                //assetid = Convert.ToInt16(txtassignasset.Text);
                if (assetid != 0)
                {
                    objincidenttoasset.Insert(incid, assetid);
                    objusertoasset.Insert(userid, assetid);
                    Session.Abandon();
                }
            }

            #endregion
        }

        if (FlagInsert == 1)
        {
            int FlagIncdStatesInsert;
            int incidentid;
            incidentid = objIncident.Get_Current_Incidentid();
            objIncidentStates.Incidentid    = incidentid;
            objIncidentStates.Priorityid    = Convert.ToInt16(drpPriority.SelectedValue);
            objIncidentStates.Categoryid    = Convert.ToInt16(drpCategory.SelectedValue);
            objIncidentStates.Statusid      = Convert.ToInt16(drpStatus.SelectedValue);
            objIncidentStates.Subcategoryid = Convert.ToInt16(drpSubcategory.SelectedValue);
            objIncidentStates.Technicianid  = Convert.ToInt16(drpTechnician.SelectedValue);
            if (Convert.ToInt16(drpTechnician.SelectedValue) != 0)
            {
                objIncidentStates.AssignedTime = DateTime.Now.ToString();
            }
            objIncidentStates.Requesttypeid = Convert.ToInt16(drpRequestType.SelectedValue);
            FlagIncdStatesInsert            = objIncidentStates.Insert();
            if (FlagIncdStatesInsert == 1)
            {
                objIncidentHistory.Incidentid       = incidentid;
                objIncidentHistory.Operation        = "create";
                objIncidentHistory.Operationownerid = createdbyid;
                objIncidentHistory.Insert();

                objSentmailtoUser.SentmailUser(requesterid, incidentid, "open");
                if (Convert.ToInt16(drpTechnician.SelectedValue) != 0)
                {
                    objSentmailtoUser.SentmailTechnician(Convert.ToInt16(drpTechnician.SelectedValue), incidentid);
                }
                ////////////////////Added by lalit 28nov to /////////////////////////////////////////////////////
                if (Session["id"] != null)
                {
                    int           id = Convert.ToInt32(Session["id"].ToString());
                    SqlConnection con;
                    SqlCommand    cmd;
                    string        connection = ConfigurationManager.ConnectionStrings["CSM_DB"].ConnectionString;
                    con = new SqlConnection(connection);
                    cmd = new SqlCommand();
                    con.Open();
                    cmd.Connection  = con;
                    cmd.CommandText = "update storemail set IsActive=2 where id='" + id + "'";
                    cmd.ExecuteNonQuery();
                }

                Response.Redirect("~/Incident/IncidentRequestUpdate.aspx?" + incidentid + "");
            }
        }
    }
    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.ToInt16(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.ToInt16(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
    }
Beispiel #27
0
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        Session["UserCreate"] = "Exist";

        #region Declaration of Local Variables
        int    siteid, priorityid;
        int    SLAid       = 0;
        int    createdbyid = 0;
        int    requesterid = 0;
        int    FlagInsert;
        int    requesttypeid;
        string userName;
        bool   FlagUserStatus;
        FlagUserStatus = true;
        FlagInsert     = 0;
        #endregion

        #region Fetch Current User
        MembershipUser User = Membership.GetUser();
        userName = User.UserName.ToString();
        #endregion
        #region Get Current Site and Priority id
        siteid     = Convert.ToInt16(drpSite.SelectedValue);
        priorityid = Convert.ToInt16(drpPriority.SelectedValue);
        #endregion


        #region Get SLAid on the basis of siteid and Priority id

        if (siteid != 0 && priorityid != 0)
        {
            SLAid         = objIncident.Get_By_SLAid(siteid, priorityid);
            requesttypeid = Convert.ToInt16(Resources.MessageResource.strRequestTypeId.ToString());
            if (requesttypeid == Convert.ToInt16(drpRequestType.SelectedValue))
            {
                SLAid = 0;
            }
        }
        #endregion
        if (userName != "")
        {
            #region Find Userid of User who Created this Request
            objOrganization = objOrganization.Get_Organization();
            objUser         = objUser.Get_UserLogin_By_UserName(userName, objOrganization.Orgid);
            if (objUser.Userid != 0)
            {
                createdbyid = objUser.Userid;
            }

            #endregion



            #region Find Userid of User who is Requesting to log a call

            #region If User Already Exist
            if (Session["UserCreate"].ToString() == "Exist")
            {
                objUser = objUser.Get_UserLogin_By_UserName(txtUsername.Text.ToString().Trim(), objOrganization.Orgid);
                if (objUser.Userid != 0)
                {
                    requesterid = objUser.Userid;
                }
            }
            #endregion



            #endregion
        }


        objIncident.Title          = txtTitle.Text.ToString().Trim();
        objIncident.Slaid          = SLAid;
        objIncident.Createdbyid    = createdbyid;
        objIncident.Requesterid    = requesterid;
        objIncident.Siteid         = siteid;
        objIncident.Description    = txtDescription.Text.ToString().Trim();
        objIncident.Deptid         = 0;
        objIncident.Createdatetime = DateTime.Now.ToString();
        objIncident.Modeid         = Convert.ToInt16(drpMode.SelectedValue);

        if (FlagUserStatus == true)
        {
            FlagInsert = objIncident.Insert();

            #region Save Assetid and incident id in incidenttoassetmaaping


            objOrganization = objOrganization.Get_Organization();
            objUser         = objUser.Get_UserLogin_By_UserName(txtUsername.Text.ToString().Trim(), objOrganization.Orgid);
            int userid    = Convert.ToInt16(objUser.Userid);
            int tempuser1 = Convert.ToInt16(Session["tempuser1"]);
            if (tempuser1 == 1)
            {
                assetid = Convert.ToInt16(Session["assetid"]);
            }
            else
            {
                assetid = Convert.ToInt16(objusertoasset.Get_AssetId_By_UserId(userid));
            }
            int incid = Convert.ToInt16(objIncident.Get_TopIncidentId());
            if (txtassignasset.Text != "")
            {
                //assetid = Convert.ToInt16(txtassignasset.Text);
                if (assetid != 0)
                {
                    objincidenttoasset.Insert(incid, assetid);
                    objusertoasset.Insert(userid, assetid);
                    Session.Abandon();
                }
            }

            #endregion
        }

        if (FlagInsert == 1)
        {
            int FlagIncdStatesInsert;
            int incidentid;
            incidentid = objIncident.Get_Current_Incidentid();
            objIncidentStates.Incidentid    = incidentid;
            objIncidentStates.Priorityid    = Convert.ToInt16(drpPriority.SelectedValue);
            objIncidentStates.Categoryid    = Convert.ToInt16(drpCategory.SelectedValue);
            objIncidentStates.Statusid      = Convert.ToInt16(drpStatus.SelectedValue);
            objIncidentStates.Subcategoryid = Convert.ToInt16(drpSubcategory.SelectedValue);
            objIncidentStates.Technicianid  = 0;

            objIncidentStates.Requesttypeid = Convert.ToInt16(drpRequestType.SelectedValue);
            FlagIncdStatesInsert            = objIncidentStates.Insert();
            if (FlagIncdStatesInsert == 1)
            {
                objIncidentHistory.Incidentid       = incidentid;
                objIncidentHistory.Operation        = "create";
                objIncidentHistory.Operationownerid = createdbyid;
                objIncidentHistory.Insert();
                objSentmailtoUser.SentmailUser(requesterid, incidentid, "open");
                // change code/////////////////////////////////////////////////////////////////


                if (FileUpload1.HasFile)
                {
                    string   filepath    = Server.MapPath("~/FileAttach/");
                    string[] filenameupd = FileUpload1.FileName.Split(new char[] { '.' });
                    string   filenew     = Convert.ToString(incidentid) + "." + filenameupd[1];
                    FileUpload1.PostedFile.SaveAs(filepath + filenew);
                }
                ///////////////////////////////////////////////////////////////////////////////
                Response.Redirect("../Login/AllUserCall.aspx");
            }
        }
    }
    protected void buttonadd_click(object sender, EventArgs e)
    {
        #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.ToInt16(drpStatus.SelectedValue);
        ObjChange.Categoryid = Convert.ToInt16(drpCategory.SelectedValue);
        ObjChange.Subcategoryid = Convert.ToInt16(drpSubcategory.SelectedValue);
           // ObjChange.Technician =Convert.ToInt16(drpTechnician.SelectedValue);
        ObjChange.Title = txtTitle.Text;
        ObjChange.Description = txtDescription.Text;
        ObjChange.Createdtime = DateTime.Now.ToString();
        ObjChange.Changetype =Convert.ToInt16(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.ToInt16(ObjUserLogin.Userid);
         ObjChange.CreatedByID = userid;
        ObjUserLogin=ObjUserLogin.Get_UserLogin_By_UserName(txtUsername.Text,objOrganization.Orgid);
        ObjChange.Requestedby = ObjUserLogin.Userid;
           // ObjChange.Priority = Convert.ToInt16(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.ToInt16(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.ToInt16(drpchangetype.SelectedValue);

        objSentEmailToChange.SentMailToChangeCommittee(changeid, changetype);

        Response.Redirect("~/Change/EditChange.aspx?" + changeid + " ");
    }