private void get_autoCS_numPedido()
        {
            try
            {
                var BL = new tb_cp_comercialcabBL();
                var BE = new tb_cp_comercialcab();
                var dt = new DataTable();
                BE.moduloid = modulo;
                BE.perianio = VariablesPublicas.perianio;
                BE.serop = ser_op.Text;
                dt = BL.GetAllNuevoNumero(EmpresaID, BE).Tables[0];
                if (dt.Rows.Count > 0)
                {
                    serdoc.Text = dt.Rows[0]["perianio"].ToString();
                    numdoc.Text = dt.Rows[0]["Cnum_cp"].ToString();

                    ser_op.Text = dt.Rows[0]["ser_op"].ToString();
                    num_op.Text = dt.Rows[0]["Cnum_op"].ToString();
                }
                else
                {
                    serdoc.Text = string.Empty;
                    numdoc.Text = string.Empty;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void LlenarGrilla()
        {
            try
            {
                var BL = new tb_cp_comercialcabBL();
                var BE = new tb_cp_comercialcab();

                if (cboVendedor.Enabled)
                {
                    if ((cboVendedor.SelectedValue != null))
                    {
                        BE.vendedorid = cboVendedor.SelectedValue.ToString();
                    }
                }
                if (Fechaini.Enabled)
                {
                }
                if (txtEstilo.Enabled)
                {
                }

                pTabla = BL.GetAll(VariablesPublicas.EmpresaID.ToString(), BE).Tables[0];
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void form_cargar_datos(String posicion)
        {
            try
            {
                limpiar_documento();
                var BL = new tb_cp_comercialcabBL();
                var BE = new tb_cp_comercialcab();
                var dt = new DataTable();

                BE.moduloid = modulo;
                BE.local = local;
                BE.tipdoc = tipdoc.Text;
                BE.serdoc = serdoc.Text.Trim().PadLeft(4, '0');
                if (numdoc.Text.Trim().Length > 0)
                {
                    BE.numdoc = numdoc.Text.Trim().PadLeft(10, '0');
                }

                BE.posicion = posicion.Trim();

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

                if (dt.Rows.Count > 0)
                {
                    ssModo = "EDIT";
                    serdoc.Text = dt.Rows[0]["serdoc"].ToString().Trim();
                    numdoc.Text = dt.Rows[0]["numdoc"].ToString().Trim();
                    fechdoc.Text = dt.Rows[0]["fechdoc"].ToString().Trim();
                    ctacte.Text = dt.Rows[0]["ctacte"].ToString().Trim();
                    ctactename.Text = dt.Rows[0]["ctactename"].ToString().Trim();
                    cboCanalventa.SelectedValue = dt.Rows[0]["canalventaid"].ToString().Trim();

                    if (dt.Rows[0]["fechentrega"].ToString().Trim().Substring(0, 10) != "01/01/1900")
                    {
                        fechentrega.Format = DateTimePickerFormat.Short;
                        fechentrega.Text = dt.Rows[0]["fechentrega"].ToString().Trim();
                    }
                    glosa.Text = dt.Rows[0]["observacion"].ToString().Trim();

                    data_TabladetallePedido();
                    if (dt.Rows[0]["status"].ToString().Trim() != "9")
                    {
                        btn_editar.Enabled = true;
                        btn_eliminar.Enabled = true;
                        btn_imprimir.Enabled = true;
                        btn_attachedfile.Enabled = true;

                        btn_salir.Enabled = true;
                        griddetallepedido.Focus();
                        griddetallepedido.Rows[0].Selected = false;
                        ;
                    }
                    else
                    {
                        ssModo = "ANULADO";
                        btn_editar.Enabled = false;
                        btn_eliminar.Enabled = false;
                        btn_imprimir.Enabled = true;
                        btn_salir.Enabled = true;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }