protected void Page_Load(object sender, EventArgs e)
 {
     //lblUser.Text = Session["User"].ToString();
     if (!IsPostBack)
     {
         MembershipUser User = Membership.GetUser();
         objOrganization = objOrganization.Get_Organization();
         int userid = objUser.Get_By_UserName(User.UserName.ToString(), objOrganization.Orgid);
         if (userid != 0)
         {
             objContact   = objContact.Get_By_id(userid);
             lblUser.Text = objContact.Firstname + "  " + objContact.Lastname;
         }
         //added by lalit to view Mail link only to SDE. checking here SDE is logged on.
         if (Roles.IsUserInRole(User.UserName.ToString(), "SDE"))
         {
             trautocall.Visible = true;
             //trRejectedcall.Visible = true;
         }
         if (Roles.IsUserInRole(User.UserName.ToString(), "admin"))
         {
             //trautocall.Visible = true;
             trRejectedcall.Visible = true;
         }
         //if (Roles.IsUserInRole(User.UserName.ToString(), "SDE"))
         //{
         //    //trautocall.Visible = true;
         //    trRejectedcall.Visible = true;
         //}
     }
 }
Beispiel #2
0
 protected void Page_Load(object sender, EventArgs e)
 {//Add Exception handilng try catch change by vishal 21-05-2012
     try
     {
         if (!IsPostBack)
         {
             MembershipUser User = Membership.GetUser();
             objOrganization = objOrganization.Get_Organization();
             int userid = objUser.Get_By_UserName(User.UserName.ToString(), objOrganization.Orgid);
             if (userid != 0)
             {
                 objContact   = objContact.Get_By_id(userid);
                 lblUser.Text = objContact.Firstname + "  " + objContact.Lastname;
             }
         }
         XmlDataSource ds = new XmlDataSource();
         ds.EnableCaching     = false;
         ds.DataFile          = Server.MapPath("../Files/Admin.xml");
         TreeView1.DataSource = ds;
         TreeView1.DataBind();
     }
     catch (Exception ex)
     {
         string myScript;
         myScript = "<script language=javascript>alert('Exception - '" + ex + "');</script>";
         Page.RegisterClientScriptBlock("MyScript", myScript);
         return;
     }
 }
Beispiel #3
0
    protected void btnadd_Click(object sender, EventArgs e)
    {
        /////Add Exception handilng try catch change by vishal 21-05-2012
        try
        {
            #region Fetch Current User

            // Fetch Current User and assign to local variable userName
            MembershipUser User     = Membership.GetUser();
            string         userName = User.UserName.ToString();
            #endregion
            ObjOrganization = ObjOrganization.Get_Organization();
            int orgid  = Convert.ToInt32(ObjOrganization.Orgid);
            int userid = ObjUser.Get_By_UserName(userName, orgid);
            ObjChangeNotes.Username = userid;
            ObjChangeNotes.Changeid = Convert.ToInt32(Request.QueryString[0]);
            ObjChangeNotes.Comments = txtcomments.Text.ToString();
            ObjChangeNotes.Insert();
            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 Page_Load(object sender, EventArgs e)
 {///Add Exception handilng try catch change by vishal 21-05-2012
     try
     {
         //lblUser.Text = Session["User"].ToString();
         if (!IsPostBack)
         {
             MembershipUser User = Membership.GetUser();
             objOrganization = objOrganization.Get_Organization();
             int userid = objUser.Get_By_UserName(User.UserName.ToString(), objOrganization.Orgid);
             if (userid != 0)
             {
                 objContact   = objContact.Get_By_id(userid);
                 lblUser.Text = objContact.Firstname + "&nbsp;&nbsp;" + objContact.Lastname;
             }
         }
     }
     catch (Exception ex)
     {
         string myScript;
         myScript = "<script language=javascript>alert('Exception - '" + ex + "');</script>";
         Page.RegisterClientScriptBlock("MyScript", myScript);
         return;
     }
 }
Beispiel #5
0
    protected void Page_Load(object sender, EventArgs e)
    {
        ////Add Exception handilng try catch change by vishal 21-05-2012
        try
        {
            if (!IsPostBack)
            {
                MembershipUser User = Membership.GetUser();
                objOrganization = objOrganization.Get_Organization();
                int userid = objUser.Get_By_UserName(User.UserName.ToString(), objOrganization.Orgid);
                if (userid != 0)
                {
                    string userName;
                    userName = User.UserName.ToString();
                    if (Roles.IsUserInRole(userName, "admin"))
                    {
                        panel1.Visible = true;
                    }
                    objContact   = objContact.Get_By_id(userid);
                    lblUser.Text = objContact.Firstname + "&nbsp;&nbsp;" + objContact.Lastname;
                    //  Bind_Tree();

                    BindRepeater();
                }
            }
        }
        catch (Exception ex)
        {
            string myScript;
            myScript = "<script language=javascript>alert('Exception - '" + ex + "');</script>";
            Page.RegisterClientScriptBlock("MyScript", myScript);
            return;
        }
    }
Beispiel #6
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         MembershipUser User = Membership.GetUser();
         objOrganization = objOrganization.Get_Organization();
         int userid = objUser.Get_By_UserName(User.UserName.ToString(), objOrganization.Orgid);
         if (userid != 0)
         {
             objContact   = objContact.Get_By_id(userid);
             lblUser.Text = objContact.Firstname + "&nbsp;&nbsp;" + objContact.Lastname;
         }
     }
 }
