public CollectionBase GenerateUserToSiteMapping_mstCollection(ref IDataReader returnData) { BLLCollection<UserToSiteMapping> col = new BLLCollection<UserToSiteMapping>(); while (returnData.Read()) { UserToSiteMapping obj = new UserToSiteMapping(); obj.Userid = (int)returnData["Userid"]; obj.Siteid = (int)returnData["Siteid"]; col.Add(obj); } returnData.Close(); returnData.Dispose(); return col; }
public CollectionBase GenerateUserToSiteMapping_mstCollection(ref IDataReader returnData) { BLLCollection <UserToSiteMapping> col = new BLLCollection <UserToSiteMapping>(); while (returnData.Read()) { UserToSiteMapping obj = new UserToSiteMapping(); obj.Userid = (int)returnData["Userid"]; obj.Siteid = (int)returnData["Siteid"]; col.Add(obj); } returnData.Close(); returnData.Dispose(); return(col); }
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 BindDropCustomer() //{ // BLLCollection<Customer_mst> colCtS = new BLLCollection<Customer_mst>(); // string userName = ""; // MembershipUser User = Membership.GetUser(); // if (User != null) // { // userName = User.UserName.ToString(); // } // if (userName != "") // { // int userid; // int Flagcount = 0; // objOrganization = objOrganization.Get_Organization(); // objUser = objUser.Get_UserLogin_By_UserName(userName, objOrganization.Orgid); // if (objUser.Userid != 0) // { // userid = objUser.Userid; // colUserToSite = ObjUserToSite.Get_All_By_userid(userid); // foreach (UserToSiteMapping obj in colUserToSite) // { // int siteid; // Site_mst objSite1 = new Site_mst(); // siteid = obj.Siteid; // objSite1 = objSite1.Get_By_id(siteid); // if (objSite1.Siteid != 0) // { // colCustToSite=objCustToSite.Get_All_By_siteid(objSite1.Siteid); // foreach (CustomerToSiteMapping objcts in colCustToSite) // { // Customer_mst objC = new Customer_mst(); // int FlagStatus = 0; // objC = objC.Get_By_id(objcts.Custid); // if (Flagcount == 0) // { // colCtS.Add(objC); // } // else // { // foreach (Customer_mst objCus in colCtS) // { // if (objC.Custid == objCus.Custid) // { // FlagStatus = 1; // } // } // if (FlagStatus==0) // { // colCtS.Add(objC); // } // } // Flagcount = Flagcount + 1; // } // } // } // } // } // drpCustomer.DataTextField = "Customer_Name"; // drpCustomer.DataValueField = "CustId"; // drpCustomer.DataSource = colCtS; // drpCustomer.DataBind(); // if (colCtS.Count == 0) // { // ListItem item = new ListItem(); // item.Text = "-------------Select-------------"; // item.Value = "0"; // drpCustomer.Items.Add(item); // } //} protected void btnAdd_Click(object sender, EventArgs e) { //Add Exception handilng try catch change by vishal 21-05-2012 try { Session["UserCreate"] = "Exist"; #region Declaration of Local Variables int siteid, priorityid; int SLAid = 0; int createdbyid = 0; int requesterid = 0; int FlagInsert; int requesttypeid; string userName; bool FlagUserStatus; FlagUserStatus = true; FlagInsert = 0; #endregion #region Fetch Current User MembershipUser User = Membership.GetUser(); userName = User.UserName.ToString(); #endregion #region Get Current Site and Priority id siteid = Convert.ToInt32(drpSite.SelectedValue); priorityid = Convert.ToInt32(drpPriority.SelectedValue); #endregion #region Get SLAid on the basis of siteid and Priority id if (siteid != 0 && priorityid != 0) { SLAid = objIncident.Get_By_SLAid(siteid, priorityid); requesttypeid = Convert.ToInt32(Resources.MessageResource.strRequestTypeId.ToString()); if (requesttypeid == Convert.ToInt32(drpRequestType.SelectedValue)) { SLAid = 0; } } #endregion if (userName != "") { #region Find Userid of User who Created this Request objOrganization = objOrganization.Get_Organization(); objUser = objUser.Get_UserLogin_By_UserName(userName, objOrganization.Orgid); if (objUser.Userid != 0) { createdbyid = objUser.Userid; } #endregion #region Find Userid of User who is Requesting to log a call #region If User Already Exist if (Session["UserCreate"].ToString() == "Exist") { objUser = objUser.Get_UserLogin_By_UserName(txtUsername.Text.ToString().Trim(), objOrganization.Orgid); if (objUser.Userid != 0) { requesterid = objUser.Userid; } } #endregion #endregion } //added by lalit objIncident.Reporteddatetime =DBNull.Value.ToString(); objIncident.AMCCall = false; //end objIncident.Title = txtTitle.Text.ToString().Trim() + "-" + TxtExtension.Text.Trim(); objIncident.Slaid = SLAid; objIncident.Createdbyid = createdbyid; objIncident.Requesterid = requesterid; objIncident.Siteid = siteid; objIncident.Description = txtDescription.Text.ToString().Trim(); objIncident.Deptid = 0; objIncident.Createdatetime = DateTime.Now.ToString(); objIncident.Modeid = Convert.ToInt32(drpMode.SelectedValue); UserToSiteMapping objUserToSite = new UserToSiteMapping(); if (FlagUserStatus == true) { FlagInsert = objIncident.Insert(); #region Save Assetid and incident id in incidenttoassetmaaping objOrganization = objOrganization.Get_Organization(); objUser = objUser.Get_UserLogin_By_UserName(txtUsername.Text.ToString().Trim(), objOrganization.Orgid); int userid = Convert.ToInt32(objUser.Userid); int tempuser1 = Convert.ToInt32(Session["tempuser1"]); if (tempuser1 == 1) { assetid = Convert.ToInt32(Session["assetid"]); } else { assetid = Convert.ToInt32(objusertoasset.Get_AssetId_By_UserId(userid)); } int incid = Convert.ToInt32(objIncident.Get_TopIncidentId()); if (txtassignasset.Text != "") { //assetid = Convert.ToInt32(txtassignasset.Text); if (assetid != 0) { objincidenttoasset.Insert(incid, assetid); objusertoasset.Insert(userid, assetid, objUser.City, objUser.Company); //added a new column siteid Session.Abandon(); } } #endregion } if (FlagInsert == 1) { int FlagIncdStatesInsert; int incidentid; incidentid = objIncident.Get_Current_Incidentid(); objIncidentStates.Incidentid = incidentid; objIncidentStates.Priorityid = Convert.ToInt32(drpPriority.SelectedValue); objIncidentStates.Categoryid = Convert.ToInt32(drpCategory.SelectedValue); objIncidentStates.Statusid = Convert.ToInt32(drpStatus.SelectedValue); objIncidentStates.Subcategoryid = Convert.ToInt32(drpSubcategory.SelectedValue); objIncidentStates.Technicianid = 0; objIncidentStates.Requesttypeid = Convert.ToInt32(drpRequestType.SelectedValue); FlagIncdStatesInsert = objIncidentStates.Insert(); if (FlagIncdStatesInsert == 1) { objIncidentHistory.Incidentid = incidentid; objIncidentHistory.Operation = "create"; objIncidentHistory.Operationownerid = createdbyid; objIncidentHistory.Insert(); objSentmailtoUser.SentmailUser(requesterid, incidentid, "open"); // change code///////////////////////////////////////////////////////////////// if (FileUpload1.HasFile) { string filepath = Server.MapPath("~/FileAttach/"); string[] filenameupd = FileUpload1.FileName.Split(new char[] { '.' }); string filenew = Convert.ToString(incidentid) + "." + filenameupd[1]; FileUpload1.PostedFile.SaveAs(filepath + filenew); } /////////////////////////////////////////////////////////////////////////////// ////////change code on 27 march/// #region Map Site to user //FlagInsert=0; int FlagDelete = 0; int FlagStatus = 0; //string Username; //string gvIDs; int organizationId; //string gv; // Get object of Organization to get organization id and assign to local variable organizationId objOrganization = objOrganization.Get_Organization(); organizationId = objOrganization.Orgid; // Get username from textbox and assign to local variable Username //Username = txtUserName.Text.ToString().Trim(); // Find User Exist ,by calling function Get_UserLogin_By_UserName() //objUser = objUser.Get_UserLogin_By_UserName(Username, organizationId); // If Userid is not zero ,then user exist in database if (objUser.Userid != 0) { //'Navigate through each row in the GridView for checkbox items //foreach (GridViewRow gv in grdvwSite.Rows) //{ // Declare local variable deleteChkBxItem of Checkbox type to get the Checkbox Instance of Grid Row // CheckBox deleteChkBxItem = (CheckBox)gv.FindControl("deleteRec"); // If deleteChkBxItem is Checked then ,mapped Current site to this user //if (deleteChkBxItem.Checked) //{ // Get the Site Id from variable of Label type declare in GridView of grdvwSite //gvIDs = ((Label)gv.FindControl("SiteID")).Text.ToString(); // Check if gvIDs is not null // if (gvIDs != "") //{ // Declare local variable userid and siteid to get userid and SiteId int userid; userid = Convert.ToInt32(objUser.Userid); //siteid = Convert.ToInt32(gvIDs); // To Find Current Site to this User is Mapped by Calling Function objUserToSite.Get_By_Id() FlagStatus = objUserToSite.Get_By_Id(userid, siteid); // If FlagStatus is zero then site is not mapped to this user if (FlagStatus == 0) { objUserToSite.Siteid = siteid; objUserToSite.Userid = userid; // Mapped Current Site to this User by calling function objUserToSite.Insert() FlagInsert = objUserToSite.Insert(); } //} } // If deleteChkBxItem is Un Checked then ,Un mapped Current site to this user else { // Get the Site Id from variable of Label type declare in GridView of grdvwSite // gvIDs = ((Label)gv.FindControl("SiteID")).Text.ToString(); // Check if gvIDs is not null //if (gvIDs != "") // { // Declare local variable userid and siteid to get userid and SiteId int userid; userid = Convert.ToInt32(objUser.Userid); //siteid = Convert.ToInt32(gvIDs); // To Find Current Site to this User is Mapped by Calling Function objUserToSite.Get_By_Id() FlagStatus = objUserToSite.Get_By_Id(userid, siteid); // If FlagStatus is not zero then site is mapped to this user if (FlagStatus != 0) { // Un Mapped Current Site to this User by calling function objUserToSite.Delete() FlagDelete = objUserToSite.Delete(userid, siteid); } //} } //} #endregion /////////////end///////////////// Response.Redirect("../Login/AllUserCall.aspx"); } } } catch (Exception ex) { string myScript; myScript = "<script language=javascript>alert('Exception - '" + ex + "');</script>"; Page.RegisterClientScriptBlock("MyScript", myScript); return; } }
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) { string OrgId = GetOrgId(); //LogMessage("OrgId='"+OrgId+"'"); 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); Flag = IsUserExist(UName, OrgId); if (Flag == 0 && FlagMembership == false) { // LogMessage("Flag == 0 && FlagMembership == false"); int status; status = InsertInIncidentMst(OrgId, UName, Password, roleid, DateTime.Now.ToString(), true, false); if (status != 1) { LogMessage("Function- Add User- Insert in UserLoginMst','User is not Add in UserLogin Table"); //EventLog.WriteEntry("Function- Add User- Insert in UserLoginMst", "User is not Add in UserLogin Table"); } if (status == 1) { LogMessage("UserLoginMst user entered"); string varEmail=""; if (UserEmailId != "") { varEmail = UserEmailId.Trim(); } varRoleName = RoleName.Trim(); MembershipCreateStatus Mstatus = default(MembershipCreateStatus); Membership.CreateUser(UName.Trim(), Password.Trim(), varEmail, "Project Name", "Helpdesk", true, out Mstatus); Roles.AddUserToRole(UName.Trim(), varRoleName); int userid; userid = IsUserExist(UName, OrgId); UserToSiteMapping objusertositemapping = new UserToSiteMapping(); if (userid != 0) { int k= InsertInLoginStatus(userid.ToString(), UName.Trim(), UName.Trim(), UserEmailId, MobileNo, LandLineNo, DepartmentId, UserEmailId, Description, Location,DepartmentId); LogMessage("Contact Info-Mst user created:'"+ k +"'"); if (k != 1) { LogMessage("Function- Add User- Insert in UserLoginMst','User is not Add in UserLogin Table"); //EventLog.WriteEntry("Function- Add User- Insert in UserLoginMst", "User is not Add in UserLogin Table"); } int i=UserToSiteMaping(userid.ToString(), Location); LogMessage("User To Site Mapping:'" + i + "'"); if (i != 1) { EventLog.WriteEntry("Function- Add User- Asset Mapping","User To Site Maaping is not done"); } i = UserToMailMaping(userid.ToString(), UserEmailId); 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 BindDropCustomer() //{ // BLLCollection<Customer_mst> colCtS = new BLLCollection<Customer_mst>(); // string userName = ""; // MembershipUser User = Membership.GetUser(); // if (User != null) // { // userName = User.UserName.ToString(); // } // if (userName != "") // { // int userid; // int Flagcount = 0; // objOrganization = objOrganization.Get_Organization(); // objUser = objUser.Get_UserLogin_By_UserName(userName, objOrganization.Orgid); // if (objUser.Userid != 0) // { // userid = objUser.Userid; // colUserToSite = ObjUserToSite.Get_All_By_userid(userid); // foreach (UserToSiteMapping obj in colUserToSite) // { // int siteid; // Site_mst objSite1 = new Site_mst(); // siteid = obj.Siteid; // objSite1 = objSite1.Get_By_id(siteid); // if (objSite1.Siteid != 0) // { // colCustToSite=objCustToSite.Get_All_By_siteid(objSite1.Siteid); // foreach (CustomerToSiteMapping objcts in colCustToSite) // { // Customer_mst objC = new Customer_mst(); // int FlagStatus = 0; // objC = objC.Get_By_id(objcts.Custid); // if (Flagcount == 0) // { // colCtS.Add(objC); // } // else // { // foreach (Customer_mst objCus in colCtS) // { // if (objC.Custid == objCus.Custid) // { // FlagStatus = 1; // } // } // if (FlagStatus==0) // { // colCtS.Add(objC); // } // } // Flagcount = Flagcount + 1; // } // } // } // } // } // drpCustomer.DataTextField = "Customer_Name"; // drpCustomer.DataValueField = "CustId"; // drpCustomer.DataSource = colCtS; // drpCustomer.DataBind(); // if (colCtS.Count == 0) // { // ListItem item = new ListItem(); // item.Text = "-------------Select-------------"; // item.Value = "0"; // drpCustomer.Items.Add(item); // } //} protected void btnAdd_Click(object sender, EventArgs e) {//Add Exception handilng try catch change by vishal 21-05-2012 try { Session["UserCreate"] = "Exist"; #region Declaration of Local Variables int siteid, priorityid; int SLAid = 0; int createdbyid = 0; int requesterid = 0; int FlagInsert; int requesttypeid; string userName; bool FlagUserStatus; FlagUserStatus = true; FlagInsert = 0; #endregion #region Fetch Current User MembershipUser User = Membership.GetUser(); userName = User.UserName.ToString(); #endregion #region Get Current Site and Priority id siteid = Convert.ToInt32(drpSite.SelectedValue); priorityid = Convert.ToInt32(drpPriority.SelectedValue); #endregion #region Get SLAid on the basis of siteid and Priority id if (siteid != 0 && priorityid != 0) { SLAid = objIncident.Get_By_SLAid(siteid, priorityid); requesttypeid = Convert.ToInt32(Resources.MessageResource.strRequestTypeId.ToString()); if (requesttypeid == Convert.ToInt32(drpRequestType.SelectedValue)) { SLAid = 0; } } #endregion if (userName != "") { #region Find Userid of User who Created this Request objOrganization = objOrganization.Get_Organization(); objUser = objUser.Get_UserLogin_By_UserName(userName, objOrganization.Orgid); if (objUser.Userid != 0) { createdbyid = objUser.Userid; } #endregion #region Find Userid of User who is Requesting to log a call #region If User Already Exist if (Session["UserCreate"].ToString() == "Exist") { objUser = objUser.Get_UserLogin_By_UserName(txtUsername.Text.ToString().Trim(), objOrganization.Orgid); if (objUser.Userid != 0) { requesterid = objUser.Userid; } } #endregion #endregion } //added by lalit objIncident.Reporteddatetime = DBNull.Value.ToString(); objIncident.AMCCall = false; //end objIncident.Title = txtTitle.Text.ToString().Trim() + "-" + TxtExtension.Text.Trim(); objIncident.Slaid = SLAid; objIncident.Createdbyid = createdbyid; objIncident.Requesterid = requesterid; objIncident.Siteid = siteid; objIncident.Description = txtDescription.Text.ToString().Trim(); objIncident.Deptid = 0; objIncident.Createdatetime = DateTime.Now.ToString(); objIncident.Modeid = Convert.ToInt32(drpMode.SelectedValue); UserToSiteMapping objUserToSite = new UserToSiteMapping(); if (FlagUserStatus == true) { FlagInsert = objIncident.Insert(); #region Save Assetid and incident id in incidenttoassetmaaping objOrganization = objOrganization.Get_Organization(); objUser = objUser.Get_UserLogin_By_UserName(txtUsername.Text.ToString().Trim(), objOrganization.Orgid); int userid = Convert.ToInt32(objUser.Userid); int tempuser1 = Convert.ToInt32(Session["tempuser1"]); if (tempuser1 == 1) { assetid = Convert.ToInt32(Session["assetid"]); } else { assetid = Convert.ToInt32(objusertoasset.Get_AssetId_By_UserId(userid)); } int incid = Convert.ToInt32(objIncident.Get_TopIncidentId()); if (txtassignasset.Text != "") { //assetid = Convert.ToInt32(txtassignasset.Text); if (assetid != 0) { objincidenttoasset.Insert(incid, assetid); objusertoasset.Insert(userid, assetid, objUser.City, objUser.Company); //added a new column siteid Session.Abandon(); } } #endregion } if (FlagInsert == 1) { int FlagIncdStatesInsert; int incidentid; incidentid = objIncident.Get_Current_Incidentid(); objIncidentStates.Incidentid = incidentid; objIncidentStates.Priorityid = Convert.ToInt32(drpPriority.SelectedValue); objIncidentStates.Categoryid = Convert.ToInt32(drpCategory.SelectedValue); objIncidentStates.Statusid = Convert.ToInt32(drpStatus.SelectedValue); objIncidentStates.Subcategoryid = Convert.ToInt32(drpSubcategory.SelectedValue); objIncidentStates.Technicianid = 0; objIncidentStates.Requesttypeid = Convert.ToInt32(drpRequestType.SelectedValue); FlagIncdStatesInsert = objIncidentStates.Insert(); if (FlagIncdStatesInsert == 1) { objIncidentHistory.Incidentid = incidentid; objIncidentHistory.Operation = "create"; objIncidentHistory.Operationownerid = createdbyid; objIncidentHistory.Insert(); objSentmailtoUser.SentmailUser(requesterid, incidentid, "open"); // change code///////////////////////////////////////////////////////////////// if (FileUpload1.HasFile) { string filepath = Server.MapPath("~/FileAttach/"); string[] filenameupd = FileUpload1.FileName.Split(new char[] { '.' }); string filenew = Convert.ToString(incidentid) + "." + filenameupd[1]; FileUpload1.PostedFile.SaveAs(filepath + filenew); } /////////////////////////////////////////////////////////////////////////////// ////////change code on 27 march/// #region Map Site to user //FlagInsert=0; int FlagDelete = 0; int FlagStatus = 0; //string Username; //string gvIDs; int organizationId; //string gv; // Get object of Organization to get organization id and assign to local variable organizationId objOrganization = objOrganization.Get_Organization(); organizationId = objOrganization.Orgid; // Get username from textbox and assign to local variable Username //Username = txtUserName.Text.ToString().Trim(); // Find User Exist ,by calling function Get_UserLogin_By_UserName() //objUser = objUser.Get_UserLogin_By_UserName(Username, organizationId); // If Userid is not zero ,then user exist in database if (objUser.Userid != 0) { //'Navigate through each row in the GridView for checkbox items //foreach (GridViewRow gv in grdvwSite.Rows) //{ // Declare local variable deleteChkBxItem of Checkbox type to get the Checkbox Instance of Grid Row // CheckBox deleteChkBxItem = (CheckBox)gv.FindControl("deleteRec"); // If deleteChkBxItem is Checked then ,mapped Current site to this user //if (deleteChkBxItem.Checked) //{ // Get the Site Id from variable of Label type declare in GridView of grdvwSite //gvIDs = ((Label)gv.FindControl("SiteID")).Text.ToString(); // Check if gvIDs is not null // if (gvIDs != "") //{ // Declare local variable userid and siteid to get userid and SiteId int userid; userid = Convert.ToInt32(objUser.Userid); //siteid = Convert.ToInt32(gvIDs); // To Find Current Site to this User is Mapped by Calling Function objUserToSite.Get_By_Id() FlagStatus = objUserToSite.Get_By_Id(userid, siteid); // If FlagStatus is zero then site is not mapped to this user if (FlagStatus == 0) { objUserToSite.Siteid = siteid; objUserToSite.Userid = userid; // Mapped Current Site to this User by calling function objUserToSite.Insert() FlagInsert = objUserToSite.Insert(); } //} } // If deleteChkBxItem is Un Checked then ,Un mapped Current site to this user else { // Get the Site Id from variable of Label type declare in GridView of grdvwSite // gvIDs = ((Label)gv.FindControl("SiteID")).Text.ToString(); // Check if gvIDs is not null //if (gvIDs != "") // { // Declare local variable userid and siteid to get userid and SiteId int userid; userid = Convert.ToInt32(objUser.Userid); //siteid = Convert.ToInt32(gvIDs); // To Find Current Site to this User is Mapped by Calling Function objUserToSite.Get_By_Id() FlagStatus = objUserToSite.Get_By_Id(userid, siteid); // If FlagStatus is not zero then site is mapped to this user if (FlagStatus != 0) { // Un Mapped Current Site to this User by calling function objUserToSite.Delete() FlagDelete = objUserToSite.Delete(userid, siteid); } //} } //} #endregion /////////////end///////////////// Response.Redirect("../Login/AllUserCall.aspx"); } } } catch (Exception ex) { string myScript; myScript = "<script language=javascript>alert('Exception - '" + ex + "');</script>"; Page.RegisterClientScriptBlock("MyScript", myScript); return; } }
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 int Insert_UserToSiteMapping_mst(UserToSiteMapping objUserToSiteMapping) { return (int)ExecuteNonQuery(Sp_UserToSiteMapping_Insert, new object[] { objUserToSiteMapping.Userid, objUserToSiteMapping.Siteid }); }
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 }
public int Insert_UserToSiteMapping_mst(UserToSiteMapping objUserToSiteMapping) { return((int)ExecuteNonQuery(Sp_UserToSiteMapping_Insert, new object[] { objUserToSiteMapping.Userid, objUserToSiteMapping.Siteid })); }