private void Importar_Excel() { var CuadroDialogo = new OpenFileDialog(); CuadroDialogo.DefaultExt = "xls"; CuadroDialogo.Filter = "xls file(*.xls)|*.xlsx"; CuadroDialogo.AddExtension = true; CuadroDialogo.RestoreDirectory = true; CuadroDialogo.Title = "Seleccionar Archivo"; if (CuadroDialogo.ShowDialog() == DialogResult.OK) { try { var excelApp = new Excel.Application(); var excelBook = excelApp.Workbooks.Open(CuadroDialogo.FileName, Type.Missing, false, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, true, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing); var excelWorksheet = (Excel._Worksheet)excelBook.Worksheets.get_Item(1); excelApp.Visible = false; var x = 2; if (TablaCuotasDet.Rows.Count > 0) { TablaCuotasDet.Rows.Clear(); } while (excelWorksheet.get_Range("A" + x).Value2 != null) { TablaCuotasDet.Rows.Add( excelWorksheet.get_Range("A" + x).Value2.ToString(), excelWorksheet.get_Range("B" + x).Value2.ToString(), excelWorksheet.get_Range("C" + x).Value2.ToString()); x++; } var BL = new tb_me_cuota_tiendaBL(); var BE = new tb_me_cuota_tienda(); var Detalle = new tb_me_cuota_tienda.Item(); var ListaItems = new List<tb_me_cuota_tienda.Item>(); var item = 0; foreach (DataRow fila in TablaCuotasDet.Rows) { Detalle = new tb_me_cuota_tienda.Item(); item++; Detalle.perianio = perianio.Text.ToString().Trim(); Detalle.perimes = cmb_perimes.SelectedValue.ToString().Trim(); Detalle.local = fila["local"].ToString().Trim(); Detalle.cuota = Convert.ToDecimal(fila["cuota"].ToString().Trim()); Detalle.usuar = VariablesPublicas.Usuar; ListaItems.Add(Detalle); } if (ListaItems.Count == 0) { MessageBox.Show("Documento SIN DETALLE Y/O DETALLE INCORRECTO !!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } BE.perianio = perianio.Text.ToString().Trim(); BE.perimes = cmb_perimes.SelectedValue.ToString().Trim(); BE.ListaItems = ListaItems; if (BL.Insert2(EmpresaID, BE)) { MessageBox.Show("Datos Grabados Correctamente !!!", "Confirmación", MessageBoxButtons.OK, MessageBoxIcon.Information); CargarDetalle(); Nuevo2(false); btn_add.Enabled = true; } excelApp.Quit(); } catch (Exception sms) { MessageBox.Show(sms.Message); } } }
private void Insert() { try { if (perianio.Text.Trim().Length == 0) { MessageBox.Show("Ingrese Año", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else { if (cmb_perimes.SelectedIndex == -1) { MessageBox.Show("Seleccione El Mes", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else { if (cuota1.Text.ToString().Length == 0) { MessageBox.Show("Ingresar el Valor de La Cuota", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else { var BL = new tb_me_cuota_tiendaBL(); var BE = new tb_me_cuota_tienda(); BE.perianio = perianio.Text.ToString().Trim(); BE.perimes = cmb_perimes.SelectedValue.ToString(); BE.cuota = Convert.ToDecimal(cuota1.Text.ToString().Trim()); BE.local = cmb_local.SelectedValue.ToString(); BE.usuar = VariablesPublicas.Usuar.Trim(); BE.fecre = Convert.ToDateTime(DateTime.Today.ToShortDateString()); BE.feact = Convert.ToDateTime(DateTime.Today.ToShortDateString()); if (BL.Insert(EmpresaID, BE)) { MessageBox.Show("Datos Grabados Correctamente !!!", "Confirmación", MessageBoxButtons.OK, MessageBoxIcon.Information); procesado = true; } } } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void Delete() { try { if (perianio.Text.Trim().Length == 0) { MessageBox.Show("Ingrese Año", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else { if (cmb_perimes.SelectedIndex == -1) { MessageBox.Show("Seleccione El Mes", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else { var BL = new tb_me_cuota_tiendaBL(); var BE = new tb_me_cuota_tienda(); BE.perianio = perianio.Text.ToString().Trim(); BE.perimes = cmb_perimes.SelectedValue.ToString(); BE.local = cmb_local.SelectedValue.ToString(); if (BL.Delete(EmpresaID, BE)) { SEGURIDAD_LOG("E"); MessageBox.Show("Datos Eliminado Correctamente !!!", "Confirmación", MessageBoxButtons.OK, MessageBoxIcon.Information); NIVEL_FORMS(); limpiar_documento(); form_bloqueado(false); data_TablaCuotas(); CargarDetalle(); btn_nuevo.Enabled = true; } } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void data_TablaCuotas() { try { TablaCuotas = new DataTable(); if (TablaCuotas.Rows.Count > 0) { TablaCuotas.Rows.Clear(); } var BL = new tb_me_cuota_tiendaBL(); var BE = new tb_me_cuota_tienda(); if (cmb_perianio.SelectedIndex != -1) { BE.perianio = cmb_perianio.SelectedValue.ToString(); } TablaCuotas = BL.GetAll2(EmpresaID, BE).Tables[0]; if (TablaCuotas.Rows.Count > 0) { btn_imprimir.Enabled = true; Mdi_dgv_promociones.DataSource = TablaCuotas; } else { Mdi_dgv_promociones.DataSource = TablaCuotas; } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void CargarDetalle() { var BL = new tb_me_cuota_tiendaBL(); var BE = new tb_me_cuota_tienda(); TablaCuotasDet = new DataTable(); if (perianio.Text.Trim().Length > 0) { BE.perianio = perianio.Text.Trim(); } if (cmb_perimes.SelectedIndex != -1) { BE.perimes = cmb_perimes.SelectedValue.ToString().Trim(); } TablaCuotasDet = BL.GetAll(EmpresaID, BE).Tables[0]; if (TablaCuotasDet.Rows.Count > 0) { dgb_localcuota.DataSource = TablaCuotasDet; } else { dgb_localcuota.DataSource = TablaCuotasDet; } }
private void btn_save_Click(object sender, EventArgs e) { var BL = new tb_me_cuota_tiendaBL(); var BE = new tb_me_cuota_tienda(); BE.perianio = perianio.Text.ToString().Trim(); BE.perimes = cmb_perimes.SelectedValue.ToString(); BE.cuota = Convert.ToDecimal(cuota1.Text.ToString().Trim()); BE.local = cmb_local.SelectedValue.ToString(); BE.usuar = VariablesPublicas.Usuar.Trim(); BE.fecre = Convert.ToDateTime(DateTime.Today.ToShortDateString()); BE.feact = Convert.ToDateTime(DateTime.Today.ToShortDateString()); if (BL.Insert(EmpresaID, BE)) { MessageBox.Show("Datos Grabados Correctamente !!!", "Confirmación", MessageBoxButtons.OK, MessageBoxIcon.Information); CargarDetalle(); Nuevo2(false); btn_add.Enabled = true; } }
private void btn_del_Click(object sender, EventArgs e) { if ((dgb_localcuota.RowCount != null)) { if (perianio.Text.Trim().Length == 0) { MessageBox.Show("Ingrese Año", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else { if (cmb_perimes.SelectedIndex == -1) { MessageBox.Show("Seleccione El Mes", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else { var BL = new tb_me_cuota_tiendaBL(); var BE = new tb_me_cuota_tienda(); BE.perianio = perianio.Text.ToString().Trim(); BE.perimes = cmb_perimes.SelectedValue.ToString(); BE.local = cmb_local.SelectedValue.ToString(); BE.filtro = 1; if (BL.Delete(EmpresaID, BE)) { CargarDetalle(); cuota1.Text = string.Empty; cuota2.Text = string.Empty; cmb_local.SelectedIndex = -1; btn_del.Enabled = false; } } } } }