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 bool eliminarRegistro(eDESCUENTO_P oeDESCUENTO_P) { using (SqlConnection cnn = new SqlConnection(ConfigurationManager.ConnectionStrings["CadenaPrincipal"].ToString())) { string sp = "pa_crud_DESCUENTO_P_eliminarRegistro"; SqlCommand cmd = new SqlCommand(sp, cnn); cmd.CommandType = CommandType.StoredProcedure; cnn.Open(); cmd.Parameters.Add(new SqlParameter("@SOC_CODIGO", oeDESCUENTO_P.SOC_codigo)); cmd.Parameters.Add(new SqlParameter("@PRO_CODIGO", oeDESCUENTO_P.PRO_codigo)); return(cmd.ExecuteNonQuery() > 0); } }
public bool actualizarDescuentoP(eDESCUENTO_P oeDESCUENTOP) { using (SqlConnection cnn = new SqlConnection(ConfigurationManager.ConnectionStrings["CadenaPrincipal"].ToString())) { string sp = "[pa_op_DESCUENTO_ActualizarDescuentoP]"; SqlCommand cmd = new SqlCommand(sp, cnn); cmd.CommandType = CommandType.StoredProcedure; cnn.Open(); cmd.Parameters.Add(new SqlParameter("@SOC_CODIGO", oeDESCUENTOP.SOC_codigo)); cmd.Parameters.Add(new SqlParameter("@PRO_CODIGO", oeDESCUENTOP.PRO_codigo)); cmd.Parameters.Add(new SqlParameter("@DSC_PORCENTAJE", oeDESCUENTOP.DSC_porcentaje)); //variable tipo:double return(cmd.ExecuteNonQuery() > 0); } }
public bool insertarRegistro(eDESCUENTO_P oeDESCUENTO_P) { using (SqlConnection cnn = new SqlConnection(ConfigurationManager.ConnectionStrings["CadenaPrincipal"].ToString())) { string sp = "pa_crud_DESCUENTO_P_insertarRegistro"; SqlCommand cmd = new SqlCommand(sp, cnn); cmd.CommandType = CommandType.StoredProcedure; cnn.Open(); cmd.Parameters.Add(new SqlParameter("@SOC_CODIGO", oeDESCUENTO_P.SOC_codigo)); //variable tipo:int cmd.Parameters.Add(new SqlParameter("@PRO_CODIGO", oeDESCUENTO_P.PRO_codigo)); //variable tipo:string cmd.Parameters.Add(new SqlParameter("@DSC_PORCENTAJE", oeDESCUENTO_P.DSC_porcentaje)); //variable tipo:double return(cmd.ExecuteNonQuery() > 0); } }
//ADICIONALES DAL DESCUENTO P public DataTable mostrarDescuentosPPorProducto(eDESCUENTO_P oeDESCUENTOP) { using (SqlConnection cnn = new SqlConnection(ConfigurationManager.ConnectionStrings["CadenaPrincipal"].ToString())) { string sp = "pa_op_DESCUENTO_MostrarDescuentosPPorProducto"; SqlCommand cmd = new SqlCommand(sp, cnn); cmd.CommandType = CommandType.StoredProcedure; SqlDataAdapter dad = new SqlDataAdapter(cmd); dad.SelectCommand.Parameters.Add(new SqlParameter("@SOC_CODIGO", oeDESCUENTOP.SOC_codigo)); dad.SelectCommand.Parameters.Add(new SqlParameter("@PRO_CODIGO", oeDESCUENTOP.PRO_codigo)); DataTable dt = new DataTable(); dad.Fill(dt); return(dt); } }
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(); } }