private void cargarGrillaDescuentosP() { balDESCUENTO_P obalDESCUENTOP = new balDESCUENTO_P(); eDESCUENTO_P oeDESCUENTOP = new eDESCUENTO_P(); oeDESCUENTOP.SOC_codigo = Convert.ToInt16(this.txtCodigoSocio.Text); this.dgvDescuentoSocio.DataSource = obalDESCUENTOP.mostrarDescuentosPPorProducto(oeDESCUENTOP); }
private void mostrarDescuentosSocio() { foreach (DataGridViewRow fila in this.dgvDescuentoSocio.Rows) { eDESCUENTO_P oeDESCUENTOP = new eDESCUENTO_P(); oeDESCUENTOP.SOC_codigo = Convert.ToInt16(this.txtCodigoSocio.Text); oeDESCUENTOP.PRO_codigo = this.dgvDescuentoSocio["PRO_codigo2", fila.Index].Value.ToString(); balDESCUENTO_P obalDESCUENTOP = new balDESCUENTO_P(); this.dgvDescuentoSocio["DSC_porcentaje2", fila.Index].Value = obalDESCUENTOP.mostrarDescuentosPPorProducto(oeDESCUENTOP).Rows[0][0].ToString(); } }
public override void Guardar() { if (tabDescuentos.SelectedTab == tabDescuentos.TabPages["Grupal"])//your specific tabname { eDESCUENTO oeDESCUENTO = new eDESCUENTO(); balDESCUENTO obalDESCUENTO = new balDESCUENTO(); int contadorInsertadosCorrectos = 0; int contadorInsertadosIncorrectos = 0; DateTime u; foreach (DataGridViewRow row in this.dgvDescuentoGrupal.Rows) { string CAN_codigo = this.cmbCanal.SelectedValue.ToString(); string PRO_codigo = row.Cells["PRO_codigo"].Value.ToString(); string DSC_is_especial = row.Cells["DSC_is_especial"].Value.ToString(); double porcentaje = row.Cells["DSC_porcentaje"].Value != null?Convert.ToDouble(row.Cells["DSC_porcentaje"].Value.ToString()) : 0; double esp_porcentaje = row.Cells["DSC_esp_porcentaje"].Value != null?Convert.ToDouble(row.Cells["DSC_esp_porcentaje"].Value.ToString()) : 0; DateTime?DSC_fecha_vencimiento = (row.Cells["DSC_fecha_vencimiento"].Value != null) ? DateTime.TryParse(row.Cells["DSC_fecha_vencimiento"].Value.ToString(), out u) ? Convert.ToDateTime(row.Cells["DSC_fecha_vencimiento"].Value.ToString()) : (DateTime?)null : null; oeDESCUENTO.CAN_codigo = CAN_codigo; oeDESCUENTO.PRO_codigo = PRO_codigo; oeDESCUENTO.DSC_is_especial = DSC_is_especial; oeDESCUENTO.DSC_porcentaje = porcentaje; oeDESCUENTO.DSC_esp_porcentaje = esp_porcentaje; oeDESCUENTO.DSC_fecha_vencimiento = DSC_fecha_vencimiento; if (balDESCUENTO.actualizarDescuento(oeDESCUENTO)) { contadorInsertadosCorrectos++; } else { contadorInsertadosIncorrectos++; } } mensaje("guardar", contadorInsertadosCorrectos, contadorInsertadosIncorrectos); //MessageBox.Show("Se actualizaron los " + contadorInsertadosCorrectos + " registros en la tabla de descuentos.", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information); mostrarDescuentosGrupales(); } else { eDESCUENTO_P oeDESCUENTOP = new eDESCUENTO_P(); balDESCUENTO_P obalDESCUENTOP = new balDESCUENTO_P(); int contadorInsertadosCorrectos = 0; int contadorInsertadosIncorrectos = 0; foreach (DataGridViewRow row in this.dgvDescuentoSocio.Rows) { int SOC_codigo = Convert.ToInt16(this.txtCodigoSocio.Text); string PRO_codigo = row.Cells["PRO_codigo2"].Value.ToString(); double porcentaje = row.Cells["DSC_porcentaje2"].Value != null?Convert.ToDouble(row.Cells["DSC_porcentaje2"].Value.ToString()) : 0; oeDESCUENTOP.SOC_codigo = SOC_codigo; oeDESCUENTOP.PRO_codigo = PRO_codigo; oeDESCUENTOP.DSC_porcentaje = porcentaje; if (obalDESCUENTOP.actualizarDescuentoP(oeDESCUENTOP)) { contadorInsertadosCorrectos++; } else { contadorInsertadosIncorrectos++; } } mensaje("guardar", contadorInsertadosCorrectos, contadorInsertadosIncorrectos); //MessageBox.Show("Se actualizaron los " + contadorInsertadosCorrectos + " registros en la tabla de descuentos.", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information); mostrarDescuentosSocio(); } }