// 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; } } } } }
public void SentMailToSDM(int siteid, int incidentid, int requesterid) { string strYourSinscerely = Resources.MessageResource.strYourSinscerely.ToString(); string strContactNumber = Resources.MessageResource.strContactNumber.ToString(); int FlagUser; string varRole = Resources.MessageResource.strSDMRole.ToString(); int roleid; roleid = objRole.Get_By_RoleName(varRole); colUser = objUser.Get_All_By_Role(roleid); foreach (UserLogin_mst objusr in colUser) { FlagUser = objUserToSiteMapping.Get_By_Id(objusr.Userid, siteid); if (FlagUser != 0) { objIncident = objIncident.Get_By_id(incidentid); objSite = objSite.Get_By_id(objIncident.Siteid); objIncidentStates = objIncidentStates.Get_By_id(incidentid); objPriority = objPriority.Get_By_id(objIncidentStates.Priorityid); UserLogin_mst obju = new UserLogin_mst(); UserLogin_mst objReq = new UserLogin_mst(); obju = obju.Get_By_id(objUserToSiteMapping.Userid); objC_info = objC_info.Get_By_id(objusr.Userid); objReq = objReq.Get_By_id(requesterid); ContactInfo_mst objReqContInfo = new ContactInfo_mst(); objReqContInfo = objReqContInfo.Get_By_id(objReq.Userid); obj.From = Resources.MessageResource.strAdminEmail.ToString(); obj.To = objC_info.Emailid; obj.Subject = "High Priority Call. Ticket Id: " + incidentid; obj.Body = "Dear Sir/Madam,<br/>High Priority Call has been logged, please find below the Complaint details .<br/><br/><b>Complaints Details : </b> <br/><br/><b>Ticket Id :</b>" + incidentid + "<br/><b>Title of Call :</b>" + objIncident.Title + " <br/><b>Site :</b>" + objSite.Sitename + "<br/><b>Logged Date & Time   :</b>" + objIncident.Createdatetime + "<br/><b>Description :</b>" + objIncident.Description + "<br/><b>Priority :</b> " + objPriority.Name + "<br/><b>UserName :</b>" + objReq.Username + "<br/><b>Mail Address :</b>" + objReqContInfo.Emailid + "<br/><br/> <b>This is an auto generated mail. Please do not reply.</b><br/><br/><b>Yours sincerely,</b><br/> <b>" + strYourSinscerely + "</b>"; obj.SmtpServer = Resources.MessageResource.strSMTPServer.ToString(); obj.SentMail(); } } }
protected void btnMapping_Click(object sender, EventArgs e) { int FlagInsert = 0; int FlagDelete = 0; int FlagStatus = 0; // string Username; string gvIDs; //'Navigate through each row in the GridView for checkbox items foreach (GridViewRow gv in grdvwSitetest.Rows) { // Declare local variable deleteChkBxItem of Checkbox type to get the Checkbox Instance of Grid Row CheckBox deleteChkBxItem = (CheckBox)gv.FindControl("chkbxcheck"); // If deleteChkBxItem is Checked then ,mapped Current site to this user if (deleteChkBxItem.Checked) { // Get the Site Id from variable of Label type declare in GridView of grdvwSite // gvIDs = ((Label)gv.FindControl("SiteID")).Text.ToString(); gvIDs = drpRegion.SelectedItem.Value; // Check if gvIDs is not null if (gvIDs != "") { // Declare local variable userid and siteid to get userid and SiteId int userid; int siteid; Label usrid = (Label)gv.FindControl("Lbluserid"); userid = Convert.ToInt32(usrid.Text.ToString()); siteid = Convert.ToInt32(gvIDs); // To Find Current Site to this User is Mapped by Calling Function objUserToSite.Get_By_Id() FlagStatus = objUserToSite.Get_By_Id(userid, siteid); // If FlagStatus is zero then site is not mapped to this user if (FlagStatus == 0) { objUserToSite.Siteid = siteid; objUserToSite.Userid = userid; // Mapped Current Site to this User by calling function objUserToSite.Insert() FlagInsert = objUserToSite.Insert(); } } } // If deleteChkBxItem is Un Checked then ,Un mapped Current site to this user else { // Get the Site Id from variable of Label type declare in GridView of grdvwSite gvIDs = drpRegion.SelectedItem.Value; // Check if gvIDs is not null if (gvIDs != "") { // Declare local variable userid and siteid to get userid and SiteId int userid; int siteid; Label usrid = (Label)gv.FindControl("Lbluserid"); userid = Convert.ToInt32(usrid.Text.ToString()); siteid = Convert.ToInt32(gvIDs); // To Find Current Site to this User is Mapped by Calling Function objUserToSite.Get_By_Id() FlagStatus = objUserToSite.Get_By_Id(userid, siteid); // If FlagStatus is not zero then site is mapped to this user if (FlagStatus != 0) { // Un Mapped Current Site to this User by calling function objUserToSite.Delete() FlagDelete = objUserToSite.Delete(userid, siteid); } } } } // Display message from MessageResource file located at App_GlobalResource Directory if (FlagInsert == 1 && FlagDelete == 1) { lblErrorMsg.Text = Resources.MessageResource.errSiteMpUmp.ToString(); } // Display message from MessageResource file located at App_GlobalResource Directory else if (FlagInsert == 1) { lblErrorMsg.Text = Resources.MessageResource.errSiteMapped.ToString(); } // Display message from MessageResource file located at App_GlobalResource Directory else if (FlagDelete == 1) { lblErrorMsg.Text = Resources.MessageResource.errSitesUnMapped.ToString(); } // Display message from MessageResource file located at App_GlobalResource Directory else if (FlagStatus == 1 && FlagDelete == 1) { lblErrorMsg.Text = Resources.MessageResource.errSitesUnMapped.ToString(); } // Display message from MessageResource file located at App_GlobalResource Directory else if (FlagStatus == 1) { lblErrorMsg.Text = Resources.MessageResource.errAlrdyMapped.ToString(); } // Display message from MessageResource file located at App_GlobalResource Directory //else //{ // lblErrorMsg.Text = Resources.MessageResource.errNoOperation.ToString(); //} //} //else //{ // // Display message from MessageResource file located at App_GlobalResource Directory // lblErrorMsg.Text = Resources.MessageResource.errOccured.ToString(); //} }
//protected void BindDropCustomer() //{ // BLLCollection<Customer_mst> colCtS = new BLLCollection<Customer_mst>(); // string userName = ""; // MembershipUser User = Membership.GetUser(); // if (User != null) // { // userName = User.UserName.ToString(); // } // if (userName != "") // { // int userid; // int Flagcount = 0; // objOrganization = objOrganization.Get_Organization(); // objUser = objUser.Get_UserLogin_By_UserName(userName, objOrganization.Orgid); // if (objUser.Userid != 0) // { // userid = objUser.Userid; // colUserToSite = ObjUserToSite.Get_All_By_userid(userid); // foreach (UserToSiteMapping obj in colUserToSite) // { // int siteid; // Site_mst objSite1 = new Site_mst(); // siteid = obj.Siteid; // objSite1 = objSite1.Get_By_id(siteid); // if (objSite1.Siteid != 0) // { // colCustToSite=objCustToSite.Get_All_By_siteid(objSite1.Siteid); // foreach (CustomerToSiteMapping objcts in colCustToSite) // { // Customer_mst objC = new Customer_mst(); // int FlagStatus = 0; // objC = objC.Get_By_id(objcts.Custid); // if (Flagcount == 0) // { // colCtS.Add(objC); // } // else // { // foreach (Customer_mst objCus in colCtS) // { // if (objC.Custid == objCus.Custid) // { // FlagStatus = 1; // } // } // if (FlagStatus==0) // { // colCtS.Add(objC); // } // } // Flagcount = Flagcount + 1; // } // } // } // } // } // drpCustomer.DataTextField = "Customer_Name"; // drpCustomer.DataValueField = "CustId"; // drpCustomer.DataSource = colCtS; // drpCustomer.DataBind(); // if (colCtS.Count == 0) // { // ListItem item = new ListItem(); // item.Text = "-------------Select-------------"; // item.Value = "0"; // drpCustomer.Items.Add(item); // } //} protected void btnAdd_Click(object sender, EventArgs e) { //Add Exception handilng try catch change by vishal 21-05-2012 try { Session["UserCreate"] = "Exist"; #region Declaration of Local Variables int siteid, priorityid; int SLAid = 0; int createdbyid = 0; int requesterid = 0; int FlagInsert; int requesttypeid; string userName; bool FlagUserStatus; FlagUserStatus = true; FlagInsert = 0; #endregion #region Fetch Current User MembershipUser User = Membership.GetUser(); userName = User.UserName.ToString(); #endregion #region Get Current Site and Priority id siteid = Convert.ToInt32(drpSite.SelectedValue); priorityid = Convert.ToInt32(drpPriority.SelectedValue); #endregion #region Get SLAid on the basis of siteid and Priority id if (siteid != 0 && priorityid != 0) { SLAid = objIncident.Get_By_SLAid(siteid, priorityid); requesttypeid = Convert.ToInt32(Resources.MessageResource.strRequestTypeId.ToString()); if (requesttypeid == Convert.ToInt32(drpRequestType.SelectedValue)) { SLAid = 0; } } #endregion if (userName != "") { #region Find Userid of User who Created this Request objOrganization = objOrganization.Get_Organization(); objUser = objUser.Get_UserLogin_By_UserName(userName, objOrganization.Orgid); if (objUser.Userid != 0) { createdbyid = objUser.Userid; } #endregion #region Find Userid of User who is Requesting to log a call #region If User Already Exist if (Session["UserCreate"].ToString() == "Exist") { objUser = objUser.Get_UserLogin_By_UserName(txtUsername.Text.ToString().Trim(), objOrganization.Orgid); if (objUser.Userid != 0) { requesterid = objUser.Userid; } } #endregion #endregion } //added by lalit objIncident.Reporteddatetime =DBNull.Value.ToString(); objIncident.AMCCall = false; //end objIncident.Title = txtTitle.Text.ToString().Trim() + "-" + TxtExtension.Text.Trim(); objIncident.Slaid = SLAid; objIncident.Createdbyid = createdbyid; objIncident.Requesterid = requesterid; objIncident.Siteid = siteid; objIncident.Description = txtDescription.Text.ToString().Trim(); objIncident.Deptid = 0; objIncident.Createdatetime = DateTime.Now.ToString(); objIncident.Modeid = Convert.ToInt32(drpMode.SelectedValue); UserToSiteMapping objUserToSite = new UserToSiteMapping(); if (FlagUserStatus == true) { FlagInsert = objIncident.Insert(); #region Save Assetid and incident id in incidenttoassetmaaping objOrganization = objOrganization.Get_Organization(); objUser = objUser.Get_UserLogin_By_UserName(txtUsername.Text.ToString().Trim(), objOrganization.Orgid); int userid = Convert.ToInt32(objUser.Userid); int tempuser1 = Convert.ToInt32(Session["tempuser1"]); if (tempuser1 == 1) { assetid = Convert.ToInt32(Session["assetid"]); } else { assetid = Convert.ToInt32(objusertoasset.Get_AssetId_By_UserId(userid)); } int incid = Convert.ToInt32(objIncident.Get_TopIncidentId()); if (txtassignasset.Text != "") { //assetid = Convert.ToInt32(txtassignasset.Text); if (assetid != 0) { objincidenttoasset.Insert(incid, assetid); objusertoasset.Insert(userid, assetid, objUser.City, objUser.Company); //added a new column siteid Session.Abandon(); } } #endregion } if (FlagInsert == 1) { int FlagIncdStatesInsert; int incidentid; incidentid = objIncident.Get_Current_Incidentid(); objIncidentStates.Incidentid = incidentid; objIncidentStates.Priorityid = Convert.ToInt32(drpPriority.SelectedValue); objIncidentStates.Categoryid = Convert.ToInt32(drpCategory.SelectedValue); objIncidentStates.Statusid = Convert.ToInt32(drpStatus.SelectedValue); objIncidentStates.Subcategoryid = Convert.ToInt32(drpSubcategory.SelectedValue); objIncidentStates.Technicianid = 0; objIncidentStates.Requesttypeid = Convert.ToInt32(drpRequestType.SelectedValue); FlagIncdStatesInsert = objIncidentStates.Insert(); if (FlagIncdStatesInsert == 1) { objIncidentHistory.Incidentid = incidentid; objIncidentHistory.Operation = "create"; objIncidentHistory.Operationownerid = createdbyid; objIncidentHistory.Insert(); objSentmailtoUser.SentmailUser(requesterid, incidentid, "open"); // change code///////////////////////////////////////////////////////////////// if (FileUpload1.HasFile) { string filepath = Server.MapPath("~/FileAttach/"); string[] filenameupd = FileUpload1.FileName.Split(new char[] { '.' }); string filenew = Convert.ToString(incidentid) + "." + filenameupd[1]; FileUpload1.PostedFile.SaveAs(filepath + filenew); } /////////////////////////////////////////////////////////////////////////////// ////////change code on 27 march/// #region Map Site to user //FlagInsert=0; int FlagDelete = 0; int FlagStatus = 0; //string Username; //string gvIDs; int organizationId; //string gv; // Get object of Organization to get organization id and assign to local variable organizationId objOrganization = objOrganization.Get_Organization(); organizationId = objOrganization.Orgid; // Get username from textbox and assign to local variable Username //Username = txtUserName.Text.ToString().Trim(); // Find User Exist ,by calling function Get_UserLogin_By_UserName() //objUser = objUser.Get_UserLogin_By_UserName(Username, organizationId); // If Userid is not zero ,then user exist in database if (objUser.Userid != 0) { //'Navigate through each row in the GridView for checkbox items //foreach (GridViewRow gv in grdvwSite.Rows) //{ // Declare local variable deleteChkBxItem of Checkbox type to get the Checkbox Instance of Grid Row // CheckBox deleteChkBxItem = (CheckBox)gv.FindControl("deleteRec"); // If deleteChkBxItem is Checked then ,mapped Current site to this user //if (deleteChkBxItem.Checked) //{ // Get the Site Id from variable of Label type declare in GridView of grdvwSite //gvIDs = ((Label)gv.FindControl("SiteID")).Text.ToString(); // Check if gvIDs is not null // if (gvIDs != "") //{ // Declare local variable userid and siteid to get userid and SiteId int userid; userid = Convert.ToInt32(objUser.Userid); //siteid = Convert.ToInt32(gvIDs); // To Find Current Site to this User is Mapped by Calling Function objUserToSite.Get_By_Id() FlagStatus = objUserToSite.Get_By_Id(userid, siteid); // If FlagStatus is zero then site is not mapped to this user if (FlagStatus == 0) { objUserToSite.Siteid = siteid; objUserToSite.Userid = userid; // Mapped Current Site to this User by calling function objUserToSite.Insert() FlagInsert = objUserToSite.Insert(); } //} } // If deleteChkBxItem is Un Checked then ,Un mapped Current site to this user else { // Get the Site Id from variable of Label type declare in GridView of grdvwSite // gvIDs = ((Label)gv.FindControl("SiteID")).Text.ToString(); // Check if gvIDs is not null //if (gvIDs != "") // { // Declare local variable userid and siteid to get userid and SiteId int userid; userid = Convert.ToInt32(objUser.Userid); //siteid = Convert.ToInt32(gvIDs); // To Find Current Site to this User is Mapped by Calling Function objUserToSite.Get_By_Id() FlagStatus = objUserToSite.Get_By_Id(userid, siteid); // If FlagStatus is not zero then site is mapped to this user if (FlagStatus != 0) { // Un Mapped Current Site to this User by calling function objUserToSite.Delete() FlagDelete = objUserToSite.Delete(userid, siteid); } //} } //} #endregion /////////////end///////////////// Response.Redirect("../Login/AllUserCall.aspx"); } } } catch (Exception ex) { string myScript; myScript = "<script language=javascript>alert('Exception - '" + ex + "');</script>"; Page.RegisterClientScriptBlock("MyScript", myScript); return; } }
//protected void BindDropCustomer() //{ // BLLCollection<Customer_mst> colCtS = new BLLCollection<Customer_mst>(); // string userName = ""; // MembershipUser User = Membership.GetUser(); // if (User != null) // { // userName = User.UserName.ToString(); // } // if (userName != "") // { // int userid; // int Flagcount = 0; // objOrganization = objOrganization.Get_Organization(); // objUser = objUser.Get_UserLogin_By_UserName(userName, objOrganization.Orgid); // if (objUser.Userid != 0) // { // userid = objUser.Userid; // colUserToSite = ObjUserToSite.Get_All_By_userid(userid); // foreach (UserToSiteMapping obj in colUserToSite) // { // int siteid; // Site_mst objSite1 = new Site_mst(); // siteid = obj.Siteid; // objSite1 = objSite1.Get_By_id(siteid); // if (objSite1.Siteid != 0) // { // colCustToSite=objCustToSite.Get_All_By_siteid(objSite1.Siteid); // foreach (CustomerToSiteMapping objcts in colCustToSite) // { // Customer_mst objC = new Customer_mst(); // int FlagStatus = 0; // objC = objC.Get_By_id(objcts.Custid); // if (Flagcount == 0) // { // colCtS.Add(objC); // } // else // { // foreach (Customer_mst objCus in colCtS) // { // if (objC.Custid == objCus.Custid) // { // FlagStatus = 1; // } // } // if (FlagStatus==0) // { // colCtS.Add(objC); // } // } // Flagcount = Flagcount + 1; // } // } // } // } // } // drpCustomer.DataTextField = "Customer_Name"; // drpCustomer.DataValueField = "CustId"; // drpCustomer.DataSource = colCtS; // drpCustomer.DataBind(); // if (colCtS.Count == 0) // { // ListItem item = new ListItem(); // item.Text = "-------------Select-------------"; // item.Value = "0"; // drpCustomer.Items.Add(item); // } //} protected void btnAdd_Click(object sender, EventArgs e) {//Add Exception handilng try catch change by vishal 21-05-2012 try { Session["UserCreate"] = "Exist"; #region Declaration of Local Variables int siteid, priorityid; int SLAid = 0; int createdbyid = 0; int requesterid = 0; int FlagInsert; int requesttypeid; string userName; bool FlagUserStatus; FlagUserStatus = true; FlagInsert = 0; #endregion #region Fetch Current User MembershipUser User = Membership.GetUser(); userName = User.UserName.ToString(); #endregion #region Get Current Site and Priority id siteid = Convert.ToInt32(drpSite.SelectedValue); priorityid = Convert.ToInt32(drpPriority.SelectedValue); #endregion #region Get SLAid on the basis of siteid and Priority id if (siteid != 0 && priorityid != 0) { SLAid = objIncident.Get_By_SLAid(siteid, priorityid); requesttypeid = Convert.ToInt32(Resources.MessageResource.strRequestTypeId.ToString()); if (requesttypeid == Convert.ToInt32(drpRequestType.SelectedValue)) { SLAid = 0; } } #endregion if (userName != "") { #region Find Userid of User who Created this Request objOrganization = objOrganization.Get_Organization(); objUser = objUser.Get_UserLogin_By_UserName(userName, objOrganization.Orgid); if (objUser.Userid != 0) { createdbyid = objUser.Userid; } #endregion #region Find Userid of User who is Requesting to log a call #region If User Already Exist if (Session["UserCreate"].ToString() == "Exist") { objUser = objUser.Get_UserLogin_By_UserName(txtUsername.Text.ToString().Trim(), objOrganization.Orgid); if (objUser.Userid != 0) { requesterid = objUser.Userid; } } #endregion #endregion } //added by lalit objIncident.Reporteddatetime = DBNull.Value.ToString(); objIncident.AMCCall = false; //end objIncident.Title = txtTitle.Text.ToString().Trim() + "-" + TxtExtension.Text.Trim(); objIncident.Slaid = SLAid; objIncident.Createdbyid = createdbyid; objIncident.Requesterid = requesterid; objIncident.Siteid = siteid; objIncident.Description = txtDescription.Text.ToString().Trim(); objIncident.Deptid = 0; objIncident.Createdatetime = DateTime.Now.ToString(); objIncident.Modeid = Convert.ToInt32(drpMode.SelectedValue); UserToSiteMapping objUserToSite = new UserToSiteMapping(); if (FlagUserStatus == true) { FlagInsert = objIncident.Insert(); #region Save Assetid and incident id in incidenttoassetmaaping objOrganization = objOrganization.Get_Organization(); objUser = objUser.Get_UserLogin_By_UserName(txtUsername.Text.ToString().Trim(), objOrganization.Orgid); int userid = Convert.ToInt32(objUser.Userid); int tempuser1 = Convert.ToInt32(Session["tempuser1"]); if (tempuser1 == 1) { assetid = Convert.ToInt32(Session["assetid"]); } else { assetid = Convert.ToInt32(objusertoasset.Get_AssetId_By_UserId(userid)); } int incid = Convert.ToInt32(objIncident.Get_TopIncidentId()); if (txtassignasset.Text != "") { //assetid = Convert.ToInt32(txtassignasset.Text); if (assetid != 0) { objincidenttoasset.Insert(incid, assetid); objusertoasset.Insert(userid, assetid, objUser.City, objUser.Company); //added a new column siteid Session.Abandon(); } } #endregion } if (FlagInsert == 1) { int FlagIncdStatesInsert; int incidentid; incidentid = objIncident.Get_Current_Incidentid(); objIncidentStates.Incidentid = incidentid; objIncidentStates.Priorityid = Convert.ToInt32(drpPriority.SelectedValue); objIncidentStates.Categoryid = Convert.ToInt32(drpCategory.SelectedValue); objIncidentStates.Statusid = Convert.ToInt32(drpStatus.SelectedValue); objIncidentStates.Subcategoryid = Convert.ToInt32(drpSubcategory.SelectedValue); objIncidentStates.Technicianid = 0; objIncidentStates.Requesttypeid = Convert.ToInt32(drpRequestType.SelectedValue); FlagIncdStatesInsert = objIncidentStates.Insert(); if (FlagIncdStatesInsert == 1) { objIncidentHistory.Incidentid = incidentid; objIncidentHistory.Operation = "create"; objIncidentHistory.Operationownerid = createdbyid; objIncidentHistory.Insert(); objSentmailtoUser.SentmailUser(requesterid, incidentid, "open"); // change code///////////////////////////////////////////////////////////////// if (FileUpload1.HasFile) { string filepath = Server.MapPath("~/FileAttach/"); string[] filenameupd = FileUpload1.FileName.Split(new char[] { '.' }); string filenew = Convert.ToString(incidentid) + "." + filenameupd[1]; FileUpload1.PostedFile.SaveAs(filepath + filenew); } /////////////////////////////////////////////////////////////////////////////// ////////change code on 27 march/// #region Map Site to user //FlagInsert=0; int FlagDelete = 0; int FlagStatus = 0; //string Username; //string gvIDs; int organizationId; //string gv; // Get object of Organization to get organization id and assign to local variable organizationId objOrganization = objOrganization.Get_Organization(); organizationId = objOrganization.Orgid; // Get username from textbox and assign to local variable Username //Username = txtUserName.Text.ToString().Trim(); // Find User Exist ,by calling function Get_UserLogin_By_UserName() //objUser = objUser.Get_UserLogin_By_UserName(Username, organizationId); // If Userid is not zero ,then user exist in database if (objUser.Userid != 0) { //'Navigate through each row in the GridView for checkbox items //foreach (GridViewRow gv in grdvwSite.Rows) //{ // Declare local variable deleteChkBxItem of Checkbox type to get the Checkbox Instance of Grid Row // CheckBox deleteChkBxItem = (CheckBox)gv.FindControl("deleteRec"); // If deleteChkBxItem is Checked then ,mapped Current site to this user //if (deleteChkBxItem.Checked) //{ // Get the Site Id from variable of Label type declare in GridView of grdvwSite //gvIDs = ((Label)gv.FindControl("SiteID")).Text.ToString(); // Check if gvIDs is not null // if (gvIDs != "") //{ // Declare local variable userid and siteid to get userid and SiteId int userid; userid = Convert.ToInt32(objUser.Userid); //siteid = Convert.ToInt32(gvIDs); // To Find Current Site to this User is Mapped by Calling Function objUserToSite.Get_By_Id() FlagStatus = objUserToSite.Get_By_Id(userid, siteid); // If FlagStatus is zero then site is not mapped to this user if (FlagStatus == 0) { objUserToSite.Siteid = siteid; objUserToSite.Userid = userid; // Mapped Current Site to this User by calling function objUserToSite.Insert() FlagInsert = objUserToSite.Insert(); } //} } // If deleteChkBxItem is Un Checked then ,Un mapped Current site to this user else { // Get the Site Id from variable of Label type declare in GridView of grdvwSite // gvIDs = ((Label)gv.FindControl("SiteID")).Text.ToString(); // Check if gvIDs is not null //if (gvIDs != "") // { // Declare local variable userid and siteid to get userid and SiteId int userid; userid = Convert.ToInt32(objUser.Userid); //siteid = Convert.ToInt32(gvIDs); // To Find Current Site to this User is Mapped by Calling Function objUserToSite.Get_By_Id() FlagStatus = objUserToSite.Get_By_Id(userid, siteid); // If FlagStatus is not zero then site is mapped to this user if (FlagStatus != 0) { // Un Mapped Current Site to this User by calling function objUserToSite.Delete() FlagDelete = objUserToSite.Delete(userid, siteid); } //} } //} #endregion /////////////end///////////////// Response.Redirect("../Login/AllUserCall.aspx"); } } } catch (Exception ex) { string myScript; myScript = "<script language=javascript>alert('Exception - '" + ex + "');</script>"; Page.RegisterClientScriptBlock("MyScript", myScript); return; } }