Beispiel #7
0
    protected void Page_Load(object sender, EventArgs e)
    {
        #region Get Current User and his Role
        MembershipUser User = Membership.GetUser();
        objOrganization = objOrganization.Get_Organization();
        int userid = objUser.Get_By_UserName(User.UserName.ToString(), objOrganization.Orgid);
        if (userid != 0)
        {
            objContact   = objContact.Get_By_id(userid);
            lblUser.Text = objContact.Firstname + "&nbsp;&nbsp;" + objContact.Lastname;
        }


        #endregion
    }
Beispiel #8
0
 protected void Page_Load(object sender, EventArgs e)
 {///Add Exception handilng try catch change by vishal 21-05-2012
     try
     {
         //lblUser.Text = Session["User"].ToString();
         if (!IsPostBack)
         {
             MembershipUser User = Membership.GetUser();
             objOrganization = objOrganization.Get_Organization();
             int userid = objUser.Get_By_UserName(User.UserName.ToString(), objOrganization.Orgid);
             if (userid != 0)
             {
                 objContact   = objContact.Get_By_id(userid);
                 lblUser.Text = objContact.Firstname + "&nbsp;&nbsp;" + objContact.Lastname;
             }
             //added by lalit to view Mail link only to SDE. checking here SDE is logged on.
             string AutoCalls = Resources.MessageResource.strAutoCalls.ToString();
             if (Roles.IsUserInRole(User.UserName.ToString(), "SDE"))
             {
                 if (AutoCalls == "1")
                 {
                     trautocall.Visible     = true;
                     trRejectedcall.Visible = true;
                 }
             }
             if (Roles.IsUserInRole(User.UserName.ToString(), "admin"))
             {
                 //trautocall.Visible = true;
                 if (AutoCalls == "1")
                 {
                     trRejectedcall.Visible = true;
                 }
             }
         }
     }
     catch (Exception ex)
     {
         string myScript;
         myScript = "<script language=javascript>alert('Exception - '" + ex + "');</script>";
         Page.RegisterClientScriptBlock("MyScript", myScript);
         return;
     }
 }
Beispiel #9
0
    protected void btnadd_Click(object sender, EventArgs e)
    {
        #region Fetch Current User

        // Fetch Current User and assign to local variable userName
        MembershipUser User     = Membership.GetUser();
        string         userName = User.UserName.ToString();
        #endregion
        ObjOrganization = ObjOrganization.Get_Organization();
        int orgid  = Convert.ToInt16(ObjOrganization.Orgid);
        int userid = ObjUser.Get_By_UserName(userName, orgid);
        ObjProblemNotes.UserName  = userid;
        ObjProblemNotes.Problemid = Convert.ToInt16(Request.QueryString[0]);
        ObjProblemNotes.Comments  = txtcomments.Text.ToString();
        ObjProblemNotes.Insert();
        string myScript;
        myScript = "<script language=javascript>refreshParent();</script>";
        Page.RegisterClientScriptBlock("MyScript", myScript);
    }
Beispiel #10
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            MembershipUser User = Membership.GetUser();
            objOrganization = objOrganization.Get_Organization();
            int userid = objUser.Get_By_UserName(User.UserName.ToString(), objOrganization.Orgid);
            if (userid != 0)
            {
                objContact   = objContact.Get_By_id(userid);
                lblUser.Text = objContact.Firstname + "&nbsp;&nbsp;" + objContact.Lastname;
            }
        }
        XmlDataSource ds = new XmlDataSource();

        ds.EnableCaching     = false;
        ds.DataFile          = Server.MapPath("../Files/Admin.xml");
        TreeView1.DataSource = ds;
        TreeView1.DataBind();
    }
