public DataSet GetAll_paginacion(string empresaid, tb_pt_categoria BE) { using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid))) { using (SqlCommand cmd = new SqlCommand("gspTbPtCategoria_SEARCH_paginacion", cnx)) { DataSet ds = new DataSet(); { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@categoriaid", SqlDbType.Char, 2).Value = BE.categoriaid; cmd.Parameters.Add("@posicion", SqlDbType.Char, 10).Value = BE.posicion; } 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_pt_categoria BE) { using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid))) { using (SqlCommand cmd = new SqlCommand("gspTbPtCategoria_DELETE", cnx)) { { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@categoriaid", SqlDbType.Char, 2).Value = BE.categoriaid; } try { cnx.Open(); if (cmd.ExecuteNonQuery() > 0) { return true; } else { return false; } } catch (Exception ex) { throw new Exception(ex.Message); } } } }
private void Cargar_cmbCategoria() { var BE = new tb_pt_categoria(); var BL = new tb_pt_categoriaBL(); var dt = new DataTable(); dt = BL.GetAll(EmpresaID, BE).Tables[0]; if (dt.Rows.Count > 0) { cmb_categoriaid.DataSource = dt; cmb_categoriaid.ValueMember = "categoriaid"; cmb_categoriaid.DisplayMember = "categorianame"; } }
public bool Insert(string empresaid, tb_pt_categoria BE) { using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid))) { using (SqlCommand cmd = new SqlCommand("gspTbPtCategoria_INSERT", cnx)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@categoriaid", SqlDbType.Char, 2).Value = BE.categoriaid; cmd.Parameters.Add("@categorianame", SqlDbType.VarChar, 30).Value = BE.categorianame; cmd.Parameters.Add("@es_saldo", SqlDbType.Bit).Value = BE.es_saldo; cmd.Parameters.Add("@usuar", SqlDbType.Char, 15).Value = BE.usuar; try { cnx.Open(); if (cmd.ExecuteNonQuery() > 0) { return true; } else { return false; } } catch (Exception ex) { throw new Exception(ex.Message); } } } }
private void Update() { try { if (categoriaid.Text.Trim().Length != 2) { MessageBox.Show("Falta Codigo Categoria !!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else if (categorianame.Text.Trim().Length == 0) { MessageBox.Show("Ingrese Nombre de Categoria", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else { tb_pt_categoriaBL BL = new tb_pt_categoriaBL(); tb_pt_categoria BE = new tb_pt_categoria(); BE.categoriaid = categoriaid.Text.Trim().PadLeft(2, '0'); BE.categorianame = categorianame.Text.ToUpper(); BE.es_saldo = chkessaldo.Checked; BE.usuar = VariablesPublicas.Usuar.Trim(); if (BL.Update(EmpresaID, BE)) { SEGURIDAD_LOG("M"); MessageBox.Show("Datos Modificado Correctamente !!!", "Confirmación", MessageBoxButtons.OK, MessageBoxIcon.Information); procesado = true; } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void Insert() { try { if (categorianame.Text.Trim().Length == 0) { MessageBox.Show("Ingrese Nombre de categoria", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else { tb_pt_categoriaBL BL = new tb_pt_categoriaBL(); tb_pt_categoria BE = new tb_pt_categoria(); BE.categoriaid = categoriaid.Text.Trim().PadLeft(2, '0'); BE.categorianame = categorianame.Text.ToUpper(); BE.es_saldo = chkessaldo.Checked; BE.usuar = VariablesPublicas.Usuar.Trim(); 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 form_cargar_datos(String posicion) { try { tb_pt_categoriaBL BL = new tb_pt_categoriaBL(); tb_pt_categoria BE = new tb_pt_categoria(); DataTable dt = new DataTable(); if (categoriaid.Text.Trim().Length > 0) { BE.categoriaid = categoriaid.Text.Trim().PadLeft(2, '0'); } BE.posicion = posicion.Trim(); dt = BL.GetAll_paginacion(EmpresaID, BE).Tables[0]; if (dt.Rows.Count > 0) { limpiar_documento(); ssModo = "EDIT"; categoriaid.Text = dt.Rows[0]["categoriaid"].ToString().Trim(); categorianame.Text = dt.Rows[0]["categorianame"].ToString().Trim(); chkessaldo.Checked = Convert.ToBoolean(dt.Rows[0]["es_saldo"].ToString()); btn_editar.Enabled = true; btn_eliminar.Enabled = true; btn_imprimir.Enabled = true; btn_primero.Enabled = true; btn_anterior.Enabled = true; btn_siguiente.Enabled = true; btn_ultimo.Enabled = true; btn_buscar.Enabled = true; btn_salir.Enabled = true; } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void Delete() { try { if (categoriaid.Text.Trim().Length != 2) { MessageBox.Show("Falta Codigo Categoria !!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else { tb_pt_categoriaBL BL = new tb_pt_categoriaBL(); tb_pt_categoria BE = new tb_pt_categoria(); BE.categoriaid = categoriaid.Text.Trim().PadLeft(2, '0'); //BE.categorianame = categorianame.Text.ToUpper(); //BE.usuar = VariablesPublicas.Usuar.Trim(); if (BL.Delete(EmpresaID, BE)) { SEGURIDAD_LOG("E"); MessageBox.Show("Datos Eliminados Correctamente !!!", "Confirmación", MessageBoxButtons.OK, MessageBoxIcon.Information); NIVEL_FORMS(); limpiar_documento(); data_Tablacategoria(); form_bloqueado(false); btn_nuevo.Enabled = true; btn_primero.Enabled = true; btn_anterior.Enabled = true; btn_siguiente.Enabled = true; btn_ultimo.Enabled = true; btn_buscar.Enabled = true; btn_salir.Enabled = true; } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void data_Tablacategoria() { try { if (Tablacategoria.Rows.Count > 0) Tablacategoria.Rows.Clear(); tb_pt_categoriaBL BL = new tb_pt_categoriaBL(); tb_pt_categoria BE = new tb_pt_categoria(); BE.categorianame = txt_criterio.Text.Trim().ToUpper(); Tablacategoria = BL.GetAll(EmpresaID, BE).Tables[0]; if (Tablacategoria.Rows.Count > 0) { btn_imprimir.Enabled = true; gridcategoria.DataSource = Tablacategoria; gridcategoria.Rows[0].Selected = false; gridcategoria.Focus(); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }