protected void IncidentToAsset(int userid) { objOrganization = objOrganization.Get_Organization(); objUser = objUser.Get_UserLogin_By_UserName(txtUsername.Text.ToString().Trim(), objOrganization.Orgid); userid = Convert.ToInt16(objUser.Userid); assetid = Convert.ToInt16(objusertoasset.Get_AssetId_By_UserId(userid)); objassetmst = objassetmst.Get_By_id(assetid); compname = objassetmst.Computername; }
//protected void btngetuser_Click(object sender, EventArgs e) //{ // lblErrorMsg.Text = ""; // string Username = txtusername.Text.ToString().Trim(); // objUser = objUser.Get_UserLogin_By_UserName_Like(Username); // if (objUser.Userid != 0) // { // txtusername.Text = objUser.Username.ToString().Trim(); // userid = objUser.Userid; // } // else // { // txtusername.Text = ""; // } //} //protected void btnshow_Click(object sender, EventArgs e) //{ // lblErrorMsg.Text = ""; // string Username = txtusername.Text.ToString().Trim(); // objUser = objUser.Get_UserLogin_By_UserName_Like(Username); // userid = objUser.Userid; // int assid=Convert.ToInt32(objusertoasset.Get_AssetId_By_UserId(userid)); // int usercount = objusertoasset.Get_UserId_From_UserToAssetMap(userid); // col = ObjAsset.Get_Assetdetails_By_Assetid(assid); // grdvwViewAsset.DataSource = col; // grdvwViewAsset.DataBind(); // foreach (GridViewRow gv in grdvwViewAsset.Rows) // { // RadioButton selectonebutton = (RadioButton)gv.FindControl("selectone"); // selectonebutton.Checked = true; // } //} protected void btnMapped_Click(object sender, EventArgs e) { /////Add Exception handilng try catch change by vishal 21-05-2012 try { lblErrorMsg.Text = ""; int flag = 0; foreach (GridViewRow gv in grdvwViewAsset.Rows) { string gvIDs; RadioButton selectonebutton = (RadioButton)gv.FindControl("selectone"); if (selectonebutton.Checked) { flag = 1; int assetid; gvIDs = ((Label)gv.FindControl("lblAssetID")).Text.ToString(); assetid = Convert.ToInt32(gvIDs); string Username = txtusername.Text.ToString().Trim(); objUser = objUser.Get_UserLogin_By_UserName_Like(Username); //objcontactinfo = objcontactinfo.Get_By_id(objUser.Userid); //added by lalit 24 feb 2012 userid = objUser.Userid; if (txtusername.Text == "") { lblErrorMsg.Text = "Enter the user name for mapped a particular Asset"; break; } else if (userid == 0) { lblErrorMsg.Text = "User Name doesn't exist"; break; } else { assetcount = objusertoasset.Get_AssetId_From_UserToAssetMap(assetid); usercount = objusertoasset.Get_UserId_From_UserToAssetMap(userid); assetlocation = objUser.City; //added by lalit 24 feb 2012 companyname = objUser.Company; if (assetcount == 0) { if (usercount == 0) { objusertoasset.Insert(userid, assetid, assetlocation, companyname); //added a new field siteid on 24 feb. lblErrorMsg.Text = "Asset Mapped Successfully to the Current User"; break; } else { int oldassetid = Convert.ToInt32(objusertoasset.Get_AssetId_By_UserId(userid)); objusertoasset.Update_Assetid(oldassetid, assetid, assetlocation, companyname); lblErrorMsg.Text = "Asset Mapped Successfully to the Current User"; break; } } else { lblErrorMsg.Text = "Asset already Mapped"; break; } } } } if (flag == 0) { lblErrorMsg.Text = "Select Asset for mapping"; } } 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 btngetuser_Click(object sender, EventArgs e) //{ // lblErrorMsg.Text = ""; // string Username = txtusername.Text.ToString().Trim(); // objUser = objUser.Get_UserLogin_By_UserName_Like(Username); // if (objUser.Userid != 0) // { // txtusername.Text = objUser.Username.ToString().Trim(); // userid = objUser.Userid; // } // else // { // txtusername.Text = ""; // } //} //protected void btnshow_Click(object sender, EventArgs e) //{ // lblErrorMsg.Text = ""; // string Username = txtusername.Text.ToString().Trim(); // objUser = objUser.Get_UserLogin_By_UserName_Like(Username); // userid = objUser.Userid; // int assid=Convert.ToInt16(objusertoasset.Get_AssetId_By_UserId(userid)); // int usercount = objusertoasset.Get_UserId_From_UserToAssetMap(userid); // col = ObjAsset.Get_Assetdetails_By_Assetid(assid); // grdvwViewAsset.DataSource = col; // grdvwViewAsset.DataBind(); // foreach (GridViewRow gv in grdvwViewAsset.Rows) // { // RadioButton selectonebutton = (RadioButton)gv.FindControl("selectone"); // selectonebutton.Checked = true; // } //} protected void btnMapped_Click(object sender, EventArgs e) { lblErrorMsg.Text = ""; int flag = 0; foreach (GridViewRow gv in grdvwViewAsset.Rows) { string gvIDs; RadioButton selectonebutton = (RadioButton)gv.FindControl("selectone"); if (selectonebutton.Checked) { flag = 1; int assetid; gvIDs = ((Label)gv.FindControl("lblAssetID")).Text.ToString(); assetid = Convert.ToInt16(gvIDs); string Username = txtusername.Text.ToString().Trim(); objUser = objUser.Get_UserLogin_By_UserName_Like(Username); userid = objUser.Userid; if (txtusername.Text == "") { lblErrorMsg.Text = "Enter the user name for mapped a particular Asset"; break; } else if (userid == 0) { lblErrorMsg.Text = "User Name doesn't exist"; break; } else { assetcount = objusertoasset.Get_AssetId_From_UserToAssetMap(assetid); usercount = objusertoasset.Get_UserId_From_UserToAssetMap(userid); if (assetcount == 0) { if (usercount == 0) { objusertoasset.Insert(userid, assetid); lblErrorMsg.Text = "Asset Mapped Successfully to the Current User"; break; } else { int oldassetid = Convert.ToInt16(objusertoasset.Get_AssetId_By_UserId(userid)); objusertoasset.Update_Assetid(oldassetid, assetid); lblErrorMsg.Text = "Asset Mapped Successfully to the Current User"; break; } } else { lblErrorMsg.Text = "Asset already Mapped"; break; } } } } if (flag == 0) { lblErrorMsg.Text = "Select Asset for mapping"; } }
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; } }