public DataSet GetAll2(string empresaid, tb_me_cuota_tiendacargo BE) { using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid))) { using (SqlCommand cmd = new SqlCommand("gspTbMeCuotaTiendacargo_SEARCH2", cnx)) { DataSet ds = new DataSet(); { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@perianio", SqlDbType.Char, 4).Value = BE.perianio; cmd.Parameters.Add("@perimes", SqlDbType.Char, 2).Value = BE.perimes; } try { cnx.Open(); using (SqlDataAdapter da = new SqlDataAdapter(cmd)) { da.Fill(ds); } return ds; } catch (Exception ex) { throw new Exception(ex.Message); } } } }
public bool Delete(string empresaid, tb_me_cuota_tiendacargo BE) { using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid))) { using (SqlCommand cmd = new SqlCommand("gspTbMeCuotaTiendacargo_DELETE", cnx)) { { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@perianio", SqlDbType.Char, 4).Value = BE.perianio; cmd.Parameters.Add("@perimes", SqlDbType.Char, 2).Value = BE.perimes; cmd.Parameters.Add("@local", SqlDbType.Char, 3).Value = BE.local; cmd.Parameters.Add("@cargoid", SqlDbType.Char, 3).Value = BE.cargoid; cmd.Parameters.Add("@filtro", SqlDbType.Int).Value = BE.filtro; } try { cnx.Open(); if (cmd.ExecuteNonQuery() > 0) { return true; } else { return false; } } catch (Exception ex) { throw new Exception(ex.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 { tb_me_cuota_tiendacargoBL BL = new tb_me_cuota_tiendacargoBL(); tb_me_cuota_tiendacargo BE = new tb_me_cuota_tiendacargo(); 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 Importar_Excel() { OpenFileDialog 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 { // Instancia de Excel Excel.Application excelApp = new Excel.Application(); // Abrimos el libro. Excel.Workbook 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); // Obtener primera hoja del libro actual Excel._Worksheet excelWorksheet = (Excel._Worksheet)excelBook.Worksheets.get_Item(1); // Visible o no Excel de preferencia falso excelApp.Visible = false; // Leer el valor dela Celda Especificada en el rango int x = 2;//Inicio de la iteraccion para recorrer el archivo. Nota: A diferencia del Array, en el libro de excel se empieza en 1 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++; } //dgb_listaPrecios.DataSource = TablaCuotasDet; #region **** Ingreso Cuota Detalle*** tb_me_cuota_tiendacargoBL BL = new tb_me_cuota_tiendacargoBL(); tb_me_cuota_tiendacargo BE = new tb_me_cuota_tiendacargo(); tb_me_cuota_tiendacargo.Item Detalle = new tb_me_cuota_tiendacargo.Item(); List<tb_me_cuota_tiendacargo.Item> ListaItems = new List<tb_me_cuota_tiendacargo.Item>(); int item = 0; foreach (DataRow fila in TablaCuotasDet.Rows) { Detalle = new tb_me_cuota_tiendacargo.Item(); item++; // Datos Detalle Detalle.perianio = perianio.Text.ToString().Trim(); Detalle.perimes = cmb_perimes.SelectedValue.ToString().Trim(); Detalle.local = cmb_local.SelectedValue.ToString().Trim(); Detalle.cargoid = fila["cargoid"].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; } #endregion //Salimos de la Instancia de Excel. excelApp.Quit(); } catch (Exception sms) { MessageBox.Show(sms.Message); } } }
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 { tb_me_cuota_tiendacargoBL BL = new tb_me_cuota_tiendacargoBL(); tb_me_cuota_tiendacargo BE = new tb_me_cuota_tiendacargo(); 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(); tb_me_cuota_tiendacargoBL BL = new tb_me_cuota_tiendacargoBL(); tb_me_cuota_tiendacargo BE = new tb_me_cuota_tiendacargo(); if (cmb_perianio.SelectedIndex != -1) { BE.perianio = cmb_perianio.SelectedValue.ToString(); } if (cmb_perimes2.SelectedIndex != -1) { BE.perimes = cmb_perimes2.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); } }
void CargarDetalle() { tb_me_cuota_tiendacargoBL BL = new tb_me_cuota_tiendacargoBL(); tb_me_cuota_tiendacargo BE = new tb_me_cuota_tiendacargo(); 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();} if (cmb_local.SelectedIndex != -1) { BE.local = cmb_local.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) { tb_me_cuota_tiendacargoBL BL = new tb_me_cuota_tiendacargoBL(); tb_me_cuota_tiendacargo BE = new tb_me_cuota_tiendacargo(); 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.cargoid = cmb_cargo.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; //btn_cancelar.PerformClick(); } }
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 { tb_me_cuota_tiendacargoBL BL = new tb_me_cuota_tiendacargoBL(); tb_me_cuota_tiendacargo BE = new tb_me_cuota_tiendacargo(); BE.perianio = perianio.Text.ToString().Trim(); BE.perimes = cmb_perimes.SelectedValue.ToString(); BE.local = cmb_local.SelectedValue.ToString(); BE.cargoid = cmb_cargo.SelectedValue.ToString(); BE.filtro = 1; if (BL.Delete(EmpresaID, BE)) { CargarDetalle(); cuota1.Text = ""; cuota2.Text = ""; cmb_cargo.SelectedIndex = -1; btn_del.Enabled = false; } } } }
public bool Update(string empresaid, tb_me_cuota_tiendacargo BE) { return tablaDA.Update(empresaid, BE); }
public bool Insert2(string empresaid, tb_me_cuota_tiendacargo BE) { return tablaDA.Insert2(empresaid, BE); }
public DataSet GetAll2(string empresaid, tb_me_cuota_tiendacargo BE) { return tablaDA.GetAll2(empresaid, BE); }
public bool Update(string empresaid, tb_me_cuota_tiendacargo BE) { using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid))) { using (SqlCommand cmd = new SqlCommand("gspTbMeCuotaTiendacargo_UPDATE", cnx)) { { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@perianio", SqlDbType.Char, 4).Value = BE.perianio; cmd.Parameters.Add("@perimes", SqlDbType.Char, 2).Value = BE.perimes; cmd.Parameters.Add("@local", SqlDbType.Char, 3).Value = BE.local; cmd.Parameters.Add("@cargoid", SqlDbType.Char, 3).Value = BE.cargoid; cmd.Parameters.Add("@cuota", SqlDbType.Decimal).Value = BE.cuota; cmd.Parameters.Add("@usuar", SqlDbType.Char, 15).Value = BE.usuar; cmd.Parameters.Add("@fecre", SqlDbType.DateTime).Value = BE.fecre; cmd.Parameters.Add("@feact", SqlDbType.DateTime).Value = BE.feact; } try { cnx.Open(); if (cmd.ExecuteNonQuery() > 0) { return true; } else { return false; } } catch (Exception ex) { throw new Exception(ex.Message); } finally { cnx.Close(); } } } }
public bool Insert2(string empresaid, tb_me_cuota_tiendacargo BE) { using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid))) { using (SqlCommand cmd = new SqlCommand("gspTbMeCuotaTiendacargo_INSERT_xml", cnx)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@perianio", SqlDbType.Char, 4).Value = BE.perianio; cmd.Parameters.Add("@perimes", SqlDbType.Char, 2).Value = BE.perimes; cmd.Parameters.Add("@XML", SqlDbType.Xml).Value = BE.GetItemXML(); try { cnx.Open(); if (cmd.ExecuteNonQuery() > 0) { return true; } else { return false; } } catch (Exception ex) { throw new Exception(ex.Message); } } } }