protected void btnGrabar_Click(object sender, EventArgs e) { IgvDTO obj = new IgvDTO(); if (this.txtId.Text == "") { obj.Igv = Convert.ToDecimal(this.txtIGV.Text); obj.Descripcion = this.txtDescripcion.Text; if (this.txtFechaInicial.Text != "") obj.FechaInicio = AppUtilidad.stringToDateTime(this.txtFechaInicial.Text,"DD/MM/YYYY"); if (this.txtFechaFinal.Text != "") obj.FechaFin = AppUtilidad.stringToDateTime(this.txtFechaFinal.Text, "DD/MM/YYYY"); int id = objIgvDAO.Agregar(obj); this.txtId.Text = id.ToString(); this.panRegistro.Visible = true; this.panLista.Visible = false; this.btnGrabar.Visible = false; this.btnActualizar.Visible = true; this.btnEliminar.Visible = true; this.btnCancelar.Visible = true; } }
protected void btnEliminar_Click(object sender, EventArgs e) { IgvDTO obj = new IgvDTO(); if (this.txtId.Text != "") { objIgvDAO.Eliminar(Convert.ToInt32(this.txtId.Text)); this.txtId.Text = ""; this.txtIGV.Text = ""; this.txtDescripcion.Text = ""; this.txtFechaInicial.Text = ""; this.txtFechaFinal.Text = ""; } this.panRegistro.Visible = false; this.panLista.Visible = true; this.btnGrabar.Visible = false; this.btnActualizar.Visible = false; this.btnEliminar.Visible = false; this.btnCancelar.Visible = false; Listar(); }
protected void btnActualizar_Click(object sender, EventArgs e) { IgvDTO obj = new IgvDTO(); obj = objIgvDAO.ListarPorClave(Convert.ToInt32(this.txtId.Text)); obj.Igv = Convert.ToDecimal(this.txtIGV.Text); obj.Descripcion = this.txtDescripcion.Text; if (this.txtFechaInicial.Text != "") obj.FechaInicio = AppUtilidad.stringToDateTime(this.txtFechaInicial.Text, "DD/MM/YYYY"); if (this.txtFechaFinal.Text != "") obj.FechaFin = AppUtilidad.stringToDateTime(this.txtFechaFinal.Text, "DD/MM/YYYY"); objIgvDAO.Actualizar(obj); }
public void Actualizar(IgvDTO obj) { Database db = DatabaseFactory.CreateDatabase("ApplicationConnectionString"); DbCommand dbCommand = db.GetStoredProcCommand(C_ACTUALIZAR); db.AddInParameter(dbCommand, "@id_registro", DbType.Int32, obj.IdRegistro); db.AddInParameter(dbCommand, "@igv", DbType.Decimal, obj.Igv); db.AddInParameter(dbCommand, "@descripcion", DbType.String, obj.Descripcion); if (obj.FechaInicio.Year == 1) db.AddInParameter(dbCommand, "@fecha_inicio", DbType.DateTime, null); else db.AddInParameter(dbCommand, "@fecha_inicio", DbType.DateTime, obj.FechaInicio); if (obj.FechaFin.Year == 1) db.AddInParameter(dbCommand, "@fecha_fin", DbType.DateTime, null); else db.AddInParameter(dbCommand, "@fecha_fin", DbType.DateTime, obj.FechaFin); db.ExecuteNonQuery(dbCommand); }
public int Agregar(IgvDTO obj) { Database db = DatabaseFactory.CreateDatabase("ApplicationConnectionString"); DbCommand dbCommand = db.GetStoredProcCommand(C_AGREGAR); db.AddInParameter(dbCommand, "@igv", DbType.Decimal, obj.Igv); db.AddInParameter(dbCommand, "@descripcion", DbType.String, obj.Descripcion); if (obj.FechaInicio.Year == 1) db.AddInParameter(dbCommand, "@fecha_inicio", DbType.DateTime, null); else db.AddInParameter(dbCommand, "@fecha_inicio", DbType.DateTime, obj.FechaInicio); if (obj.FechaFin.Year == 1) db.AddInParameter(dbCommand, "@fecha_fin", DbType.DateTime, null); else db.AddInParameter(dbCommand, "@fecha_fin", DbType.DateTime, obj.FechaFin); int id = Convert.ToInt32(db.ExecuteScalar(dbCommand)); return id; }
protected void gvLista_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "Seleccionar") { IgvDTO obj = new IgvDTO(); try { int Id = int.Parse(e.CommandArgument.ToString()); this.txtId.Text = Id.ToString(); obj = objIgvDAO.ListarPorClave(Convert.ToInt32(this.txtId.Text)); this.txtIGV.Text = obj.Igv.ToString(); this.txtDescripcion.Text = obj.Descripcion; if (obj.FechaInicio.Year == 1) this.txtFechaInicial.Text = ""; else this.txtFechaInicial.Text = obj.FechaInicio.ToString("dd/MM/yyyy"); if (obj.FechaFin.Year == 1) this.txtFechaFinal.Text = ""; else this.txtFechaFinal.Text = obj.FechaInicio.ToString("dd/MM/yyyy"); this.panRegistro.Visible = true; this.panLista.Visible = false; this.btnGrabar.Visible = false; this.btnActualizar.Visible = true; this.btnEliminar.Visible = true; this.btnCancelar.Visible = true; } catch (Exception err) { // this.lblMensaje.Text = err.Message.ToString(); } } }
public List<IgvDTO> Listar() { List<IgvDTO> Lista = new List<IgvDTO>(); Database db = DatabaseFactory.CreateDatabase("ApplicationConnectionString"); DbCommand dbCommand = db.GetStoredProcCommand(C_LISTAR); using (IDataReader dr = db.ExecuteReader(dbCommand)) { while (dr.Read()) { IgvDTO obj = new IgvDTO(); if (dr["id_registro"] != System.DBNull.Value) obj.IdRegistro = (int)dr["id_registro"]; if (dr["igv"] != System.DBNull.Value) obj.Igv = (Decimal)dr["igv"]; if (dr["descripcion"] != System.DBNull.Value) obj.Descripcion = (string)dr["descripcion"]; if (dr["fecha_inicio"] != System.DBNull.Value) obj.FechaInicio = (DateTime)dr["fecha_inicio"]; if (dr["fecha_fin"] != System.DBNull.Value) obj.FechaFin = (DateTime)dr["fecha_fin"]; Lista.Add(obj); } } return Lista; }
public IgvDTO ListarPorClave(int IdRegistro) { IgvDTO obj = null; Database db = DatabaseFactory.CreateDatabase("ApplicationConnectionString"); DbCommand dbCommand = db.GetStoredProcCommand(C_LISTAR_POR_CLAVE); db.AddInParameter(dbCommand, "@id_registro", DbType.Int32, IdRegistro); using (IDataReader dr = db.ExecuteReader(dbCommand)) { if (dr.Read()) { obj = new IgvDTO(); if (dr["id_registro"] != System.DBNull.Value) obj.IdRegistro = (int)dr["id_registro"]; if (dr["igv"] != System.DBNull.Value) obj.Igv = (Decimal)dr["igv"]; if (dr["descripcion"] != System.DBNull.Value) obj.Descripcion = (string)dr["descripcion"]; if (dr["fecha_inicio"] != System.DBNull.Value) obj.FechaInicio = (DateTime)dr["fecha_inicio"]; if (dr["fecha_fin"] != System.DBNull.Value) obj.FechaFin = (DateTime)dr["fecha_fin"]; } } return obj; }
public IgvDTO ListarIGVVigente(DateTime dtmFecha) { IgvDTO obj = null; Database db = DatabaseFactory.CreateDatabase("ApplicationConnectionString"); DbCommand dbCommand = db.GetSqlStringCommand(C_LISTAR_IGV_VIGENTE_FECHA); string strFecha = dtmFecha.ToShortTimeString(); db.AddInParameter(dbCommand, "@fecha", DbType.DateTime, dtmFecha); using (IDataReader dr = db.ExecuteReader(dbCommand)) { while (dr.Read()) { obj = new IgvDTO(); obj.Igv = (decimal)dr["igv"]; } } return obj; }
public IgvDTO ListarIGVVigente() { IgvDTO obj = null; Database db = DatabaseFactory.CreateDatabase("ApplicationConnectionString"); DbCommand dbCommand = db.GetSqlStringCommand(C_LISTAR_IGV_VIGENTE); using (IDataReader dr = db.ExecuteReader(dbCommand)) { while (dr.Read()) { obj = new IgvDTO(); obj.Igv = (decimal)dr["igv"]; } } return obj; }