private void buscarInicio() { try { CLS_Precios_Fechas insPre = new CLS_Precios_Fechas(); insPre.MtdSeleccionar(); if (insPre.Exito) { if (insPre.Datos.Rows.Count > 0) { dtgPrecios.DataSource = insPre.Datos; } else { XtraMessageBox.Show("No existen datos para mostrar"); } } else { XtraMessageBox.Show(insPre.Mensaje); } } catch (Exception ex) { XtraMessageBox.Show(ex.Message); } }
private bool insertar(string c_codigo_cal, string c_codigo_dis, string d_fecha_pre, decimal n_preciobanda_pre, decimal n_precioventa_pre, string c_codigo_uss) { bool Valor = true; try { CLS_Precios_Fechas insPre = new CLS_Precios_Fechas(); insPre.c_codigo_pre = c_codigo_pre; insPre.c_codigo_cal = c_codigo_cal; insPre.c_codigo_dis = c_codigo_dis; insPre.d_fecha_pre = d_fecha_pre; insPre.n_preciobanda_pre = n_preciobanda_pre; insPre.n_precioventa_pre = n_precioventa_pre; insPre.c_codigo_usu = c_codigo_uss; insPre.MtdInsertar(); if (!insPre.Exito) { Valor = false; XtraMessageBox.Show(insPre.Mensaje); } } catch (Exception ex) { Valor = false; XtraMessageBox.Show(ex.Message); } return(Valor); }
private bool buscar(string c_codigo_cal, string c_codigo_dis, string d_fecha_pre, string d_fecha_preIni, string d_fecha_preFin, int Opcion) { bool Valor = true; try { CLS_Precios_Fechas insPre = new CLS_Precios_Fechas(); insPre.c_codigo_pre = c_codigo_pre; insPre.c_codigo_cal = c_codigo_cal; insPre.c_codigo_dis = c_codigo_dis; insPre.d_fecha_pre = d_fecha_pre; insPre.d_fecha_preIni = d_fecha_preIni; insPre.d_fecha_preFin = d_fecha_preFin; insPre.Opcion = Opcion; insPre.MtdSeleccionarCodigoNombre(); if (insPre.Exito) { if (insPre.Datos.Rows.Count > 0) { dtgPrecios.DataSource = insPre.Datos; } else { XtraMessageBox.Show("No existen datos para mostrar"); } } else { XtraMessageBox.Show(insPre.Mensaje); } } catch (Exception ex) { Valor = false; XtraMessageBox.Show(ex.Message); } return(Valor); }
private void btnGuardar_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { if (ValidaDatos()) { if (rdbFechas.SelectedIndex == 0) { CLS_Precios_Fechas selFecha = new CLS_Precios_Fechas(); selFecha.c_codigo_cal = txtCodigoCal.Text; selFecha.c_codigo_dis = txtCodigoDis.Text; DateTime FActual = dtFechaUnica.DateTime; selFecha.d_fecha_pre = FActual.Year + DosCeros1(FActual.Month.ToString()) + DosCeros1(FActual.Day.ToString()); selFecha.MtdSeleccionarCalDisFecha(); if (selFecha.Exito) { if (selFecha.Datos.Rows.Count == 0) { int vOpcion = 1; string vc_codigo_cal = txtCodigoCal.Text; string vc_codigo_dis = txtCodigoDis.Text; string vd_fecha_pre = FActual.Year + DosCeros1(FActual.Month.ToString()) + DosCeros1(FActual.Day.ToString()); decimal vn_preciobanda_pre = Convert.ToDecimal(txtPrecioBanda.Value); decimal vn_precioventa_pre = Convert.ToDecimal(txtPrecioEstimado.Value); string vd_fecha_preIni = string.Empty; string vd_fecha_preFin = string.Empty; string vc_codigo_usu = c_codigo_usu; if (insertar(vc_codigo_cal, vc_codigo_dis, vd_fecha_pre, vn_preciobanda_pre, vn_precioventa_pre, vc_codigo_usu)) { XtraMessageBox.Show("Se ha insertado el registro con exito"); buscar(vc_codigo_cal, vc_codigo_dis, vd_fecha_pre, vd_fecha_preIni, vd_fecha_preFin, vOpcion); } } else { int vOpcion = 1; string vc_codigo_cal = txtCodigoCal.Text; string vc_codigo_dis = txtCodigoDis.Text; string vd_fecha_pre = FActual.Year + DosCeros1(FActual.Month.ToString()) + DosCeros1(FActual.Day.ToString()); decimal vn_preciobanda_pre = Convert.ToDecimal(txtPrecioBanda.Value); decimal vn_precioventa_pre = Convert.ToDecimal(txtPrecioEstimado.Value); string vd_fecha_preIni = string.Empty; string vd_fecha_preFin = string.Empty; string vc_codigo_usu = c_codigo_usu; if (modificar(c_codigo_pre, vc_codigo_cal, vc_codigo_dis, vd_fecha_pre, vn_preciobanda_pre, vn_precioventa_pre, vc_codigo_usu)) { XtraMessageBox.Show("Se ha modificado el registro con exito"); buscar(vc_codigo_cal, vc_codigo_dis, vd_fecha_pre, vd_fecha_preIni, vd_fecha_preFin, vOpcion); } } } else { XtraMessageBox.Show(selFecha.Mensaje); } } else { DateTime FechaInicio = Convert.ToDateTime(dtFechaInicio.EditValue.ToString()); DateTime FechaFin = Convert.ToDateTime(dtFechaFin.EditValue.ToString()); int result = DateTime.Compare(FechaInicio, FechaFin); if (result > 0) { XtraMessageBox.Show("La fecha de Inicio debe ser menor que la fecha Fin"); } else { string FechaIni = dtFechaInicio.DateTime.Year + "-" + DosCeros1(dtFechaInicio.DateTime.Month.ToString()) + "-" + DosCeros1(dtFechaInicio.DateTime.Day.ToString()); string FechaF = dtFechaFin.DateTime.Year + "-" + DosCeros1(dtFechaFin.DateTime.Month.ToString()) + "-" + DosCeros1(dtFechaFin.DateTime.Day.ToString()); int vOpcion = 2; List <String> Fechas = new List <string>(); Fechas = CrearRangoFecha(FechaIni, FechaF); int Cont = 0; FechaIni = dtFechaInicio.DateTime.Year + DosCeros1(dtFechaInicio.DateTime.Month.ToString()) + DosCeros1(dtFechaInicio.DateTime.Day.ToString()); FechaF = dtFechaFin.DateTime.Year + DosCeros1(dtFechaFin.DateTime.Month.ToString()) + DosCeros1(dtFechaFin.DateTime.Day.ToString()); string vc_codigo_cal = txtCodigoCal.Text; string vc_codigo_dis = txtCodigoDis.Text; for (int i = 0; i < Fechas.Count; i++) { CLS_Precios_Fechas selFecha = new CLS_Precios_Fechas(); selFecha.c_codigo_cal = txtCodigoCal.Text; selFecha.c_codigo_dis = txtCodigoDis.Text; DateTime FActual = Convert.ToDateTime(Fechas[i]); selFecha.d_fecha_pre = FActual.Year + DosCeros1(FActual.Month.ToString()) + DosCeros1(FActual.Day.ToString()); selFecha.MtdSeleccionarCalDisFecha(); string vd_fecha_pre = FActual.Year + DosCeros1(FActual.Month.ToString()) + DosCeros1(FActual.Day.ToString()); decimal vn_preciobanda_pre = Convert.ToDecimal(txtPrecioBanda.Value); decimal vn_precioventa_pre = Convert.ToDecimal(txtPrecioEstimado.Value); string vc_codigo_usu = c_codigo_usu; if (selFecha.Exito) { if (selFecha.Datos.Rows.Count == 0) { if (insertar(vc_codigo_cal, vc_codigo_dis, vd_fecha_pre, vn_preciobanda_pre, vn_precioventa_pre, vc_codigo_usu)) { Cont++; } } else { c_codigo_pre = Convert.ToInt32(selFecha.Datos.Rows[0][0].ToString()); if (modificar(c_codigo_pre, vc_codigo_cal, vc_codigo_dis, vd_fecha_pre, vn_preciobanda_pre, vn_precioventa_pre, vc_codigo_usu)) { Cont++; } } } else { XtraMessageBox.Show(selFecha.Mensaje); } } if (Cont == Fechas.Count) { XtraMessageBox.Show("Se han Procesado Todos los Registros"); buscar(vc_codigo_cal, vc_codigo_dis, string.Empty, FechaIni, FechaF, vOpcion); } else { XtraMessageBox.Show("han faltado de Procesar algunos Registros"); } } } } else { XtraMessageBox.Show("Faltan datos por Capturar oalguno de los precios estan en 0"); } }
private void btnGuardar_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { if (ValidaDatos()) { int Cont = 0; for (int x = 0; x < dtgValPrecios.DataRowCount; x++) { if (rdbFechas.SelectedIndex == 0) { CLS_Precios_Fechas selFecha = new CLS_Precios_Fechas(); selFecha.c_codigo_cal = dtgValPrecios.GetRowCellValue(x, dtgValPrecios.Columns["c_codigo_cal"]).ToString(); selFecha.c_codigo_dis = txtCodigoDis.Text; DateTime FActual = dtFechaUnica.DateTime; selFecha.d_fecha_pre = FActual.Year + DosCeros1(FActual.Month.ToString()) + DosCeros1(FActual.Day.ToString()); selFecha.MtdSeleccionarCalDisFecha(); if (selFecha.Exito) { string vc_codigo_cal = dtgValPrecios.GetRowCellValue(x, dtgValPrecios.Columns["c_codigo_cal"]).ToString(); string vc_codigo_dis = txtCodigoDis.Text; string vd_fecha_pre = FActual.Year + DosCeros1(FActual.Month.ToString()) + DosCeros1(FActual.Day.ToString()); decimal vPreciosBanda = 0; Decimal.TryParse(dtgValPrecios.GetRowCellValue(x, dtgValPrecios.Columns["n_preciobanda_pre"]).ToString(), style, culture, out vPreciosBanda); decimal vn_preciobanda_pre = vPreciosBanda; decimal vPreciosEstimado = 0; Decimal.TryParse(dtgValPrecios.GetRowCellValue(x, dtgValPrecios.Columns["n_precioventa_pre"]).ToString(), style, culture, out vPreciosEstimado); decimal vn_precioventa_pre = vPreciosEstimado; string vd_fecha_preIni = string.Empty; string vd_fecha_preFin = string.Empty; string vc_codigo_usu = c_codigo_usu; if (vPreciosBanda > 0 || vPreciosEstimado > 0) { if (selFecha.Datos.Rows.Count == 0) { if (insertar(vc_codigo_cal, vc_codigo_dis, vd_fecha_pre, vn_preciobanda_pre, vn_precioventa_pre, vc_codigo_usu)) { Cont++; } } else { c_codigo_pre = Convert.ToInt32(selFecha.Datos.Rows[0][0].ToString()); if (modificar(c_codigo_pre, vc_codigo_cal, vc_codigo_dis, vd_fecha_pre, vn_preciobanda_pre, vn_precioventa_pre, vc_codigo_usu)) { Cont++; } } } } else { XtraMessageBox.Show(selFecha.Mensaje); } } else { DateTime FechaInicio = Convert.ToDateTime(dtFechaInicio.EditValue.ToString()); DateTime FechaFin = Convert.ToDateTime(dtFechaFin.EditValue.ToString()); int result = DateTime.Compare(FechaInicio, FechaFin); if (result > 0) { XtraMessageBox.Show("La fecha de Inicio debe ser menor que la fecha Fin"); } else { string FechaIni = string.Format("{0}-{1}-{2}", dtFechaInicio.DateTime.Year, DosCeros1(dtFechaInicio.DateTime.Month.ToString()), DosCeros1(dtFechaInicio.DateTime.Day.ToString())); string FechaF = string.Format("{0}-{1}-{2}", dtFechaFin.DateTime.Year, DosCeros1(dtFechaFin.DateTime.Month.ToString()), DosCeros1(dtFechaFin.DateTime.Day.ToString())); List <String> Fechas = new List <string>(); Fechas = CrearRangoFecha(FechaIni, FechaF); FechaIni = dtFechaInicio.DateTime.Year + DosCeros1(dtFechaInicio.DateTime.Month.ToString()) + DosCeros1(dtFechaInicio.DateTime.Day.ToString()); FechaF = dtFechaFin.DateTime.Year + DosCeros1(dtFechaFin.DateTime.Month.ToString()) + DosCeros1(dtFechaFin.DateTime.Day.ToString()); string vc_codigo_cal = dtgValPrecios.GetRowCellValue(x, dtgValPrecios.Columns["c_codigo_cal"]).ToString(); string vc_codigo_dis = txtCodigoDis.Text; for (int i = 0; i < Fechas.Count; i++) { CLS_Precios_Fechas selFecha = new CLS_Precios_Fechas(); selFecha.c_codigo_cal = dtgValPrecios.GetRowCellValue(x, dtgValPrecios.Columns["c_codigo_cal"]).ToString(); selFecha.c_codigo_dis = txtCodigoDis.Text; DateTime FActual = Convert.ToDateTime(Fechas[i]); selFecha.d_fecha_pre = FActual.Year + DosCeros1(FActual.Month.ToString()) + DosCeros1(FActual.Day.ToString()); selFecha.MtdSeleccionarCalDisFecha(); if (selFecha.Exito) { string vd_fecha_pre = FActual.Year + DosCeros1(FActual.Month.ToString()) + DosCeros1(FActual.Day.ToString()); decimal vPreciosBanda = 0; Decimal.TryParse(dtgValPrecios.GetRowCellValue(x, dtgValPrecios.Columns["n_preciobanda_pre"]).ToString(), style, culture, out vPreciosBanda); decimal vn_preciobanda_pre = vPreciosBanda; decimal vPreciosEstimado = 0; Decimal.TryParse(dtgValPrecios.GetRowCellValue(x, dtgValPrecios.Columns["n_precioventa_pre"]).ToString(), style, culture, out vPreciosEstimado); decimal vn_precioventa_pre = vPreciosEstimado; string vc_codigo_usu = c_codigo_usu; if (vPreciosBanda > 0 || vPreciosEstimado > 0) { if (selFecha.Datos.Rows.Count == 0) { if (insertar(vc_codigo_cal, vc_codigo_dis, vd_fecha_pre, vn_preciobanda_pre, vn_precioventa_pre, vc_codigo_usu)) { Cont++; } } else { c_codigo_pre = Convert.ToInt32(selFecha.Datos.Rows[0][0].ToString()); if (modificar(c_codigo_pre, vc_codigo_cal, vc_codigo_dis, vd_fecha_pre, vn_preciobanda_pre, vn_precioventa_pre, vc_codigo_usu)) { Cont++; } } } } else { XtraMessageBox.Show(selFecha.Mensaje); } } } } } XtraMessageBox.Show("Se han procesado " + Cont + " Registros"); } else { XtraMessageBox.Show("Faltan datos por Capturar Pais o Distribuidor"); } }