public DataSet GetAll(string empresaid, tb_me_tienda BE)
        {
            using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid)))
            {
                using (SqlCommand cmd = new SqlCommand("gspTbMeTiendalist_SEARCH", cnx))
                {
                    DataSet ds = new DataSet();
                    {
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.Add("@tiendalist", SqlDbType.Int).Value = BE.tiendalist;
                        cmd.Parameters.Add("@filtro", SqlDbType.Char, 1).Value = BE.filtro;

                    }
                    try
                    {
                        cnx.Open();
                        using (SqlDataAdapter da = new SqlDataAdapter(cmd))
                        {
                            da.Fill(ds);
                        }
                        return ds;
                    }
                    catch (Exception ex)
                    {
                        throw new Exception(ex.Message);
                    }
                }
            }
        }
 public bool DeleteItem(string empresaid, tb_me_tienda BE)
 {
     using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid)))
     {
         using (SqlCommand cmd = new SqlCommand("gspTbMeTiendalistitem_DELETE", cnx))
         {
             {
                 cmd.CommandType = CommandType.StoredProcedure;
                 cmd.Parameters.Add("@tiendalist", SqlDbType.Int).Value = BE.tiendalist;
                 cmd.Parameters.Add("@local", SqlDbType.Char, 3).Value = BE.local;
                 cmd.Parameters.Add("@tiendalist", SqlDbType.Int).Value = BE.tiendalist;
             }
             try
             {
                 cnx.Open();
                 if (cmd.ExecuteNonQuery() > 0)
                 {
                     return true;
                 }
                 else
                 {
                     return false;
                 }
             }
             catch (Exception ex)
             {
                 throw new Exception(ex.Message);
             }
         }
     }
 }
        private void LlenarGrid_Tiendalistitem()
        {
            try
            {
                var BL = new tb_me_tiendaBL();
                var BE = new tb_me_tienda();

                BE.tiendalist = Convert.ToInt32(tiendalist2.Text);
                BE.filtro = "3";

                TablaTiendaItem = BL.GetAll(EmpresaID, BE).Tables[0];
                if (TablaTiendaItem.Rows.Count > 0)
                {
                    btn_imprimir.Enabled = true;
                    dgb_tiendaitem.DataSource = TablaTiendaItem;
                    dgb_tiendaitem.Rows[0].Selected = false;
                    dgb_tiendaitem.Focus();
                }
                else
                {
                    dgb_tiendaitem.DataSource = TablaTiendaItem;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void Insert_Item()
        {
            try
            {
                if (tiendalist2.Text == string.Empty)
                {
                    MessageBox.Show("Debe de Seleccionar un Codigo de Tienda Para Asignarle Item !!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                if (locid.Text == string.Empty)
                {
                    MessageBox.Show("Falta Codigo Local !!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                else
                {
                    var BL = new tb_me_tiendaBL();
                    var BE = new tb_me_tienda();

                    BE.tiendalist = Convert.ToInt32(tiendalist2.Text);
                    BE.local = locid.Text.ToString();
                    BE.usuar = VariablesPublicas.Usuar.Trim();

                    if (BL.Insert_Item(EmpresaID, BE))
                    {
                        MessageBox.Show("Datos Adicionados Correctamente !!!", "Confirmación", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        procesado = true;
                        locid.Text = string.Empty;
                        localname.Text = string.Empty;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void Insert()
        {
            try
            {
                if (tiendalistname.Text == string.Empty)
                {
                    MessageBox.Show("Ingrese Nombre de Tienda", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                else
                {
                    var BL = new tb_me_tiendaBL();
                    var BE = new tb_me_tienda();

                    BE.tiendalistname = tiendalistname.Text.Trim().ToString();
                    BE.usuar = VariablesPublicas.Usuar.Trim();
                    BE.local = locid.Text.ToString();

                    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
            {
                var BL = new tb_me_tiendaBL();
                var BE = new tb_me_tienda();

                var dt = new DataTable();

                if (tiendalist.Text.Trim().Length > 0)
                {
                    BE.tiendalist = Convert.ToInt32(tiendalist.Text);
                }
                BE.posicion = posicion.Trim();

                dt = BL.GetAll_paginacion(EmpresaID, BE).Tables[0];

                if (dt.Rows.Count > 0)
                {
                    limpiar_documento();
                    ssModo = "EDIT";

                    tiendalist.Text = dt.Rows[0]["tiendalist"].ToString().Trim();
                    localname.Text = dt.Rows[0]["tiendaname"].ToString().Trim();

                    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_salir.Enabled = true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void Delete()
        {
            try
            {
                if (tiendalist.Text.ToString() == string.Empty)
                {
                    MessageBox.Show("Falta Codigo Tienda !!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                else
                {
                    var BL = new tb_me_tiendaBL();
                    var BE = new tb_me_tienda();

                    BE.tiendalist = Convert.ToInt32(tiendalist.Text);

                    if (BL.Delete(EmpresaID, BE))
                    {
                        SEGURIDAD_LOG("E");
                        MessageBox.Show("Datos Eliminado Correctamente !!!", "Confirmación", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        NIVEL_FORMS();
                        form_bloqueado(false);
                        data_TablaTienda();
                        btn_nuevo.Enabled = true;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void data_TablaTienda()
        {
            try
            {
                var BL = new tb_me_tiendaBL();
                var BE = new tb_me_tienda();

                BE.filtro = "1";

                TablaTienda = BL.GetAll(EmpresaID, BE).Tables[0];
                if (TablaTienda.Rows.Count > 0)
                {
                    btn_imprimir.Enabled = true;
                    gridtienda.DataSource = TablaTienda;
                    gridtienda.Rows[0].Selected = false;
                    gridtienda.Focus();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void btn_eliminar_Click(object sender, EventArgs e)
        {
            if (XNIVEL == "0")
            {
                var sw_prosigue = false;
                sw_prosigue = (MessageBox.Show("¿Desea Eliminar Documento actual ?", "Mensaje del Sistema", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes);

                if (sw_prosigue)
                {
                    if (control.SelectedTab == control.TabPages[0])
                    {
                        Delete();
                    }
                    if (control.SelectedTab == control.TabPages[1])
                    {
                        if (locid.Text.ToString() == string.Empty)
                        {
                            MessageBox.Show("Falta Codigo Local !!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }
                        else
                        {
                            var BL = new tb_me_tiendaBL();
                            var BE = new tb_me_tienda();

                            BE.local = locid.Text.ToString();
                            BE.tiendalist = Convert.ToInt32(tiendalist2.Text);

                            if (BL.DeleteItem(EmpresaID, BE))
                            {
                                SEGURIDAD_LOG("E");
                                MessageBox.Show("Datos Eliminado Correctamente !!!", "Confirmación", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                NIVEL_FORMS();
                                form_bloqueado(false);
                                limpiar_documento();
                                data_TablaTiendaItem();
                                btn_nuevo.Enabled = true;
                            }
                        }
                    }
                }
            }
        }
        private void Update()
        {
            try
            {
                if (tiendalist.Text.ToString() == string.Empty)
                {
                    MessageBox.Show("Falta Codigo Tienda !!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                else
                {
                    if (localname.Text.Trim().Length == 0)
                    {
                        MessageBox.Show("Ingrese Nombre de Tienda", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    else
                    {
                        var BL = new tb_me_tiendaBL();
                        var BE = new tb_me_tienda();

                        BE.tiendalist = Convert.ToInt32(tiendalist.Text);
                        BE.tiendalistname = tiendalistname.Text.Trim().ToString();
                        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);
            }
        }
 public bool Update(string empresaid, tb_me_tienda BE)
 {
     using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid)))
     {
         using (SqlCommand cmd = new SqlCommand("gspTbMeTiendalist_UPDATE", cnx))
         {
             {
                 cmd.CommandType = CommandType.StoredProcedure;
                  cmd.Parameters.Add("@tiendalist", SqlDbType.Int).Value = BE.tiendalist;
                 cmd.Parameters.Add("@tiendalistname", SqlDbType.Char, 100).Value = BE.tiendalistname;
                  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);
             }
         }
     }
 }
예제 #12
0
        private void Llenar_ComboTiendas()
        {
            var BL = new tb_me_tiendaBL();
            var BE = new tb_me_tienda();
            var dt = new DataTable();

            BE.filtro = "1";

            dt = BL.GetAll(EmpresaID, BE).Tables[0];
            if (dt.Rows.Count > 0)
            {
                cboTiendaslist.DataSource = dt;
                cboTiendaslist.DisplayMember = "tiendalistname";
                cboTiendaslist.ValueMember = "tiendalist";
            }
        }