Exemplo n.º 1
0
        protected void gvUsuario_RowEditing(object sender, GridViewEditEventArgs e)
        {
            pnlTab1.Visible = false;
            pnlTab2.Visible = true;

            txtUsuarioId.Text     = gvUsuario.Rows[e.NewEditIndex].Cells[0].Text.ToString().Replace(" ", "");;
            txtApellido.Text      = gvUsuario.Rows[e.NewEditIndex].Cells[1].Text.ToString().Replace(" ", "");;
            txtNombre.Text        = gvUsuario.Rows[e.NewEditIndex].Cells[2].Text.ToString().Replace(" ", "");;
            ddlRol.SelectedValue  = ((Label)gvUsuario.Rows[e.NewEditIndex].FindControl("lblIdRol")).Text;
            ddlTipoDocumento.Text = gvUsuario.Rows[e.NewEditIndex].Cells[4].Text.ToString();
            txtNroDocumento.Text  = gvUsuario.Rows[e.NewEditIndex].Cells[5].Text.ToString().Replace(" ", "");;
            txtMail.Text          = gvUsuario.Rows[e.NewEditIndex].Cells[6].Text.ToString().Replace(" ", "");;
            txtMail.Enabled       = false;
            txtTelefono.Text      = gvUsuario.Rows[e.NewEditIndex].Cells[7].Text.ToString().Replace(" ", "");;
            e.Cancel = true;

            if (ddlRol.SelectedValue == "2" || ddlRol.SelectedValue == "4")
            {
                divConductor.Visible = true;
                DataSet dsVehiculo = BIZVehiculo.SelectByIdUsr(txtUsuarioId.Text);
                txtMarca.Text      = dsVehiculo.Tables[0].Rows[0]["marca"].ToString();
                txtModelo.Text     = dsVehiculo.Tables[0].Rows[0]["modelo"].ToString();
                txtPatente.Text    = dsVehiculo.Tables[0].Rows[0]["patente"].ToString();
                hdIdVehiculo.Value = dsVehiculo.Tables[0].Rows[0]["idVehiculo"].ToString();
            }
            else
            {
                divConductor.Visible = false;
            }

            ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "pepe", "mostrar();", true);
        }
Exemplo n.º 2
0
        private void cargarDatos()
        {
            try
            {
                gvDatosPersonales.DataSource = BIZ.BIZDatosPersonales.SelectByIdUsr(User.Identity.GetUserId());
                gvDatosPersonales.DataBind();

                gvVehiculo.DataSource = BIZVehiculo.SelectByIdUsr(User.Identity.GetUserId());
                gvVehiculo.DataBind();

                if (gvDatosPersonales.Rows.Count > 0)
                {
                    //Attribute to show the Plus Minus Button.
                    gvDatosPersonales.HeaderRow.Cells[0].Attributes["data-class"] = "expand";

                    //Attribute to hide column in Phone.
                    gvDatosPersonales.HeaderRow.Cells[1].Attributes["data-hide"] = "phone";

                    //Adds THEAD and TBODY to GridView.
                    gvDatosPersonales.HeaderRow.TableSection = TableRowSection.TableHeader;
                }
                if (Context.User.IsInRole("Propietario") || Context.User.IsInRole("Administrador"))
                {
                    pnlTab3.Visible = false;
                }
            }
            catch (Exception ex)
            {
                string error = ex.Message;
                Response.Redirect("ErrorDB.aspx");
            }
        }
Exemplo n.º 3
0
 private void AltaDatosPersonales(string id, string email)
 {
     try
     {
         BIZDatosPersonales.Insert(id, "DNI", "00000000", email, "9999999999", "MOVIL", "Nombre Apellido", string.Empty, string.Empty, string.Empty, string.Empty);
         BIZVehiculo.Insert(id, "MARCA", "MODELO", "XXX XXX");
     }
     catch (Exception)
     {
         return;
     }
 }
