/// <summary> /// busca el cliente 1 que es el consumidor final , el cliente por defecto /// </summary> private void buscarCliente() { N_Cliente ncliente = new N_Cliente(); //si el txt id de cliente esta vacio pone por defecto el valor uno del consumidor final if (string.IsNullOrEmpty(txtIdCliente.Text)) { txtIdCliente.Text = Convert.ToString(1); } E_Cliente cliente = ncliente.getOne(Convert.ToInt64(txtIdCliente.Text)); // si el cliete es null es que no lo ah encontrado entonce se pone por defecto consumidor final if (cliente == null) { cliente = ncliente.getOne(1); } txtIdCliente.Text = cliente.idCliente.ToString(); txtDescripcion.Text = cliente.descripcion; txtDireccion.Text = cliente.direccion; txtCuitDni.Text = cliente.dni.ToString(); if (cliente.boletinProtec) // si tiene boletin protectivo le muestra una cartel { MessageBox.Show("El Cliente Se Encuentra en el boletin Protectivo", "Boletin Protectivo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
//Insertar, Modifica y Elimina cliente (Procedimiento) #region Abm public int abmCliente(string pAccion, E_Cliente objE_Cliente) { int Resultado = 0; SqlCommand cmd = new SqlCommand("usp_Ventas_abmCliente", Conexion); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@Accion", pAccion); cmd.Parameters.AddWithValue("@clienteId", objE_Cliente.ClienteId); cmd.Parameters.AddWithValue("@nit", objE_Cliente.Nit); cmd.Parameters.AddWithValue("@nombres", objE_Cliente.Nombres); cmd.Parameters.AddWithValue("@apellidos", objE_Cliente.Apellidos); cmd.Parameters.AddWithValue("@telefono", objE_Cliente.Telefono); cmd.Parameters.AddWithValue("@direccion", objE_Cliente.Direccion); cmd.Parameters.AddWithValue("@email", objE_Cliente.Email); cmd.Parameters.AddWithValue("@sexo", objE_Cliente.Sexo); try { AbrirConexion(); Resultado = cmd.ExecuteNonQuery(); } catch (Exception e) { throw new Exception("Error al tratar de almacenar, Borrar o Modificar datos de Clientes", e); } finally { CerrarConexion(); cmd.Dispose(); } return(Resultado); }
protected void B_agregarcliente_Click(object sender, EventArgs e) { E_Cliente nuevo = new E_Cliente(); Dao_Cliente cliente = new Dao_Cliente(); ClientScriptManager cm = this.ClientScript; if (Double.Parse(TB_telefonocliente.Text) <= 99999999999) { nuevo.Nombre = TB_nombrecliente.Text; nuevo.Apellido = TB_apellidocliente.Text; nuevo.Telefono = Double.Parse(TB_telefonocliente.Text); nuevo.Direccion = TB_direccioncliente.Text; nuevo.Correo = TB_correocliente.Text; nuevo.Usuario = TB_usuario.Text; nuevo.Clave = TB_clave.Text; nuevo.Id_rol = Int32.Parse(DDL_rol.SelectedValue); cliente.insertarCliente(nuevo); cm.RegisterClientScriptBlock(this.GetType(), "", "<script type='text/javascript'>alert('Agregado correctamente');window.location=\"AgregarCliente.aspx\"</script>"); } else { cm.RegisterClientScriptBlock(this.GetType(), "", "<script type='text/javascript'>alert('Telefono muy extenso');</script>"); } }
public bool Editar(E_Cliente ModificarCliente) { try { SqlConnection Conexion = new SqlConnection(Properties.Settings.Default.Cadena_conexion); SqlCommand Comando = new SqlCommand(); Comando.CommandType = CommandType.StoredProcedure; Comando.CommandText = "Editar_clientes"; Comando.Parameters.AddWithValue("@Id_cliente", ModificarCliente.Id_cliente); Comando.Parameters.AddWithValue("@No_cedula", ModificarCliente.No_cedula); Comando.Parameters.AddWithValue("@Nombre", ModificarCliente.Nombre); Comando.Parameters.AddWithValue("@Apellido", ModificarCliente.Apellido); Comando.Parameters.AddWithValue("@Telefono", ModificarCliente.Telefono); Comando.Parameters.AddWithValue("@Direccion", ModificarCliente.Direccion); Comando.Parameters.AddWithValue("@Ciudad", ModificarCliente.Ciudad); Comando.Parameters.AddWithValue("@Email", ModificarCliente.Email); Comando.Connection = Conexion; Conexion.Open(); Comando.ExecuteNonQuery(); Conexion.Close(); return(true); } catch (Exception ex) { throw ex; } }
public List <E_Cliente> ListaBuscarCliente() { try { SqlConnection Conexion = new SqlConnection(Properties.Settings.Default.Cadena_conexion); SqlCommand Comando = new SqlCommand(); Comando.CommandType = CommandType.StoredProcedure; Comando.CommandText = "MostrarClientes"; Comando.Connection = Conexion; Conexion.Open(); SqlDataReader leer = Comando.ExecuteReader(); List <E_Cliente> Lista = new List <E_Cliente>(); while (leer.Read()) { E_Cliente FilaCliente = new E_Cliente(); FilaCliente.Id_cliente = leer["Id_cliente"].ToString(); FilaCliente.No_cedula = leer["No_cedula"].ToString(); FilaCliente.Nombre = leer["Nombre"].ToString(); FilaCliente.Apellido = leer["Apellido"].ToString(); FilaCliente.Telefono = Convert.ToInt32(leer["Telefono"].ToString()); FilaCliente.Direccion = leer["Direccion"].ToString(); FilaCliente.Ciudad = leer["Ciudad"].ToString(); FilaCliente.Email = leer["Email"].ToString(); Lista.Add(FilaCliente); } Conexion.Close(); return(Lista); } catch (Exception ex) { throw ex; } }
private void btn_eliminar_Click(object sender, EventArgs e) { try { if (dgv_clientes.SelectedRows.Count > 0) { txt_cedula.Tag = dgv_clientes.CurrentRow.Cells["Id_cliente"].Value.ToString(); if (MessageBox.Show("Quieres eliminar este cliente?", "Cliente", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { E_Cliente Elim = new E_Cliente(); N_Cliente nClientes = new N_Cliente(); Elim.Id_cliente = txt_cedula.Tag.ToString(); if (nClientes.Eliminar(Elim)) { MessageBox.Show("Se elimino correctamente", "Clientes", MessageBoxButtons.OK, MessageBoxIcon.Information); Cargargrid(); } } } } catch (Exception ex) { MessageBox.Show("error" + ex); } }
static public void AddCliente() { E_Cliente c = new E_Cliente(); BD_Cliente bdC = new BD_Cliente(); Console.WriteLine("Agregar Cliente"); //c.nombre = "nicolas"; //c.apellido = "bringa"; c.fecNac = Convert.ToDateTime("23/02/1991"); c.localidad.idLocalidad = 2; c.telefono = "1527371231"; c.direccion = "Los talas"; c.dni = 35471756; c.descripcion = "nuevocliente"; c.boletinProtec = false; BD_Cliente BD = new BD_Cliente(); BD.add_Cliente(c); Console.WriteLine("Cliente Agregado"); }
public bool AgregarMasivo(E_Cliente cliente1) { string query; MySqlCommand cmd; query = "insert into tbl_Cliente(codigo,cliente) values " + "(@codigo,@cliente)"; try { cmd = new MySqlCommand(query, MySQLConexion); cmd.Parameters.AddWithValue("@codigo", cliente1.Codigo); cmd.Parameters.AddWithValue("@cliente", cliente1.Cliente); cmd.ExecuteNonQuery(); } catch (Exception ex) { Mensaje = ex.Message; Desconectar(); return(false); } Desconectar(); return(true); }
protected void B_registro_Click(object sender, EventArgs e) { E_Cliente nuevo = new E_Cliente(); Dao_Cliente cliente = new Dao_Cliente(); ClientScriptManager cm = this.ClientScript; nuevo.Nombre = TB_nombre.Text; nuevo.Apellido = TB_apellido.Text; if (Double.Parse(TB_tl.Text) <= 99999999999) { nuevo.Telefono = Double.Parse(TB_tl.Text); nuevo.Correo = TB_correo.Text; nuevo.Direccion = TB_direccion.Text; nuevo.Usuario = TB_usuario.Text; nuevo.Clave = TB_clave.Text; nuevo.Id_rol = 2; cliente.Registro(nuevo); cm.RegisterClientScriptBlock(this.GetType(), "", "<script type='text/javascript'>alert('Regitrado correctamente');window.location=\"login.aspx\"</script>"); } else { cm.RegisterClientScriptBlock(this.GetType(), "", "<script type='text/javascript'>alert('Telefono incorrecto');</script>"); //Response.Redirect("loggin.aspx"); } }
//Modificar cliente mantenedor public bool Modificar(E_Cliente cliente1) { string query; MySqlCommand cmd; query = "update tbl_Cliente set codigo=@codigo,cliente=@cliente WHERE ID=@ID"; try { if (Conectar() == true) { cmd = new MySqlCommand(query, MySQLConexion); cmd.Parameters.AddWithValue("@ID", cliente1.ID); cmd.Parameters.AddWithValue("@codigo", cliente1.Codigo); cmd.Parameters.AddWithValue("@cliente", cliente1.Cliente); cmd.ExecuteNonQuery(); } } catch (Exception ex) { Mensaje = ex.Message; Desconectar(); return(false); } Desconectar(); return(true); }
public Int32 InsertCliente(E_Cliente ObjCliente) { Int32 ClienteID = 0; CD_Cliente objCD_Cliente = new CD_Cliente(AppSettings.GetConnectionString); ClienteID = objCD_Cliente.InsertCliente(ObjCliente); return(ClienteID); }
static public void getAllCliente() { E_Cliente c = new E_Cliente(); BD_Cliente bdC = new BD_Cliente(); c = bdC.getOne_Cliente(23); Console.WriteLine(c.boletinProtec); }
public void eliminarCliente(E_Cliente e_Cliente) { cmd = new SqlCommand("sp_eliminar_cliente", conex); cmd.CommandType = CommandType.StoredProcedure; conex.Open(); cmd.Parameters.AddWithValue("@ced", e_Cliente.ced); cmd.ExecuteNonQuery(); conex.Close(); }
private void ObtenerDatosControles() { ObjCliente = new E_Cliente(); if (TxtClienteID.Text != "") { ObjCliente.ClienteID = Convert.ToInt32(TxtClienteID.Text); } if (CboTipoCliente.SelectedIndex != -1) { ObjCliente.TipoClienteID = Convert.ToInt16(CboTipoCliente.SelectedValue.ToString()); } if (CboTipoDocumento.SelectedIndex != -1) { ObjCliente.IDTipoDocumento = Convert.ToInt16(CboTipoDocumento.SelectedValue.ToString()); } ObjCliente.NroDocumento = TxtNroDocumento.Text; ObjCliente.RazonSocial = RazonSocial; ObjCliente.Alias = TxtAlias.Text; ObjCliente.Contacto = TxtContacto.Text; ObjCliente.TelefonoFijo = TxtTelefonoFijo.Text; ObjCliente.TelefonoMovil = TxtTelefonoMovil.Text; ObjCliente.Fax = TxtFax.Text; ObjCliente.Email = TxtEmail.Text; ObjCliente.Direccion = Direccion; if (CboDistrito.SelectedIndex != -1) { ObjCliente.DistritoId = Convert.ToInt16(CboDistrito.SelectedValue.ToString()); } if (CboProvincia.SelectedIndex != -1) { ObjCliente.ProvinciaId = Convert.ToInt16(CboProvincia.SelectedValue.ToString()); } if (CboDepartamento.SelectedIndex != -1) { ObjCliente.DepartamentoId = Convert.ToInt16(CboDepartamento.SelectedValue.ToString()); } ObjCliente.Nombre1 = TxtNombre1.Text; ObjCliente.Nombre2 = TxtNombre2.Text; ObjCliente.Apellido1 = TxtApellido1.Text; ObjCliente.Apellido2 = TxtApellido2.Text; if (CboPais.SelectedIndex != -1) { ObjCliente.PaisId = Convert.ToInt16(CboPais.SelectedValue.ToString()); } ObjCliente.NombreVia = TxtNombreVia.Text; if (CboVia.SelectedIndex != -1) { ObjCliente.DireccionViaId = Convert.ToInt16(CboVia.SelectedValue.ToString()); } ObjCliente.DireccionNumero = TxtDireccionNumero.Text; ObjCliente.DireccionInterior = TxtDireccionInterior.Text; ObjCliente.Observaciones = TxtObservacion.Text; ObjCliente.UsuarioID = AppSettings.UserID; }
public bool Guardar(E_Cliente NuevoCliente) { try { D_Cliente DatosClientes = new D_Cliente(); return(DatosClientes.Guardar(NuevoCliente)); } catch (Exception ex) { throw ex; } }
public bool Editar(E_Cliente ModificarCliente) { try { D_Cliente DatosCliente = new D_Cliente(); return(DatosCliente.Editar(ModificarCliente)); } catch (Exception ex) { throw ex; } }
public void Recibir_Datos(E_Cliente obj) { txt_apellidos.Text = obj._APELLIDOS; txt_id.Text = obj._ID_CLIENTE.ToString(); txt_nombres.Text = obj._NOMBRES; txt_direccion.Text = obj._DIRECCION; txt_cedula.Text = obj._CEDULA; cb_estado.Text = obj._ESTADO; cb_sexo.Text = obj._SEXO; txt_telefono.Text = obj._TELEFONO; txt_celular.Text = obj._CELULAR; }
public bool Eliminar(E_Cliente EliminarCliente) { try { D_Cliente DatosClientes = new D_Cliente(); return(DatosClientes.Eliminar(EliminarCliente)); } catch (Exception ex) { throw ex; } }
public void UpdateCliente(E_Cliente ObjCliente, string Tipo) { SqlDatabase SqlClient = new SqlDatabase(connectionString); DbConnection tCnn; tCnn = SqlClient.CreateConnection(); tCnn.Open(); DbTransaction tran = tCnn.BeginTransaction(); try { DbCommand SqlCommand = SqlClient.GetStoredProcCommand("ventas.Usp_UpdateCliente"); SqlClient.AddInParameter(SqlCommand, "@ClienteID", SqlDbType.Int, ObjCliente.ClienteID); SqlClient.AddInParameter(SqlCommand, "@TipoClienteID", SqlDbType.Int, ObjCliente.TipoClienteID); SqlClient.AddInParameter(SqlCommand, "@IDTipoDocumento", SqlDbType.Int, ObjCliente.IDTipoDocumento); SqlClient.AddInParameter(SqlCommand, "@NroDocumento", SqlDbType.VarChar, ObjCliente.NroDocumento); SqlClient.AddInParameter(SqlCommand, "@RazonSocial", SqlDbType.VarChar, ObjCliente.RazonSocial); SqlClient.AddInParameter(SqlCommand, "@Alias", SqlDbType.VarChar, ObjCliente.Alias); SqlClient.AddInParameter(SqlCommand, "@Contacto", SqlDbType.VarChar, ObjCliente.Contacto); SqlClient.AddInParameter(SqlCommand, "@TelefonoFijo", SqlDbType.VarChar, ObjCliente.TelefonoFijo); SqlClient.AddInParameter(SqlCommand, "@TelefonoMovil", SqlDbType.VarChar, ObjCliente.TelefonoMovil); SqlClient.AddInParameter(SqlCommand, "@Fax", SqlDbType.VarChar, ObjCliente.Fax); SqlClient.AddInParameter(SqlCommand, "@Email", SqlDbType.VarChar, ObjCliente.Email); SqlClient.AddInParameter(SqlCommand, "@Direccion", SqlDbType.VarChar, ObjCliente.Direccion); SqlClient.AddInParameter(SqlCommand, "@DistritoId", SqlDbType.Int, ObjCliente.DistritoId); SqlClient.AddInParameter(SqlCommand, "@ProvinciaId", SqlDbType.Int, ObjCliente.ProvinciaId); SqlClient.AddInParameter(SqlCommand, "@DepartamentoId", SqlDbType.Int, ObjCliente.DepartamentoId); SqlClient.AddInParameter(SqlCommand, "@Nombre1", SqlDbType.VarChar, ObjCliente.Nombre1); SqlClient.AddInParameter(SqlCommand, "@Nombre2", SqlDbType.VarChar, ObjCliente.Nombre2); SqlClient.AddInParameter(SqlCommand, "@Apellido1", SqlDbType.VarChar, ObjCliente.Apellido1); SqlClient.AddInParameter(SqlCommand, "@Apellido2", SqlDbType.VarChar, ObjCliente.Apellido2); SqlClient.AddInParameter(SqlCommand, "@PaisId", SqlDbType.Int, ObjCliente.PaisId); SqlClient.AddInParameter(SqlCommand, "@NombreVia", SqlDbType.VarChar, ObjCliente.NombreVia); SqlClient.AddInParameter(SqlCommand, "@DireccionViaId", SqlDbType.Int, ObjCliente.DireccionViaId); SqlClient.AddInParameter(SqlCommand, "@DireccionNumero", SqlDbType.VarChar, ObjCliente.DireccionNumero); SqlClient.AddInParameter(SqlCommand, "@DireccionInterior", SqlDbType.VarChar, ObjCliente.DireccionInterior); SqlClient.AddInParameter(SqlCommand, "@Observaciones", SqlDbType.VarChar, ObjCliente.Observaciones); SqlClient.AddInParameter(SqlCommand, "@UsuarioID", SqlDbType.Int, ObjCliente.UsuarioID); SqlClient.AddInParameter(SqlCommand, "@Tipo", SqlDbType.Char, Tipo); SqlClient.ExecuteNonQuery(SqlCommand, tran); SqlCommand.Dispose(); tran.Commit(); tCnn.Close(); tCnn.Dispose(); } catch (Exception ex) { tran.Rollback(); throw new Exception(ex.Message); } }
private void buscarCliente(Int64 idCliente) { N_Cliente ncliente = new N_Cliente(); E_Cliente cliente = ncliente.getOne(Convert.ToInt64(idCliente)); txtIdCliente.Text = cliente.idCliente.ToString(); txtDescripcion.Text = cliente.descripcion; txtDireccion.Text = cliente.direccion; txtCuitDni.Text = cliente.dni.ToString(); if (cliente.boletinProtec) // si tiene boletin protectivo le muestra una cartel { MessageBox.Show("El Cliente Se Encuentra en el boletin Protectivo", "Boletin Protectivo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
public void EliminarRegistro(E_Cliente cliente) { SqlCommand SqlCmd = new SqlCommand("SPELIMINAR_CLIENTE", conectar) { CommandType = CommandType.StoredProcedure }; conectar.Open(); SqlCmd.Parameters.AddWithValue("@ClienteID", cliente.ClienteID); SqlCmd.ExecuteNonQuery(); conectar.Close(); }
public void Insertar_Actualizar() { try { if (Validar() == false) { return; } E_Cliente obj = new E_Cliente(); string mensaje = ""; obj._APELLIDOS = txt_apellidos.Text.Trim(); obj._CEDULA = txt_cedula.Text.Trim(); obj._CELULAR = txt_celular.Text.Trim(); obj._CREADO_POR = Funciones.Utilitario.Datos_Usuarios.USUARIO; obj._DIRECCION = txt_direccion.Text.Trim(); obj._ESTADO = cb_estado.Text; obj._FECHA_CREADO = DateTime.Now; obj._NOMBRES = txt_nombres.Text.Trim(); obj._SEXO = cb_sexo.Text; obj._TELEFONO = txt_telefono.Text.Trim(); if (txt_id.Text.Equals("")) { N_Cliente.Insertar_Datos(obj); mensaje = "Datos Insertados Con Exito"; } else { obj._ID_CLIENTE = Convert.ToInt32(txt_id.Text); N_Cliente.Actualizar_Datos(obj); mensaje = "Datos Actualizados Con Exito"; } Frm_Mant_Clientes frm = this.Owner as Frm_Mant_Clientes; if (frm != null) { frm.Consultar(); } this.Close(); Funciones.Utilitario.Mensaje_Informacion(mensaje); } catch (Exception ex) { Funciones.Utilitario.Mensaje_Error(ex.Message); } }
public void actualizarCliente(E_Cliente e_Cliente) { cmd = new SqlCommand("sp_actualizar_cliente", conex); cmd.CommandType = CommandType.StoredProcedure; conex.Open(); cmd.Parameters.AddWithValue("@nom", e_Cliente.nom); cmd.Parameters.AddWithValue("@ape", e_Cliente.ape); cmd.Parameters.AddWithValue("@dir", e_Cliente.dir); cmd.Parameters.AddWithValue("@tel", e_Cliente.tel); cmd.Parameters.AddWithValue("@ced", e_Cliente.ced); cmd.ExecuteNonQuery(); conex.Close(); }
/// <summary> /// Metodo que guarda un cliente /// si el ID de cliente es 0 crear una nuevo cliente /// sino modificara una cliente existente /// </summary> /// <param name="cliente"></param> /// <returns></returns> public string guardar(E_Cliente cliente) { string xRet; BD_Cliente bdCliente = new BD_Cliente(); if (cliente.idCliente == 0) // si el id de cliente es igual a 0 creara un nuevo cliente { xRet = bdCliente.add_Cliente(cliente); } else // sino modificara un cliente existente { xRet = bdCliente.set_Cliente(cliente); } return(xRet); }
public E_Cliente Obtener_Cliente(string ID) { string query; MySqlCommand cmd; query = "select * from tbl_cliente where id = @ID"; try { if (Conectar() == true) { cmd = new MySqlCommand(query, MySQLConexion); cmd.Parameters.AddWithValue("@ID", ID); MySqlDataReader reader = cmd.ExecuteReader(); E_Cliente cliente1; if (reader.Read()) { cliente1 = new E_Cliente { ID = Convert.ToString(reader["ID"]), Codigo = Convert.ToString(reader["codigo"]), Cliente = Convert.ToString(reader["cliente"]) }; Desconectar(); return(cliente1); } else { Desconectar(); return(null); } } else { Desconectar(); return(null); } } catch (Exception ex) { Mensaje = ex.Message; Desconectar(); return(null); } } //Fin funcion Lista
}//addCliente /// <summary> /// Devuelve todos los clientes de la base de datos /// si se la coleccion de clientes devuelve NULL /// no se puedo realizar la consulta /// </summary> /// <returns></returns> public List <E_Cliente> getAll_Clientes(string filtro) { List <E_Cliente> clientes = new List <E_Cliente>(); try { cn.Open(); cmd = new SqlCommand("getAllClientes", cn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("filtro", filtro); SqlDataReader oReader = cmd.ExecuteReader(); while (oReader.Read()) { E_Cliente cliente = new E_Cliente(); cliente.idCliente = Convert.ToInt64(oReader["idCliente"]); cliente.direccion = oReader["Direccion"].ToString(); cliente.descripcion = oReader["Descripcion"].ToString(); cliente.dni = Convert.ToInt32(oReader["Dni"]); cliente.localidad.idLocalidad = Convert.ToInt64(oReader["idLocalidad"]); cliente.localidad.nombre = oReader["Localidad"].ToString(); cliente.telefono = oReader["Telefono"].ToString(); cliente.boletinProtec = Convert.ToBoolean(oReader["BoletinProtec"]); if (oReader["FecNac"] != DBNull.Value) { cliente.fecNac = Convert.ToDateTime(oReader["FecNac"]); } clientes.Add(cliente); } } catch (Exception) { clientes = null; } finally { if (cn.State == ConnectionState.Open) { cn.Close(); } } return(clientes); }//getAll_Clientes
void ModificarCliente() { N_Cliente cliente1 = new N_Cliente(); E_Cliente cliente2 = new E_Cliente(); cliente2.ID = lblIDCliente.Text; cliente2.Codigo = txtCodigoCliente.Text; cliente2.Cliente = txtDescripcionCliente.Text; if (cliente1.Modificar(cliente2) == true) { dgvLista.DataSource = cliente1.Lista(); } else { MessageBox.Show("Error: No se pudo modificar el registro", "Modificar"); } }
}//delete_Cliente /// <summary> /// Devuelve un cliente /// </summary> /// <param name="idCliente"></param> /// <returns></returns> public E_Cliente getOne_Cliente(Int64 idCliente) { E_Cliente cliente = null; try { cn.Open(); cmd = new SqlCommand("getOneCliente", cn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@idCliente", idCliente); SqlDataReader oReader = cmd.ExecuteReader(); while (oReader.Read()) { cliente = new E_Cliente(); cliente.idCliente = Convert.ToInt64(oReader["idCliente"]); cliente.direccion = oReader["Direccion"].ToString(); cliente.descripcion = oReader["Descripcion"].ToString(); cliente.dni = Convert.ToInt32(oReader["Dni"]); cliente.localidad.idLocalidad = Convert.ToInt64(oReader["idLocalidad"]); cliente.localidad.nombre = oReader["Localidad"].ToString(); cliente.telefono = oReader["Telefono"].ToString(); cliente.boletinProtec = Convert.ToBoolean(oReader["BoletinProtec"]); if (oReader["FecNac"] != DBNull.Value) { cliente.fecNac = Convert.ToDateTime(oReader["FecNac"]); } cliente.observacion = oReader["observacion"].ToString(); cliente.mail = oReader["Mail"].ToString(); cliente.localidad.provincia.IdProvincia = Convert.ToInt16(oReader["idProvincia"]); } } catch (Exception) { cliente = null; } finally { if (cn.State == ConnectionState.Open) { cn.Close(); } } return(cliente); }//getOneCliente
public Int32 InsertCliente(E_Cliente ObjCliente) { try { Int32 ClienteID = 0; SqlDatabase SqlClient = new SqlDatabase(connectionString); DbCommand SqlCommand = SqlClient.GetStoredProcCommand("ventas.Usp_InsertCliente"); SqlClient.AddInParameter(SqlCommand, "@TipoClienteID", SqlDbType.Int, ObjCliente.TipoClienteID); SqlClient.AddInParameter(SqlCommand, "@IDTipoDocumento", SqlDbType.Int, ObjCliente.IDTipoDocumento); SqlClient.AddInParameter(SqlCommand, "@NroDocumento", SqlDbType.VarChar, ObjCliente.NroDocumento); SqlClient.AddInParameter(SqlCommand, "@RazonSocial", SqlDbType.VarChar, ObjCliente.RazonSocial); SqlClient.AddInParameter(SqlCommand, "@Alias", SqlDbType.VarChar, ObjCliente.Alias); SqlClient.AddInParameter(SqlCommand, "@Contacto", SqlDbType.VarChar, ObjCliente.Contacto); SqlClient.AddInParameter(SqlCommand, "@TelefonoFijo", SqlDbType.VarChar, ObjCliente.TelefonoFijo); SqlClient.AddInParameter(SqlCommand, "@TelefonoMovil", SqlDbType.VarChar, ObjCliente.TelefonoMovil); SqlClient.AddInParameter(SqlCommand, "@Fax", SqlDbType.VarChar, ObjCliente.Fax); SqlClient.AddInParameter(SqlCommand, "@Email", SqlDbType.VarChar, ObjCliente.Email); SqlClient.AddInParameter(SqlCommand, "@Direccion", SqlDbType.VarChar, ObjCliente.Direccion); SqlClient.AddInParameter(SqlCommand, "@DistritoId", SqlDbType.Int, ObjCliente.DistritoId); SqlClient.AddInParameter(SqlCommand, "@ProvinciaId", SqlDbType.Int, ObjCliente.ProvinciaId); SqlClient.AddInParameter(SqlCommand, "@DepartamentoId", SqlDbType.Int, ObjCliente.DepartamentoId); SqlClient.AddInParameter(SqlCommand, "@Nombre1", SqlDbType.VarChar, ObjCliente.Nombre1); SqlClient.AddInParameter(SqlCommand, "@Nombre2", SqlDbType.VarChar, ObjCliente.Nombre2); SqlClient.AddInParameter(SqlCommand, "@Apellido1", SqlDbType.VarChar, ObjCliente.Apellido1); SqlClient.AddInParameter(SqlCommand, "@Apellido2", SqlDbType.VarChar, ObjCliente.Apellido2); SqlClient.AddInParameter(SqlCommand, "@PaisId", SqlDbType.Int, ObjCliente.PaisId); SqlClient.AddInParameter(SqlCommand, "@NombreVia", SqlDbType.VarChar, ObjCliente.NombreVia); SqlClient.AddInParameter(SqlCommand, "@DireccionViaId", SqlDbType.Int, ObjCliente.DireccionViaId); SqlClient.AddInParameter(SqlCommand, "@DireccionNumero", SqlDbType.VarChar, ObjCliente.DireccionNumero); SqlClient.AddInParameter(SqlCommand, "@DireccionInterior", SqlDbType.VarChar, ObjCliente.DireccionInterior); SqlClient.AddInParameter(SqlCommand, "@Observaciones", SqlDbType.VarChar, ObjCliente.Observaciones); SqlClient.AddInParameter(SqlCommand, "@UsuarioID", SqlDbType.Int, ObjCliente.UsuarioID); SqlCommand.CommandTimeout = 180; ClienteID = Convert.ToInt32(SqlClient.ExecuteScalar(SqlCommand)); return ClienteID; } catch (Exception ex) { throw new Exception(ex.Message); } }
public void EditarRegistro(E_Cliente cliente) { SqlCommand SqlCmd = new SqlCommand("SPEDITAR_CLIENTE", conectar) { CommandType = CommandType.StoredProcedure }; conectar.Open(); SqlCmd.Parameters.AddWithValue("@ClienteID", cliente.ClienteID); SqlCmd.Parameters.AddWithValue("@AgenteDeInmobiliariaID", cliente.AgenteDeInmobiliariaID); SqlCmd.Parameters.AddWithValue("@Nombre", cliente.Nombre); SqlCmd.Parameters.AddWithValue("@DNI", cliente.DNI); SqlCmd.Parameters.AddWithValue("@Telefono", cliente.Telefono); SqlCmd.ExecuteNonQuery(); conectar.Close(); }