Esempio n. 1
0
        private void agregarHistorialDescuentos(HistorialDescuentos historial)
        {
            try
            {
                int rowIndex = -1;
                foreach (DataGridViewRow row in this.dgvHistorialDescuentos.Rows)
                {
                    if (row.Cells["ParteID"].Value.ToString().Equals(historial.ParteID.ToString())
                        && row.Cells["TipoDescuento"].Value.ToString().Equals(historial.TipoDescuento.ToString()))
                    {
                        rowIndex = row.Index;
                    }
                }

                if (rowIndex >= 0)
                {
                    //existe:. actualizar
                    this.dgvHistorialDescuentos.Rows[rowIndex].Cells["DescuentoUno"].Value = historial.DescuentoUno;
                    this.dgvHistorialDescuentos.Rows[rowIndex].Cells["DescuentoDos"].Value = historial.DescuentoDos;
                    this.dgvHistorialDescuentos.Rows[rowIndex].Cells["DescuentoTres"].Value = historial.DescuentoTres;
                    this.dgvHistorialDescuentos.Rows[rowIndex].Cells["DescuentoCuatro"].Value = historial.DescuentoCuatro;
                    this.dgvHistorialDescuentos.Rows[rowIndex].Cells["DescuentoCinco"].Value = historial.DescuentoCinco;
                }
                else
                {
                    //es nuevo
                    DataRow row;
                    if (historial != null)
                    {
                        row = dtHistorialDescuentos.NewRow();
                        row["ParteID"] = historial.ParteID;
                        row["TipoDescuento"] = historial.TipoDescuento;
                        row["DescuentoUno"] = historial.DescuentoUno;
                        row["DescuentoDos"] = historial.DescuentoDos;
                        row["DescuentoTres"] = historial.DescuentoTres;
                        row["DescuentoCuatro"] = historial.DescuentoCuatro;
                        row["DescuentoCinco"] = historial.DescuentoCinco;
                        dtHistorialDescuentos.Rows.Add(row);
                    }
                }
            }
            catch (Exception ex)
            {
                Util.MensajeError(ex.Message, GlobalClass.NombreApp);
            }
        }
Esempio n. 2
0
 private void establecerHistoriaDescuentos(decimal resultado, int tipoDescuento, int parteId, decimal desUno, decimal desDos, decimal desTres, decimal desCuatro, decimal desCinco)
 {
     if (resultado > 0) //agregar
     {
         var his = new HistorialDescuentos()
         {
             ParteID = parteId,
             TipoDescuento = tipoDescuento,
             DescuentoUno = desUno,
             DescuentoDos = desDos,
             DescuentoTres = desTres,
             DescuentoCuatro = desCuatro,
             DescuentoCinco = desCinco
         };
         this.agregarHistorialDescuentos(his);
     }
     else //buscar y eliminar
     {
         //var rowIndex = Util.findRowIndex(this.dgvHistorialDescuentos, "ParteID", parteId.ToString());
         int rowIndex = -1;
         foreach (DataGridViewRow row in this.dgvHistorialDescuentos.Rows)
         {
             if (row.Cells["ParteID"].Value.ToString().Equals(parteId.ToString())
                 && row.Cells["TipoDescuento"].Value.ToString().Equals(tipoDescuento.ToString()))
             {
                 rowIndex = row.Index;
             }
         }
         if (rowIndex >= 0)
         {
             this.dgvHistorialDescuentos.Rows.RemoveAt(rowIndex);
         }
     }
 }