Beispiel #11
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         MembershipUser User = Membership.GetUser();
         objOrganization = objOrganization.Get_Organization();
         int userid = objUser.Get_By_UserName(User.UserName.ToString(), objOrganization.Orgid);
         if (userid != 0)
         {
             string userName;
             userName = User.UserName.ToString();
             if (Roles.IsUserInRole(userName, "admin"))
             {
                 panel1.Visible = true;
             }
             objContact   = objContact.Get_By_id(userid);
             lblUser.Text = objContact.Firstname + "&nbsp;&nbsp;" + objContact.Lastname;
         }
     }
     Bind_Tree();
 }
    protected void buttonadd_click(object sender, EventArgs e)
    {
        /////Add Exception handilng try catch change by vishal 21-05-2012
        try
        {
            #region Find Userid of User who is Requesting to log a call

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

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

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

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

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

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

            }
            #endregion

            #endregion
            ObjChange.Active = true;

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

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

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

            objIncidentToChange.Insert();
            int changetype = Convert.ToInt32(ObjChange.Changetype);
            objSentEmailToChange.SentMailToChangeCommittee(changeid, changetype);
            ScriptManager.RegisterStartupScript(this, this.GetType(), "Close()", "Close();", true);
        }
        catch (Exception ex)
        {
            string myScript;
            myScript = "<script language=javascript>alert('Exception - '" + ex + "');</script>";
            Page.RegisterClientScriptBlock("MyScript", myScript);
            return;
        }
    }
    protected void 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;
        }
    }
Beispiel #14
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 btnAdd_Click(object sender, EventArgs e)
    {
        /////Add Exception handilng try catch change by vishal 21-05-2012
        try
        {
            #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_Ex(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.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();
                        /// added by vishal 18-05-2012
                       Session["UserCreate"] = "";

                    }

                }
                #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.Title = txtTitle.Text.Trim() + "-" + Txtextension.Text.Trim();
            //objIncident.Title = txtTitle.Text.Trim();
            if (Txtextension.Text != "")
            {
                string extension = Txtextension.Text;
                Int64 vOut = Convert.ToInt64(extension);
                //int vOut = Convert.ToInt32(extension);
                objIncident.Extension = vOut;
            }
            //start changed by prachi-19thmarch
            if (drpAMCcall.SelectedItem.Text == "NO")
            {
                objIncident.AMCCall = false;
            }
            else if (drpAMCcall.SelectedItem.Text == "YES")
            {
                objIncident.AMCCall = true;
            }
            //end
            objIncident.Slaid = SLAid;
            objIncident.Createdbyid = createdbyid;
            objIncident.Requesterid = requesterid;
            objIncident.Siteid = siteid;
            objIncident.Description = txtDescription.Text.ToString().Trim();
            objIncident.Deptid = Convert.ToInt32(drpDepartment.SelectedValue);
            objIncident.Createdatetime = DateTime.Now.ToString();
            objIncident.Modeid = Convert.ToInt32(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_Ex(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);
                        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 = Convert.ToInt32(drpTechnician.SelectedValue);
                if (Convert.ToInt32(drpTechnician.SelectedValue) != 0)
                {
                    objIncidentStates.AssignedTime = DateTime.Now.ToString();
                }
                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);
                    }
                    ///////////////////////////////////////////////////////////////////////////////

                    if (Convert.ToInt32(drpTechnician.SelectedValue) != 0)
                    {

                        objSentmailtoUser.SentmailTechnician(Convert.ToInt32(drpTechnician.SelectedValue), incidentid);

                    }

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

                }

            }
        }
        catch (Exception ex)
        {
            string myScript;
            myScript = "<script language=javascript>alert('Exception - '" + ex + "');</script>";
            Page.RegisterClientScriptBlock("MyScript", myScript);
            return;
        }
    }
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        /////Add Exception handilng try catch change by vishal 21-05-2012
        try
        {
            #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_Ex(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.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();
                        /// added by vishal 18-05-2012
                        Session["UserCreate"] = "";
                    }
                }
                #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.Title = txtTitle.Text.Trim() + "-" + Txtextension.Text.Trim();
            //objIncident.Title = txtTitle.Text.Trim();
            if (Txtextension.Text != "")
            {
                string extension = Txtextension.Text;
                Int64  vOut      = Convert.ToInt64(extension);
                //int vOut = Convert.ToInt32(extension);
                objIncident.Extension = vOut;
            }
            //start changed by prachi-19thmarch
            if (drpAMCcall.SelectedItem.Text == "NO")
            {
                objIncident.AMCCall = false;
            }
            else if (drpAMCcall.SelectedItem.Text == "YES")
            {
                objIncident.AMCCall = true;
            }
            //end
            objIncident.Slaid          = SLAid;
            objIncident.Createdbyid    = createdbyid;
            objIncident.Requesterid    = requesterid;
            objIncident.Siteid         = siteid;
            objIncident.Description    = txtDescription.Text.ToString().Trim();
            objIncident.Deptid         = Convert.ToInt32(drpDepartment.SelectedValue);
            objIncident.Createdatetime = DateTime.Now.ToString();
            objIncident.Modeid         = Convert.ToInt32(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_Ex(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);
                        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  = Convert.ToInt32(drpTechnician.SelectedValue);
                if (Convert.ToInt32(drpTechnician.SelectedValue) != 0)
                {
                    objIncidentStates.AssignedTime = DateTime.Now.ToString();
                }
                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);
                    }
                    ///////////////////////////////////////////////////////////////////////////////


                    if (Convert.ToInt32(drpTechnician.SelectedValue) != 0)
                    {
                        objSentmailtoUser.SentmailTechnician(Convert.ToInt32(drpTechnician.SelectedValue), incidentid);
                    }

                    Response.Redirect("~/Incident/IncidentRequestUpdate.aspx?incidentid=" + incidentid + "");
                }
            }
        }
        catch (Exception ex)
        {
            string myScript;
            myScript = "<script language=javascript>alert('Exception - '" + ex + "');</script>";
            Page.RegisterClientScriptBlock("MyScript", myScript);
            return;
        }
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        // Save User to Database on Button Save click Event
        // Start
        objOrganization = objOrganization.Get_Organization();
        //Declare Local Variables - Flag,varRolename,FlagMembership
        int    Flag;
        string varRoleName;
        bool   FlagMembership;

        // Use Asp.Net Membership Validator Control Membership.ValidateUser to check User Exist in aspnet Database
        FlagMembership = Membership.ValidateUser(txtUserName.Text.ToString().Trim(), txtPassword.Text.ToString().Trim());

        //  Create Object of UserLogin_mst Class to Check User Exist in Database UserLogin_mst table
        UserLogin_mst objUserLogin = new UserLogin_mst();

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

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

                    // Call objContactInfo.Insert function to Insert record in Contact_info table
                    objContactInfo.Insert();
                    // Show Message Operation perform successfully
                    //lblMessage.Text = Resources.MessageResource.errDataSave.ToString();
                    // Calling Function Clear() to Clear all controls on Form
                    objusertositemapping.Userid = userid;
                    objusertositemapping.Siteid = Convert.ToInt32(DrpSite.SelectedValue);
                    objusertositemapping.Insert();
                    Clear();
                    Response.Redirect("~/admin/ViewUser.aspx");
                }
                else
                {
                    // Show Message Error Occured due to some Reason
                    lblMessage.Text = Resources.MessageResource.errOccured.ToString();
                }
            }
            else
            {
                // Show Message Error Occured due to some Reason
                lblMessage.Text = Resources.MessageResource.errOccured.ToString();
            }
        }
        else
        {
            // Show Message User Already Exist
            lblMessage.Text = Resources.MessageResource.errUserExist.ToString();
        }



        // End Save button Click
    }
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        bool FlagUserStatus = true;
        #region Find Userid of User who is Requesting to log a call

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

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

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

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

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

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

        }
        #endregion

        #endregion

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

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

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

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

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

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

            }

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

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

        }
    }
