public DataSet GetAll(string empresaid, tb_constantesgenerales BE)
 {
     using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid)))
     {
         using (SqlCommand cmd = new SqlCommand("gspTbConstantesgenerales_SEARCH", cnx))
         {
             DataSet ds = new DataSet();
             {
                 cmd.CommandType = CommandType.StoredProcedure;
                 cmd.Parameters.Add("@dominioid", SqlDbType.Char, 2).Value = BE.dominioid;
                 cmd.Parameters.Add("@moduloid", SqlDbType.Char, 4).Value = BE.moduloid;
                 cmd.Parameters.Add("@local", SqlDbType.VarChar, 3).Value = BE.local;
                 cmd.Parameters.Add("@perianio", SqlDbType.Char, 4).Value = BE.perianio;
                 cmd.Parameters.Add("@perimes", SqlDbType.Char, 2).Value = BE.perimes;
                 /*cmd.Parameters.Add("@tcamb", SqlDbType.Decimal).Value = BE.tcamb;
                 cmd.Parameters.Add("@igv", SqlDbType.Decimal).Value = BE.igv;*/
                 cmd.Parameters.Add("@inprec", SqlDbType.Char, 1).Value = BE.inprec;
                 cmd.Parameters.Add("@tipfactura", SqlDbType.Char, 2).Value = BE.tipfactura;
                 cmd.Parameters.Add("@tipboleta", SqlDbType.Char, 2).Value = BE.tipboleta;
                 cmd.Parameters.Add("@tipordprod", SqlDbType.Char, 2).Value = BE.tipordprod;
                 cmd.Parameters.Add("@tipordcomp", SqlDbType.Char, 2).Value = BE.tipordcomp;
                 cmd.Parameters.Add("@tipproforma", SqlDbType.Char, 2).Value = BE.tipproforma;
                 cmd.Parameters.Add("@tipguia1", SqlDbType.Char, 2).Value = BE.tipguia1;
                 cmd.Parameters.Add("@tipguia2", SqlDbType.Char, 2).Value = BE.tipguia2;
                 cmd.Parameters.Add("@tipguia3", SqlDbType.Char, 2).Value = BE.tipguia3;
                 cmd.Parameters.Add("@tipajusteing", SqlDbType.Char, 2).Value = BE.tipajusteing;
                 cmd.Parameters.Add("@tipajustesal", SqlDbType.Char, 2).Value = BE.tipajustesal;
                 cmd.Parameters.Add("@monedn", SqlDbType.Char, 1).Value = BE.monedn;
                 cmd.Parameters.Add("@monede", SqlDbType.Char, 1).Value = BE.monede;
                 cmd.Parameters.Add("@monedu", SqlDbType.Char, 1).Value = BE.monedu;
                 cmd.Parameters.Add("@monednsimbolo", SqlDbType.VarChar, 30).Value = BE.monednsimbolo;
                 cmd.Parameters.Add("@monedesimbolo", SqlDbType.VarChar, 30).Value = BE.monedesimbolo;
                 /*cmd.Parameters.Add("@posl1", SqlDbType.SmallInt).Value = BE.posl1;
                 cmd.Parameters.Add("@longl1", SqlDbType.SmallInt).Value = BE.longl1;
                 cmd.Parameters.Add("@posl2", SqlDbType.SmallInt).Value = BE.posl2;
                 cmd.Parameters.Add("@longl2", SqlDbType.SmallInt).Value = BE.longl2;
                 cmd.Parameters.Add("@posl3", SqlDbType.SmallInt).Value = BE.posl3;
                 cmd.Parameters.Add("@longl3", SqlDbType.SmallInt).Value = BE.longl3;*/
                 cmd.Parameters.Add("@descl1", SqlDbType.VarChar, 30).Value = BE.descl1;
                 cmd.Parameters.Add("@descl2", SqlDbType.VarChar, 30).Value = BE.descl2;
                 cmd.Parameters.Add("@descl3", SqlDbType.VarChar, 30).Value = BE.descl3;
                 /*cmd.Parameters.Add("@fechdigini", SqlDbType.DateTime).Value = BE.fechdigini;
                 cmd.Parameters.Add("@fechdigfin", SqlDbType.DateTime).Value = BE.fechdigfin;*/
             }
             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_constantesgenerales BE)
 {
     using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid)))
     {
         using (SqlCommand cmd = new SqlCommand("gspTbConstantesgenerales_DELETE", cnx))
         {
             {
                 cmd.CommandType = CommandType.StoredProcedure;
                 cmd.Parameters.Add("@dominioid", SqlDbType.Char, 2).Value = BE.dominioid;
                 cmd.Parameters.Add("@moduloid", SqlDbType.Char, 4).Value = BE.moduloid;
                 cmd.Parameters.Add("@local", SqlDbType.VarChar, 3).Value = BE.local;
             }
             try
             {
                 cnx.Open();
                 if (cmd.ExecuteNonQuery() > 0)
                 {
                     return true;
                 }
                 else
                 {
                     return false;
                 }
             }
             catch (Exception ex)
             {
                 throw new Exception(ex.Message);
             }
         }
     }
 }
 public bool Update(string empresaid, tb_constantesgenerales BE)
 {
     return tablaDA.Update(empresaid, BE);
 }
 public bool Insert(string empresaid, tb_constantesgenerales BE)
 {
     return tablaDA.Insert(empresaid, BE);
 }
 public DataSet GetAll(string empresaid, tb_constantesgenerales BE)
 {
     return tablaDA.GetAll(empresaid, BE);
 }
        public bool Update(string empresaid, tb_constantesgenerales BE)
        {
            using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid)))
            {
                using (SqlCommand cmd = new SqlCommand("gspTbConstantesgenerales_UPDATE", cnx))
                {

                    {
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.Add("@dominioid", SqlDbType.Char, 2).Value = BE.dominioid;
                        cmd.Parameters.Add("@moduloid", SqlDbType.Char, 4).Value = BE.moduloid;
                        cmd.Parameters.Add("@local", SqlDbType.VarChar, 3).Value = BE.local;
                        cmd.Parameters.Add("@perianio", SqlDbType.Char, 4).Value = BE.perianio;
                        cmd.Parameters.Add("@perimes", SqlDbType.Char, 2).Value = BE.perimes;
                        cmd.Parameters.Add("@fechadocedit", SqlDbType.Bit).Value = BE.fechadocedit;
                        cmd.Parameters.Add("@tcamb", SqlDbType.Decimal).Value = BE.tcamb;
                        cmd.Parameters.Add("@igv", SqlDbType.Decimal).Value = BE.igv;
                        cmd.Parameters.Add("@inprec", SqlDbType.Char, 1).Value = BE.inprec;
                        cmd.Parameters.Add("@tipfactura", SqlDbType.Char, 2).Value = BE.tipfactura;
                        cmd.Parameters.Add("@tipboleta", SqlDbType.Char, 2).Value = BE.tipboleta;
                        cmd.Parameters.Add("@tipordprod", SqlDbType.Char, 2).Value = BE.tipordprod;
                        cmd.Parameters.Add("@tipordcomp", SqlDbType.Char, 2).Value = BE.tipordcomp;
                        cmd.Parameters.Add("@tipproforma", SqlDbType.Char, 2).Value = BE.tipproforma;
                        cmd.Parameters.Add("@tipguia1", SqlDbType.Char, 2).Value = BE.tipguia1;
                        cmd.Parameters.Add("@tipguia2", SqlDbType.Char, 2).Value = BE.tipguia2;
                        cmd.Parameters.Add("@tipguia3", SqlDbType.Char, 2).Value = BE.tipguia3;
                        cmd.Parameters.Add("@tipajusteing", SqlDbType.Char, 2).Value = BE.tipajusteing;
                        cmd.Parameters.Add("@tipajustesal", SqlDbType.Char, 2).Value = BE.tipajustesal;
                        cmd.Parameters.Add("@monedn", SqlDbType.Char, 1).Value = BE.monedn;
                        cmd.Parameters.Add("@monede", SqlDbType.Char, 1).Value = BE.monede;
                        cmd.Parameters.Add("@monedu", SqlDbType.Char, 1).Value = BE.monedu;
                        cmd.Parameters.Add("@monednsimbolo", SqlDbType.VarChar, 30).Value = BE.monednsimbolo;
                        cmd.Parameters.Add("@monedesimbolo", SqlDbType.VarChar, 30).Value = BE.monedesimbolo;
                        cmd.Parameters.Add("@posl1", SqlDbType.SmallInt).Value = BE.posl1;
                        cmd.Parameters.Add("@longl1", SqlDbType.SmallInt).Value = BE.longl1;
                        cmd.Parameters.Add("@posl2", SqlDbType.SmallInt).Value = BE.posl2;
                        cmd.Parameters.Add("@longl2", SqlDbType.SmallInt).Value = BE.longl2;
                        cmd.Parameters.Add("@posl3", SqlDbType.SmallInt).Value = BE.posl3;
                        cmd.Parameters.Add("@longl3", SqlDbType.SmallInt).Value = BE.longl3;
                        cmd.Parameters.Add("@descl1", SqlDbType.VarChar, 30).Value = BE.descl1;
                        cmd.Parameters.Add("@descl2", SqlDbType.VarChar, 30).Value = BE.descl2;
                        cmd.Parameters.Add("@descl3", SqlDbType.VarChar, 30).Value = BE.descl3;
                        cmd.Parameters.Add("@fechdigini", SqlDbType.DateTime).Value = BE.fechdigini;
                        cmd.Parameters.Add("@fechdigfin", SqlDbType.DateTime).Value = BE.fechdigfin;
                        cmd.Parameters.Add("@ctactecli", SqlDbType.Char, 7).Value = BE.ctacteclie;
                        cmd.Parameters.Add("@ctacteinv", SqlDbType.Char, 7).Value = BE.ctacteinv;
                    }
                    try
                    {
                        cnx.Open();
                        if (cmd.ExecuteNonQuery() > 0)
                        {
                            return true;
                        }
                        else
                        {
                            return false;
                        }
                    }
                    catch (Exception ex)
                    {
                        throw new Exception(ex.Message);
                    }
                }
            }
        }
