protected void Page_Load(object sender, EventArgs e) { if ((Request.ServerVariables["HTTP_REFERER"] == null) || (Request.ServerVariables["HTTP_REFERER"] == "")) { Response.Redirect("~/Error.aspx"); } else { string http_ref = Request.ServerVariables["HTTP_REFERER"].Trim(); string http_hos = Request.ServerVariables["HTTP_HOST"].Trim(); int len = http_hos.Length; if (http_ref.IndexOf(http_hos, 0) < 0) { Response.Redirect("~/Error.aspx"); } } //clear Caching PrevBrowCache.enforceNoCache(); //if (Session["UsrName"] == null && Session["Role"].ToString() != "District Agriculture Officer") if (Session["UsrName"] == null && Session["RoleID"].ToString() != "3") { Response.Redirect("~/Error.aspx"); } else { dist = Session["distCode"].ToString(); conkey = Session["ConnKey"].ToString(); } if (!IsPostBack) { random(); lblUsrName.Text = Session["Role"].ToString(); lblDist.Text = Session["district"].ToString(); lblDate.Text = DateTime.Now.Day + "/" + DateTime.Now.Month + "/" + DateTime.Now.Year; lblyear.Text = cf.getCurrentFinancialYear(); objbe.month = DateTime.Now.Month.ToString(); objbe.Action = "Season"; lblseason.Text = objm.GetSeasonByMonth(objbe, conkey); objbe.season = lblseason.Text; if (lblseason.Text == "Kharif") { lblseason.Text = "VANAKALAM"; } else if (lblseason.Text == "Rabi") { lblseason.Text = "YASANGI"; } BindGrid(); } }
protected void Button1_Click(object sender, EventArgs e) { if (PageValidate()) { objbe.year = objCommon.getCurrentFinancialYear(); objbe.month = DateTime.Now.Month.ToString(); objbe.season = objm.GetSeasonByMonth(objbe, ConnKey); objbe.userid = Session["UserID"].ToString(); DataTable dtLogin = objLogin.GetLoginDetails(objbe, ConnKey); if (dtLogin.Rows.Count > 0) { string password = dtLogin.Rows[0]["Password"].ToString(); string myval = ShaEncrypt(ViewState["KeyGenerator"].ToString()); string value = ShaEncrypt(password.ToLower() + myval.ToLower()); if (password.ToLower() != txtNewPwdHash.Value) { if (txtOldPwdHash.Value == value.ToLower()) { objbe.userid = user; objbe.pwd = txtNewPwdHash.Value; objbe.ipaddress = Request.ServerVariables["REMOTE_ADDR"].ToString(); dt = objLogin.GetLoginDetails(objbe, ConnKey); if (dt.Rows.Count > 0) { objCommon.ShowAlertMessage("Password successfully changed"); Response.Redirect("login.aspx"); } else { txtOldPwdHash.Value = ""; txtNewPwdHash.Value = ""; objCommon.ShowAlertMessage("Invalid Old Password"); } } else { txtOldPwdHash.Value = ""; txtNewPwdHash.Value = ""; objCommon.ShowAlertMessage("Invalid Old Password"); } } else { objCommon.ShowAlertMessage("New Password should not be same as old password"); } } else { objCommon.ShowAlertMessage("New Password should not be same as old password"); } } }
protected void btnLogin_Click(object sender, EventArgs e) { check(); try { if (CheckCaptcha()) { Login_DL objLogin = new Login_DL(); objbe.month = DateTime.Now.Month.ToString(); objbe.season = objm.GetSeasonByMonth(objbe, ConnKey); objbe.year = objCommon.getCurrentFinancialYear(); objbe.username = txtUname.Text.Trim(); objbe.Action = "R"; DataTable dtLogin = objLogin.GetLoginDetails(objbe, ConnKey); if (dtLogin.Rows.Count > 0) { string password = dtLogin.Rows[0]["Password"].ToString(); string StateCode = dtLogin.Rows[0]["StateCode"].ToString(); string DistCode = dtLogin.Rows[0]["DistCode"].ToString(); string MandCode = dtLogin.Rows[0]["MandCode"].ToString(); string SPCode = dtLogin.Rows[0]["code"].ToString(); string district = dtLogin.Rows[0]["DistName"].ToString(); string mandal = dtLogin.Rows[0]["MandName"].ToString(); string roleNm = dtLogin.Rows[0]["role_name"].ToString(); string section = dtLogin.Rows[0]["section"].ToString(); string userid = dtLogin.Rows[0]["Sno"].ToString(); string myval = ShaEncrypt(ViewState["KeyGenerator"].ToString()); string value = ShaEncrypt(password.ToLower() + myval.ToLower()); if (txtPwdHash.Value == value.ToLower()) { string guid = Guid.NewGuid().ToString(); Session["AuthToken"] = guid; Response.ClearContent(); Response.Cookies.Add(new HttpCookie("AuthToken", guid)); Session["ConnKey"] = ConnKey; objbe.username = txtUname.Text.Trim(); objbe.date_time = DateTime.Now; objbe.ipaddress = Request.ServerVariables["REMOTE_ADDR"].ToString(); objbe.loginStatus = "Login Successful"; Session["UserID"] = userid; //Session["UserID"] = objLogin.UserLoginStatus(objbe, ConnKey); //if (password.ToUpper() == "6B4C8CBCB6B66F050C12D6A0203C58A8BC6D36E5A8C28B74111681F7AECE378A") //{ // Session["Role"] = roleNm; // Session["UsrName"] = txtUname.Text; // Session["StateCode"] = StateCode; // Session["SpCode"] = SPCode; // Session["distCode"] = DistCode; // Session["mandcode"] = MandCode; // Session["district"] = district; // Session["mandal"] = mandal; // Response.Redirect("ChangePWD.aspx", false); //} //else if (dtLogin.Rows[0]["Role"].ToString() == "2") { Session["Role"] = roleNm; Session["UsrName"] = txtUname.Text; Session["StateCode"] = StateCode; Session["SpCode"] = SPCode; Session["distCode"] = DistCode; Session["mandcode"] = MandCode; Session["district"] = district; Session["mandal"] = mandal; Response.Redirect("~/Salepoint/DashBoard.aspx", false); } else if (dtLogin.Rows[0]["Role"].ToString() == "1") { Session["Role"] = roleNm; Session["UsrName"] = txtUname.Text; Session["StateCode"] = StateCode; Session["Section"] = section; Response.Redirect("~/Admin/DashBoard.aspx", false); } else if (dtLogin.Rows[0]["Role"].ToString() == "0") { Session["Role"] = roleNm; Session["UsrName"] = txtUname.Text; Session["StateCode"] = StateCode; Response.Redirect("~/SuperAdmin/Discussion.aspx", false); } else if (dtLogin.Rows[0]["Role"].ToString() == "3") { Session["Role"] = roleNm; Session["UsrName"] = txtUname.Text; Session["StateCode"] = StateCode; Session["distCode"] = DistCode; Session["district"] = district; Response.Redirect("~/DAO/Dashboard.aspx", false); } else if (dtLogin.Rows[0]["Role"].ToString() == "4") { Session["Role"] = roleNm; Session["UsrName"] = txtUname.Text; Session["StateCode"] = StateCode; Session["distCode"] = DistCode; Session["district"] = district; Session["mandcode"] = MandCode; Session["mandal"] = mandal; Response.Redirect("~/MAO/DashBoard.aspx", false); } else if (dtLogin.Rows[0]["Role"].ToString() == "5") { Session["Role"] = roleNm; Session["UsrName"] = txtUname.Text; Session["StateCode"] = StateCode; Session["distCode"] = DistCode; Session["district"] = district; Session["mandcode"] = MandCode; Session["mandal"] = mandal; Session["repid"] = dtLogin.Rows[0]["code"].ToString(); Response.Redirect("~/Rep/home.aspx", false); } else if (dtLogin.Rows[0]["Role"].ToString() == "6") { Session["Role"] = roleNm; Session["UsrName"] = txtUname.Text; Session["StateCode"] = StateCode; Session["distCode"] = DistCode; Session["district"] = district; Session["agency_id"] = dtLogin.Rows[0]["code"].ToString(); Response.Redirect("~/DM/home.aspx", false); } else if (dtLogin.Rows[0]["Role"].ToString() == "7") { Session["Role"] = roleNm; Session["UsrName"] = txtUname.Text; Session["StateCode"] = StateCode; Session["agency_id"] = dtLogin.Rows[0]["code"].ToString(); Response.Redirect("~/SM/home.aspx", false); } else if (dtLogin.Rows[0]["Role"].ToString() == "8") { Session["Role"] = roleNm; Session["UsrName"] = txtUname.Text; Session["StateCode"] = StateCode; Session["Section"] = section; Response.Redirect("~/NFSM/DashBoard.aspx", false); } } else { //captch.Text = ""; ViewState["KeyGenerator"] = Guid.NewGuid().ToString("N").Substring(0, 16); getCaptchaImage(); objCommon.ShowAlertMessage("Invalid Username & Password"); } } else { //captch.Text = ""; ViewState["KeyGenerator"] = Guid.NewGuid().ToString("N").Substring(0, 16); getCaptchaImage(); objCommon.ShowAlertMessage("Please Enter Valid user name"); } } else { //captch.Text = ""; ViewState["KeyGenerator"] = Guid.NewGuid().ToString("N").Substring(0, 16); getCaptchaImage(); lblmsg.Text = "The characters you entered didn't match.Please try again"; } } catch (Exception ex) { ExceptionLogging.SendExcepToDB(ex, Session["UsrName"].ToString(), Request.ServerVariables["REMOTE_ADDR"].ToString()); //Response.Redirect("~/Error.aspx"); } }
protected void getReports() { // pfc.AddFontFile("../Fonts/madfont.ttf"); objbe.month = DateTime.Now.Month.ToString(); lblyear.Text = objbe.year; lblSeason.Text = objbe.season; dt = new DataTable(); dt = sr.ViewRequest(objbe, con); if (dt.Rows.Count > 0) { lbltitle.Visible = true; gvrequest.DataSource = dt; gvrequest.DataBind(); } else { lbltitle.Visible = false; gvrequest.DataSource = null; gvrequest.DataBind(); } dt = new DataTable(); objbe.year = cf.getCurrentFinancialYear(); objbe.season = objm.GetSeasonByMonth(objbe, con); objbe.distcd = dist; objbe.Action = "Alotmnt"; dt = rprt.GetDetails(objbe, con); if (dt.Rows.Count > 0) { gvAllotment.DataSource = dt; gvAllotment.DataBind(); } objbe.Action = "unfrzdAdmin"; dt = rprt.GetDetails(objbe, con); if (dt.Rows.Count > 0) { gvUnfrzStk.DataSource = dt; gvUnfrzStk.DataBind(); } dt = new DataTable(); objbe.Action = "stock"; dt = rprt.GetDetails(objbe, con); if (dt.Rows.Count > 0) { GvStock.DataSource = dt; GvStock.DataBind(); } objbe.Action = "unfrzdDao"; dt = rprt.GetDetails(objbe, con); if (dt.Rows.Count > 0) { gvUnfrzAllot.DataSource = dt; gvUnfrzAllot.DataBind(); } }