Beispiel #19
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 btnSave_Click(object sender, EventArgs e)
    {
        // Save User to Database on Button Save click Event
        // Start
        objOrganization = objOrganization.Get_Organization();
            //Declare Local Variables - Flag,varRolename,FlagMembership
              int Flag;
              string varRoleName;
              bool FlagMembership;
              // Use Asp.Net Membership Validator Control Membership.ValidateUser to check User Exist in aspnet Database
                 FlagMembership = Membership.ValidateUser(txtUserName.Text.ToString().Trim(), txtPassword.Text.ToString().Trim());

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

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

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

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

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

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

               }

           // End Save button Click
    }
    protected void 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 + "");

            }

        }
    }
Beispiel #22
0
    public string UserCreate(string UName, string Password, string Company, string city, string roleid,
                             string UserEmailId, string RoleName, string Description, string EmployeeId, string LandLineNo,
                             string MobileNo, string Location, string DepartmentId)
    {
        objOrganization = objOrganization.Get_Organization();
        //Declare Local Variables - Flag,varRolename,FlagMembership
        int    Flag;
        string varRoleName;
        bool   FlagMembership;

        // Use Asp.Net Membership Validator Control Membership.ValidateUser to check User Exist in aspnet Database
        FlagMembership = Membership.ValidateUser(UName, Password);

        //  Create Object of UserLogin_mst Class to Check User Exist in Database UserLogin_mst table
        UserLogin_mst objUserLogin = new UserLogin_mst();

        //  Declare local Variable Flag to Check Status User Exist in databse
        Flag = objUserLogin.Get_By_UserName(UName, objOrganization.Orgid);
        //  If User Does'nt exist in Database and in aspnet databse then flag value will 0 and FlagMembership value will be False
        if (Flag == 0 && FlagMembership == false)
        {
            // Declare status local variable
            int status;
            // Create Object objUserLogin of UserLogin_mst() Class to insert record in table
            objUserLogin                = new UserLogin_mst();
            objUserLogin.Username       = UName;
            objUserLogin.Password       = Password;
            objUserLogin.Company        = Company;
            objUserLogin.City           = city;
            objUserLogin.Roleid         = Convert.ToInt32(roleid);
            objUserLogin.Orgid          = objOrganization.Orgid;
            objUserLogin.ADEnable       = false;
            objUserLogin.Enable         = true;
            objUserLogin.Createdatetime = DateTime.Now.ToString();
            // Call Insert function to insert record in UserLogin_mst table
            // Check status whether Record inserted Successfully or Not,If status=1 then Success otherwise Operation Fail
            status = objUserLogin.Insert();
            if (status == 1)
            {
                // Declare local variable varEmail to fetch email of user from textbox
                string varEmail;
                //If Email field is Not Empty then Assign value to varEmail Local Variable
                if (UserEmailId != "")
                {
                    varEmail = UserEmailId.Trim();
                }
                // Else Assign value define in MessagesResources.resx file in errMemshipCreateUserEmail field
                else
                {
                    varEmail = Resources.MessageResource.errMemshipCreateUserEmail.ToString();
                }
                // Assign selected text from droprole down to  local variable field varRoleName
                varRoleName = RoleName.Trim();
                // Create Mstatus field to send in Membership.CreateUser function as Out Variable for creating Membership User database
                MembershipCreateStatus Mstatus = default(MembershipCreateStatus);
                // Call Membership.CreateUser function to create Membership user

                Membership.CreateUser(UName.Trim(), Password.Trim(), varEmail, "Project Name", "Helpdesk", true, out Mstatus);
                // Call Roles.AddUserToRole Function to Add User To Role
                Roles.AddUserToRole(UName.Trim(), varRoleName);
                // Declare Local Variable Userid to fetch userid of newly created user
                int userid;
                // Create Object objUserLogin of UserLogin_mst()Class
                objUserLogin = new UserLogin_mst();
                // Fetch userid of Newly created user and assign to local variable userid by calling function objUserLogin.Get_By_UserName
                userid = objUserLogin.Get_By_UserName(UName.Trim(), objOrganization.Orgid);
                // If userid not equal to 0 then we get userid of Newly created user otherwise error Occured
                UserToSiteMapping objusertositemapping = new UserToSiteMapping();
                if (userid != 0)
                {
                    // Create Object objContactInfo of ContactInfo_mst class to Store User Contact Information in Contact_info table
                    ContactInfo_mst objContactInfo = new ContactInfo_mst();
                    objContactInfo.Userid      = userid;
                    objContactInfo.Firstname   = UName.Trim();
                    objContactInfo.Lastname    = UName.Trim();
                    objContactInfo.Description = Description;
                    objContactInfo.Empid       = EmployeeId;
                    objContactInfo.Emailid     = UserEmailId;
                    objContactInfo.Landline    = LandLineNo;
                    objContactInfo.Mobile      = MobileNo;
                    objContactInfo.Siteid      = Convert.ToInt32(Location);

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

                    // Call objContactInfo.Insert function to Insert record in Contact_info table
                    objContactInfo.Insert();
                    // Show Message Operation perform successfully
                    //lblMessage.Text = Resources.MessageResource.errDataSave.ToString();
                    // Calling Function Clear() to Clear all controls on Form
                    objusertositemapping.Userid = userid;
                    objusertositemapping.Siteid = Convert.ToInt32(Location);
                    objusertositemapping.Insert();
                    return("Created");
                }
                else
                {
                    return("Error");
                }
            }
            else
            {
                return("Error");
            }
        }
        else
        {
            return("Already Exist");
        }
    }
