protected void Page_Load(object sender, EventArgs e) { Class.Encrypt clsEncrypt = new Class.Encrypt(); string strEmail = Convert.ToString(Session["IdUsuario"]); if (string.IsNullOrEmpty(strEmail)) { Response.Redirect("Default.aspx"); } else { clsEncrypt.strData = Session["Fullname"].ToString(); lblUserName.Text = clsEncrypt.DecryptData(); } }
protected void Button1_Click(object sender, EventArgs e) { string strEmailusr = string.Empty; string strIdUsuario = string.Empty; string strIdRol = string.Empty; try { string FullName = string.Empty; if (IsPostBack) { if (txtUsrEmail.Text == "") { ScriptManager.RegisterStartupScript(this, GetType(), "muestraError", "swal('','Falta usuario ','error');", true); txtUsrEmail.Focus(); } else if (txtPassword.Text == "") { ScriptManager.RegisterStartupScript(this, GetType(), "muestraError", "swal('','Falta contraseña ','error');", true); txtPassword.Focus(); } Class.Login Exists = new Class.Login(); Class.Encrypt clsEncrypt = new Class.Encrypt(); clsEncrypt.strData = txtPassword.Text.ToString(); Exists.UserName = txtUsrEmail.Text.ToString(); Exists.Password = clsEncrypt.EncryptData(); DataTable Usr = Exists.GetUser(); if (Usr.Rows.Count > 0) { foreach (DataRow row in Usr.Rows) { FullName = Convert.ToString(row["FirstName"]) + " " + Convert.ToString(row["LastName"]); strEmailusr = Convert.ToString(row["Email"]); strIdUsuario = Convert.ToString(row["IdGestor"]); strIdRol = Convert.ToString(row["IdRol"]); } } if (!string.IsNullOrWhiteSpace(FullName)) { clsEncrypt.strData = FullName; Session["Fullname"] = clsEncrypt.EncryptData(); clsEncrypt.strData = txtUsrEmail.Text; Session["email"] = strEmailusr; Session["IdUsuario"] = strIdUsuario; Session["Rol"] = strIdRol; Response.Redirect("principal.aspx"); } else { ScriptManager.RegisterStartupScript(this, GetType(), "muestraError", "swal('','Usuario o contraseña inválido ','error');", true); txtUsrEmail.Text = ""; // ErrorMsg.InnerHtml = "<div class='alert alert-danger alert-dismissible' role='alert'><button type='button' class='close' data-dismiss='alert' aria-label='Close'><span aria-hidden='true'>×</span></button><strong>Error:</strong> </div>"; } } } catch (Exception ex) { clsError.logMessage = ex.ToString(); clsError.logModule = "Button1_Click"; clsError.LogWrite(); } }
protected void Page_Load(object sender, EventArgs e) { clsElectricMeters oClsElectricMeters = new clsElectricMeters(); Class.Encrypt oclsEncrypt = new Class.Encrypt(); DataTable dtGetLadingCharge; try { string strRpu = Request["rpu"]; string strgp = Request["gp"]; string strlch = Request["lch"]; if (!IsPostBack) { DataTable dtAllGroups; oClsElectricMeters.intActive = 1; dtAllGroups = oClsElectricMeters.GetAllDistinctGroup(); cmbGroup.DataSource = dtAllGroups; cmbGroup.DataTextField = "Grupo"; cmbGroup.DataValueField = "IdGrupo"; cmbGroup.DataBind(); CargaDDl(); //cmbGroup.Items.Add("-- TODOS --"); //cmbGroup.SelectedValue = "-- TODOS --"; //if variable are not empty fill combo with input variable if (!string.IsNullOrEmpty(strRpu) && !string.IsNullOrEmpty(strgp) && !string.IsNullOrEmpty(strlch)) { oclsEncrypt.strData = strRpu; strRpu = oclsEncrypt.DecryptData(); //oclsEncrypt.strData = strgp; //strgp = oclsEncrypt.DecryptData(); //oclsEncrypt.strData = strlch; //strlch = oclsEncrypt.DecryptData(); _strgp = strgp; _strlch = strlch; _strRpu = strRpu; oClsElectricMeters.strGroup = strgp; oClsElectricMeters.intActive = 1; dtGetLadingCharge = oClsElectricMeters.SearchRPU(strRpu); if (dtGetLadingCharge == null) { ScriptManager.RegisterStartupScript(this, GetType(), "muestraError", "swal('','Error al recuperar los datos','error');", true); //msgErrNew.InnerHtml = ""; //msgErrNew.Style.Add("display", "none"); //msgErrNew.InnerHtml = ""; } else { if (dtGetLadingCharge.Rows.Count > 0) { dtGetLadingCharge.Rows.Add("-- TODOS --"); DataSet ds = new DataSet(); ds.Tables.Add(dtGetLadingCharge.Copy()); //cmbLoadingCharge.DataSource = ds; //cmbLoadingCharge.DataTextField = "RPUPuntoCarga"; //cmbLoadingCharge.DataValueField = "RPU"; //cmbLoadingCharge.SelectedIndex =0; ddl.DataSource = ds; ddl.DataTextField = "PuntoCarga"; ddl.DataValueField = "RPU"; ddl.DataBind(); //cmbLoadingCharge.DataBind(); ddl.Items.Add(""); foreach (DataRow renglon in ds.Tables[0].Rows) { strgp = renglon["Grupo"].ToString(); strlch = renglon["PuntoCarga"].ToString(); break; } ddl.SelectedValue = strRpu; cmbGroup.SelectedValue = strgp; } } } } } catch (Exception ex) { clsError.logMessage = ex.ToString(); clsError.logModule = "Page_Load"; clsError.LogWrite(); } }