private void FillDetalle(short DescuentoID) { ClearFormDetalle(); cmpToday.Enabled = false; eDescuento oDescuento = cCRM.Descuento_item(DescuentoID); if (oDescuento != null) { txtNombre.Text = oDescuento.nombre; txtDescripcion.Text = oDescuento.descripcion; txtDescuentoValor.Text = oDescuento.descuento_valor.ToString("0.00"); try { drpTipoDescuento.SelectedValue = oDescuento.descuento_tipo; } catch { lblFormError.Text = "Descuento tipo = " + oDescuento.descuento_tipo; } rblClientesFerreyros.SelectedValue = oDescuento.regla_clientes_ferreyros? "1": "0"; txtFechaInicio.Text = oDescuento.regla_fecha_inicio.ToShortDateString(); txtFechaFin.Text = oDescuento.regla_fecha_fin.ToShortDateString(); VerifyValidators(); } }
public List <eDescuento> GetList_Activo() { SqlCommand cmd = new SqlCommand("usp_tb_descuentoActivoList"); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@fecha_actual", SqlDbType.DateTime).Value = DateTime.Now; SqlDataReader reader = ExecuteReader(cmd); List <eDescuento> lista = new List <eDescuento>(); while (reader.Read()) { eDescuento oDescuento = new eDescuento(); oDescuento.id_descuento = reader.GetInt32(0); oDescuento.nombre = reader.GetString(1); oDescuento.descripcion = !reader[2].Equals(DBNull.Value) ? reader.GetString(2) : string.Empty; oDescuento.descuento_tipo = reader.GetString(3); oDescuento.descuento_valor = reader.GetDecimal(4); oDescuento.regla_clientes_ferreyros = !reader[5].Equals(DBNull.Value) ? reader.GetBoolean(5) : false; oDescuento.regla_fecha_inicio = !reader[6].Equals(DBNull.Value) ? reader.GetDateTime(6) : DefaultDateTime; oDescuento.regla_fecha_fin = !reader[7].Equals(DBNull.Value) ? reader.GetDateTime(7) : DefaultDateTime; oDescuento.regla_monto_minimo = !reader[8].Equals(DBNull.Value) ? reader.GetDecimal(8) : 0; oDescuento.fecha_creacion = !reader[9].Equals(DBNull.Value) ? reader.GetDateTime(9) : DefaultDateTime; oDescuento.fecha_actualizacion = !reader[10].Equals(DBNull.Value) ? reader.GetDateTime(10) : DefaultDateTime; lista.Add(oDescuento); } reader.Close(); return(lista); }
public eDescuento GetItem(int id_descuento) { SqlCommand cmd = new SqlCommand("usp_tb_descuentoSelect"); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@id_descuento", SqlDbType.Int).Value = id_descuento; SqlDataReader reader = ExecuteReader(cmd); eDescuento oDescuento = null; if (reader.Read()) { oDescuento = new eDescuento(); oDescuento.id_descuento = reader.GetInt32(0); oDescuento.nombre = reader.GetString(1); oDescuento.descripcion = !reader[2].Equals(DBNull.Value)? reader.GetString(2): string.Empty; oDescuento.descuento_tipo = reader.GetString(3); oDescuento.descuento_valor = reader.GetDecimal(4); oDescuento.regla_clientes_ferreyros = !reader[5].Equals(DBNull.Value) ? reader.GetBoolean(5) : false; oDescuento.regla_fecha_inicio = !reader[6].Equals(DBNull.Value) ? reader.GetDateTime(6) : DefaultDateTime; oDescuento.regla_fecha_fin = !reader[7].Equals(DBNull.Value) ? reader.GetDateTime(7) : DefaultDateTime; oDescuento.regla_monto_minimo = !reader[8].Equals(DBNull.Value) ? reader.GetDecimal(8) : 0; oDescuento.fecha_creacion = !reader[9].Equals(DBNull.Value) ? reader.GetDateTime(9) : DefaultDateTime; oDescuento.fecha_actualizacion = !reader[10].Equals(DBNull.Value) ? reader.GetDateTime(10) : DefaultDateTime; } reader.Close(); return(oDescuento); }
protected void btnSave_Click(object sender, EventArgs e) { if (!validateUserAction(IdModulo, CMD_Administrar)) { return; } eDescuento _oDescuento = new eDescuento(); bool success = false; _oDescuento.nombre = this.txtNombre.Text; _oDescuento.descripcion = this.txtDescripcion.Text; _oDescuento.descuento_tipo = this.drpTipoDescuento.SelectedValue; _oDescuento.descuento_valor = Convert.ToDecimal(this.txtDescuentoValor.Text); _oDescuento.regla_clientes_ferreyros = this.rblClientesFerreyros.SelectedValue == "1"; _oDescuento.regla_fecha_inicio = Convert.ToDateTime(this.txtFechaInicio.Text != ""? this.txtFechaInicio.Text: "01/01/1900"); _oDescuento.regla_fecha_fin = Convert.ToDateTime(this.txtFechaFin.Text != "" ? this.txtFechaFin.Text : "01/01/1900"); _oDescuento.regla_monto_minimo = Convert.ToDecimal(this.txtMontoMinimo.Text); //Validaciones Adicionales if (_oDescuento.descuento_tipo == "P" && _oDescuento.descuento_valor >= 100) { lblFormError.Text = "Rango de descuento no permitido"; return; } if (grvListado.SelectedIndex >= 0) { _oDescuento.id_descuento = Convert.ToInt16(grvListado.SelectedDataKey.Value); success = cCRM.Descuento_edit(_oDescuento); RegistrarLog(IdModulo, CMD_Administrar, "Se ha actualizado el Descuento: " + _oDescuento.id_descuento.ToString()); } else { _oDescuento.id_descuento = cCRM.Descuento_add(_oDescuento); success = (_oDescuento.id_descuento > 0); RegistrarLog(IdModulo, CMD_Administrar, "Se ha insertado un Nuevo Descuento: " + _oDescuento.id_descuento.ToString()); } if (success) { modDetalle.Hide(); BindListado(); } else { lblFormError.Text = cCRM.getErrorMessage(); } }
public int Insert(eDescuento oDescuento) { SqlCommand cmd = new SqlCommand("usp_tb_descuentoInsert"); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@nombre", SqlDbType.VarChar, 255).Value = oDescuento.nombre; cmd.Parameters.Add("@descripcion", SqlDbType.VarChar, 255).Value = oDescuento.descripcion; cmd.Parameters.Add("@descuento_tipo", SqlDbType.Char, 1).Value = oDescuento.descuento_tipo; cmd.Parameters.Add("@descuento_valor", SqlDbType.Decimal).Value = oDescuento.descuento_valor; cmd.Parameters.Add("@regla_clientes_ferreyros", SqlDbType.Bit).Value = oDescuento.regla_clientes_ferreyros; cmd.Parameters.Add("@regla_fecha_inicio", SqlDbType.DateTime).Value = oDescuento.regla_fecha_inicio; cmd.Parameters.Add("@regla_fecha_fin", SqlDbType.DateTime).Value = oDescuento.regla_fecha_fin; cmd.Parameters.Add("@regla_monto_minimo", SqlDbType.Decimal).Value = oDescuento.regla_monto_minimo; return(InsertCommand(cmd, true)); }
protected void grvListado_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { eDescuento _oDescuento = (eDescuento)e.Row.DataItem; if (_oDescuento.regla_fecha_fin.AddDays(1) < DateTime.Now) { e.Row.ForeColor = Color.Red; e.Row.Cells[6].Text = "No"; } else { e.Row.ForeColor = Color.Green; e.Row.Cells[6].Text = "Sí"; e.Row.Cells[5].Text = "US$" + _oDescuento.descuento_valor.ToString("N2"); if (_oDescuento.descuento_tipo == "P") { if (_oDescuento.regla_clientes_ferreyros) { totalPorcentajeFerreycorp += _oDescuento.descuento_valor; } else { totalPorcentaje += _oDescuento.descuento_valor; totalPorcentajeFerreycorp += _oDescuento.descuento_valor; } e.Row.Cells[5].Text = _oDescuento.descuento_valor.ToString("N0") + "%"; } else { if (_oDescuento.regla_clientes_ferreyros) { totalMontoFerreycorp += _oDescuento.descuento_valor; } else { totalMonto += _oDescuento.descuento_valor; totalMontoFerreycorp += _oDescuento.descuento_valor; } } } } }
public bool Descuento_edit(eDescuento oDescuento) { IdException = cDescuento.Update(oDescuento); return(IdException == 0); }
public int Descuento_add(eDescuento oDescuento) { IdException = cDescuento.Insert(oDescuento); return((IdException == 0) ? cDescuento.getLastID : 0); }