Example #1
0
        protected void btnEliminar_Click(object sender, EventArgs e)
        {
            try
            {
                Usuario         user          = new Usuario();
                UsuarioMandante userMan       = new UsuarioMandante();
                LinkButton      btn           = (LinkButton)sender;
                GridViewRow     row           = (GridViewRow)btn.NamingContainer;
                Label           _lblIdUsuario = (Label)grvUsuarios.Rows[row.RowIndex].FindControl("lblIdUsuario");
                user.IdUsuario    = Convert.ToInt32(_lblIdUsuario.Text);
                userMan.IdUsuario = Convert.ToInt32(_lblIdUsuario.Text);
                dal.setDelUsuarioMandante(userMan);
                dal.setDelUsuarioSucursal(user.IdUsuario);
                dal.setDelUsuario(user);

                lblInfo.Text = "Usuario Eliminado Correctamente";
                divAlerta.Attributes["class"] = "alert alert-success";
                divAlerta.Visible             = true;

                buscar();
            }
            catch (Exception ex)
            {
                divAlerta.Visible = true;
                lblInfo.Text      = ex.Message;
            }
        }
Example #2
0
        protected void BtnEliminar_Click(object sender, EventArgs e)
        {
            try
            {
                Usuario         user          = new Usuario();
                UsuarioMandante userMan       = new UsuarioMandante();
                LinkButton      btn           = (LinkButton)sender;
                GridViewRow     row           = (GridViewRow)btn.NamingContainer;
                Label           _lblIdUsuario = (Label)grvUsuarios.Rows[row.RowIndex].FindControl("lblIdUsuario");
                user.IdUsuario    = Convert.ToInt32(_lblIdUsuario.Text);
                userMan.IdUsuario = Convert.ToInt32(_lblIdUsuario.Text);
                dal.SetDelMensajes(user);
                dal.SetDelUsuarioMandante(userMan);
                dal.SetDelUsuario(user);

                Buscar();

                lblInformacion.Text = "Usuario Eliminado Correctamente";
                mdlInformacion.Show();
            }
            catch (Exception ex)
            {
                lblInformacion.Text = ex.Message;
                mdlInformacion.Show();
            }
        }
Example #3
0
        protected void BtnEditar_Click(object sender, EventArgs e)
        {
            try
            {
                limpiar(this.Controls);
                Usuario         user          = new Usuario();
                UsuarioMandante userMan       = new UsuarioMandante();
                LinkButton      btn           = (LinkButton)sender;
                GridViewRow     row           = (GridViewRow)btn.NamingContainer;
                Label           _lblIdUsuario = (Label)grvUsuarios.Rows[row.RowIndex].FindControl("lblIdUsuario");

                user.IdUsuario    = Convert.ToInt32(_lblIdUsuario.Text);
                hfIdUsuario.Value = _lblIdUsuario.Text;

                DataTable dt = new DataTable();
                dt = dal.GetBuscarUsuario(user).Tables[0];
                foreach (DataRow item in dt.Rows)
                {
                    txtRut.Text    = item["Rut"].ToString();
                    txtNombre.Text = item["Nombre"].ToString();
                    txtLogin.Text  = item["Login"].ToString();
                    txtEmail.Text  = item["Email"].ToString();
                    txtClave.Attributes.Add("Value", item["Clave"].ToString());
                    txtAreaCargo.Text = item["AreaCargo"].ToString();
                    if (item["IdPerfil"].ToString() != string.Empty)
                    {
                        ddlPerfil.SelectedValue = item["IdPerfil"].ToString();
                    }
                    if (item["Activo"].ToString() != string.Empty)
                    {
                        ddlActivo.SelectedValue = item["Activo"].ToString();
                    }
                    imgLogo.Src = item["foto"].ToString();
                }

                foreach (DataRow item in dal.GetBuscarUsuarioMandante(user).Tables[0].Rows)
                {
                    string idCliente = Convert.ToString(item["IdMandante"]);
                    foreach (ListItem fila in chkMandantes.Items)
                    {
                        if (idCliente == fila.Value.ToString())
                        {
                            fila.Selected = true;
                        }
                    }
                }

                divImagenLogo.Visible = true;

                divSearch.Visible  = false;
                divAddEdit.Visible = true;
            }
            catch (Exception ex)
            {
                lblInformacion.Text = ex.Message;
                mdlInformacion.Show();
            }
        }
Example #4
0
        public void SetDelUsuarioMandante(UsuarioMandante user)
        {
            DbCommand cmd = db.GetStoredProcCommand("stp_DelUsuarioMandante");

            db.AddInParameter(cmd, "@idUsuario", DbType.String, user.IdUsuario);

            try
            {
                db.ExecuteNonQuery(cmd);
            }
            catch (SqlException ex)
            {
                throw new Exception("No se pudo eliminar el usuario , " + ex.Message, ex);
            }
            catch (Exception ex)
            {
                throw new Exception("No se pudo eliminar el usuario , " + ex.Message, ex);
            }
        }