Beispiel #23
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 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);
    }
Beispiel #25
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;
        }
    }
    public string UserCreate(string UName, string Password, string Company, string city, string roleid,
                              string UserEmailId, string RoleName, string Description, string EmployeeId, string LandLineNo,
                              string MobileNo, string Location, string DepartmentId)
    {
        objOrganization = objOrganization.Get_Organization();
        //Declare Local Variables - Flag,varRolename,FlagMembership
        int Flag;
        string varRoleName;
        bool FlagMembership;
        // Use Asp.Net Membership Validator Control Membership.ValidateUser to check User Exist in aspnet Database
        FlagMembership = Membership.ValidateUser(UName, Password);

        //  Create Object of UserLogin_mst Class to Check User Exist in Database UserLogin_mst table
        UserLogin_mst objUserLogin = new UserLogin_mst();
        //  Declare local Variable Flag to Check Status User Exist in databse
        Flag = objUserLogin.Get_By_UserName(UName, objOrganization.Orgid);
        //  If User Does'nt exist in Database and in aspnet databse then flag value will 0 and FlagMembership value will be False
        if (Flag == 0 && FlagMembership == false)
        {
            // Declare status local variable
            int status;
            // Create Object objUserLogin of UserLogin_mst() Class to insert record in table
            objUserLogin = new UserLogin_mst();
            objUserLogin.Username = UName;
            objUserLogin.Password = Password;
            objUserLogin.Company = Company;
            objUserLogin.City = city;
            objUserLogin.Roleid = Convert.ToInt32(roleid);
            objUserLogin.Orgid = objOrganization.Orgid;
            objUserLogin.ADEnable = false;
            objUserLogin.Enable = true;
            objUserLogin.Createdatetime = DateTime.Now.ToString();
            // Call Insert function to insert record in UserLogin_mst table
            // Check status whether Record inserted Successfully or Not,If status=1 then Success otherwise Operation Fail
            status = objUserLogin.Insert();
            if (status == 1)
            {
                // Declare local variable varEmail to fetch email of user from textbox
                string varEmail;
                //If Email field is Not Empty then Assign value to varEmail Local Variable
                if (UserEmailId != "")
                {
                    varEmail = UserEmailId.Trim();
                }
                // Else Assign value define in MessagesResources.resx file in errMemshipCreateUserEmail field
                else
                {
                    varEmail = Resources.MessageResource.errMemshipCreateUserEmail.ToString();
                }
                // Assign selected text from droprole down to  local variable field varRoleName
                varRoleName = RoleName.Trim();
                // Create Mstatus field to send in Membership.CreateUser function as Out Variable for creating Membership User database
                MembershipCreateStatus Mstatus = default(MembershipCreateStatus);
                // Call Membership.CreateUser function to create Membership user

                Membership.CreateUser(UName.Trim(), Password.Trim(), varEmail, "Project Name", "Helpdesk", true, out Mstatus);
                // Call Roles.AddUserToRole Function to Add User To Role
                Roles.AddUserToRole(UName.Trim(), varRoleName);
                // Declare Local Variable Userid to fetch userid of newly created user
                int userid;
                // Create Object objUserLogin of UserLogin_mst()Class
                objUserLogin = new UserLogin_mst();
                // Fetch userid of Newly created user and assign to local variable userid by calling function objUserLogin.Get_By_UserName
                userid = objUserLogin.Get_By_UserName(UName.Trim(), objOrganization.Orgid);
                // If userid not equal to 0 then we get userid of Newly created user otherwise error Occured
                UserToSiteMapping objusertositemapping = new UserToSiteMapping();
                if (userid != 0)
                {
                    // Create Object objContactInfo of ContactInfo_mst class to Store User Contact Information in Contact_info table
                    ContactInfo_mst objContactInfo = new ContactInfo_mst();
                    objContactInfo.Userid = userid;
                    objContactInfo.Firstname = UName.Trim();
                    objContactInfo.Lastname = UName.Trim();
                    objContactInfo.Description = Description;
                    objContactInfo.Empid = EmployeeId;
                    objContactInfo.Emailid = UserEmailId;
                    objContactInfo.Landline = LandLineNo;
                    objContactInfo.Mobile = MobileNo;
                    objContactInfo.Siteid = Convert.ToInt32(Location);

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

                    // Call objContactInfo.Insert function to Insert record in Contact_info table
                    objContactInfo.Insert();
                    // Show Message Operation perform successfully
                    //lblMessage.Text = Resources.MessageResource.errDataSave.ToString();
                    // Calling Function Clear() to Clear all controls on Form
                    objusertositemapping.Userid = userid;
                    objusertositemapping.Siteid = Convert.ToInt32(Location);
                    objusertositemapping.Insert();
                    return "Created";
                }
                else
                {
                    return "Error";
                }

            }
            else
            {
                return "Error";
            }

        }
        else
        {
            return "Already Exist";
        }
    }
