public void ActualizarHorasExtra(Cajero _cajero, DateTime _fecha, int _minutosExtra) { SqlConnection cnn = new SqlConnection(Conexion.CnnLogueo()); SqlCommand cmd = new SqlCommand("ActualizarHorasExtra", cnn); cmd.CommandType = CommandType.StoredProcedure; SqlParameter retorno = new SqlParameter("@Retorno", SqlDbType.Int); retorno.Direction = ParameterDirection.ReturnValue; cmd.Parameters.Add(retorno); cmd.Parameters.AddWithValue("@Cajero", _cajero.Ci); cmd.Parameters.AddWithValue("@Fecha", _fecha.Year.ToString() + "/" + _fecha.Month.ToString() + "/" + _fecha.Day.ToString()); cmd.Parameters.AddWithValue("@MinutosExtra", _minutosExtra); try { cnn.Open(); cmd.ExecuteNonQuery(); if ((int)retorno.Value == -1) { throw new Exception("Error al registrar horas extra"); } } catch (Exception ex) { throw new Exception(ex.Message); } finally { cnn.Close(); } }
public DateTime ChequearFacturaPaga(string[] _factura) { DateTime _fecha = new DateTime(9999, 1, 1); using (SqlConnection cnn = new SqlConnection(Conexion.CnnLogueo())) { using (SqlCommand cmd = new SqlCommand("ChequearFacturaPaga", cnn)) { cmd.CommandType = CommandType.StoredProcedure; string x = _factura[2].Substring(0, 2) + "/" + _factura[2].Substring(2, 2) + "/" + _factura[2].Substring(4, 4); cmd.Parameters.AddWithValue("@CodigoEmpresa", _factura[0]); cmd.Parameters.AddWithValue("@TipoContrato", _factura[1]); cmd.Parameters.AddWithValue("@FechaVencimiento", _factura[2].Substring(0, 2) + "/" + _factura[2].Substring(2, 2) + "/" + _factura[2].Substring(4, 4)); cmd.Parameters.AddWithValue("@CodigoCliente", _factura[3]); cmd.Parameters.AddWithValue("@Monto", _factura[4]); try { cnn.Open(); using (SqlDataReader reader = cmd.ExecuteReader()) { if (reader.HasRows) { while (reader.Read()) { _fecha = (DateTime)reader["Fecha"]; } } } } catch (Exception ex) { throw new Exception(ex.Message); } } } return(_fecha); }
public List <Contrato> ListarTodosLosContratos() { List <Contrato> _Contratos = null; using (SqlConnection cnn = new SqlConnection(Conexion.CnnLogueo())) { using (SqlCommand cmd = new SqlCommand("ListarTodosLosContratos", cnn)) { cmd.CommandType = CommandType.StoredProcedure; try { cnn.Open(); using (SqlDataReader reader = cmd.ExecuteReader()) { if (reader.HasRows) { _Contratos = new List <Contrato>(); while (reader.Read()) { Contrato _Contrato = new Contrato(); _Contrato.Empresa = FabricaP.GetPEmpresa().BuscarEmpresa((int)reader["CodEmpresa"]); _Contrato.CodContrato = Convert.ToInt32(reader["CodTipo"]); _Contrato.NomContrato = (string)reader["Nombre"]; _Contratos.Add(_Contrato); } } } } catch (Exception ex) { throw new Exception(ex.Message); } } } return(_Contratos); }
public Empresa BuscarEmpresa(int _codigo) { Empresa _Empresa = null; using (SqlConnection cnn = new SqlConnection(Conexion.CnnLogueo())) { using (SqlCommand cmd = new SqlCommand("BuscarEmpresa", cnn)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@Codigo", _codigo); try { cnn.Open(); using (SqlDataReader reader = cmd.ExecuteReader()) { if (reader.HasRows) { while (reader.Read()) { _Empresa = new Empresa((long)reader["Rut"], Convert.ToInt32(reader["Codigo"]), (string)reader["Nombre"], (string)reader["DirFiscal"], Convert.ToInt64(reader["Tel"])); } } } } catch (Exception ex) { throw new Exception(ex.Message); } return(_Empresa); } } }
public Gerente BuscarGerenteLogueo(string usu) { Gerente _gerente = null; using (SqlConnection cnn = new SqlConnection(Conexion.CnnLogueo())) { using (SqlCommand cmd = new SqlCommand("BuscarGerenteLogueo", cnn)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@Usuario", usu); try { cnn.Open(); using (SqlDataReader reader = cmd.ExecuteReader()) { if (reader.HasRows) { reader.Read(); _gerente = new Gerente(Convert.ToInt32(reader["Ci"]), (string)reader["Usuario"], (string)reader["Clave"], (string)reader["NomCompleto"], (string)reader["Email"]); } } } catch (Exception ex) { throw new Exception(ex.Message); } } } return(_gerente); }