Example #5
0
        protected void btnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                Usuario         user    = new Usuario();
                UsuarioMandante userMan = new UsuarioMandante();

                user.Activo    = Convert.ToInt32(ddlActivo.SelectedValue);
                user.AreaCargo = txtAreaCargo.Text;
                user.Clave     = txtClave.Text;
                user.Email     = txtEmail.Text;

                user.IdPerfil = Convert.ToInt32(ddlPerfil.SelectedValue);
                //user.IdSucursal = ddlSucursal.SelectedValue;
                //user.IdUsuario
                user.Login  = txtLogin.Text;
                user.Nombre = txtNombre.Text;
                user.Rut    = txtRut.Text;
                //if (txtIdUsuarioDiscador.Text != string.Empty)
                //{
                //    user.IdUsuarioDiscador = Convert.ToInt32(txtIdUsuarioDiscador.Text);
                //}

                //Nuevo o Editar
                if (hfIdUsuario.Value == string.Empty)
                {
                    DataTable dtUser = new DataTable();
                    dtUser = dal.getBuscarValUsuario(user).Tables[0];

                    if (dtUser.Rows.Count != 0)
                    {
                        lblInfo.Text = "El usuario " + user.Login + " existe en la bd";
                        divAlerta.Attributes["class"] = "alert alert-danger";
                        divAlerta.Visible             = true;
                        return;
                    }

                    user.IdUsuario    = Convert.ToInt32(dal.setInUpUsuario(user));
                    userMan.IdUsuario = user.IdUsuario;

                    //foreach (ListItem item in chkMandantes.Items)
                    //{
                    //    if (item.Selected == true)
                    //    {
                    //        //string valorCheckIdCliente = item.Value;
                    //        string valorCheckIdCliente = "1";
                    //        userMan.IdMandante = Convert.ToInt32(valorCheckIdCliente);
                    //        dal.setInUsuarioMandante(userMan);
                    //    }
                    //}

                    userMan.IdMandante = 1;
                    dal.setInUsuarioMandante(userMan);

                    foreach (ListItem item in chkSucursales.Items)
                    {
                        if (item.Selected == true)
                        {
                            string valorCheckIdCliente = item.Value;
                            dal.setInUsuarioPorSucursal(user.IdUsuario, valorCheckIdCliente);
                        }
                    }
                }
                else
                {
                    user.IdUsuario = Convert.ToInt32(hfIdUsuario.Value);
                    Convert.ToInt32(dal.setInUpUsuario(user));
                    userMan.IdUsuario = user.IdUsuario;
                    //dal.setDelUsuarioMandante(userMan);
                    dal.setDelUsuarioSucursal(user.IdUsuario);
                    foreach (ListItem item in chkMandantes.Items)
                    {
                        if (item.Selected == true)
                        {
                            string valorCheckIdCliente = item.Value;
                            userMan.IdMandante = Convert.ToInt32(valorCheckIdCliente);
                            dal.setInUsuarioMandante(userMan);
                        }
                    }

                    foreach (ListItem item in chkSucursales.Items)
                    {
                        if (item.Selected == true)
                        {
                            string valorCheckIdCliente = item.Value;
                            dal.setInUsuarioPorSucursal(user.IdUsuario, valorCheckIdCliente);
                        }
                    }
                }

                buscar();
                divSearch.Visible  = true;
                divAddEdit.Visible = false;
            }
            catch (Exception ex)
            {
                divAlerta.Visible = true;
                lblInfo.Text      = ex.Message;
            }
        }
Example #6
0
        protected void BtnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                Usuario         user    = new Usuario();
                UsuarioMandante userMan = new UsuarioMandante();

                user.Activo    = Convert.ToInt32(ddlActivo.SelectedValue);
                user.AreaCargo = txtAreaCargo.Text;
                user.Clave     = txtClave.Text;
                user.Email     = txtEmail.Text;
                //if (fuLogo.HasFile)
                //{
                //    string carpeta = "assets/img/usuario/" + "logo_" + hfIdUsuario.Value + "_" + fuLogo.FileName;
                //    fuLogo.SaveAs(Server.MapPath(carpeta));
                //    user.Foto = carpeta;
                //}
                user.IdPerfil = Convert.ToInt32(ddlPerfil.SelectedValue);
                //user.IdUsuario
                user.Login  = txtLogin.Text;
                user.Nombre = txtNombre.Text;
                user.Rut    = txtRut.Text;
                if (txtIdUsuarioDiscador.Text != string.Empty)
                {
                    user.IdUsuarioDiscador = Convert.ToInt32(txtIdUsuarioDiscador.Text);
                }

                //Nuevo o Editar
                if (hfIdUsuario.Value == string.Empty)
                {
                    //Nuevo
                    DataTable dtUser = new DataTable();
                    dtUser = dal.GetBuscarValUsuario(user).Tables[0];

                    if (dtUser.Rows.Count != 0)
                    {
                        lblInformacion.Text = "El usuario " + user.Login + " existe en la bd";
                        mdlInformacion.Show();
                        return;
                    }

                    user.IdUsuario    = Convert.ToInt32(dal.SetInUpUsuario(user));
                    userMan.IdUsuario = user.IdUsuario;

                    foreach (ListItem item in chkMandantes.Items)
                    {
                        if (item.Selected == true)
                        {
                            string valorCheckIdCliente = item.Value;
                            userMan.IdMandante = Convert.ToInt32(valorCheckIdCliente);
                            dal.SetInUsuarioMandante(userMan);
                        }
                    }
                }
                else
                {
                    //EdiciĆ³n
                    user.IdUsuario = Convert.ToInt32(hfIdUsuario.Value);
                    Convert.ToInt32(dal.SetInUpUsuario(user));
                    userMan.IdUsuario = user.IdUsuario;
                    dal.SetDelUsuarioMandante(userMan);
                    foreach (ListItem item in chkMandantes.Items)
                    {
                        if (item.Selected == true)
                        {
                            string valorCheckIdCliente = item.Value;
                            userMan.IdMandante = Convert.ToInt32(valorCheckIdCliente);
                            dal.SetInUsuarioMandante(userMan);
                        }
                    }
                }

                Buscar();
                divSearch.Visible  = true;
                divAddEdit.Visible = false;
            }
            catch (Exception ex)
            {
                lblInformacion.Text = ex.Message;
                mdlInformacion.Show();
            }
        }