private void reLoadSession() { if (Session["userType"] == null || Session["aGENT"] != null || Session["lOCATION"] != null) { USERINFO userInfo = new USERINFO(); userInfo = USERINFOManager.GetUSERINFOByUserNameType("Agent", User.Identity.Name);//"Agent" is dami in database i have not use the if (userInfo != null) { Session["userType"] = userInfo.Type.ToString(); Session["userInfoID"] = userInfo.USERINFOID.ToString(); Session["userName"] = userInfo.UserName.ToString(); //if (userInfo.Agent_LocationID.ToString() == ddlAgent.SelectedItem.Value.ToString()) if (userInfo.Type == "Agent") { Session["aGENT"] = AGENTManager.GetAGENTByID(userInfo.Agent_LocationID); Session["role"] = "Agent"; } else if (userInfo.Type == "Location") { Session["lOCATION"] = LOCATIONGROUPManager.GetLOCATIONGROUPByID(userInfo.Agent_LocationID); Session["role"] = "Location"; } } } }
protected void OnAuthenticate(object sender, AuthenticateEventArgs e) { lblMessage.Text = ""; e.Authenticated = false; Login masterLogin = (Login)masterview.FindControl("masterLogin"); string userName = masterLogin.UserName.ToString(); string password = masterLogin.Password.ToString(); //if (Membership.ValidateUser(userName, password) && (userName.Equals("admin"))) //{ // masterLogin.DestinationPageUrl = "Default.aspx"; // Session["role"] = "Admin"; // e.Authenticated = true; //} //else //{ if (Membership.ValidateUser(userName, password)) { USERINFO userInfo = new USERINFO(); userInfo = USERINFOManager.GetUSERINFOByUserNameType("Agent", userName);//"Agent" is dami in database i have not use the if (userInfo != null) { Session["userType"] = userInfo.Type.ToString(); Session["userInfoID"] = userInfo.USERINFOID.ToString(); Session["userName"] = userInfo.UserName.ToString(); e.Authenticated = true; //if (userInfo.Agent_LocationID.ToString() == ddlAgent.SelectedItem.Value.ToString()) if (userInfo.Type == "Agent") { Session["aGENT"] = AGENTManager.GetAGENTByID(userInfo.Agent_LocationID); Session["role"] = "Agent"; } else if (userInfo.Type == "Location") { Session["lOCATION"] = LOCATIONGROUPManager.GetLOCATIONGROUPByID(userInfo.Agent_LocationID); Session["role"] = "Location"; } //Response.Redirect("Default.aspx"); masterLogin.DestinationPageUrl = "~/Default.aspx"; } else { lblMessage.Text = "Password incorrect!!!"; } } else { //Response.Redirect("~/Forgetpassword.aspx"); } //} }
protected void lbSelect_Click(object sender, EventArgs e) { try { LinkButton linkButton = new LinkButton(); linkButton = (LinkButton)sender; int id; id = Convert.ToInt32(linkButton.CommandArgument); LOCATIONGROUP locationGroup = LOCATIONGROUPManager.GetLOCATIONGROUPByID(id); if (locationGroup != null) { txtGROUPNAME.Text = locationGroup.GROUPNAME; hdnGroupID.Value = locationGroup.LOCATIONGROUPID.ToString(); btnAdd.Visible = false; btnUpdate.Visible = true; } } catch { } }
private void showLOCATIONMAPPINGGrid() { gvLOCATIONMAPPING.DataSource = LOCATIONMAPPINGManager.GetAllLOCATIONMAPPINGs(); gvLOCATIONMAPPING.DataBind(); foreach (GridViewRow gvr in gvLOCATIONMAPPING.Rows) { Label lblLOCATIONID = gvr.FindControl("lblLOCATIONID") as Label; Label lblLOCATIONGROUPID = gvr.FindControl("lblLOCATIONGROUPID") as Label; LOCATION location = LOCATIONManager.GetLOCATIONByID(int.Parse(lblLOCATIONID.Text)); if (location != null) { lblLOCATIONID.Text = location.COUNTRY + ", " + location.CITY + ", " + location.BRANCH; } LOCATIONGROUP locationGroup = LOCATIONGROUPManager.GetLOCATIONGROUPByID(int.Parse(lblLOCATIONGROUPID.Text)); if (locationGroup != null) { lblLOCATIONGROUPID.Text = locationGroup.GROUPNAME; } } }
protected void btnUpdate_Click(object sender, EventArgs e) { try { LOCATIONGROUP lOCATIONGROUP = new LOCATIONGROUP(); lOCATIONGROUP = LOCATIONGROUPManager.GetLOCATIONGROUPByID(Int32.Parse(hdnGroupID.Value)); LOCATIONGROUP tempLOCATIONGROUP = new LOCATIONGROUP(); tempLOCATIONGROUP.LOCATIONGROUPID = lOCATIONGROUP.LOCATIONGROUPID; tempLOCATIONGROUP.ADDEDDATE = DateTime.Now; tempLOCATIONGROUP.GROUPNAME = txtGROUPNAME.Text; bool result = LOCATIONGROUPManager.UpdateLOCATIONGROUP(tempLOCATIONGROUP); if (result == true) { lblErr.Text = "successfully updated!"; btnClear_Click(null, null); showLOCATIONGROUPGrid(); } } catch (Exception ex) { lblErr.Text = ex.Message; } }