protected void txtUsername_TextChanged(object sender, EventArgs e) { #region Find Userid of User who is Requesting to log a call /////Add Exception handilng try catch change by vishal 21-05-2012 try { objOrganization = objOrganization.Get_Organization(); ObjUserLogin = ObjUserLogin.Get_UserLogin_By_UserName(txtUsername.Text.ToString().Trim(), objOrganization.Orgid); if (ObjUserLogin.Userid == 0) { string myScript; myScript = "<script language=javascript>function __doPostBack(eventTarget, eventArgument){var theForm = document.forms['aspnetForm']; if (theForm){ theForm.__EVENTTARGET.value = eventTarget;theForm.__EVENTARGUMENT.value = eventArgument;theForm.submit(); }} var Flag= confirm('User Does not Exist,Do You Want to Create User');if(Flag==true){ __doPostBack('callPostBack', 'create');}if(Flag==false){ __doPostBack('callPostBack', 'notcreate');}</script>"; Page.RegisterClientScriptBlock("MyScript", myScript); } else { ViewState["UserCreate"] = "Exist"; ContactInfo_mst objCont = new ContactInfo_mst(); objCont = objCont.Get_By_id(ObjUserLogin.Userid); txtEmail.Text = objCont.Emailid; } } catch (Exception ex) { string myScript; myScript = "<script language=javascript>alert('Exception - '" + ex + "');</script>"; Page.RegisterClientScriptBlock("MyScript", myScript); return; } #endregion }
protected void GetUserDetail() { string userName = ""; MembershipUser User = Membership.GetUser(); if (User != null) { userName = User.UserName.ToString(); txtUsername.Text = User.UserName.ToString(); } if (userName != "") { int userid; objOrganization = objOrganization.Get_Organization(); objUser = objUser.Get_UserLogin_By_UserName(userName, objOrganization.Orgid); if (objUser.Userid != 0) { ContactInfo_mst objConInfo = new ContactInfo_mst(); userid = objUser.Userid; IncidentToAsset(userid); objConInfo = objConInfo.Get_By_id(userid); txtEmail.Text = objConInfo.Emailid; txtassignasset.Text = compname; } } }
public void updatecomment() { string userName; MembershipUser User = Membership.GetUser(); solutionstatusid = Convert.ToInt16(Request.QueryString[0]); flag = Convert.ToInt16(Request.QueryString[1]); int userid; if (flag == 3) { string seeionsid = Session["SolutionId"].ToString(); string[] str = seeionsid.Split(new char[] { ',' }); foreach (string s in str) { if (s == "") { break; } int solid = Convert.ToInt16(s); ObjSolution = ObjSolution.Get_By_id(solid); ObjSolution.Title = ObjSolution.Title; ObjSolution.Topicid = ObjSolution.Topicid; ObjSolution.Content = ObjSolution.Content; ObjSolution.Comments = txtcomments.Text; ObjSolution.SolutionStatus = solutionstatusid; ObjSolution.Update(); userName = User.UserName.ToString(); Objorganization = Objorganization.Get_Organization(); objUser = objUser.Get_UserLogin_By_UserName(userName, Objorganization.Orgid); ObjSolutionCreator.Solutionid = solid; ObjSolutionCreator.LastUpdateBy = objUser.Userid; ObjSolutionCreator.Update(); } } else { int solutionid = Convert.ToInt16(Request.QueryString[1]); ObjSolution = ObjSolution.Get_By_id(solutionid); ObjSolution.Title = ObjSolution.Title; ObjSolution.Topicid = ObjSolution.Topicid; ObjSolution.Content = ObjSolution.Content; ObjSolution.Comments = txtcomments.Text; ObjSolution.SolutionStatus = solutionstatusid; ObjSolution.Update(); userName = User.UserName.ToString(); Objorganization = Objorganization.Get_Organization(); objUser = objUser.Get_UserLogin_By_UserName(userName, Objorganization.Orgid); ObjSolutionCreator.Solutionid = solutionid; ObjSolutionCreator.LastUpdateBy = objUser.Userid; ObjSolutionCreator.Update(); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { reqValRegion.ErrorMessage = Resources.MessageResource.errRegionName.ToString(); objOrganization = objOrganization.Get_Organization(); BindGrid(); } }
protected void GetUserDetail() { string userName = ""; MembershipUser User = Membership.GetUser(); if (User != null) { userName = User.UserName.ToString(); txtUsername.Text = User.UserName.ToString(); } if (userName != "") { int userid; objOrganization = objOrganization.Get_Organization(); objUser = objUser.Get_UserLogin_By_UserName(userName, objOrganization.Orgid); //objRole = objRole.Get_By_id(roleid); if (objUser.Userid != 0) { ContactInfo_mst objConInfo = new ContactInfo_mst(); userid = objUser.Userid; IncidentToAsset(userid); objConInfo = objConInfo.Get_By_id(userid); txtEmail.Text = objConInfo.Emailid; txtassignasset.Text = compname; //priorityid = Convert.ToInt32(objConInfo.userpriority); //BindDropPriority(int priorityid); //ContactInfo_mst objcnt = new ContactInfo_mst(); //if (objRole.roleid != 1) //{ if (objConInfo.userpriority == 1) { priorityid = objPriority.Get_By_PriorityName("High"); } else { priorityid = objPriority.Get_By_PriorityName("Medium"); } //} Priority_mst objP = new Priority_mst(); objP = objPriority.Get_By_id(priorityid); colPriority.Add(objP); drpPriority.DataTextField = "name"; drpPriority.DataValueField = "priorityid"; drpPriority.DataSource = colPriority; drpPriority.DataBind(); } } }
// Event handler btnShow_Click , To Bind Sites to Grid View on the Selected Username and Region protected void btnShow_Click(object sender, EventArgs e) { // Declare local Variable gvIDs,Username,organizationId and FlagStatus string gvIDs; string Username; int organizationId; int FlagStatus; lblErrorMsg.Text = ""; // To get the Object of Organization ,to find the organization id objOrganization = objOrganization.Get_Organization(); // Assign Organization Id to local variable organizationId organizationId = objOrganization.Orgid; // Assign Username from textbox to local variable Username Username = txtUserName.Text.ToString().Trim(); // Get Object of UserLogin_mst Class on the basis of username and OrganizationId objUser = objUser.Get_UserLogin_By_UserName(Username, organizationId); // If Userid is not equal to Zero ,then user Exist if (objUser.Userid != 0) { // Bind Grid of Sites BindGrid(); // To check row by row of gridview ,how many sites have been mapped to this user from table UserToSiteMapping foreach (GridViewRow gv in grdvwSite.Rows) { // Declare local variable deleteChkBxItem of Checkbox type to get the Checkbox Instance of Grid Row CheckBox deleteChkBxItem = (CheckBox)gv.FindControl("deleteRec"); // Get the Site Id from variable of Label type declare in GridView of grdvwSite gvIDs = ((Label)gv.FindControl("SiteID")).Text.ToString(); // Check if gvIDs is not null if (gvIDs != "") { // Declare local variable userid and siteid to get userid and SiteId int userid; int siteid; userid = Convert.ToInt16(objUser.Userid); siteid = Convert.ToInt16(gvIDs); // To Find Current Site to this User is Mapped by Calling Function objUserToSite.Get_By_Id() FlagStatus = objUserToSite.Get_By_Id(userid, siteid); // If FlagStatus is not zero then site is mapped to this user if (FlagStatus != 0) { //Checked checkbox to show site is mapped to this user deleteChkBxItem.Checked = true; } } } } }
protected void Page_Load(object sender, EventArgs e) {//Add Exception handilng try catch change by vishal 21-05-2012 try { if (!IsPostBack) { MembershipUser User = Membership.GetUser(); objOrganization = objOrganization.Get_Organization(); int userid = objUser.Get_By_UserName(User.UserName.ToString(), objOrganization.Orgid); if (userid != 0) { objContact = objContact.Get_By_id(userid); lblUser.Text = objContact.Firstname + " " + objContact.Lastname; } } XmlDataSource ds = new XmlDataSource(); ds.EnableCaching = false; ds.DataFile = Server.MapPath("../Files/Admin.xml"); TreeView1.DataSource = ds; TreeView1.DataBind(); } catch (Exception ex) { string myScript; myScript = "<script language=javascript>alert('Exception - '" + ex + "');</script>"; Page.RegisterClientScriptBlock("MyScript", myScript); return; } }
protected void btnSolutionAdd_Click(object sender, EventArgs e) {///Add Exception handilng try catch change by vishal 21-05-2012 try { string userName; MembershipUser User = Membership.GetUser(); userName = User.UserName.ToString(); int userid; objOrganization = objOrganization.Get_Organization(); objUser = objUser.Get_UserLogin_By_UserName(userName, objOrganization.Orgid); int Solutionid; ObjSolution.Title = txtTitle.Text.ToString(); ObjSolution.Content = Editor.Text.ToString(); ObjSolution.Topicid = Convert.ToInt32(drpTopic.SelectedValue); ObjSolution.Solution = drpSolutionType.SelectedValue; ObjSolution.Insert(); Solutionid = ObjSolutionKeyword.Get_SolutionId(); ObjSolutionKeyword.Keywords = txtKeywords.Text.ToString(); ObjSolutionKeyword.Solutionid = Solutionid; ObjSolutionKeyword.Insert(); ObjSolutionCreator.Solutionid = Solutionid; ObjSolutionCreator.Createdby = objUser.Userid; ObjSolutionCreator.Insert(); objSentMailToUser.SentMailToPManager(Solutionid); Response.Redirect("ViewSolution.aspx?solutionid" + Solutionid); } catch (Exception ex) { string myScript; myScript = "<script language=javascript>alert('Exception - '" + ex + "');</script>"; Page.RegisterClientScriptBlock("MyScript", myScript); return; } }
protected void btnapprove_Click(object sender, EventArgs e) { /////Add Exception handilng try catch change by vishal 21-05-2012 try { int userid = 0; int incidentid = Convert.ToInt32(Session["incidentid"].ToString()); if (incidentid != 0) { //objIncidentLog = objIncidentLog.Get_By_id(incidentid); //if (objIncidentLog.Incidentid != 0) //{ // objIncidentLog.Incidentid = incidentid; // objIncidentLog.Incidentlog = txtcomments.Text; // objIncidentLog.Update(); //} //else //{ // objIncidentLog.Incidentid = incidentid; // objIncidentLog.Incidentlog = txtcomments.Text; // objIncidentLog.Insert(); //} string userName = ""; MembershipUser User = Membership.GetUser(); if (User != null) { userName = User.UserName.ToString(); } if (userName != "") { objOrganization = objOrganization.Get_Organization(); objUser = objUser.Get_UserLogin_By_UserName(userName, objOrganization.Orgid); if (objUser.Userid != 0) { userid = objUser.Userid; } } objIncidentLog.Incidentid = incidentid; objIncidentLog.Userid = userid; objIncidentLog.Incidentlog = txtcomments.Text; objIncidentLog.Insert(); string myScript; myScript = "<script language=javascript>javascript:refreshParent(); javascript:window.close();</script>"; Page.RegisterClientScriptBlock("MyScript", myScript); } } catch (Exception ex) { string myScript; myScript = "<script language=javascript>alert('Exception - '" + ex + "');</script>"; Page.RegisterClientScriptBlock("MyScript", myScript); return; } }
protected void Page_Load(object sender, EventArgs e) { //lblUser.Text = Session["User"].ToString(); if (!IsPostBack) { MembershipUser User = Membership.GetUser(); objOrganization = objOrganization.Get_Organization(); int userid = objUser.Get_By_UserName(User.UserName.ToString(), objOrganization.Orgid); if (userid != 0) { objContact = objContact.Get_By_id(userid); lblUser.Text = objContact.Firstname + " " + objContact.Lastname; } //added by lalit to view Mail link only to SDE. checking here SDE is logged on. if (Roles.IsUserInRole(User.UserName.ToString(), "SDE")) { trautocall.Visible = true; //trRejectedcall.Visible = true; } if (Roles.IsUserInRole(User.UserName.ToString(), "admin")) { //trautocall.Visible = true; trRejectedcall.Visible = true; } //if (Roles.IsUserInRole(User.UserName.ToString(), "SDE")) //{ // //trautocall.Visible = true; // trRejectedcall.Visible = true; //} } }
protected void Page_Load(object sender, EventArgs e) {///Add Exception handilng try catch change by vishal 21-05-2012 try { //lblUser.Text = Session["User"].ToString(); if (!IsPostBack) { MembershipUser User = Membership.GetUser(); objOrganization = objOrganization.Get_Organization(); int userid = objUser.Get_By_UserName(User.UserName.ToString(), objOrganization.Orgid); if (userid != 0) { objContact = objContact.Get_By_id(userid); lblUser.Text = objContact.Firstname + " " + objContact.Lastname; } } } catch (Exception ex) { string myScript; myScript = "<script language=javascript>alert('Exception - '" + ex + "');</script>"; Page.RegisterClientScriptBlock("MyScript", myScript); return; } }
//public void BindDrpOrg() //{ // BLLCollection<Organization_mst> col = new BLLCollection<Organization_mst>(); // Organization_mst ObjOrganization = new Organization_mst(); // col = ObjOrganization.Get_All(); // DrpOrg.DataTextField = "Orgname"; // DrpOrg.DataValueField = "orgid"; // DrpOrg.DataSource = col; // DrpOrg.DataBind(); //} protected void btnSave_Click(object sender, EventArgs e) { objOrganization = objOrganization.Get_Organization(); int FlagStatus, FlagStatus1; int userid = Convert.ToInt16(Request.QueryString[0]); ObjUserLogin.Userid = userid; ObjUserLogin.Roleid = Convert.ToInt16(dropRole.SelectedValue.ToString()); if (lblAdUser.Text.ToString().Trim() == "Yes") { ObjUserLogin.ADEnable = true; } else { ObjUserLogin.ADEnable = false; } if (DropEnable.SelectedValue == "1") { ObjUserLogin.Enable = true; } else { ObjUserLogin.Enable = false; } ObjUserLogin.Orgid = objOrganization.Orgid; ObjUserLogin.Username = txtUserName.Text.ToString().Trim(); ObjUserLogin.Password = txtPassword.Text.ToString().Trim(); ObjContactInfo.Firstname = txtFname.Text.ToString().Trim(); ObjContactInfo.Lastname = txtLname.Text.ToString().Trim(); ObjContactInfo.Mobile = txtMobile.Text.ToString().Trim(); ObjContactInfo.Landline = txtLandline.Text.ToString().Trim(); ObjContactInfo.Empid = txtEmpId.Text.ToString().Trim(); ObjContactInfo.Siteid = Convert.ToInt16(DrpSite.SelectedValue.ToString()); ObjContactInfo.Deptid = Convert.ToInt16(DrpDepartment.SelectedValue.ToString()); ObjContactInfo.Emailid = txtEmailId.Text.ToString().Trim(); ObjContactInfo.Description = txtDesc.Text.ToString().Trim(); ObjContactInfo.Userid = userid; FlagStatus = ObjUserLogin.Update(); FlagStatus1 = ObjContactInfo.Update(); RoleInfo_mst objR = new RoleInfo_mst(); int roleid = Convert.ToInt16(ViewState["Roleid"].ToString()); objR = objRole.Get_By_id(roleid); if (objR.Roleid != 0) { Roles.RemoveUserFromRole(txtUserName.Text.ToString().Trim(), objR.Rolename); Roles.AddUserToRole(txtUserName.Text.ToString().Trim(), dropRole.SelectedItem.Text.ToString().Trim()); } if (FlagStatus == 1 && FlagStatus1 == 1) { // Redirect to page ViewSite.aspx page after successfully Updation Response.Redirect("~/admin/ViewUser.aspx"); } else { //If Updation is not successfully,Display Error Message //lblErrorMsg.Text = Resources.MessageResource.errOccured.ToString().Trim(); } }
protected void btnSolutionAdd_Click(object sender, EventArgs e) { string userName; MembershipUser User = Membership.GetUser(); userName = User.UserName.ToString(); int userid; objOrganization = objOrganization.Get_Organization(); objUser = objUser.Get_UserLogin_By_UserName(userName, objOrganization.Orgid); int Solutionid; ObjSolution.Title = txtTitle.Text.ToString(); ObjSolution.Content = Editor.Text.ToString(); ObjSolution.Topicid = Convert.ToInt16(drpTopic.SelectedValue); ObjSolution.Solution = drpSolutionType.SelectedValue; ObjSolution.Insert(); Solutionid = ObjSolutionKeyword.Get_SolutionId(); ObjSolutionKeyword.Keywords = txtKeywords.Text.ToString(); ObjSolutionKeyword.Solutionid = Solutionid; ObjSolutionKeyword.Insert(); ObjSolutionCreator.Solutionid = Solutionid; ObjSolutionCreator.Createdby = objUser.Userid; ObjSolutionCreator.Insert(); objSentMailToUser.SentMailToPManager(Solutionid); Response.Redirect("ViewSolution.aspx?solutionid" + Solutionid); }
protected void btnadd_Click(object sender, EventArgs e) { /////Add Exception handilng try catch change by vishal 21-05-2012 try { #region Fetch Current User // Fetch Current User and assign to local variable userName MembershipUser User = Membership.GetUser(); string userName = User.UserName.ToString(); #endregion ObjOrganization = ObjOrganization.Get_Organization(); int orgid = Convert.ToInt32(ObjOrganization.Orgid); int userid = ObjUser.Get_By_UserName(userName, orgid); ObjChangeNotes.Username = userid; ObjChangeNotes.Changeid = Convert.ToInt32(Request.QueryString[0]); ObjChangeNotes.Comments = txtcomments.Text.ToString(); ObjChangeNotes.Insert(); string myScript; myScript = "<script language=javascript>refreshParent();</script>"; Page.RegisterClientScriptBlock("MyScript", myScript); } catch (Exception ex) { string myScript; myScript = "<script language=javascript>alert('Exception - '" + ex + "');</script>"; Page.RegisterClientScriptBlock("MyScript", myScript); return; } }
protected void Page_Load(object sender, EventArgs e) { ////Add Exception handilng try catch change by vishal 21-05-2012 try { if (!IsPostBack) { MembershipUser User = Membership.GetUser(); objOrganization = objOrganization.Get_Organization(); int userid = objUser.Get_By_UserName(User.UserName.ToString(), objOrganization.Orgid); if (userid != 0) { string userName; userName = User.UserName.ToString(); if (Roles.IsUserInRole(userName, "admin")) { panel1.Visible = true; } objContact = objContact.Get_By_id(userid); lblUser.Text = objContact.Firstname + " " + objContact.Lastname; // Bind_Tree(); BindRepeater(); } } } catch (Exception ex) { string myScript; myScript = "<script language=javascript>alert('Exception - '" + ex + "');</script>"; Page.RegisterClientScriptBlock("MyScript", myScript); return; } }
protected void btnapprove_Click(object sender, EventArgs e) { int userid = 0; int incidentid = Convert.ToInt16(Session["incidentid"].ToString()); if (incidentid != 0) { string userName = ""; MembershipUser User = Membership.GetUser(); if (User != null) { userName = User.UserName.ToString(); } if (userName != "") { objOrganization = objOrganization.Get_Organization(); objUser = objUser.Get_UserLogin_By_UserName(userName, objOrganization.Orgid); if (objUser.Userid != 0) { userid = objUser.Userid; } } objIncidentLog.Incidentid = incidentid; objIncidentLog.Userid = userid; objIncidentLog.Incidentlog = txtcomments.Text; objIncidentLog.Insert(); string myScript; myScript = "<script language=javascript>javascript:window.close();</script>"; Page.RegisterClientScriptBlock("MyScript", myScript); } }
protected void txtUsername_TextChanged(object sender, EventArgs e) { #region Find Userid of User who is Requesting to log a call objOrganization = objOrganization.Get_Organization(); ObjUserLogin = ObjUserLogin.Get_UserLogin_By_UserName(txtUsername.Text.ToString().Trim(), objOrganization.Orgid); if (ObjUserLogin.Userid == 0) { string myScript; myScript = "<script language=javascript>function __doPostBack(eventTarget, eventArgument){var theForm = document.forms['aspnetForm']; if (theForm){ theForm.__EVENTTARGET.value = eventTarget;theForm.__EVENTARGUMENT.value = eventArgument;theForm.submit(); }} var Flag= confirm('User Does not Exist,Do You Want to Create User');if(Flag==true){ __doPostBack('callPostBack', 'create');}if(Flag==false){ __doPostBack('callPostBack', 'notcreate');}</script>"; Page.RegisterClientScriptBlock("MyScript", myScript); } else { ViewState["UserCreate"] = "Exist"; } #endregion }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { MembershipUser User = Membership.GetUser(); objOrganization = objOrganization.Get_Organization(); int userid = objUser.Get_By_UserName(User.UserName.ToString(), objOrganization.Orgid); if (userid != 0) { objContact = objContact.Get_By_id(userid); lblUser.Text = objContact.Firstname + " " + objContact.Lastname; } } }
protected void Page_Load(object sender, EventArgs e) { #region Get Current User and his Role MembershipUser User = Membership.GetUser(); objOrganization = objOrganization.Get_Organization(); int userid = objUser.Get_By_UserName(User.UserName.ToString(), objOrganization.Orgid); if (userid != 0) { objContact = objContact.Get_By_id(userid); lblUser.Text = objContact.Firstname + " " + objContact.Lastname; } #endregion }
protected void btnorgadd_Click(object sender, EventArgs e) { orgobj = orgobj.Get_Organization(); if (orgobj.Orgid == 0) { orgobj.Orgname = txtorgname.Text.Trim(); orgobj.Description = txtorgdesc.Text.Trim(); orgobj.Createdatetime = DateTime.Now.ToString(); orgobj.Insert(); BindGrid(); lblErrorMsg.Text = Resources.MessageResource.erradd.ToString(); } else { lblErrorMsg.Text = Resources.MessageResource.errAddOrg.ToString(); } }
protected void Page_Load(object sender, EventArgs e) {///Add Exception handilng try catch change by vishal 21-05-2012 try { //lblUser.Text = Session["User"].ToString(); if (!IsPostBack) { MembershipUser User = Membership.GetUser(); objOrganization = objOrganization.Get_Organization(); int userid = objUser.Get_By_UserName(User.UserName.ToString(), objOrganization.Orgid); if (userid != 0) { objContact = objContact.Get_By_id(userid); lblUser.Text = objContact.Firstname + " " + objContact.Lastname; } //added by lalit to view Mail link only to SDE. checking here SDE is logged on. string AutoCalls = Resources.MessageResource.strAutoCalls.ToString(); if (Roles.IsUserInRole(User.UserName.ToString(), "SDE")) { if (AutoCalls == "1") { trautocall.Visible = true; trRejectedcall.Visible = true; } } if (Roles.IsUserInRole(User.UserName.ToString(), "admin")) { //trautocall.Visible = true; if (AutoCalls == "1") { trRejectedcall.Visible = true; } } } } catch (Exception ex) { string myScript; myScript = "<script language=javascript>alert('Exception - '" + ex + "');</script>"; Page.RegisterClientScriptBlock("MyScript", myScript); return; } }
protected void btnadd_Click(object sender, EventArgs e) { #region Fetch Current User // Fetch Current User and assign to local variable userName MembershipUser User = Membership.GetUser(); string userName = User.UserName.ToString(); #endregion ObjOrganization = ObjOrganization.Get_Organization(); int orgid = Convert.ToInt16(ObjOrganization.Orgid); int userid = ObjUser.Get_By_UserName(userName, orgid); ObjProblemNotes.UserName = userid; ObjProblemNotes.Problemid = Convert.ToInt16(Request.QueryString[0]); ObjProblemNotes.Comments = txtcomments.Text.ToString(); ObjProblemNotes.Insert(); string myScript; myScript = "<script language=javascript>refreshParent();</script>"; Page.RegisterClientScriptBlock("MyScript", myScript); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { MembershipUser User = Membership.GetUser(); objOrganization = objOrganization.Get_Organization(); int userid = objUser.Get_By_UserName(User.UserName.ToString(), objOrganization.Orgid); if (userid != 0) { objContact = objContact.Get_By_id(userid); lblUser.Text = objContact.Firstname + " " + objContact.Lastname; } } XmlDataSource ds = new XmlDataSource(); ds.EnableCaching = false; ds.DataFile = Server.MapPath("../Files/Admin.xml"); TreeView1.DataSource = ds; TreeView1.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { MembershipUser User = Membership.GetUser(); objOrganization = objOrganization.Get_Organization(); int userid = objUser.Get_By_UserName(User.UserName.ToString(), objOrganization.Orgid); if (userid != 0) { string userName; userName = User.UserName.ToString(); if (Roles.IsUserInRole(userName, "admin")) { panel1.Visible = true; } objContact = objContact.Get_By_id(userid); lblUser.Text = objContact.Firstname + " " + objContact.Lastname; } } Bind_Tree(); }
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 Bindgrid() { #region Declaration of localvariable and table Variable int filterId; DataTable dtTable = new DataTable(); dtTable = CreateDataTable(); string userName = ""; int varTechnicianId = 0; string varSortParameter = "createdatetime"; #endregion #region Get Current User and his Role MembershipUser User = Membership.GetUser(); string varUserRole = ""; string varRoleTechnician = ""; if (User != null) { userName = User.UserName.ToString(); string[] arrUserRole = Roles.GetRolesForUser(); varUserRole = arrUserRole[0].ToString(); varRoleTechnician = Resources.MessageResource.strTechnicianRole.ToString(); } #endregion #region Get User object by Calling Function Get_UserLogin_By_UserName() via passing parameter username and organizationid objOrganization = objOrganization.Get_Organization(); objUser = objUser.Get_UserLogin_By_UserName(userName, objOrganization.Orgid); #endregion #region If User Exist if (objUser.Userid != 0) { string fromdate = null; string todate = null; #region Find how many sites have been mapped to current user by calling function Get_All_By_userid() via passing parameter userid int userid = objUser.Userid; colUserToSite = ObjUserToSite.Get_All_By_userid(userid); #endregion #region Fetch each object from Collection of UserToSiteMapping foreach (UserToSiteMapping obj in colUserToSite) { #region Declare Local Variables and Collection of Incident_mst Type string Status; BLLCollection <Incident_mst> col = new BLLCollection <Incident_mst>(); int siteid; #endregion #region Get the Siteid and Filter Parameter siteid = obj.Siteid; filterId = 0; #endregion #region If Role of User is Technician #region If Filter Variable is All if (filterId == 0) { col = objIncident.Get_All_By_Siteid_Requesterid(siteid, objUser.Userid, fromdate, todate, varSortParameter); } #endregion #endregion #region Fetch Each object of type Incident_mst from Collection Incident_mst foreach (Incident_mst objInc in col) { #region Create Table row and assign value to it DataRow row; row = dtTable.NewRow(); row["incidentid"] = Convert.ToString(objInc.Incidentid); row["title"] = objInc.Title; row["requesterid"] = Convert.ToString(objInc.Requesterid); row["createdbyid"] = Convert.ToString(objInc.Createdbyid); row["siteid"] = Convert.ToString(objInc.Siteid); row["createdatetime"] = Convert.ToString(objInc.Createdatetime); objIncidentStates = objIncidentStates.Get_By_id(objInc.Incidentid); row["statusid"] = objIncidentStates.Statusid; row["technicianid"] = objIncidentStates.Technicianid; row["priorityid"] = objIncidentStates.Priorityid; dtTable.Rows.Add(row); #endregion } #endregion } #endregion #region Bind Grid from datasource dtTable DataView dvData = new DataView(dtTable); string sortFormat = "{0} {1}"; String sortDirection = "DESC"; if (varSortParameter == "createdatetime") { varSortParameter = "incidentid"; } dvData.Sort = String.Format(sortFormat, varSortParameter, sortDirection); grdvwRequest.DataSource = dvData; grdvwRequest.DataBind(); #endregion } #endregion }
protected void btnSave_Click(object sender, EventArgs e) { //Add Exception handilng try catch change by vishal 21-05-2012 try { //if (dt.Rows.Count > 0) //{ #region match keys with given keys // Create Local variable varOrganizationId to hold the Organization id from Organization_mst table int varOrganizationId; // Call function objOrganization.Get_Organization(), to get Object of Organization_mst Class objOrganization = objOrganization.Get_Organization(); // Assign Organization Id to variable varOrganizationId varOrganizationId = objOrganization.Orgid; // Call Function objUserLogin.Get_UserLogin_By_UserName ,to get Object of UserLogin_mst Class by passing parameter username and organization id objUserLogin = objUserLogin.Get_UserLogin_By_UserName(txtUserName.Text.ToString().Trim(), varOrganizationId); // Create local Variable varDomainName to get the value of domain name #region if user is AD user // Check whether User is from Active Directory User or Normal User, if objUserLogin.ADEnable == true ie user is Active Directory User if (objUserLogin.ADEnable == true) { //string varDomainName = objUserLogin.DomainName; // Create local Variable FlagStatus ,to hold the status of whether user have valid credentials against Active Directory // Call get DomainName from DB //added by lalit joshi string domainname = getdomain(); bool FlagStatus; // Call Function Authenticate to validate user credentials by passing parameters Username,Password and DomainName and store Status in variable FlagStatus FlagStatus = Authenticate(txtUserName.Text.ToString().Trim(), txtPassword.Text.ToString().Trim(), getdomain()); // If FlagStatus is True ,ie User Credentials are Valid and it's Cookie Ticket Will be Generated if (FlagStatus == true) { // Cookie Ticket is Generated and redirected to the default page FormsAuthentication.SetAuthCookie(txtUserName.Text.ToString().Trim(), false); #region find last row of Key table DataTable dt = Authenticate(); #endregion if (dt.Rows.Count > 0) { string decrytkey = Decrypt(dt.Rows[0]["Lkey"].ToString(), "pipl?123"); string keystatus = Encrypt("InActive", "pipl?123"); if (decrytkey == "bu$$1ne$$@2011" || decrytkey == "educ0mp#1nch1n@" || decrytkey == "c1v1l$0c1at@" || decrytkey == "11$1n2011" || decrytkey == "1nsp1r@t10n" || decrytkey == "c1rcum1nst@nce5" || decrytkey == "pipl$prog#" || decrytkey == "$1lverl1ghtc01n" || decrytkey == "A@B#Z123$*" || decrytkey == "Z001nP0lyt1c$" || decrytkey == "DUU3MY1$FG") { string decryptstatus = Decrypt(dt.Rows[0]["status"].ToString(), "pipl?123"); if (decryptstatus == "Active") { string dtvalid = dt.Rows[0]["validdate"].ToString(); string dtvaliddecry = Decrypt(dt.Rows[0]["validdate"].ToString(), "pipl?123"); DateTime dtvaliddecr = DateTime.Parse(dtvaliddecry); DateTime dttoday = DateTime.Now; #region if today date is exceeding expiry date if (DateTime.Compare(dttoday, dtvaliddecr) >= 0) { string sql = "update Loginkey set status='" + keystatus + "' where status='" + dt.Rows[0]["status"].ToString() + "'"; UpdateRecord(sql); Response.Redirect("~/Admin/Activate.aspx"); } #endregion if (Roles.IsUserInRole(txtUserName.Text.ToString().Trim(), "PManager")) { Response.Redirect("~/KEDB/ViewSolution.aspx"); } else if (Roles.IsUserInRole(txtUserName.Text.ToString().Trim(), "User")) { Response.Redirect("~/Login/Usercall.aspx"); } else { Response.Redirect("~/Login/Default.aspx"); } } else { Response.Redirect("~/admin/Activate.aspx"); } } } else { DateTime date = System.DateTime.Now; DateTime dateto30 = System.DateTime.Now.AddMonths(1); string keyen = Encrypt("bu$$1ne$$@2011", "pipl?123"); string keydate = Encrypt(date.ToString(), "pipl?123"); string keydateto30 = Encrypt(dateto30.ToString(), "pipl?123"); string keystatus = Encrypt("Active", "pipl?123"); string sql = "insert into LoginKey(Lkey,currentdate,validdate,status)values('" + keyen + "','" + keydate + "','" + keydateto30 + "','" + keystatus + "')"; Insert(sql); if (Roles.IsUserInRole(txtUserName.Text.ToString().Trim(), "PManager")) { Response.Redirect("~/KEDB/ViewSolution.aspx"); } else if (Roles.IsUserInRole(txtUserName.Text.ToString().Trim(), "User")) { Response.Redirect("~/Login/Usercall.aspx"); } else { Response.Redirect("~/Login/Default.aspx"); } } } else { // If User Credentials is not valid against active directory,display message Either Username or Password is not Valid lblErrorMsg.Text = Resources.MessageResource.errUserNotVaild.ToString(); } } #endregion else { int userid = objUserLogin.Get_By_UserName(txtUserName.Text.Trim(), varOrganizationId); // Check User Credentials Against Database,We Use Membership Function Membership.ValidateUser to check User Credentials against aspnet database // If it's Returns True,ie user has valid Credentials and it's Cookir ticket wiil be generated if (Membership.ValidateUser(txtUserName.Text.ToString().Trim(), txtPassword.Text.ToString().Trim()) || AuthenticateFromDB(userid, txtPassword.Text.Trim())) { // Cookie Ticket is Generated and redirected to the default page FormsAuthentication.SetAuthCookie(txtUserName.Text.ToString().Trim(), false); #region find last row of Key table DataTable dt = Authenticate(); #endregion if (dt.Rows.Count > 0) { string decrytkey = Decrypt(dt.Rows[0]["Lkey"].ToString(), "pipl?123"); string keystatus = Encrypt("InActive", "pipl?123"); if (decrytkey == "bu$$1ne$$@2011" || decrytkey == "educ0mp#1nch1n@" || decrytkey == "c1v1l$0c1at@" || decrytkey == "11$1n2011" || decrytkey == "1nsp1r@t10n" || decrytkey == "c1rcum1nst@nce5" || decrytkey == "pipl$prog#" || decrytkey == "$1lverl1ghtc01n" || decrytkey == "A@B#Z123$*" || decrytkey == "Z001nP0lyt1c$" || decrytkey == "DUU3MY1$FG" || decrytkey == "M@UU37Y1$FG") { string decryptstatus = Decrypt(dt.Rows[0]["status"].ToString(), "pipl?123"); if (decryptstatus == "Active") { string dtvalid = dt.Rows[0]["validdate"].ToString(); string dtvaliddecry = Decrypt(dt.Rows[0]["validdate"].ToString(), "pipl?123"); DateTime dtvaliddecr = DateTime.Parse(dtvaliddecry); DateTime dttoday = DateTime.Now; #region if today date is exceeding expiry date if (DateTime.Compare(dttoday, dtvaliddecr) >= 0) { string sql = "update Loginkey set status='" + keystatus + "' where status='" + dt.Rows[0]["status"].ToString() + "'"; UpdateRecord(sql); Response.Redirect("~/Admin/Activate.aspx"); } #endregion if (Roles.IsUserInRole(txtUserName.Text.ToString().Trim(), "PManager")) { Response.Redirect("~/KEDB/ViewSolution.aspx"); } else if (Roles.IsUserInRole(txtUserName.Text.ToString().Trim(), "User")) { Response.Redirect("~/Login/Usercall.aspx"); } else { Response.Redirect("~/Login/Default.aspx"); } } else { Response.Redirect("~/admin/Activate.aspx"); } } } else { DateTime date = System.DateTime.Now; DateTime dateto30 = System.DateTime.Now.AddMonths(1); string keyen = Encrypt("bu$$1ne$$@2011", "pipl?123"); string keydate = Encrypt(date.ToString(), "pipl?123"); string keydateto30 = Encrypt(dateto30.ToString(), "pipl?123"); string keystatus = Encrypt("Active", "pipl?123"); string sql = "insert into LoginKey(Lkey,currentdate,validdate,status)values('" + keyen + "','" + keydate + "','" + keydateto30 + "','" + keystatus + "')"; Insert(sql); if (Roles.IsUserInRole(txtUserName.Text.ToString().Trim(), "PManager")) { Response.Redirect("~/KEDB/ViewSolution.aspx"); } else if (Roles.IsUserInRole(txtUserName.Text.ToString().Trim(), "User")) { Response.Redirect("~/Login/Usercall.aspx"); } else { Response.Redirect("~/Login/Default.aspx"); } } } else { // If User Credentials is not valid against databse,display message Either Username or Password is not Valid lblErrorMsg.Text = Resources.MessageResource.errUserNotVaild.ToString(); } #endregion } } catch (Exception ex) { string myScript; myScript = "<script language=javascript>alert('Exception - '" + ex + "');</script>"; Page.RegisterClientScriptBlock("MyScript", myScript); return; } }
protected void btnAdd_Click(object sender, EventArgs e) { /////Add Exception handilng try catch change by vishal 21-05-2012 try { #region Declaration of Local Variables int siteid, priorityid; int SLAid = 0; int createdbyid = 0; int requesterid = 0; int FlagInsert; int requesttypeid; string userName; bool FlagUserStatus; FlagUserStatus = true; FlagInsert = 0; #endregion #region Fetch Current User MembershipUser User = Membership.GetUser(); userName = User.UserName.ToString(); #endregion #region Get Current Site and Priority id siteid = Convert.ToInt32(drpSite.SelectedValue); priorityid = Convert.ToInt32(drpPriority.SelectedValue); #endregion #region Get SLAid on the basis of siteid and Priority id if (siteid != 0 && priorityid != 0) { SLAid = objIncident.Get_By_SLAid(siteid, priorityid); requesttypeid = Convert.ToInt32(Resources.MessageResource.strRequestTypeId.ToString()); if (requesttypeid == Convert.ToInt32(drpRequestType.SelectedValue)) { SLAid = 0; } } #endregion if (userName != "") { #region Find Userid of User who Created this Request objOrganization = objOrganization.Get_Organization(); objUser = objUser.Get_UserLogin_By_UserName(userName, objOrganization.Orgid); if (objUser.Userid != 0) { createdbyid = objUser.Userid; } #endregion #region Find Userid of User who is Requesting to log a call #region If User Already Exist if (Session["UserCreate"].ToString() == "Exist") { objUser = objUser.Get_UserLogin_By_UserName_Ex(txtUsername.Text.ToString().Trim(), objOrganization.Orgid); if (objUser.Userid != 0) { requesterid = objUser.Userid; } } #endregion #region If New User is to be Created else if (Session["UserCreate"].ToString() == "create") { string varEmail = ""; string varRoleName = Resources.MessageResource.BasicUserRole.ToString(); if (txtEmail.Text == "") { varEmail = Resources.MessageResource.errMemshipCreateUserEmail.ToString(); } else { varEmail = txtEmail.Text; } int roleid = objRole.Get_By_RoleName(varRoleName); int status; objOrganization = objOrganization.Get_Organization(); UserLogin_mst objUserLogin = new UserLogin_mst(); objUserLogin.Username = txtUsername.Text.ToString(); objUserLogin.Password = Resources.MessageResource.strDefaultPassword.ToString(); objUserLogin.Roleid = roleid; objUserLogin.Orgid = objOrganization.Orgid; objUserLogin.ADEnable = false; objUserLogin.Enable = true; objUserLogin.Createdatetime = DateTime.Now.ToString(); status = objUserLogin.Insert(); if (status == 1) { // Create Mstatus field to send in Membership.CreateUser function as Out Variable for creating Membership User database MembershipCreateStatus Mstatus = default(MembershipCreateStatus); // Call Membership.CreateUser function to create Membership user Membership.CreateUser(txtUsername.Text.ToString().Trim(), Resources.MessageResource.strDefaultPassword.ToString(), varEmail, "Project Name", "Helpdesk", true, out Mstatus); // Call Roles.AddUserToRole Function to Add User To Role Roles.AddUserToRole(txtUsername.Text.ToString().Trim(), varRoleName); // Declare Local Variable Userid to fetch userid of newly created user // Create Object objUserLogin of UserLogin_mst()Class objUserLogin = new UserLogin_mst(); // Fetch userid of Newly created user and assign to local variable userid by calling function objUserLogin.Get_By_UserName requesterid = objUserLogin.Get_By_UserName(txtUsername.Text.ToString().Trim(), objOrganization.Orgid); // If userid not equal to 0 then we get userid of Newly created user otherwise error Occured ContactInfo_mst objContactInfo = new ContactInfo_mst(); objContactInfo.Userid = requesterid; objContactInfo.Emailid = varEmail; objContactInfo.Firstname = txtUsername.Text.ToString(); objContactInfo.Lastname = txtUsername.Text.ToString(); objContactInfo.Insert(); /// added by vishal 18-05-2012 Session["UserCreate"] = ""; } } #endregion #region If User is Not to be Created else if (Session["UserCreate"].ToString() == "notcreate") { FlagUserStatus = false; } #endregion #endregion } objIncident.Title = txtTitle.Text.Trim(); //objIncident.Title = drpTitle.SelectedItem.Text; // objIncident.Title = txtTitle.Text.Trim() + "-" + Txtextension.Text.Trim(); //objIncident.Title = txtTitle.Text.Trim(); if (Txtextension.Text != "") { string extension = Txtextension.Text; Int64 vOut = Convert.ToInt64(extension); //int vOut = Convert.ToInt32(extension); objIncident.Extension = vOut; } //start changed by prachi-19thmarch if (drpAMCcall.SelectedItem.Text == "NO") { objIncident.AMCCall = false; } else if (drpAMCcall.SelectedItem.Text == "YES") { objIncident.AMCCall = true; } //end objIncident.Slaid = SLAid; objIncident.Createdbyid = createdbyid; objIncident.Requesterid = requesterid; objIncident.Siteid = siteid; objIncident.Description = txtDescription.Text.ToString().Trim(); objIncident.Deptid = Convert.ToInt32(drpDepartment.SelectedValue); objIncident.Createdatetime = DateTime.Now.ToString(); objIncident.Modeid = Convert.ToInt32(drpMode.SelectedValue); //objIncident.ExternalTicketNo = txtExternalTicket.Text.ToString().Trim(); if (FlagUserStatus == true) { FlagInsert = objIncident.Insert(); #region Save Assetid and incident id in incidenttoassetmaaping // Get Asset and Incident Id for incidenttoassetmaaping objOrganization = objOrganization.Get_Organization(); objUser = objUser.Get_UserLogin_By_UserName_Ex(txtUsername.Text.ToString().Trim(), objOrganization.Orgid); int userid = Convert.ToInt32(objUser.Userid); int tempuser1 = Convert.ToInt32(Session["tempuser1"]); if (tempuser1 == 1) { assetid = Convert.ToInt32(Session["assetid"]); } else { assetid = Convert.ToInt32(objusertoasset.Get_AssetId_By_UserId(userid)); } int incid = Convert.ToInt32(objIncident.Get_TopIncidentId()); if (txtassignasset.Text != "") { //assetid = Convert.ToInt32(txtassignasset.Text); if (assetid != 0) { objincidenttoasset.Insert(incid, assetid); objusertoasset.Insert(userid, assetid, objUser.City, objUser.Company); Session.Abandon(); } } #endregion } if (FlagInsert == 1) { int FlagIncdStatesInsert; int incidentid; incidentid = objIncident.Get_Current_Incidentid(); objIncidentStates.Incidentid = incidentid; objIncidentStates.Priorityid = Convert.ToInt32(drpPriority.SelectedValue); objIncidentStates.Categoryid = Convert.ToInt32(drpCategory.SelectedValue); objIncidentStates.Statusid = Convert.ToInt32(drpStatus.SelectedValue); objIncidentStates.Subcategoryid = Convert.ToInt32(drpSubcategory.SelectedValue); objIncidentStates.Technicianid = Convert.ToInt32(drpTechnician.SelectedValue); if (Convert.ToInt32(drpTechnician.SelectedValue) != 0) { objIncidentStates.AssignedTime = DateTime.Now.ToString(); } objIncidentStates.Requesttypeid = Convert.ToInt32(drpRequestType.SelectedValue); FlagIncdStatesInsert = objIncidentStates.Insert(); if (FlagIncdStatesInsert == 1) { objIncidentHistory.Incidentid = incidentid; objIncidentHistory.Operation = "create"; objIncidentHistory.Operationownerid = createdbyid; objIncidentHistory.Insert(); objSentmailtoUser.SentmailUser(requesterid, incidentid, "open"); // change code///////////////////////////////////////////////////////////////// if (FileUpload1.HasFile) { string filepath = Server.MapPath("~/FileAttach/"); string[] filenameupd = FileUpload1.FileName.Split(new char[] { '.' }); string filenew = Convert.ToString(incidentid) + "." + filenameupd[1]; FileUpload1.PostedFile.SaveAs(filepath + filenew); } /////////////////////////////////////////////////////////////////////////////// if (Convert.ToInt32(drpTechnician.SelectedValue) != 0) { objSentmailtoUser.SentmailTechnician(Convert.ToInt32(drpTechnician.SelectedValue), incidentid); } Response.Redirect("~/Incident/IncidentRequestUpdate.aspx?incidentid=" + incidentid + ""); } } } catch (Exception ex) { string myScript; myScript = "<script language=javascript>alert('Exception - '" + ex + "');</script>"; Page.RegisterClientScriptBlock("MyScript", myScript); return; } }
protected void btnAdd_Click(object sender, EventArgs e) { #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 btnSubmit_Click(object sender, EventArgs e) { string userName; int userid = 0; int incidentid = Convert.ToInt16(Session["incidentid"].ToString()); #region Fetch Current User // Fetch Current User and assign to local variable userName MembershipUser User = Membership.GetUser(); userName = User.UserName.ToString(); #endregion #region On the basis of Username ,get Userid by calling Function Get_UserLogin_By_UserName(),via passing parameter Username and organizationid if (userName != "") { objOrganization = objOrganization.Get_Organization(); objUser = objUser.Get_UserLogin_By_UserName(userName, objOrganization.Orgid); if (objUser.Userid != 0) { userid = objUser.Userid; } } #endregion //objIncidentHistory.Incidentid = incidentid; //objIncidentHistory.Operationownerid = userid; //objIncidentHistory.Operation = "update"; //objIncidentHistory.Insert(); //#region Get the Current historyid by calling function Get_Current_IncidentHistoryid() //int historyid = objIncidentHistory.Get_Current_IncidentHistoryid(); //#endregion //#region Insert into IncidentHistoryDiff table ,By Comparing Current value and Updated Values //#region Declare local variable //string columnName; //string prev_value; //string curnt_value; //#endregion //columnName = "Resolution"; //prev_value = ""; //curnt_value = Editor.Text ; //objIncidentHistoryDiff.Historyid = historyid; //objIncidentHistoryDiff.Columnname = columnName; //objIncidentHistoryDiff.Current_value = curnt_value; //objIncidentHistoryDiff.Prev_value = prev_value; //objIncidentHistoryDiff.Insert(); //#endregion Session["ResolutionAdded"] = "true"; objIncidentResolution.Incidentid = incidentid; objIncidentResolution.Lastupdatetime = DateTime.Now.ToString(); objIncidentResolution.Resolution = Editor.Text; objIncidentResolution.Userid = userid; Editor.Text = ""; objIncidentResolution.Insert(); //ShowResolution(); string myScript; myScript = "<script language=javascript>javascript:window.close();</script>"; Page.RegisterClientScriptBlock("MyScript", myScript); }
//Added by Lalit public void BindDropCustomer() { BLLCollection <Customer_mst> colCtS = new BLLCollection <Customer_mst>(); string userName = ""; MembershipUser User = Membership.GetUser(); if (User != null) { userName = User.UserName.ToString(); } if (userName != "") { int userid; int Flagcount = 0; objOrganization = objOrganization.Get_Organization(); objUser = objUser.Get_UserLogin_By_UserName(userName, objOrganization.Orgid); if (objUser.Userid != 0) { userid = objUser.Userid; colUserToSite = ObjUserToSite.Get_All_By_userid(userid); foreach (UserToSiteMapping obj in colUserToSite) { int siteid; Site_mst objSite1 = new Site_mst(); siteid = obj.Siteid; objSite1 = objSite1.Get_By_id(siteid); if (objSite1.Siteid != 0) { colCustToSite = objCustToSite.Get_All_By_siteid(objSite1.Siteid); foreach (CustomerToSiteMapping objcts in colCustToSite) { Customer_mst objC = new Customer_mst(); int FlagStatus = 0; objC = objC.Get_By_id(objcts.Custid); if (Flagcount == 0) { colCtS.Add(objC); } else { foreach (Customer_mst objCus in colCtS) { if (objC.Custid == objCus.Custid) { FlagStatus = 1; } } if (FlagStatus == 0) { colCtS.Add(objC); } } Flagcount = Flagcount + 1; } } } } //} //DdlStock.DataBind(); // DdlOwner.DataTextField = "Customer_Name"; // DdlOwner.DataValueField = "CustId"; // DdlOwner.DataSource = colCtS; // DdlOwner.DataBind(); //if (colCtS.Count == 0) //{ ListItem item = new ListItem(); item.Text = "Other"; //item.Value = "1"; // DdlOwner.Items.Add(item); //} } }