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 btnAdd_Click(object sender, EventArgs e) {//Add Exception handilng try catch change by vishal 21-05-2012 try { bool FlagUserStatus = true; #region Find Userid of User who is Requesting to log a call #region If User Already Exist if (ViewState["UserCreate"].ToString() == "Exist") { objOrganization = objOrganization.Get_Organization(); ObjUserLogin = ObjUserLogin.Get_UserLogin_By_UserName(txtUsername.Text.ToString().Trim(), objOrganization.Orgid); if (ObjUserLogin.Userid != 0) { requesterid = ObjUserLogin.Userid; } } #endregion #region If New User is to be Created else if (ViewState["UserCreate"].ToString() == "create") { string varEmail = ""; string varRoleName = Resources.MessageResource.BasicUserRole.ToString(); if (txtEmail.Text == "") { varEmail = Resources.MessageResource.errMemshipCreateUserEmail.ToString(); } else { varEmail = txtEmail.Text; } int roleid = objRole.Get_By_RoleName(varRoleName); int status; objOrganization = objOrganization.Get_Organization(); objuser.Username = txtUsername.Text.ToString(); objuser.Password = Resources.MessageResource.strDefaultPassword.ToString(); objuser.Roleid = roleid; objuser.Orgid = objOrganization.Orgid; objuser.ADEnable = false; objuser.Enable = true; objuser.Createdatetime = DateTime.Now.ToString(); status = objuser.Insert(); if (status == 1) { // Create Mstatus field to send in Membership.CreateUser function as Out Variable for creating Membership User database MembershipCreateStatus Mstatus = default(MembershipCreateStatus); // Call Membership.CreateUser function to create Membership user Membership.CreateUser(txtUsername.Text.ToString().Trim(), Resources.MessageResource.strDefaultPassword.ToString(), varEmail, "Project Name", "Helpdesk", true, out Mstatus); // Call Roles.AddUserToRole Function to Add User To Role Roles.AddUserToRole(txtUsername.Text.ToString().Trim(), varRoleName); // Declare Local Variable Userid to fetch userid of newly created user // Create Object objUserLogin of UserLogin_mst()Class objuser = new UserLogin_mst(); // Fetch userid of Newly created user and assign to local variable userid by calling function objUserLogin.Get_By_UserName requesterid = objuser.Get_By_UserName(txtUsername.Text.ToString().Trim(), objOrganization.Orgid); // If userid not equal to 0 then we get userid of Newly created user otherwise error Occured ContactInfo_mst objContactInfo = new ContactInfo_mst(); objContactInfo.Userid = requesterid; objContactInfo.Emailid = varEmail; objContactInfo.Firstname = txtUsername.Text.ToString(); objContactInfo.Lastname = txtUsername.Text.ToString(); objContactInfo.Insert(); } } #endregion #region If User is Not to be Created else if (ViewState["UserCreate"].ToString() == "notcreate") { FlagUserStatus = false; } #endregion #endregion MembershipUser User = Membership.GetUser(); string userName; userName = User.UserName.ToString(); if (FlagUserStatus == true) { objOrganization = objOrganization.Get_Organization(); objuser = objuser.Get_UserLogin_By_UserName(userName, objOrganization.Orgid); ObjProblem.CreatedByid = objuser.Userid; ObjProblem.Requesterid = requesterid; ObjProblem.Categoryid = Convert.ToInt32(drpCategory.SelectedValue); ObjProblem.Subcategoryid = Convert.ToInt32(drpSubcategory.SelectedValue); ObjProblem.Priorityid = Convert.ToInt32(drpPriority.SelectedValue); ObjProblem.Statusid = Convert.ToInt32(drpStatus.SelectedValue); ObjProblem.Technicianid = Convert.ToInt32(drpTechnician.SelectedValue); ObjProblem.title = txtTitle.Text; ObjProblem.Description = txtDescription.Text; if (Convert.ToInt32(drpTechnician.SelectedValue) != 0) { ObjProblem.AssginedTime = DateTime.Now.ToString(); } ObjProblem.Insert(); int problemid = ObjProblem.Get_Current_Problemid(); ObjProblemHistory.Operationtime = DateTime.Now.ToString(); ObjProblemHistory.Problemid = problemid; ObjProblemHistory.Operation = "create"; ObjProblemHistory.Operationownerid = objuser.Userid; if (Session["IncidentToProblem"] != null) { int incidentid = Convert.ToInt32(Session["IncidentToProblem"].ToString()); Incident_To_Problem objIncToprob = new Incident_To_Problem(); objIncToprob.Incidentid = incidentid; objIncToprob.Problemid = problemid; objIncToprob.Insert(); } if (Convert.ToInt32(drpTechnician.SelectedValue) != 0) { objSentMailToUser.SentMailToTechnicianForProblemCall(problemid, Convert.ToInt32(drpTechnician.SelectedValue)); } ObjProblemHistory.Insert(); //ResetControls(); string myScript; myScript = "<script language=javascript>javascript:window.close();</script>"; Page.RegisterClientScriptBlock("MyScript", myScript); } } catch (Exception ex) { string myScript; myScript = "<script language=javascript>alert('Exception - '" + ex + "');</script>"; Page.RegisterClientScriptBlock("MyScript", myScript); return; } }
protected void buttonadd_click(object sender, EventArgs e) { /////Add Exception handilng try catch change by vishal 21-05-2012 try { #region Find Userid of User who is Requesting to log a call #region If User Already Exist if (ViewState["UserCreate"].ToString() == "Exist") { objOrganization = objOrganization.Get_Organization(); ObjUserLogin = ObjUserLogin.Get_UserLogin_By_UserName(txtUsername.Text.ToString().Trim(), objOrganization.Orgid); if (ObjUserLogin.Userid != 0) { requesterid = ObjUserLogin.Userid; } } #endregion #region If New User is to be Created else if (ViewState["UserCreate"].ToString() == "create") { string varEmail = ""; string varRoleName = Resources.MessageResource.BasicUserRole.ToString(); if (txtEmail.Text == "") { varEmail = Resources.MessageResource.errMemshipCreateUserEmail.ToString(); } else { varEmail = txtEmail.Text; } int roleid = objRole.Get_By_RoleName(varRoleName); int status; objOrganization = objOrganization.Get_Organization(); objuser.Username = txtUsername.Text.ToString(); objuser.Password = Resources.MessageResource.strDefaultPassword.ToString(); objuser.Roleid = roleid; objuser.Orgid = objOrganization.Orgid; objuser.ADEnable = false; objuser.Enable = true; objuser.Createdatetime = DateTime.Now.ToString(); status = objuser.Insert(); if (status == 1) { // Create Mstatus field to send in Membership.CreateUser function as Out Variable for creating Membership User database MembershipCreateStatus Mstatus = default(MembershipCreateStatus); // Call Membership.CreateUser function to create Membership user Membership.CreateUser(txtUsername.Text.ToString().Trim(), Resources.MessageResource.strDefaultPassword.ToString(), varEmail, "Project Name", "Helpdesk", true, out Mstatus); // Call Roles.AddUserToRole Function to Add User To Role Roles.AddUserToRole(txtUsername.Text.ToString().Trim(), varRoleName); // Declare Local Variable Userid to fetch userid of newly created user // Create Object objUserLogin of UserLogin_mst()Class objuser = new UserLogin_mst(); // Fetch userid of Newly created user and assign to local variable userid by calling function objUserLogin.Get_By_UserName requesterid = objuser.Get_By_UserName(txtUsername.Text.ToString().Trim(), objOrganization.Orgid); // If userid not equal to 0 then we get userid of Newly created user otherwise error Occured ContactInfo_mst objContactInfo = new ContactInfo_mst(); objContactInfo.Userid = requesterid; objContactInfo.Emailid = varEmail; objContactInfo.Firstname = txtUsername.Text.ToString(); objContactInfo.Lastname = txtUsername.Text.ToString(); objContactInfo.Insert(); } } #endregion #region If User is Not to be Created else if (ViewState["UserCreate"].ToString() == "notcreate") { // FlagUserStatus = false; } #endregion #endregion ObjChange.Active = true; ObjChange.Statusid = Convert.ToInt32(drpStatus.SelectedValue); ObjChange.Categoryid = Convert.ToInt32(drpCategory.SelectedValue); ObjChange.Subcategoryid = Convert.ToInt32(drpSubcategory.SelectedValue); // ObjChange.Technician =Convert.ToInt32(drpTechnician.SelectedValue); ObjChange.Title = txtTitle.Text; ObjChange.Description = txtDescription.Text; ObjChange.Createdtime = DateTime.Now.ToString(); ObjChange.Changetype = Convert.ToInt32(drpchangetype.SelectedValue); ObjChange.Approvalstatus = "Send For Approval"; MembershipUser user = Membership.GetUser(); string username = user.UserName.ToString(); objOrganization = objOrganization.Get_Organization(); ObjUserLogin = ObjUserLogin.Get_UserLogin_By_UserName(username, objOrganization.Orgid); int userid = Convert.ToInt32(ObjUserLogin.Userid); ObjChange.CreatedByID = userid; ObjUserLogin = ObjUserLogin.Get_UserLogin_By_UserName(txtUsername.Text, objOrganization.Orgid); ObjChange.Requestedby = ObjUserLogin.Userid; // ObjChange.Priority = Convert.ToInt32(drpPriority.SelectedValue); ObjChange.Insert(); int changeid = ObjChange.Get_Current_Changeid(); for (int i = ListAsset.Items.Count - 1; i >= 0; i--) { if (ListAsset.Items[i].Selected == true) { Objincludeaasetchange.Assetid = Convert.ToInt32(ListAsset.Items[i].Value); Objincludeaasetchange.Changeid = changeid; Objincludeaasetchange.Insert(); } } ObjChangeHistory.Changeid = changeid; // ObjChangeHistory.Description = "create"; ObjChangeHistory.Operation = "create"; ObjChangeHistory.Operationownerid = ObjUserLogin.Userid; ObjChangeHistory.Insert(); int changetype = Convert.ToInt32(drpchangetype.SelectedValue); objSentEmailToChange.SentMailToChangeCommittee(changeid, changetype); Response.Redirect("~/Change/EditChange.aspx?" + changeid + " "); } catch (Exception ex) { string myScript; myScript = "<script language=javascript>alert('Exception - '" + ex + "');</script>"; Page.RegisterClientScriptBlock("MyScript", myScript); return; } }
protected void 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 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 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); }
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"; } }
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"); } }
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 }