protected void btnAttach_Click(object sender, EventArgs e) { int incidentid = Convert.ToInt16(Session["incidentid"].ToString()); foreach (GridViewRow gv in grdvwProblem.Rows) { string gvIDs; // 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) { int probId; gvIDs = ((Label)gv.FindControl("ProblemId")).Text.ToString(); probId = Convert.ToInt16(gvIDs); // Check if gvIDs is not null if (gvIDs != "") { objIncidentToProblem = objIncidentToProblem.Get_By_id(incidentid, probId); if (objIncidentToProblem.Incidentid==0) { objIncidentToProblem.Incidentid = incidentid; objIncidentToProblem.Problemid = probId; objIncidentToProblem.Insert(); } } } } lblErrorMsg.Text = "Incident Request is Attached to Current Problems"; }
protected void btnAttach_Click(object sender, EventArgs e) { int incidentid = Convert.ToInt16(Session["incidentid"].ToString()); foreach (GridViewRow gv in grdvwProblem.Rows) { string gvIDs; // 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) { int probId; gvIDs = ((Label)gv.FindControl("ProblemId")).Text.ToString(); probId = Convert.ToInt16(gvIDs); // Check if gvIDs is not null if (gvIDs != "") { objIncidentToProblem = objIncidentToProblem.Get_By_id(incidentid, probId); if (objIncidentToProblem.Incidentid == 0) { objIncidentToProblem.Incidentid = incidentid; objIncidentToProblem.Problemid = probId; objIncidentToProblem.Insert(); } } } } lblErrorMsg.Text = "Incident Request is Attached to Current Problems"; }
protected void btnAttach_Click(object sender, EventArgs e) { //Add Exception handilng try catch change by vishal 21-05-2012 try { int incidentid = Convert.ToInt32(Session["incidentid"].ToString()); foreach (GridViewRow gv in grdvwProblem.Rows) { string gvIDs; // 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) { int probId; gvIDs = ((Label)gv.FindControl("ProblemId")).Text.ToString(); probId = Convert.ToInt32(gvIDs); // Check if gvIDs is not null if (gvIDs != "") { objIncidentToProblem = objIncidentToProblem.Get_By_id(incidentid, probId); if (objIncidentToProblem.Incidentid == 0) { objIncidentToProblem.Incidentid = incidentid; objIncidentToProblem.Problemid = probId; objIncidentToProblem.Insert(); } } } } lblErrorMsg.Text = "Incident Request is Attached to Current Problems"; } catch (Exception ex) { string myScript; myScript = "<script language=javascript>alert('Exception - '" + ex + "');</script>"; Page.RegisterClientScriptBlock("MyScript", myScript); return; } }
protected void btnAttach_Click(object sender, EventArgs e) {//Add Exception handilng try catch change by vishal 21-05-2012 try { int incidentid = Convert.ToInt32(Session["incidentid"].ToString()); foreach (GridViewRow gv in grdvwProblem.Rows) { string gvIDs; // 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) { int probId; gvIDs = ((Label)gv.FindControl("ProblemId")).Text.ToString(); probId = Convert.ToInt32(gvIDs); // Check if gvIDs is not null if (gvIDs != "") { objIncidentToProblem = objIncidentToProblem.Get_By_id(incidentid, probId); if (objIncidentToProblem.Incidentid == 0) { objIncidentToProblem.Incidentid = incidentid; objIncidentToProblem.Problemid = probId; objIncidentToProblem.Insert(); } } } } lblErrorMsg.Text = "Incident Request is Attached to Current Problems"; } 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) { bool FlagUserStatus = true; #region Find Userid of User who is Requesting to log a call #region If User Already Exist if (ViewState["UserCreate"].ToString() == "Exist") { objOrganization = objOrganization.Get_Organization(); ObjUserLogin = ObjUserLogin.Get_UserLogin_By_UserName(txtUsername.Text.ToString().Trim(), objOrganization.Orgid); if (ObjUserLogin.Userid != 0) { requesterid = ObjUserLogin.Userid; } } #endregion #region If New User is to be Created else if (ViewState["UserCreate"].ToString() == "create") { string varEmail = ""; string varRoleName = Resources.MessageResource.BasicUserRole.ToString(); if (txtEmail.Text == "") { varEmail = Resources.MessageResource.errMemshipCreateUserEmail.ToString(); } else { varEmail = txtEmail.Text; } int roleid = objRole.Get_By_RoleName(varRoleName); int status; objOrganization = objOrganization.Get_Organization(); objuser.Username = txtUsername.Text.ToString(); objuser.Password = Resources.MessageResource.strDefaultPassword.ToString(); objuser.Roleid = roleid; objuser.Orgid = objOrganization.Orgid; objuser.ADEnable = false; objuser.Enable = true; objuser.Createdatetime = DateTime.Now.ToString(); status = objuser.Insert(); if (status == 1) { // Create Mstatus field to send in Membership.CreateUser function as Out Variable for creating Membership User database MembershipCreateStatus Mstatus = default(MembershipCreateStatus); // Call Membership.CreateUser function to create Membership user Membership.CreateUser(txtUsername.Text.ToString().Trim(), Resources.MessageResource.strDefaultPassword.ToString(), varEmail, "Project Name", "Helpdesk", true, out Mstatus); // Call Roles.AddUserToRole Function to Add User To Role Roles.AddUserToRole(txtUsername.Text.ToString().Trim(), varRoleName); // Declare Local Variable Userid to fetch userid of newly created user // Create Object objUserLogin of UserLogin_mst()Class objuser = new UserLogin_mst(); // Fetch userid of Newly created user and assign to local variable userid by calling function objUserLogin.Get_By_UserName requesterid = objuser.Get_By_UserName(txtUsername.Text.ToString().Trim(), objOrganization.Orgid); // If userid not equal to 0 then we get userid of Newly created user otherwise error Occured ContactInfo_mst objContactInfo = new ContactInfo_mst(); objContactInfo.Userid = requesterid; objContactInfo.Emailid = varEmail; objContactInfo.Firstname = txtUsername.Text.ToString(); objContactInfo.Lastname = txtUsername.Text.ToString(); objContactInfo.Insert(); } } #endregion #region If User is Not to be Created else if (ViewState["UserCreate"].ToString() == "notcreate") { FlagUserStatus = false; } #endregion #endregion MembershipUser User = Membership.GetUser(); string userName; userName = User.UserName.ToString(); if (FlagUserStatus == true) { objOrganization = objOrganization.Get_Organization(); objuser = objuser.Get_UserLogin_By_UserName(userName, objOrganization.Orgid); ObjProblem.CreatedByid = objuser.Userid; ObjProblem.Requesterid = requesterid; ObjProblem.Categoryid = Convert.ToInt16(drpCategory.SelectedValue); ObjProblem.Subcategoryid = Convert.ToInt16(drpSubcategory.SelectedValue); ObjProblem.Priorityid = Convert.ToInt16(drpPriority.SelectedValue); ObjProblem.Statusid = Convert.ToInt16(drpStatus.SelectedValue); ObjProblem.Technicianid = Convert.ToInt16(drpTechnician.SelectedValue); ObjProblem.title = txtTitle.Text; ObjProblem.Description = txtDescription.Text; if (Convert.ToInt16(drpTechnician.SelectedValue) != 0) { ObjProblem.AssginedTime = DateTime.Now.ToString(); } ObjProblem.Insert(); int problemid = ObjProblem.Get_Current_Problemid(); ObjProblemHistory.Operationtime = DateTime.Now.ToString(); ObjProblemHistory.Problemid = problemid; ObjProblemHistory.Operation = "create"; ObjProblemHistory.Operationownerid = objuser.Userid; if (Session["IncidentToProblem"] != null) { int incidentid = Convert.ToInt16(Session["IncidentToProblem"].ToString()); Incident_To_Problem objIncToprob = new Incident_To_Problem(); objIncToprob.Incidentid = incidentid; objIncToprob.Problemid = problemid; objIncToprob.Insert(); } if (Convert.ToInt16(drpTechnician.SelectedValue) != 0) { objSentMailToUser.SentMailToTechnicianForProblemCall(problemid, Convert.ToInt16(drpTechnician.SelectedValue)); } ObjProblemHistory.Insert(); //ResetControls(); string myScript; myScript = "<script language=javascript>javascript:window.close();</script>"; Page.RegisterClientScriptBlock("MyScript", myScript); } }
protected void btnAdd_Click(object sender, EventArgs e) {//Add Exception handilng try catch change by vishal 21-05-2012 try { bool FlagUserStatus = true; #region Find Userid of User who is Requesting to log a call #region If User Already Exist if (ViewState["UserCreate"].ToString() == "Exist") { objOrganization = objOrganization.Get_Organization(); ObjUserLogin = ObjUserLogin.Get_UserLogin_By_UserName(txtUsername.Text.ToString().Trim(), objOrganization.Orgid); if (ObjUserLogin.Userid != 0) { requesterid = ObjUserLogin.Userid; } } #endregion #region If New User is to be Created else if (ViewState["UserCreate"].ToString() == "create") { string varEmail = ""; string varRoleName = Resources.MessageResource.BasicUserRole.ToString(); if (txtEmail.Text == "") { varEmail = Resources.MessageResource.errMemshipCreateUserEmail.ToString(); } else { varEmail = txtEmail.Text; } int roleid = objRole.Get_By_RoleName(varRoleName); int status; objOrganization = objOrganization.Get_Organization(); objuser.Username = txtUsername.Text.ToString(); objuser.Password = Resources.MessageResource.strDefaultPassword.ToString(); objuser.Roleid = roleid; objuser.Orgid = objOrganization.Orgid; objuser.ADEnable = false; objuser.Enable = true; objuser.Createdatetime = DateTime.Now.ToString(); status = objuser.Insert(); if (status == 1) { // Create Mstatus field to send in Membership.CreateUser function as Out Variable for creating Membership User database MembershipCreateStatus Mstatus = default(MembershipCreateStatus); // Call Membership.CreateUser function to create Membership user Membership.CreateUser(txtUsername.Text.ToString().Trim(), Resources.MessageResource.strDefaultPassword.ToString(), varEmail, "Project Name", "Helpdesk", true, out Mstatus); // Call Roles.AddUserToRole Function to Add User To Role Roles.AddUserToRole(txtUsername.Text.ToString().Trim(), varRoleName); // Declare Local Variable Userid to fetch userid of newly created user // Create Object objUserLogin of UserLogin_mst()Class objuser = new UserLogin_mst(); // Fetch userid of Newly created user and assign to local variable userid by calling function objUserLogin.Get_By_UserName requesterid = objuser.Get_By_UserName(txtUsername.Text.ToString().Trim(), objOrganization.Orgid); // If userid not equal to 0 then we get userid of Newly created user otherwise error Occured ContactInfo_mst objContactInfo = new ContactInfo_mst(); objContactInfo.Userid = requesterid; objContactInfo.Emailid = varEmail; objContactInfo.Firstname = txtUsername.Text.ToString(); objContactInfo.Lastname = txtUsername.Text.ToString(); objContactInfo.Insert(); } } #endregion #region If User is Not to be Created else if (ViewState["UserCreate"].ToString() == "notcreate") { FlagUserStatus = false; } #endregion #endregion MembershipUser User = Membership.GetUser(); string userName; userName = User.UserName.ToString(); if (FlagUserStatus == true) { objOrganization = objOrganization.Get_Organization(); objuser = objuser.Get_UserLogin_By_UserName(userName, objOrganization.Orgid); ObjProblem.CreatedByid = objuser.Userid; ObjProblem.Requesterid = requesterid; ObjProblem.Categoryid = Convert.ToInt32(drpCategory.SelectedValue); ObjProblem.Subcategoryid = Convert.ToInt32(drpSubcategory.SelectedValue); ObjProblem.Priorityid = Convert.ToInt32(drpPriority.SelectedValue); ObjProblem.Statusid = Convert.ToInt32(drpStatus.SelectedValue); ObjProblem.Technicianid = Convert.ToInt32(drpTechnician.SelectedValue); ObjProblem.title = txtTitle.Text; ObjProblem.Description = txtDescription.Text; if (Convert.ToInt32(drpTechnician.SelectedValue) != 0) { ObjProblem.AssginedTime = DateTime.Now.ToString(); } ObjProblem.Insert(); int problemid = ObjProblem.Get_Current_Problemid(); ObjProblemHistory.Operationtime = DateTime.Now.ToString(); ObjProblemHistory.Problemid = problemid; ObjProblemHistory.Operation = "create"; ObjProblemHistory.Operationownerid = objuser.Userid; if (Session["IncidentToProblem"] != null) { int incidentid = Convert.ToInt32(Session["IncidentToProblem"].ToString()); Incident_To_Problem objIncToprob = new Incident_To_Problem(); objIncToprob.Incidentid = incidentid; objIncToprob.Problemid = problemid; objIncToprob.Insert(); } if (Convert.ToInt32(drpTechnician.SelectedValue) != 0) { objSentMailToUser.SentMailToTechnicianForProblemCall(problemid, Convert.ToInt32(drpTechnician.SelectedValue)); } ObjProblemHistory.Insert(); //ResetControls(); string myScript; myScript = "<script language=javascript>javascript:window.close();</script>"; Page.RegisterClientScriptBlock("MyScript", myScript); } } catch (Exception ex) { string myScript; myScript = "<script language=javascript>alert('Exception - '" + ex + "');</script>"; Page.RegisterClientScriptBlock("MyScript", myScript); return; } }