Beispiel #27
0
    protected void btnImport_Click(object sender, EventArgs e)
    {
        try
        {
            string varObjDomainName;
            string Username = "";
            string Password = "";
            Username = txtUserName.Text;
            Password = txtPassword.Text;
            //Assign domain name to variable varDomainName and varObjDomainName
            varObjDomainName = txtDomainName.Text.ToString().Trim();
            //Create object de of Directory Entry Class
            //DirectoryEntry myDirectoryEntry = new DirectoryEntry(String.Format("LDAP://{0}/ou=Mahim;dc=HTmedia;dc=net", varObjDomainName));
            //DirectoryEntry myDirectoryEntry = new DirectoryEntry(String.Format("LDAP://{0}/ou='"+TxtOU1.Text+"'/ou='"+TxtOU2.Text+"';dc=HTmedia;dc=net", varObjDomainName));
            //DirectoryEntry myDirectoryEntry = new DirectoryEntry("LDAP://" + varObjDomainName);
            DirectoryEntry myDirectoryEntry = new DirectoryEntry(String.Format("LDAP://{0}", varObjDomainName));
            myDirectoryEntry.Username = Username;
            myDirectoryEntry.Password = Password;
            //  DirectoryEntry myDirectoryEntry = new DirectoryEntry(String.Format("LDAP://{0}/ou=Sur;ou=apc;dc=Terex;dc=local",varObjDomainName));
            // Create object mySearcher of DirectorySearcher Class
            DirectorySearcher mySearcher = new DirectorySearcher(myDirectoryEntry);
            mySearcher.SearchScope = SearchScope.Subtree;
            //mySearcher.Filter = "(&(objectClass=user)(objectCategory=person))";
            mySearcher.Filter = ("(objectCategory=person)");
            // mySearcher.Filter = "(objectClass=person)";
            // Create Local Variable OrganizationId to get organization id
            int OrganizationId;
            // Call Function Get_Organization() to get the object of Organization_mst
            objOrg = objOrg.Get_Organization();
            // Assign Organization id to variable OrganizationId
            OrganizationId = objOrg.Orgid;
            //  Create Localvariable varRoleName get role form Gloabl Resource File MessageResource and later assign to user when user import to database
            string varRoleName = Resources.MessageResource.BasicUserRole.ToString();
            //  Assign roleid to local variable varRoleid by calling function Get_By_RoleName
            int varRoleid = objRoleInfo.Get_By_RoleName(varRoleName);
            //  Create Local Variable  FlagSave and FlagUserExist to check status of save and user Exist
            int FlagSave      = 0;
            int FlagUserExist = 0;
            int count         = 0;
            int count1        = 0;
            foreach (SearchResult result in mySearcher.FindAll())
            {
                count++;
                count1 = result.Properties.Count;
                try
                {
                    //if (!String.IsNullOrEmpty(result.Properties["Mail"][0].ToString())
                    //    && System.Text.RegularExpressions.Regex.IsMatch(result.Properties["DisplayName"][0].ToString(), " |admin|test|service|system|[$]", System.Text.RegularExpressions.RegexOptions.IgnoreCase)                                         )
                    //{
                    string SAMAccountName = Convert.ToBoolean(result.Properties["sAMAccountName"].Count > 0) ? result.Properties["sAMAccountName"][0].ToString() : "";
                    string DisplayName    = Convert.ToBoolean(result.Properties["displayName"].Count > 0) ? result.Properties["displayName"][0].ToString() : "";
                    string mail           = Convert.ToBoolean(result.Properties["mail"].Count > 0) ? result.Properties["mail"][0].ToString() : "";
                    string company        = Convert.ToBoolean(result.Properties["company"].Count > 0) ? result.Properties["company"][0].ToString() : "";
                    string Site           = Convert.ToBoolean(result.Properties["L"].Count > 0) ? result.Properties["L"][0].ToString() : "";
                    // Create loccal variable FlagStatus,varUsername
                    int    FlagStatus;
                    string varUserName;
                    string varCompany;
                    string varSite;
                    // varCompany = objUserLogin.Company;
                    varCompany = company;
                    //varSite = objUserLogin.Site;
                    varSite = Site;
                    // Assign username to variable varUserName
                    varUserName = SAMAccountName.ToString().Trim();

                    //  Declare local Variable Flag to Check Status User Exist in databse
                    FlagStatus = objUserLogin.Get_By_UserName(varUserName, OrganizationId);
                    // If variable FlagStatus is zero  then User does not exist in database
                    if (FlagStatus == 0)
                    {
                        // Create local variable FlagInsertStatus to check insert status of function
                        int FlagInsertStatus;
                        // Create local variable VarPassword to get passowrd which is generated using function GeneratePassword()
                        string VarPassword = Membership.GeneratePassword(8, 2);
                        objUserLogin.ADEnable       = true;
                        objUserLogin.Createdatetime = DateTime.Now.ToString();
                        objUserLogin.Enable         = true;
                        objUserLogin.Orgid          = OrganizationId;
                        objUserLogin.Password       = VarPassword;
                        objUserLogin.Username       = varUserName;
                        objUserLogin.Roleid         = varRoleid;
                        objUserLogin.DomainName     = varObjDomainName;
                        objUserLogin.Company        = varCompany;
                        objUserLogin.City           = varSite;
                        // Call function objUserLogin.Insert to insert user data to UserLogin_mst table and assign  status in FlagInsertStatus variable

                        FlagInsertStatus = objUserLogin.Insert();

                        // If FlagInsertStatus is 1 then Insert operation is Success
                        if (FlagInsertStatus == 1)
                        {
                            // Create local variable UserId,varFirstName,varLastName,varFullname,arraycount,FlagContactInfo
                            int      UserId;
                            string   varFirstName = "";
                            string   varLastName  = "";
                            string[] varFullName;
                            int      arraycount;
                            int      FlagContactInfo;
                            // Assign Display Name to variable varFullname to get firstname and last name by calling split function
                            varFullName = DisplayName.Split(' ');
                            //Assign  the number of variables in array varFullName to arraycount  ,to check how many elements in varFullName array
                            arraycount   = varFullName.Count();
                            varFirstName = varFullName[0].ToString().Trim();
                            // if arraycount is greater than one,than there is more than one values in array varFullName ie it also contain lastname value
                            if (arraycount > 1)
                            {
                                // lastname assign to variable varLastName
                                varLastName = varFullName[1].ToString().Trim();
                            }
                            // Fetch userid of Newly created user and assign to local variable userid by calling function objUserLogin.Get_By_UserName
                            UserId = objUserLogin.Get_By_UserName(varUserName.ToString().Trim(), OrganizationId);
                            objContactInfo.Userid = UserId;
                            // objContactInfo.Deptname = department;
                            objContactInfo.Emailid   = mail;
                            objContactInfo.Firstname = varFirstName;
                            objContactInfo.Lastname  = varLastName;
                            // Local variable FlagContactInfo contain the status of Insert function objContactInfo.Insert()
                            FlagContactInfo = objContactInfo.Insert();
                            // if FlagContactInfo is zero,means error occured and delete the user record by calling objUserLogin.Delete function
                            if (FlagContactInfo == 0)
                            {
                                objUserLogin.Delete(UserId);
                            }
                            else
                            {
                                // Assign variable FlagSave =1 to show record added successfully in database
                                FlagSave = 1;
                                string varEmail;
                                if (mail == "")
                                {
                                    varEmail = Resources.MessageResource.errMemshipCreateUserEmail.ToString();
                                }
                                else
                                {
                                    varEmail = mail.ToString().Trim();
                                }
                                //FlagSave = 1;
                                //string varCompany;
                                //if (company == "")
                                //{
                                //    varCompany = Resources.MessageResource.errMemshipCreateUserEmail.ToString();
                                //}
                                //else { varCompany = company.ToString().Trim(); }

                                //FlagSave = 1;
                                //string varSite;
                                //if (varSite == "")
                                //{
                                //    varSite = Resources.MessageResource.errMemshipCreateUserEmail.ToString();
                                //}
                                //else { varSIte = site.ToString().Trim(); }
                                // Create Mstatus field to send in Membership.CreateUser function as Out Variable for creating Membership User database
                                MembershipCreateStatus Mstatus = default(MembershipCreateStatus);
                                // Call Membership.CreateUser function to create Membership user
                                Membership.CreateUser(varUserName.ToString().Trim(), VarPassword.ToString().Trim(), varEmail, "Project Name", "Helpdesk", true, out Mstatus);
                                // Call Roles.AddUserToRole Function to Add User To Role
                                Roles.AddUserToRole(varUserName.ToString().Trim(), varRoleName);
                            }
                        }
                    }
                    else
                    {
                        //update city and company if user already exist
                        objUserLogin.UpdateCityCompany(varUserName, varCompany, varSite);
                        //end
                        FlagUserExist = 1;
                    }
                }
                //}
                catch
                { }
            }
            if (FlagSave == 1)
            {
                // Show Messages from Resources.MessageResource resouces file located in App_GlobalResource Dir
                lblErrMsg.Text = Resources.MessageResource.errDataSave.ToString();
            }
            else
            {
                if (FlagUserExist == 1)
                {
                    lblErrMsg.Text = Resources.MessageResource.errUserDomainExist.ToString();
                }
                else
                {
                    lblErrMsg.Text = Resources.MessageResource.errOccured.ToString();
                }
            }
        }
        catch (Exception ex)
        {
            // Show Messages from Resources.MessageResource resouces file located in App_GlobalResource Dir
            lblErrMsg.Text = Resources.MessageResource.errDomainName.ToString();
        }
        Dispose();
    }
    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 + " ");
    }