Exemplo n.º 4
0
 protected void btnConfirmarVehiculo_Click(object sender, EventArgs e)
 {
     try
     {
         BIZVehiculo.Update(int.Parse(txtIdVehiculo.Text), User.Identity.GetUserId(), txtMarca.Text, txtModelo.Text, txtPatente.Text);
         BIZBitacora.Insert(Utils.GetDateTimeLocal(), Context.User.Identity.GetUserId(), "MODIFICACIÓN", "Vehículo");
         txtNumeroDocumento.Text = "";
         txtEmail.Text           = "";
         txtNroTelefono.Text     = "";
         txtAliasEmp.Text        = "";
         pnlTab2.Visible         = false;
         pnlTab3.Visible         = true;
         pnlTab1.Visible         = true;
         pnlVehiculo.Visible     = false;
         cargarDatos();
     }
     catch (Exception ex)
     {
         Response.Redirect("ErrorDB.aspx");
     }
 }
Exemplo n.º 5
0
        protected void btnConfirmar_Click(object sender, EventArgs e)
        {
            try
            {
                lblMensaje.Text = string.Empty;

                if (!string.IsNullOrEmpty(txtCuil.Text))
                {
                    bool cuilValido = BIZUtilites.ValidaCuit(txtCuil.Text);
                    if (!cuilValido)
                    {
                        lblMensaje.Text = "Verifique el CUIL";
                        return;
                    }
                }

                if (txtUsuarioId.Text == string.Empty)
                {
                    var manager       = Context.GetOwinContext().GetUserManager <ApplicationUserManager>();
                    var signInManager = Context.GetOwinContext().Get <ApplicationSignInManager>();
                    var user          = new ApplicationUser()
                    {
                        UserName = txtMail.Text, Email = txtMail.Text
                    };
                    IdentityResult result = manager.Create(user, "Dni" + "-" + txtNroDocumento.Text);
                    if (result.Succeeded)
                    {
                        //inserto el ROL para el usuario
                        BIZAspNetUserRoles.Insert(user.Id, ddlRol.SelectedValue);

                        //agregado para crear cuenta corriente cuando se registra
                        BIZCuentaCorriente.Insert(user.Id, 100, Utils.GetDateTimeLocal());

                        BIZDatosPersonales.Insert(user.Id, ddlTipoDocumento.SelectedValue, txtNroDocumento.Text, txtMail.Text, txtTelefono.Text, string.Empty, string.Empty, txtNombre.Text, txtApellido.Text, txtDireccion.Text, txtCuil.Text);
                        BIZVehiculo.Insert(user.Id, txtMarca.Text, txtModelo.Text, txtPatente.Text);

                        //envio mail
                        Send_Account_Activation_Link(txtMail.Text, user.Id);

                        // Para obtener más información sobre cómo habilitar la confirmación de cuentas y el restablecimiento de contraseña, visite http://go.microsoft.com/fwlink/?LinkID=320771
                        //string code = manager.GenerateEmailConfirmationToken(user.Id);
                        //string callbackUrl = IdentityHelper.GetUserConfirmationRedirectUrl(code, user.Id, Request);
                        //manager.SendEmail(user.Id, "Confirmar cuenta", "Para confirmar la cuenta, haga clic <a href=\"" + callbackUrl + "\">aquí</a>.");

                        //signInManager.SignIn( user, isPersistent: false, rememberBrowser: false);
                    }
                }
                else
                {
                    //actualizo el ROL para el usuario
                    BIZAspNetUserRoles.Update(txtUsuarioId.Text, ddlRol.SelectedValue);

                    BIZDatosPersonales.Update(txtUsuarioId.Text, ddlTipoDocumento.SelectedValue, txtNroDocumento.Text, txtMail.Text, txtTelefono.Text, string.Empty, string.Empty, txtNombre.Text, txtApellido.Text, txtDireccion.Text, txtCuil.Text);
                    if (!string.IsNullOrEmpty(hdIdVehiculo.Value))
                    {
                        BIZVehiculo.Update(Convert.ToDecimal(hdIdVehiculo.Value), txtUsuarioId.Text, txtMarca.Text, txtModelo.Text, txtPatente.Text);
                    }
                }
                txtUsuarioId.Text    = string.Empty;
                txtApellido.Text     = string.Empty;
                txtNombre.Text       = string.Empty;
                ddlRol.SelectedValue = "2";

                txtNroDocumento.Text = string.Empty;
                txtMail.Text         = string.Empty;
                txtTelefono.Text     = string.Empty;
                txtCuil.Text         = string.Empty;
                txtMarca.Text        = string.Empty;
                txtModelo.Text       = string.Empty;
                txtPatente.Text      = string.Empty;

                txtUsuarioId.Visible = true;
                lblUsuarioId.Visible = true;

                pnlTab2.Visible = false;
                pnlTab1.Visible = true;
                //divPrecio.Visible = false;
                lblMensaje.Text = string.Empty;
                cargarZonas();
            }
            catch (Exception)
            {
                Response.Redirect("~/ErrorPage.aspx");
            }
        }