Exemplo n.º 7
0
        private void get_constantesGen(String dominioid, String moduloid, String local)
        {
            constantesgeneralesBL BL = new constantesgeneralesBL();
            tb_constantesgenerales BE = new tb_constantesgenerales();
            DataTable dt = new DataTable();

            try
            {
                dt = BL.GetOne(VariablesPublicas.EmpresaID, dominioid, moduloid, local).Tables[0];
                VariablesPublicas.perianio = dt.Rows[0]["perianio"].ToString().Trim();
                VariablesPublicas.perimes = dt.Rows[0]["perimes"].ToString().Trim();
                VariablesPublicas.igv = dt.Rows[0]["igv"].ToString().Trim();
                VariablesPublicas.fechdigini = dt.Rows[0]["fechdigini"].ToString().Trim();
                VariablesPublicas.fechdigfin = dt.Rows[0]["fechdigfin"].ToString().Trim();
            }
            catch (Exception ex)
            {
                ex.ToString();
                VariablesPublicas.perianio = "";
                VariablesPublicas.perimes = "";
                VariablesPublicas.igv = "";
                VariablesPublicas.fechdigini = "";
                VariablesPublicas.fechdigfin = "";

                MessageBoxEx.Show("Registrar en constantes Generales !!!", "Mensaje del Sistema", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
        private void Update()
        {
            var BL = new constantesgeneralesBL();
            var BE = new tb_constantesgenerales();
            BE.dominioid = dominio;
            BE.moduloid = modulo;
            BE.local = local;

            BE.perianio = sperianio.SelectedItem.ToString();
            BE.perimes = sperimes.SelectedValue.ToString().Trim().PadLeft(2, '0');

            BE.tcamb = Convert.ToDecimal(tcamb.Text.Trim());
            BE.igv = Convert.ToDecimal(igv.Text.Trim().ToUpper());
            BE.inprec = inprec.Text.Trim().ToUpper();
            BE.tipfactura = tipfactura.Text.Trim().ToUpper();
            BE.tipboleta = tipboleta.Text.Trim().ToUpper();
            BE.tipordprod = tipordprod.Text.Trim().ToUpper();
            BE.tipordcomp = tipordcomp.Text.Trim().ToUpper();
            BE.tipproforma = tipproforma.Text.Trim().ToUpper();
            BE.tipguia1 = tipguia1.Text.Trim().ToUpper();
            BE.tipguia2 = tipguia2.Text.Trim().ToUpper();
            BE.tipguia3 = tipguia3.Text.Trim().ToUpper();
            BE.tipajusteing = tipajusteing.Text.Trim().ToUpper();
            BE.tipajustesal = tipajustesal.Text.Trim().ToUpper();
            BE.monedn = monedn.Text.Trim().ToUpper();
            BE.monede = monede.Text.Trim().ToUpper();
            BE.monedu = monedu.Text.Trim().ToUpper();
            BE.monednsimbolo = monednsimbolo.Text.Trim().ToUpper();
            BE.monedesimbolo = monedesimbolo.Text.Trim().ToUpper();
            BE.posl1 = Convert.ToInt16(posl1.Text.Trim().ToUpper());
            BE.longl1 = Convert.ToInt16(longl1.Text.Trim().ToUpper());
            BE.posl2 = Convert.ToInt16(posl2.Text.Trim().ToUpper());
            BE.longl2 = Convert.ToInt16(longl2.Text.Trim().ToUpper());
            BE.posl3 = Convert.ToInt16(posl3.Text.Trim().ToUpper());
            BE.longl3 = Convert.ToInt16(longl3.Text.Trim().ToUpper());
            BE.descl1 = descl1.Text.Trim().ToUpper();
            BE.descl2 = descl2.Text.Trim().ToUpper();
            BE.descl3 = descl3.Text.Trim().ToUpper();
            if (fechdigini.Text.Trim().Length == 0)
            {
                BE.fechdigini = Convert.ToDateTime("01/01/1900");
            }
            else
            {
                BE.fechdigini = Convert.ToDateTime(fechdigini.Text.Trim());
            }

            if (fechdigfin.Text.Trim().Length == 0)
            {
                BE.fechdigfin = Convert.ToDateTime("01/01/1900");
            }
            else
            {
                BE.fechdigfin = Convert.ToDateTime(fechdigfin.Text.Trim());
            }

            BE.ctacteclie = "0000308";
            BE.ctacteinv = "0007483";

            try
            {
                if (BL.Update(EmpresaID, BE))
                {
                    if ((perianio != sperianio.SelectedValue) || (perimes != sperimes.SelectedValue))
                    {
                        Close();
                        VariablesPublicas.CerrarSession = true;
                        DL0Logistica.MainLogistica.ActiveForm.Close();
                    }
                }
                else
                {
                    MessageBox.Show("Contacte con Sistemas");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        private void Delete()
        {
            var BL = new constantesgeneralesBL();
            var BE = new tb_constantesgenerales();
            BE.dominioid = dominio;
            BE.moduloid = modulo;
            BE.local = local;

            try
            {
                if (BL.Delete(EmpresaID, BE))
                {
                    MessageBox.Show("Se eliminó con éxito");
                    Nuevo();
                }
                else
                {
                    MessageBox.Show("Contactese con Sistemas");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        private void Insert()
        {
            var BL = new constantesgeneralesBL();
            var BE = new tb_constantesgenerales();

            BE.dominioid = dominio;
            BE.moduloid = modulo;
            BE.local = local;

            BE.perianio = sperianio.SelectedItem.ToString();
            BE.perimes = sperimes.SelectedValue.ToString().Trim().PadLeft(2, '0');

            BE.tcamb = (tcamb.Text.Trim() == string.Empty) ? 0 : Convert.ToDecimal(tcamb.Text.Trim());
            BE.igv = (igv.Text.Trim() == string.Empty) ? 18 : Convert.ToDecimal(igv.Text.Trim());
            BE.inprec = inprec.Text.Trim().ToUpper();
            BE.tipfactura = tipfactura.Text.Trim().ToUpper();
            BE.tipboleta = tipboleta.Text.Trim().ToUpper();
            BE.tipordprod = tipordprod.Text.Trim().ToUpper();
            BE.tipordcomp = tipordcomp.Text.Trim().ToUpper();
            BE.tipproforma = tipproforma.Text.Trim().ToUpper();
            BE.tipguia1 = tipguia1.Text.Trim().ToUpper();
            BE.tipguia2 = tipguia2.Text.Trim().ToUpper();
            BE.tipguia3 = tipguia3.Text.Trim().ToUpper();
            BE.tipajusteing = tipajusteing.Text.Trim().ToUpper();
            BE.tipajustesal = tipajustesal.Text.Trim().ToUpper();
            BE.monedn = monedn.Text.Trim().ToUpper();
            BE.monede = monede.Text.Trim().ToUpper();
            BE.monedu = monedu.Text.Trim().ToUpper();
            BE.monednsimbolo = monednsimbolo.Text.Trim().ToUpper();
            BE.monedesimbolo = monedesimbolo.Text.Trim().ToUpper();
            BE.posl1 = Convert.ToInt16((posl1.Text.Trim() == string.Empty) ? "0" : posl1.Text.Trim());
            BE.longl1 = Convert.ToInt16((longl1.Text.Trim() == string.Empty) ? "0" : longl1.Text.Trim());
            BE.posl2 = Convert.ToInt16((posl2.Text.Trim() == string.Empty) ? "0" : posl2.Text.Trim());
            BE.longl2 = Convert.ToInt16((longl2.Text.Trim() == string.Empty) ? "0" : longl2.Text.Trim());
            BE.posl3 = Convert.ToInt16((posl3.Text.Trim() == string.Empty) ? "0" : posl3.Text.Trim());
            BE.longl3 = Convert.ToInt16((longl3.Text.Trim() == string.Empty) ? "0" : longl3.Text.Trim());
            BE.descl1 = descl1.Text.Trim().ToUpper();
            BE.descl2 = descl2.Text.Trim().ToUpper();
            BE.descl3 = descl3.Text.Trim().ToUpper();
            BE.fechdigini = (fechdigini.Text.Trim().Length == 0) ? Convert.ToDateTime("01/01/1900") : Convert.ToDateTime(fechdigini.Text.Trim());
            BE.fechdigfin = (fechdigfin.Text.Trim().Length == 0) ? Convert.ToDateTime("01/01/1900") : Convert.ToDateTime(fechdigfin.Text.Trim());

            try
            {
                if (BL.Insert(EmpresaID, BE))
                {
                    if ((perianio != sperianio.SelectedValue) || (perimes != sperimes.SelectedValue))
                    {
                        Close();
                        VariablesPublicas.CerrarSession = true;
                        MainMercaderia.ActiveForm.Close();
                    }
                }
                else
                {
                    MessageBox.Show("Conectese Con Sistemas", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        private void get_val_fechadoc()
        {
            try
            {
                constantesgeneralesBL BL = new constantesgeneralesBL();
                tb_constantesgenerales BE = new tb_constantesgenerales();
                DataTable dt = new DataTable();

                dt = BL.GetOne(EmpresaID, dominio, modulo, local).Tables[0];
                if (dt.Rows.Count > 0)
                {
                    perianio = dt.Rows[0]["perianio"].ToString().Trim();
                    // Vamos Obtener el Check de Perimes Local Para Usar el Perimes de Constanantes o del Bapconfig
                    var BL2 = new sys_localBL();
                    var BE2 = new tb_sys_local();
                    DataTable dt2 = new DataTable();
                    BE2.dominioid = dominio.ToString();
                    BE2.moduloid = modulo.ToString(); ;
                    BE2.local = local.ToString();
                    dt2 = BL2.GetAll(VariablesPublicas.EmpresaID, BE2).Tables[0];
                    if (dt2.Rows.Count > 0)
                    {
                        if (Convert.ToBoolean(dt2.Rows[0]["perimeslocal"]))
                        {
                            // Hemos Fijado el Perimes en BapConfig
                            perimes = _perimes;
                        }
                        else
                        {
                            // Ponemos el Perimes de Constantes Generales
                            perimes = dt.Rows[0]["perimes"].ToString().Trim();
                        }
                    }
                    if (dt.Rows[0]["fechadocedit"].ToString().Trim().Length > 0)
                    {
                        fechadocedit = Convert.ToBoolean(dt.Rows[0]["fechadocedit"]);
                    }
                }

                DateTime fechaactual = DateTime.Today;
                DateTime fechaperiodo = Convert.ToDateTime("01" + "/" + perimes + "/" + perianio);

                if (fechadocedit)
                {
                    //DateTime primerdia = new DateTime(fechaperiodo.Year, fechaperiodo.Month, 1);
                    //DateTime ultimodia = primerdia.AddMonths(1).AddDays(-1);
                    //if (fechaactual.Day <= ultimodia.Day)
                    //{
                    //    fechdoc.Value = Convert.ToDateTime(fechaactual.Day + "/" + perimes + "/" + perianio);
                    //}
                    //else
                    //{
                    //    fechdoc.Value = Convert.ToDateTime(ultimodia.Day + "/" + perimes + "/" + perianio);
                    //}
                    //fechdoc.MaxDate = ultimodia;
                    //fechdoc.MinDate = primerdia;
                }
                else
                {
                    if (fechaactual.Month == fechaperiodo.Month && fechaactual.Year == fechaperiodo.Year)
                    {
                        fechdoc.Value = fechaactual;
                        //fechdoc.Enabled = false;
                    }
                    else
                    {
                        MessageBox.Show("Actualizar a Periodo Actual en Tabla Constantes Generales !!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        statusDoc = false;
                    }
                }
                get_tipocambio(fechdoc.Text);
                get_tipimptoid();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                statusDoc = false;
            }
        }