protected void btnEditar_Click(object sender, EventArgs e) { //Recorre Grid buscando chk foreach (GridViewRow row in ClientesGridView.Rows) { //busca el la fila if (row.RowType == DataControlRowType.DataRow) { //si esta checkeado instancia las propiedades del objeto CheckBox chkRow = (row.Cells[0].FindControl("chkRow") as CheckBox); if (chkRow.Checked) { //Se instancia objeto Obj_Clientes_DAL = new Cls_Clientes_DAL(); //Secion tipo Editar Session["tipo"] = BD.Actualizar; Obj_Clientes_DAL.sIdCliente = Convert.ToInt16(row.Cells[0].Text); string sTipoCliente = row.Cells[1].Text; Obj_Clientes_DAL.sIdPersona = row.Cells[2].Text; //Sesion estado lleva el objeto Session["Clientes"] = Obj_Clientes_DAL; Session["sTipoCliente"] = sTipoCliente; Response.Redirect(pantallaMantenimiento, false); } } } }
protected void btnEliminar_Click(object sender, EventArgs e) { Obj_Clientes_DAL = new Cls_Clientes_DAL(); //Recorre Grid buscando chk foreach (GridViewRow row in ClientesGridView.Rows) { //busca el la fila if (row.RowType == DataControlRowType.DataRow) { //si esta checkeado instancia las propiedades del objeto CheckBox chkRow = (row.Cells[0].FindControl("chkRow") as CheckBox); if (chkRow.Checked) { Obj_Clientes_DAL.sIdCliente = Convert.ToInt16(row.Cells[0].Text); //llamado metodo eliminar cliente Obj_Clientes_BLL.crudCliente(ref Obj_Clientes_DAL, BD.Eliminar);// eliminar cliente } } } if (Obj_Clientes_DAL.sMsjError == string.Empty) { this.errorMensaje.InnerHtml = "Clientes Eliminado con exito."; this.BindGrid(); } else { this.errorMensaje.InnerHtml = "Se presento un error a la hora de Eliminar Clientes."; this.BindGrid(); } }
//Metodo Listar private void BindGrid() { //Instancia del Objeto Obj_Clientes_DAL = new Cls_Clientes_DAL(); if (this.txtFiltrar.Value.Trim() == string.Empty) { Obj_Clientes_BLL.crudCliente(ref Obj_Clientes_DAL, BD.Listar); } else { Obj_Clientes_DAL.sIdPersona = this.txtFiltrar.Value.Trim(); //Llamado del metodo filtrar clientes Obj_Clientes_BLL.crudCliente(ref Obj_Clientes_DAL, BD.FiltrarVista); } if (Obj_Clientes_DAL.sMsjError == string.Empty) { //Se cargan los datos con DS con la instancia del DAL this.ClientesGridView.DataSource = Obj_Clientes_DAL.DS.Tables[0]; this.ClientesGridView.DataBind(); } else { this.errorMensaje.InnerHtml = "Se presento un error a la hora de listar los Clientes."; this.BindGrid(); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { CargaTipoCliente(); CargarPersona(); txtidcliente.Disabled = true; if ((BD)Session["tipo"] == BD.Actualizar) { Obj_Clientes_DAL = (Cls_Clientes_DAL)Session["Clientes"]; this.mantenimiento.InnerHtml = "Modificacion de Clientes"; this.DropDownTClientes.Value = Session["sTipoCliente"].ToString(); this.txtidcliente.Value = Obj_Clientes_DAL.sIdCliente.ToString(); this.txtidpersona.Value = Obj_Clientes_DAL.sIdPersona.ToString(); this.txtidpersona.Disabled = true; DropDownPersona.Value = Obj_Clientes_DAL.sIdPersona; DropDownPersona.Disabled = true; } else { lblidCliente.Visible = false; this.txtidcliente.Visible = false; this.mantenimiento.InnerHtml = "Nuevos de Clientes"; this.txtidcliente.Value = string.Empty; this.txtidpersona.Value = string.Empty; txtidpersona.Visible = false; } } }
private string returnaIdCliente() { Cls_Clientes_BLL Obj_Cliente_BLL = new Cls_Clientes_BLL(); Cls_Clientes_DAL Obj_Cliente_DAL = new Cls_Clientes_DAL(); Obj_Cliente_DAL.sIdPersona = this.cedulaRG.Value.Trim(); Obj_Cliente_DAL.sIdCliente = short.MinValue; Obj_Cliente_DAL.bIdTipoCliente = byte.MinValue; Obj_Cliente_BLL.crudCliente(ref Obj_Cliente_DAL, BD.Filtrar); return(Obj_Cliente_DAL.DS.Tables[0].Rows[0][0].ToString()); }
public void crudCliente(ref Cls_Clientes_DAL Obj_Clientes_DAL, BD Accion) { // Se instancia el Objeto de CatalogosMantenimientosClient (WCF) CatalogosMantenimientosClient Obj_Clientes_Client = new CatalogosMantenimientosClient(); try { // Se abre la conexion al servicio Obj_Clientes_Client.Open(); // Se cargan trae el DataTable y se carga al Obj_Estado_DAL string sMsjError = string.Empty; switch (Accion) { case BD.Actualizar: Obj_Clientes_Client.actualizarClientes(Obj_Clientes_DAL.sIdCliente, Obj_Clientes_DAL.bIdTipoCliente, Obj_Clientes_DAL.sIdPersona, ref sMsjError); break; case BD.Eliminar: Obj_Clientes_Client.eliminarClientes(Obj_Clientes_DAL.sIdCliente, ref sMsjError); break; case BD.Filtrar: Obj_Clientes_DAL.DS.Tables.Add(Obj_Clientes_Client.filtrarClientes(Obj_Clientes_DAL.sIdCliente, Obj_Clientes_DAL.bIdTipoCliente, Obj_Clientes_DAL.sIdPersona, ref sMsjError)); break; case BD.Insertar: Obj_Clientes_Client.insertarClientes(Obj_Clientes_DAL.bIdTipoCliente, Obj_Clientes_DAL.sIdPersona, ref sMsjError); break; case BD.Listar: Obj_Clientes_DAL.DS.Tables.Add(Obj_Clientes_Client.listarClientes(ref sMsjError)); break; case BD.FiltrarVista: Obj_Clientes_DAL.DS.Tables.Add(Obj_Clientes_Client.filtrarClientesV(Obj_Clientes_DAL.sIdCliente, string.Empty, Obj_Clientes_DAL.sIdPersona, string.Empty, string.Empty, string.Empty, ref sMsjError)); break; default: break; } Obj_Clientes_DAL.sMsjError = sMsjError; } catch (Exception ex) { Obj_Clientes_DAL.sMsjError = ex.Message.ToString(); } finally { if (Obj_Clientes_Client.State == System.ServiceModel.CommunicationState.Opened) { Obj_Clientes_Client.Close(); } } }
protected void Registrarse(object sender, EventArgs e) { Cls_Persona_DAL Obj_Persona_DAL = new Cls_Persona_DAL(); Cls_Persona_BLL Obj_Persona_BLL = new Cls_Persona_BLL(); Obj_Persona_DAL.sIdPersona = this.cedulaRG.Value.ToString().Trim(); Obj_Persona_DAL.sNombre = this.nombreRG.Value.ToString().Trim(); Obj_Persona_DAL.sDireccion = this.direccionRG.Value.ToString().Trim(); Obj_Persona_DAL.bIdRol = (byte)Rol.Cliente; Obj_Persona_BLL.crudPersona(ref Obj_Persona_DAL, BD.Insertar); Cls_Telefonos_DAL Obj_Telefonos_DAL = new Cls_Telefonos_DAL(); Cls_Telefono_BLL Obj_Telefonos_BLL = new Cls_Telefono_BLL(); Obj_Telefonos_DAL.sTelefono = this.telefonoRG.Value.ToString().Trim(); Obj_Telefonos_DAL.sIdPersona = this.cedulaRG.Value.ToString().Trim(); Obj_Telefonos_BLL.crudTelefono(ref Obj_Telefonos_DAL, BD.Insertar);// insertar Cls_Correos_DAL Obj_Correo_DAL = new Cls_Correos_DAL(); Cls_Correos_BLL Obj_Correo_BLL = new Cls_Correos_BLL(); Obj_Correo_DAL.sIdPersona = this.cedulaRG.Value.ToString().Trim(); Obj_Correo_DAL.sCorreo = this.emailRG.Value.ToString().Trim(); Obj_Correo_BLL.crudCorreos(ref Obj_Correo_DAL, BD.Insertar);// insertar Cls_Clientes_DAL Obj_Cliente_DAL = new Cls_Clientes_DAL(); Cls_Clientes_BLL Obj_Cliente_BLL = new Cls_Clientes_BLL(); Obj_Cliente_DAL.sIdPersona = this.cedulaRG.Value.ToString().Trim(); Obj_Cliente_DAL.bIdTipoCliente = (byte)Cliente.Socio; Obj_Cliente_BLL.crudCliente(ref Obj_Cliente_DAL, BD.Insertar); Cls_Usuario_DAL Obj_Usuario_DAL = new Cls_Usuario_DAL(); Cls_Usuario_BLL Obj_Usuario_BLL = new Cls_Usuario_BLL(); Obj_Usuario_DAL.SIdUsuario = this.cedulaRG.Value.ToString().Trim(); Obj_Usuario_DAL.SIdPersona = this.cedulaRG.Value.ToString().Trim(); Obj_Usuario_DAL.SContrasena = this.passwordRG.Value.ToString().Trim(); Obj_Usuario_BLL.Encripta(ref Obj_Usuario_DAL); Obj_Usuario_BLL.crudUsuario(ref Obj_Usuario_DAL, BD.Insertar); Obj_Persona_DAL.sIdPersona = this.cedulaRG.Value.ToString().Trim(); Obj_Persona_BLL.crudPersona(ref Obj_Persona_DAL, BD.Filtrar); Session["Login"] = Obj_Persona_DAL; Server.Transfer("IndexCliente.aspx"); }
protected void btnGuardar_Click(object sender, EventArgs e) { Obj_Clientes_DAL = new Cls_Clientes_DAL(); Obj_Clientes_DAL.bIdTipoCliente = Convert.ToByte(DropDownTClientes.Value); //Obj_Clientes_DAL.sIdPersona = txtidpersona.Value.Trim(); Obj_Clientes_DAL.sIdPersona = DropDownPersona.Value; if ((BD)Session["tipo"] == BD.Actualizar) { Obj_Clientes_DAL.sIdCliente = Convert.ToInt16(txtidcliente.Value); Obj_Clientes_BLL.crudCliente(ref Obj_Clientes_DAL, BD.Actualizar); } else { Obj_Clientes_BLL.crudCliente(ref Obj_Clientes_DAL, BD.Insertar); } Response.Redirect(pantallaMantenimiento, true); }