Exemplo n.º 6
0
        protected void UploadArchivo(object sender, EventArgs e)
        {
            string fileName = Path.GetFileName(FileUpload1.PostedFile.FileName);
            string filePath = Server.MapPath("~/Uploads/") + fileName;

            FileUpload1.SaveAs(filePath);
            string xml = File.ReadAllText(filePath);

            string extension = fileName.Split('.').Length > 0 ? fileName.Split('.')[fileName.Split('.').Length - 1] : "";

            if (!extension.ToUpper().Equals("CSV"))
            {
                lblMje.ForeColor = Color.Red;
                lblMje.Text      = "El archivo debe tener extension CSV.";
                return;
            }

            using (var reader = new StreamReader(@filePath))
            {
                List <string> listA    = new List <string>();
                List <string> listB    = new List <string>();
                int           registro = 0;
                while (!reader.EndOfStream)
                {
                    registro++;
                    try
                    {
                        var      line   = reader.ReadLine();
                        string[] values = line.Split(';');

                        if (values.Length == 11 || values.Length == 8)
                        {
                            if ((values[7] == "2" || values[7] == "4") && values.Length != 11)
                            {
                                txtResultado.Text += "Se produjo error al procesar el registro Nº " + registro + ": Si el usuario es Conductor debe indicar datos del vehículo.\n";
                            }
                            else
                            {
                                var manager       = Context.GetOwinContext().GetUserManager <ApplicationUserManager>();
                                var signInManager = Context.GetOwinContext().Get <ApplicationSignInManager>();
                                var user          = new ApplicationUser()
                                {
                                    UserName = values[0], Email = values[0]
                                };
                                IdentityResult result = manager.Create(user, "Dni" + "-" + values[2]);
                                if (result.Succeeded)
                                {
                                    //inserto el ROL para el usuario
                                    BIZAspNetUserRoles.Insert(user.Id, values[7]);

                                    //agregado para crear cuenta corriente cuando se registra
                                    BIZCuentaCorriente.Insert(user.Id, 100, Utils.GetDateTimeLocal());

                                    BIZDatosPersonales.Insert(user.Id, values[1], values[2], values[0], values[5], string.Empty, string.Empty, values[4], values[3], values[6], string.Empty);
                                    if (values[7] == "2" || values[7] == "4")
                                    {
                                        BIZVehiculo.Insert(user.Id, values[8], values[9], values[10]);
                                    }

                                    BIZBitacora.Insert(Utils.GetDateTimeLocal(), Context.User.Identity.GetUserId(), "ALTA", "Carga Masiva Usuarios");

                                    //envio mail
                                    Send_Account_Activation_Link(values[0], user.Id, values[2]);

                                    txtResultado.Text += "Registro Nº " + registro + " OK\n";
                                }
                                else
                                {
                                    txtResultado.Text += "Se produjo error al procesar el registro Nº " + registro + " " + result.Errors.First() + "\n";
                                }
                            }
                        }
                        else
                        {
                            txtResultado.Text += "Se produjo error al procesar el registro Nº " + registro + ": La cantidad de campos no es correcta.\n";
                        }
                    }
                    catch (Exception ex)
                    {
                        txtResultado.Text += "Se produjo error al procesar el registro Nº " + registro + " " + ex.Message + ".\n";
                    }
                }
            }
        }