public bool Delete(string empresaid, tb_co_tabla10_comprobantes BE)
 {
     using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid)))
     {
         using (SqlCommand cmd = new SqlCommand("gspTbCoTabla10Comprobantes_DELETE", cnx))
         {
             {
                 cmd.CommandTimeout = 0;
                 cmd.CommandType = CommandType.StoredProcedure;
                 cmd.Parameters.Add("@codigoid", SqlDbType.Char, 2).Value = BE.codigoid;
             }
             try
             {
                 cnx.Open();
                 if (cmd.ExecuteNonQuery() > 0)
                 {
                     return true;
                 }
                 else
                 {
                     return false;
                 }
             }
             catch (Exception ex)
             {
                 throw new Exception(ex.Message);
             }
         }
     }
 }
 public DataSet GetAll(string empresaid, tb_co_tabla10_comprobantes BE)
 {
     using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid)))
     {
         using (SqlCommand cmd = new SqlCommand("gspTbCoTabla10Comprobantes_SEARCH", cnx))
         {
             DataSet ds = new DataSet();
             {
                 cmd.CommandTimeout = 0;
                 cmd.CommandType = CommandType.StoredProcedure;
                 cmd.Parameters.Add("@codigoid", SqlDbType.Char, 2).Value = BE.codigoid;
                 cmd.Parameters.Add("@descripcion", SqlDbType.VarChar, 100).Value = BE.descripcion;
                 cmd.Parameters.Add("@sigla", SqlDbType.Char, 3).Value = BE.sigla;
                 cmd.Parameters.Add("@docref", SqlDbType.Bit).Value = BE.docref;
             }
             cnx.Open();
             try
             {
                 using (SqlDataAdapter da = new SqlDataAdapter(cmd))
                 {
                     da.Fill(ds);
                 }
                 return ds;
             }
             catch (Exception ex)
             {
                 Sql_Error = ex.Message;
                 throw new Exception(ex.Message);
             }
         }
     }
 }
 public DataSet GetAll(string empresaid, tb_co_tabla10_comprobantes BE)
 {
     //return tablaDA.GetAll(empresaid, BE);
     DataSet xreturn = null;
     xreturn = tablaDA.GetAll(empresaid, BE);
     Sql_Error = tablaDA.Sql_Error;
     return xreturn;
 }
        private void validaTipoDocumento()
        {
            sw_novaluechange = true;
            Int16 lc_cont = default(Int16);
            bool zhallado = false;
            string VMNROITEM = gridgastos.Rows[gridgastos.CurrentRow.Index].Cells["asientoitems"].Value.ToString();
            string xcodartic = "..";
            //me.gas
            if ((!object.ReferenceEquals(gridgastos.Rows[gridgastos.CurrentRow.Index].Cells["gasto_tipdoc"].Value, DBNull.Value)))
            {
                xcodartic = gridgastos.Rows[gridgastos.CurrentRow.Index].Cells["gasto_tipdoc"].Value.ToString();
            }
            if (xcodartic.Trim().Length == 0)
            {
                TabCac3p00GastosAdic.Rows[gridgastos.CurrentRow.Index]["gasto_tipdoc"] = "";
                zhallado = true;
            }
            else
            {
                xcodartic = VariablesPublicas.PADL(xcodartic, 2, "0");
                tb_co_tabla10_comprobantesBL BL = new tb_co_tabla10_comprobantesBL();
                tb_co_tabla10_comprobantes BE = new tb_co_tabla10_comprobantes();

                BE.codigoid = xcodartic;
                tmptabla = BL.GetAll(VariablesPublicas.EmpresaID.ToString(), BE).Tables[0];
                //tmptabla = ocapa.cag3i00_consulta(GlobalVars.GetInstance.Company, xcodartic, "", 1, GlobalVars.GetInstance.TipoDocumentoContableTodos, "", "", "");
                for (lc_cont = 0; lc_cont <= TabCac3p00GastosAdic.Rows.Count - 1; lc_cont++)
                {
                    if (TabCac3p00GastosAdic.Rows[lc_cont]["asientoitems"].ToString() == VMNROITEM)
                    {
                        if (tmptabla.Rows.Count > 0)
                        {
                            TabCac3p00GastosAdic.Rows[lc_cont]["tipdoc"] = tmptabla.Rows[0]["codigoid"];
                            zhallado = true;
                            break;
                        }
                        break;
                    }
                }
            }
            if (!zhallado & xcodartic.Length > 0)
            {
                gridgastos.Rows[gridgastos.CurrentRow.Index].Cells["gasto_tipdoc"].Value = j_TipDocGasAdic;
            }
            gridgastos.Refresh();
            sw_novaluechange = false;
        }
        //GRID GASTOS ADICIONALES
        private void gridgastos_SelectionChanged(object sender, EventArgs e)
        {
            string prvcod = "";
            txtdescripcampo.Text = "";
            if ((gridgastos.CurrentCell != null))
            {
                if (gridgastos.Columns[gridgastos.CurrentCell.ColumnIndex].Name.ToUpper() == "gasto_cuentaid".ToUpper())
                {
                    txtdescripcampo.Text = gridgastos.Rows[gridgastos.CurrentCell.RowIndex].Cells["gasto_cuentaname"].Value.ToString();
                }
                if (gridgastos.Columns[gridgastos.CurrentCell.ColumnIndex].Name.ToUpper() == "gasto_moneda".ToUpper())
                {
                    txtdescripcampo.Text = "[1] SOLES [2] DOLARES";
                }
                if (gridgastos.Columns[gridgastos.CurrentCell.ColumnIndex].Name.ToUpper() == "gasto_tipdoc".ToUpper())
                {
                    if ((!object.ReferenceEquals(gridgastos.Rows[gridgastos.CurrentCell.RowIndex].Cells["gasto_tipdoc"].Value, DBNull.Value)))
                    {
                        prvcod = gridgastos.Rows[gridgastos.CurrentCell.RowIndex].Cells["gasto_tipdoc"].Value.ToString();
                    }
                    if (prvcod.Trim().Length == 0)
                    {
                        prvcod = "...";
                    }
                    tb_co_tabla10_comprobantesBL BL = new tb_co_tabla10_comprobantesBL();
                    tb_co_tabla10_comprobantes BE = new tb_co_tabla10_comprobantes();

                    BE.codigoid = prvcod;
                    tmptabla = BL.GetAll(VariablesPublicas.EmpresaID.ToString(), BE).Tables[0];
                    //tmptabla = ocapa.cag3i00_consulta(GlobalVars.GetInstance.Company, prvcod, "", 1, GlobalVars.GetInstance.TipDocusTodos, "", "", "");
                    //if (ocapa.sql_error.Length == 0)
                    //{
                        if (tmptabla.Rows.Count > 0)
                        {
                            txtdescripcampo.Text = tmptabla.Rows[0]["descripcion"].ToString();
                        }
                    //}
                }
                //Centro de Costo
                if (gridgastos.Columns[gridgastos.CurrentCell.ColumnIndex].Name.ToUpper() == "gasto_cencosid".ToUpper())
                {
                    if ((!object.ReferenceEquals(gridgastos.Rows[gridgastos.CurrentCell.RowIndex].Cells["gasto_cencosid"].Value, DBNull.Value)))
                    {
                        prvcod = gridgastos.Rows[gridgastos.CurrentCell.RowIndex].Cells["gasto_cencosid"].Value.ToString();
                    }
                    if (prvcod.Trim().Length == 0)
                    {
                        prvcod = "...";
                    }
                    centrocostoBL BL = new centrocostoBL();
                    tb_centrocosto BE = new tb_centrocosto();

                    BE.cencosid = prvcod;
                    //BE.cencosdivi = xclasecuenta;

                    tmptabla = BL.GetAll(VariablesPublicas.EmpresaID.ToString(), BE).Tables[0];
                    //tmptabla = ocapa.pag0101_consulta(GlobalVars.GetInstance.Company, prvcod, "", 2, 1, "", "", "", "");
                    //if (ocapa.sql_error.Length == 0)
                    //{
                    if (tmptabla.Rows.Count > 0)
                    {
                        txtdescripcampo.Text = tmptabla.Rows[0]["cencosname"].ToString();
                    }
                    //}
                }
            }
            u_RefrescaControles();
        }
 public bool Update(string empresaid, tb_co_tabla10_comprobantes BE)
 {
     using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid)))
     {
         using (SqlCommand cmd = new SqlCommand("gspTbCoTabla10Comprobantes_UPDATE", cnx))
         {
             {
                 cmd.CommandTimeout = 0;
                 cmd.CommandType = CommandType.StoredProcedure;
                 cmd.Parameters.Add("@codigoid", SqlDbType.Char, 2).Value = BE.codigoid;
                 cmd.Parameters.Add("@descripcion", SqlDbType.VarChar, 100).Value = BE.descripcion;
                 cmd.Parameters.Add("@sigla", SqlDbType.Char, 3).Value = BE.sigla;
                 cmd.Parameters.Add("@usuar", SqlDbType.Char, 15).Value = BE.usuar;
                 cmd.Parameters.Add("@docref", SqlDbType.Bit).Value = BE.docref;
             }
             try
             {
                 cnx.Open();
                 if (cmd.ExecuteNonQuery() > 0)
                 {
                     return true;
                 }
                 else
                 {
                     return false;
                 }
             }
             catch (Exception ex)
             {
                 throw new Exception(ex.Message);
             }
         }
     }
 }
        private void validaTipoDocumento()
        {
            sw_novaluechange = true;
            string vmxtipdoc = "";
            if (!(GridExaminar.Rows[GridExaminar.CurrentRow.Index].Cells["tipguia"].Value == DBNull.Value))
            {
                vmxtipdoc = GridExaminar.Rows[GridExaminar.CurrentRow.Index].Cells["tipguia"].Value.ToString();
            }
            if ((vmxtipdoc.Trim().Length == 0))
            {
                return;
            }
            if ((VariablesPublicas.StringtoDecimal(vmxtipdoc) > 0))
            {
                vmxtipdoc = VariablesPublicas.PADL(vmxtipdoc, 2, "0");
            }

            tb_co_tabla10_comprobantesBL BL = new tb_co_tabla10_comprobantesBL();
            tb_co_tabla10_comprobantes BE = new tb_co_tabla10_comprobantes();

            BE.codigoid = vmxtipdoc;
            DataTable tmptabla = BL.GetAll(VariablesPublicas.EmpresaID.ToString(), BE).Tables[0];

            if ((tmptabla.Rows.Count > 0))
            {
                GridExaminar.Rows[GridExaminar.CurrentRow.Index].Cells["tipguia"].Value = tmptabla.Rows[0]["codigoid"].ToString();
                txtDescripcampo.Text = tmptabla.Rows[0]["descripcion"].ToString();
            }
            else
            {
                GridExaminar.Rows[GridExaminar.CurrentRow.Index].Cells["tipguia"].Value = j_ctipdoc_3a;
            }
            sw_novaluechange = false;
        }
        private BindingSource NewMethodDoc()
        {
            tb_co_tabla10_comprobantesBL BL = new tb_co_tabla10_comprobantesBL();
            tb_co_tabla10_comprobantes BE = new tb_co_tabla10_comprobantes();

            DataTable table = BL.GetAll(VariablesPublicas.EmpresaID.ToString(), BE).Tables[0];
            DataRowCollection rows = table.Rows;

            object[] cell;
            Dictionary<string, string> dic = new Dictionary<string, string>();
            BindingSource binding = new BindingSource();

            foreach (DataRow item in rows)
            {
                cell = item.ItemArray;
                dic.Add(cell[0].ToString(), cell[0].ToString() + " - " + cell[1].ToString());
                cell = null;
            }
            binding.DataSource = dic;
            return binding;
        }
        void Docref()
        {
            if (u_n_opsel > 0)
            {
                tb_co_tabla10_comprobantesBL BL = new tb_co_tabla10_comprobantesBL();
                tb_co_tabla10_comprobantes BE = new tb_co_tabla10_comprobantes();
                try
                {
                    string xTipodoc = "";
                    if (Equivalencias.Left(cboTipdoc.Text, 2) == "07" | Equivalencias.Left(cboTipdoc.Text, 2) == "08" |
                        Equivalencias.Left(cboTipdoc.Text, 2) == "87" | Equivalencias.Left(cboTipdoc.Text, 2) == "88")
                    {
                        xTipodoc = cboTipdoc.SelectedValue.ToString();
                    }

                    BE.codigoid = xTipodoc;
                    DataTable table = BL.GetAll(VariablesPublicas.EmpresaID.ToString(), BE).Tables[0];
                    if (Convert.ToBoolean(table.Rows[0]["docref"].ToString()) == true)
                    {
                        gpoReferencia.Enabled = (u_n_opsel) > 0;
                    }
                }
                catch (Exception ex)
                {
                    DevExpress.XtraEditors.XtraMessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                gpoReferencia.Enabled = false;
            }

            if (u_n_opsel > 0)
            {
                if (Equivalencias.Left(cboTipdoc.Text, 2) == "03" | Equivalencias.Left(cboTipdoc.Text, 2) == "12") // |
                //Equivalencias.Left(cboTipdoc.Text, 2) == "87" | Equivalencias.Left(cboTipdoc.Text, 2) == "88")
                {
                    txtNumFin.Enabled = true;
                }
            }
        }
        //Para activar Doc.Referencia
        private void cboTipdoc_SelectedValueChanged(object sender, EventArgs e)
        {
            tb_co_tabla10_comprobantesBL BL = new tb_co_tabla10_comprobantesBL();
            tb_co_tabla10_comprobantes BE = new tb_co_tabla10_comprobantes();

            if (u_n_opsel > 0)
            {
                try
                {
                    BE.codigoid = cboTipdoc.Text.Substring(0, 2);
                    DataTable table = BL.GetAll(VariablesPublicas.EmpresaID.ToString(), BE).Tables[0];
                    // gpoReferencia.Enabled = Convert.ToBoolean(table.Rows[0]["docref"].ToString())
                    if (Convert.ToBoolean(table.Rows[0]["docref"].ToString()) == true)
                    {
                        gpoReferencia.Enabled = true;
                        cboTipdocref.SelectedIndex = 1;
                        cboTipdocref.Focus();
                    }
                    else
                    {
                        gpoReferencia.Enabled = false;
                        cboTipdocref.SelectedIndex = -1;
                        txtSerieref.Clear();
                        txtNumeroref.Clear();
                    }
                }
                catch (Exception ex)
                {
                    DevExpress.XtraEditors.XtraMessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
        private void validaTipoDocumento()
        {
            txtTipdoc.Text = VariablesPublicas.PADL(txtTipdoc.Text.Trim(), 2, "0");
            tb_co_tabla10_comprobantesBL BL = new tb_co_tabla10_comprobantesBL();
            tb_co_tabla10_comprobantes BE = new tb_co_tabla10_comprobantes();

            BE.codigoid = (txtTipdoc.Text.Trim().Length == 0 ? ".." : txtTipdoc.Text.Trim());
            tmptabla = BL.GetAll(VariablesPublicas.EmpresaID.ToString(), BE).Tables[0];
            if (BL.Sql_Error.Length == 0)
            {
                if (tmptabla.Rows.Count > 0)
                {
                    txtTipdoc.Text = tmptabla.Rows[0]["codigoid"].ToString();
                    txtdtipdoc.Text = tmptabla.Rows[0]["descripcion"].ToString();
                }
                else
                {
                    txtTipdoc.Text = j_String;
                }
            }
        }
        private void Frm_AyudaParteingresoalmacen_Activated(object sender, EventArgs e)
        {
            if (sw_load)
            {
                tb_co_tabla10_comprobantesBL BL = new tb_co_tabla10_comprobantesBL();
                tb_co_tabla10_comprobantes BE = new tb_co_tabla10_comprobantes();

                BE.codigoid = "09";
                tmptabla = BL.GetAll(VariablesPublicas.EmpresaID.ToString(), BE).Tables[0];
                if (BL.Sql_Error.Length == 0)
                {
                    if (tmptabla.Rows.Count > 0)
                    {
                        txtTipdoc.Text = tmptabla.Rows[0]["codigoid"].ToString();
                        txtdtipdoc.Text = tmptabla.Rows[0]["descripcion"].ToString();
                    }
                }
                LlenarGridMovimientoAlmacen();
                sw_load = false;
                GridMovimientoAlmacen.Focus();
                if (GridMovimientoAlmacen.RowCount > 0)
                {
                    GridMovimientoAlmacen.BeginEdit(true);
                }
            }
        }
        private void POnerDatos()
        {
            SortOrder sorted = default(SortOrder);
            string xnomcolumna = "";
            if (!(dgAyuda.SortedColumn == null))
            {
                xnomcolumna = dgAyuda.Columns[dgAyuda.SortedColumn.Index].Name;
                sorted = dgAyuda.SortOrder;
            }

            tb_co_tabla10_comprobantesBL BL = new tb_co_tabla10_comprobantesBL();
            tb_co_tabla10_comprobantes BE = new tb_co_tabla10_comprobantes();

            switch (cboCriterioBusqueda.SelectedItem.ToString())
            {
                case "Código":
                    BE.codigoid = txtBuscar.Text.Trim().ToUpper();
                    break;
                case "Descripción":
                    BE.descripcion = txtBuscar.Text.Trim().ToUpper();
                    break;
                default:
                    BE.codigoid = txtBuscar.Text.Trim().ToUpper();
                    break;
            }
            PCGCURSOR = BL.GetAll(VariablesPublicas.EmpresaID.ToString(), BE).Tables[0];
            dgAyuda.AutoGenerateColumns = false;
            dgAyuda.DataSource = PCGCURSOR;
            if ((xnomcolumna.Trim().Length > 0))
            {
                if ((sorted == SortOrder.Ascending))
                {
                    dgAyuda.Sort(dgAyuda.Columns[xnomcolumna], System.ComponentModel.ListSortDirection.Ascending);
                }
                else
                {
                    dgAyuda.Sort(dgAyuda.Columns[xnomcolumna], System.ComponentModel.ListSortDirection.Descending);
                }
            }
            else
            {
                dgAyuda.Sort(dgAyuda.Columns["codigoid"], System.ComponentModel.ListSortDirection.Ascending);
            }
        }
 public bool Update(string empresaid, tb_co_tabla10_comprobantes BE)
 {
     return tablaDA.Update(empresaid, BE);
 }
 public bool Insert(string empresaid, tb_co_tabla10_comprobantes BE)
 {
     return tablaDA.Insert(empresaid, BE);
 }