public bool Delete(string empresaid, tb_ad_movimientos BE)
        {
            using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid)))
            {
                using (SqlCommand cmd1 = new SqlCommand("gspTbAdMovimientos_DELETE", cnx))
                {
                    cmd1.CommandTimeout = 0;
                    cmd1.CommandType = CommandType.StoredProcedure;
                    cmd1.Parameters.Add("@moduloid", SqlDbType.Char, 4).Value = BE.moduloid;
                    cmd1.Parameters.Add("@local", SqlDbType.Char, 3).Value = BE.local;
                    cmd1.Parameters.Add("@tipodoc", SqlDbType.Char, 2).Value = BE.tipodoc;
                    cmd1.Parameters.Add("@serdoc", SqlDbType.Char, 4).Value = BE.serdoc;
                    cmd1.Parameters.Add("@numdoc", SqlDbType.Char, 10).Value = BE.numdoc;
                    cmd1.Parameters.Add("@status", SqlDbType.Char, 1).Value = BE.status;
                    cmd1.Parameters.Add("@usuar", SqlDbType.Char, 15).Value = BE.usuar;

                    try
                    {
                        cnx.Open();
                        if (cmd1.ExecuteNonQuery() > 0)
                        {
                            return true;
                        }
                        else
                        {
                            return false;
                        }
                    }
                    catch (Exception ex)
                    {
                        throw new Exception(ex.Message);
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void data_Tabladetallemovmov_referencia()
        {
            try
            {
                Decimal xxprecventa = 0;
                Decimal xxcostoultimo = 0;
                Decimal xxstock = 0;
                Decimal xxcostopromed = 0;
                griddetallemov.AutoGenerateColumns = false;

                var BL = new tb_ad_movimientosBL();
                var BE = new tb_ad_movimientos();
                var dt = new DataTable();
                BE.moduloid = modulo;
                BE.local = local;
                BE.tipodoc = tipfac.Text.Trim();
                BE.serdoc = serfac.Text.Trim().PadLeft(4, '0');
                BE.numdoc = numfac.Text.Trim().PadLeft(6, '0');

                dt = null; //BL.GetAll_datosdetalle(EmpresaID, BE).Tables[0];

                if (dt.Rows.Count > 0)
                {
                    statcostopromed = dt.Rows[0]["statcostopromed"].ToString();
                    tiptransac = dt.Rows[0]["tiptransac"].ToString();
                    incprec = dt.Rows[0]["incprec"].ToString().Trim();
                }

                if (Tabladetallemov != null)
                {
                    Tabladetallemov.Clear();
                }

                foreach (DataRow fila in dt.Rows)
                {
                    var BL2 = new tb_ad_local_stockBL();
                    var BE2 = new tb_ad_local_stock();
                    var dt2 = new DataTable();
                    BE2.moduloid = modulo;
                    BE2.productid = fila["productid"].ToString();
                    dt2.Clear();
                    dt2 = BL2.GetAll(EmpresaID, BE2).Tables[0];

                    if (dt2.Rows.Count > 0)
                    {

                        if (almacaccionid.Trim() == "20" || almacaccionid.Trim() == "21")
                        {
                            lbl_valor.Text = "Cost.Prom";
                            xxprecventa = 0;
                            xxcostopromed = Convert.ToDecimal(dt2.Rows[0]["costopromed"]);
                        }
                        else
                        {
                            if (almacaccionid.Trim() == "10" || almacaccionid.Trim() == "11")
                            {
                                lbl_valor.Text = "Cost.Ultm";
                                xxcostoultimo = Convert.ToDecimal(dt2.Rows[0]["costoultimo"]);
                            }
                        }
                        xxstock = Convert.ToDecimal(dt2.Rows[0]["stock"]);
                    }

                    row = Tabladetallemov.NewRow();
                    row["itemref"] = fila["itemref"].ToString();
                    row["items"] = fila["items"].ToString();
                    row["productid"] = fila["productid"].ToString().Trim();
                    row["productname"] = fila["productname"].ToString().Trim();
                    row["rollo"] = fila["rollo"].ToString();
                    row["stock"] = xxstock;
                    row["stock_old"] = xxstock;
                    row["precventa"] = xxprecventa;
                    row["costoultimo"] = xxcostoultimo;
                    row["costopromed"] = xxcostopromed;

                    var cantidad = Math.Round(Convert.ToDecimal(fila["cantidad"]), 4);
                    var cantidadcta = Math.Round(Convert.ToDecimal(fila["cantidadcta"]), 4);
                    Decimal total;
                    total = cantidad - cantidadcta;

                    row["cantidad"] = total;

                    row["cantidad_old"] = Math.Round(Convert.ToDecimal(fila["cantidad"]), 4);
                    row["precunit"] = Math.Round(Convert.ToDecimal(Convert.ToDecimal(fila["precunit"]).ToString("###,###,##0.000000")), 6);
                    row["importfac"] = Math.Round(Convert.ToDecimal(fila["importfac"]), 2);
                    row["valor"] = Math.Round(Convert.ToDecimal(fila["valor"]), 6);
                    row["importe"] = Math.Round(Convert.ToDecimal(fila["importe"]), 6);
                    row["totimpto"] = Math.Round(Math.Round(Convert.ToDecimal(fila["importe"]), 6) * (Convert.ToDecimal(18) / 100), 6);
                    row["almacaccionid"] = almacaccionid.Trim();
                    row["unmed"] = fila["unmed"].ToString().Trim();
                    row["ubicacion"] = fila["ubicacion"].ToString().Trim();
                    row["nostock"] = xnostock;
                    Tabladetallemov.Rows.Add(row);
                }
                griddetallemov.DataSource = Tabladetallemov;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
 public DataSet GetAll(string empresaid, tb_ad_movimientos BE)
 {
     using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid)))
     {
         using (SqlCommand cmd = new SqlCommand("gspTbTaMovimientoscab_SEARCH", cnx))
         {
             DataSet ds = new DataSet();
             {
                 cmd.CommandType = CommandType.StoredProcedure;
                 cmd.Parameters.Add("@moduloid", SqlDbType.Char, 4).Value = BE.moduloid;
                 cmd.Parameters.Add("@local", SqlDbType.Char, 3).Value = BE.local;
                 cmd.Parameters.Add("@tipodoc", SqlDbType.Char, 2).Value = BE.tipodoc;
                 cmd.Parameters.Add("@serdoc", SqlDbType.Char, 4).Value = BE.serdoc;
                 cmd.Parameters.Add("@numdoc", SqlDbType.Char, 10).Value = BE.numdoc;
                 cmd.Parameters.Add("@status", SqlDbType.Char, 1).Value = BE.status;
                 cmd.Parameters.Add("@almacaccionid", SqlDbType.Char, 2).Value = BE.almacaccionid;
                 cmd.Parameters.Add("@tipoperacionid", SqlDbType.Char, 2).Value = BE.tipoperacionid;
                 cmd.Parameters.Add("@ctacteaccionid", SqlDbType.Char, 2).Value = BE.ctacteaccionid;
                 //cmd.Parameters.Add("@fechdoc", SqlDbType.DateTime).Value = BE.fechdoc;
                 cmd.Parameters.Add("@ctacte", SqlDbType.Char, 7).Value = BE.ctacte;
                 cmd.Parameters.Add("@ctactename", SqlDbType.VarChar, 70).Value = BE.ctactename;
                 cmd.Parameters.Add("@direcnume", SqlDbType.Char, 6).Value = BE.direcnume;
                 cmd.Parameters.Add("@direcname", SqlDbType.VarChar, 25).Value = BE.direcname;
                 cmd.Parameters.Add("@direcdeta", SqlDbType.VarChar, 70).Value = BE.direcdeta;
                 cmd.Parameters.Add("@tipdid", SqlDbType.Char, 1).Value = BE.tipdid;
                 cmd.Parameters.Add("@nmruc", SqlDbType.Char, 11).Value = BE.nmruc;
                 cmd.Parameters.Add("@tipref", SqlDbType.Char, 2).Value = BE.tipref;
                 cmd.Parameters.Add("@serref", SqlDbType.Char, 4).Value = BE.serref;
                 cmd.Parameters.Add("@numref", SqlDbType.Char, 10).Value = BE.numref;
                 cmd.Parameters.Add("@tipfac", SqlDbType.Char, 2).Value = BE.tipfac;
                 cmd.Parameters.Add("@serfac", SqlDbType.Char, 4).Value = BE.serfac;
                 cmd.Parameters.Add("@numfac", SqlDbType.Char, 10).Value = BE.numfac;
                 //cmd.Parameters.Add("@fechfac", SqlDbType.DateTime).Value = BE.fechfac;
                 cmd.Parameters.Add("@tipguia", SqlDbType.Char, 2).Value = BE.tipguia;
                 cmd.Parameters.Add("@serguia", SqlDbType.Char, 4).Value = BE.serguia;
                 cmd.Parameters.Add("@numguia", SqlDbType.Char, 10).Value = BE.numguia;
                 //cmd.Parameters.Add("@fechguia", SqlDbType.DateTime).Value = BE.fechguia;
                 cmd.Parameters.Add("@tipnotac", SqlDbType.Char, 2).Value = BE.tipnotac;
                 cmd.Parameters.Add("@sernotac", SqlDbType.Char, 4).Value = BE.sernotac;
                 cmd.Parameters.Add("@numnotac", SqlDbType.Char, 10).Value = BE.numnotac;
                 //cmd.Parameters.Add("@fechnotac", SqlDbType.DateTime).Value = BE.fechnotac;
                 cmd.Parameters.Add("@vendorid", SqlDbType.Char, 4).Value = BE.vendorid;
                 cmd.Parameters.Add("@cencosid", SqlDbType.Char, 5).Value = BE.cencosid;
                 //cmd.Parameters.Add("@dscto3", SqlDbType.Decimal).Value = BE.dscto3;
                 //cmd.Parameters.Add("@totdscto1", SqlDbType.Decimal).Value = BE.totdscto1;
                 //cmd.Parameters.Add("@totdscto2", SqlDbType.Decimal).Value = BE.totdscto2;
                 //cmd.Parameters.Add("@totdscto3", SqlDbType.Decimal).Value = BE.totdscto3;
                 cmd.Parameters.Add("@condpago", SqlDbType.Char, 4).Value = BE.condpago;
                 //cmd.Parameters.Add("@transporte", SqlDbType.Decimal).Value = BE.transporte;
                 //cmd.Parameters.Add("@embalaje", SqlDbType.Decimal).Value = BE.embalaje;
                 //cmd.Parameters.Add("@otros", SqlDbType.Decimal).Value = BE.otros;
                 cmd.Parameters.Add("@tipimptoid", SqlDbType.Char, 1).Value = BE.tipimptoid;
                 //cmd.Parameters.Add("@igv", SqlDbType.Decimal).Value = BE.igv;
                 cmd.Parameters.Add("@incprec", SqlDbType.Char, 1).Value = BE.incprec;
                 //cmd.Parameters.Add("@totimpto", SqlDbType.Decimal).Value = BE.totimpto;
                 //cmd.Parameters.Add("@valventa", SqlDbType.Decimal).Value = BE.valventa;
                 //cmd.Parameters.Add("@totimporte", SqlDbType.Decimal).Value = BE.totimporte;
                 //cmd.Parameters.Add("@bruto", SqlDbType.Decimal).Value = BE.bruto;
                 //cmd.Parameters.Add("@cargo", SqlDbType.Decimal).Value = BE.cargo;
                 //cmd.Parameters.Add("@abono", SqlDbType.Decimal).Value = BE.abono;
                 //cmd.Parameters.Add("@tcamb", SqlDbType.Decimal).Value = BE.tcamb;
                 cmd.Parameters.Add("@glosa", SqlDbType.VarChar, 300).Value = BE.glosa;
                 //cmd.Parameters.Add("@totpzas", SqlDbType.Decimal).Value = BE.totpzas;
                 //cmd.Parameters.Add("@fechentrega", SqlDbType.DateTime).Value = BE.fechentrega;
                 //cmd.Parameters.Add("@fechpago", SqlDbType.DateTime).Value = BE.fechpago;
                 //cmd.Parameters.Add("@fechcancel", SqlDbType.DateTime).Value = BE.fechcancel;
                 cmd.Parameters.Add("@moneda", SqlDbType.Char).Value = BE.moneda;
                 cmd.Parameters.Add("@transpid", SqlDbType.Char, 5).Value = BE.transpid;
                 cmd.Parameters.Add("@transpname", SqlDbType.VarChar, 40).Value = BE.transpname;
                 cmd.Parameters.Add("@motivotrasladoid", SqlDbType.Char, 2).Value = BE.motivotrasladoid;
                 cmd.Parameters.Add("@mottrasladointid", SqlDbType.Char, 2).Value = BE.mottrasladointid;
                 //cmd.Parameters.Add("@items", SqlDbType.Decimal).Value = BE.items;
                 cmd.Parameters.Add("@perianio", SqlDbType.Char, 4).Value = BE.perianio;
                 cmd.Parameters.Add("@perimes", SqlDbType.Char, 2).Value = BE.perimes;
                 cmd.Parameters.Add("@usuar", SqlDbType.Char, 15).Value = BE.usuar;
             }
             try
             {
                 cnx.Open();
                 using (SqlDataAdapter da = new SqlDataAdapter(cmd))
                 {
                     da.Fill(ds);
                 }
                 return ds;
             }
             catch (Exception ex)
             {
                 throw new Exception(ex.Message);
             }
         }
     }
 }
        public bool Update(string empresaid, tb_ad_movimientos BE)
        {
            using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid)))
            {
                using (SqlCommand cmd = new SqlCommand("gspTbAdMovimientos_UPDATE", cnx))
                {
                    cmd.CommandTimeout = 0;
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add("@moduloid", SqlDbType.Char, 4).Value = BE.moduloid;
                    cmd.Parameters.Add("@local", SqlDbType.Char, 3).Value = BE.local;
                    cmd.Parameters.Add("@tipodoc", SqlDbType.Char, 2).Value = BE.tipodoc;
                    cmd.Parameters.Add("@serdoc", SqlDbType.Char, 4).Value = BE.serdoc;
                    cmd.Parameters.Add("@numdoc", SqlDbType.Char, 10).Value = BE.numdoc;
                    cmd.Parameters.Add("@status", SqlDbType.Char, 1).Value = BE.status;
                    cmd.Parameters.Add("@almacaccionid", SqlDbType.Char, 2).Value = BE.almacaccionid;
                    cmd.Parameters.Add("@tipoperacionid", SqlDbType.Char, 2).Value = BE.tipoperacionid;
                    cmd.Parameters.Add("@ctacteaccionid", SqlDbType.Char, 2).Value = BE.ctacteaccionid;
                    cmd.Parameters.Add("@fechdoc", SqlDbType.DateTime).Value = fecha(BE.fechdoc);
                    cmd.Parameters.Add("@ctacte", SqlDbType.Char, 7).Value = BE.ctacte;
                    cmd.Parameters.Add("@ctactename", SqlDbType.VarChar, 70).Value = BE.ctactename;
                    cmd.Parameters.Add("@direcnume", SqlDbType.Char, 6).Value = BE.direcnume;
                    cmd.Parameters.Add("@direcname", SqlDbType.VarChar, 25).Value = BE.direcname;
                    cmd.Parameters.Add("@direcdeta", SqlDbType.VarChar, 70).Value = BE.direcdeta;
                    cmd.Parameters.Add("@tipdid", SqlDbType.Char, 1).Value = BE.tipdid;
                    cmd.Parameters.Add("@nmruc", SqlDbType.Char, 11).Value = BE.nmruc;
                    cmd.Parameters.Add("@tipref", SqlDbType.Char, 2).Value = BE.tipref;
                    cmd.Parameters.Add("@serref", SqlDbType.Char, 4).Value = BE.serref;
                    cmd.Parameters.Add("@numref", SqlDbType.Char, 10).Value = BE.numref;
                    cmd.Parameters.Add("@fechref", SqlDbType.DateTime).Value = fecha(BE.fechref);
                    cmd.Parameters.Add("@tipfac", SqlDbType.Char, 2).Value = BE.tipfac;
                    cmd.Parameters.Add("@serfac", SqlDbType.Char, 4).Value = BE.serfac;
                    cmd.Parameters.Add("@numfac", SqlDbType.Char, 10).Value = BE.numfac;
                    cmd.Parameters.Add("@fechfac", SqlDbType.DateTime).Value = BE.fechfac;
                    cmd.Parameters.Add("@tipguia", SqlDbType.Char, 2).Value = BE.tipguia;
                    cmd.Parameters.Add("@serguia", SqlDbType.Char, 4).Value = BE.serguia;
                    cmd.Parameters.Add("@numguia", SqlDbType.Char, 10).Value = BE.numguia;
                    cmd.Parameters.Add("@fechguia", SqlDbType.DateTime).Value = BE.fechguia;
                    cmd.Parameters.Add("@tipnotac", SqlDbType.Char, 2).Value = BE.tipnotac;
                    cmd.Parameters.Add("@sernotac", SqlDbType.Char, 4).Value = BE.sernotac;
                    cmd.Parameters.Add("@numnotac", SqlDbType.Char, 10).Value = BE.numnotac;
                    cmd.Parameters.Add("@fechnotac", SqlDbType.DateTime).Value = BE.fechnotac;
                    cmd.Parameters.Add("@vendorid", SqlDbType.Char, 4).Value = BE.vendorid;
                    cmd.Parameters.Add("@cencosid", SqlDbType.Char, 5).Value = BE.cencosid;
                    cmd.Parameters.Add("@totdscto1", SqlDbType.Decimal).Value = BE.totdsctoEmp;
                    cmd.Parameters.Add("@totdscto2", SqlDbType.Decimal).Value = BE.totdsctoTar;
                    cmd.Parameters.Add("@totdscto3", SqlDbType.Decimal).Value = BE.totdsctoAdd;
                    cmd.Parameters.Add("@condpago", SqlDbType.Char, 4).Value = BE.condpago;
                    cmd.Parameters.Add("@tipimptoid", SqlDbType.Char, 1).Value = BE.tipimptoid;
                    cmd.Parameters.Add("@igv", SqlDbType.Decimal).Value = BE.tasaigv;
                    cmd.Parameters.Add("@incprec", SqlDbType.Char, 1).Value = BE.incprec;
                    cmd.Parameters.Add("@totimpto", SqlDbType.Decimal).Value = BE.totimpto;
                    cmd.Parameters.Add("@valventa", SqlDbType.Decimal).Value = BE.valventa;
                    cmd.Parameters.Add("@totimporte", SqlDbType.Decimal).Value = BE.totimporte;
                    cmd.Parameters.Add("@tcamb", SqlDbType.Decimal).Value = BE.tcamb;
                    cmd.Parameters.Add("@glosa", SqlDbType.VarChar, 300).Value = BE.glosa;
                    cmd.Parameters.Add("@totpzas", SqlDbType.Decimal).Value = BE.totpzas;
                    cmd.Parameters.Add("@moneda", SqlDbType.Char).Value = BE.moneda;
                    cmd.Parameters.Add("@transpid", SqlDbType.Char, 5).Value = BE.transpid;
                    cmd.Parameters.Add("@transpname", SqlDbType.VarChar, 40).Value = BE.transpname;
                    cmd.Parameters.Add("@motivotrasladoid", SqlDbType.Char, 2).Value = BE.motivotrasladoid;
                    cmd.Parameters.Add("@mottrasladointid", SqlDbType.Char, 2).Value = BE.mottrasladointid;
                    cmd.Parameters.Add("@items", SqlDbType.Decimal).Value = BE.items;
                    cmd.Parameters.Add("@perianio", SqlDbType.Char, 4).Value = BE.perianio;
                    cmd.Parameters.Add("@perimes", SqlDbType.Char, 2).Value = BE.perimes;
                    cmd.Parameters.Add("@usuar", SqlDbType.Char, 15).Value = BE.usuar;

                    cmd.Parameters.Add("@tarjimporte1", SqlDbType.Decimal).Value = BE.tarjimporte;
                    cmd.Parameters.Add("@efectivo", SqlDbType.Decimal).Value = BE.efectivo;
                    /***************************************************************************************/

                    //
                    cmd.Parameters.Add("@XMLnew", SqlDbType.Xml).Value = BE.GetItemXML();
                    cmd.Parameters.Add("@XMLold", SqlDbType.Xml).Value = BE.GetItemXML2();
                    if (BE.tipodoc == "BV" || BE.tipodoc == "FA")
                    { cmd.Parameters.Add("@XMLT", SqlDbType.Xml).Value = BE.TarjetasXML(); }

                    try
                    {
                        cnx.Open();
                        if (cmd.ExecuteNonQuery() > 0)
                        {
                            return true;
                        }
                        else
                        {
                            return false;
                        }
                    }
                    catch (Exception ex)
                    {
                        throw new Exception(ex.Message);
                    }
                }
            }
        }
        public DataSet Sunat141_RegVentas(string empresaid, tb_ad_movimientos BE)
        {
            using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid)))
            {
                using (SqlCommand cmd = new SqlCommand("gspTbAdMovimientos_Sunat141_RegVentas", cnx))
                {
                    DataSet ds = new DataSet();

                    {
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.Add("@moduloid", SqlDbType.Char, 4).Value = BE.moduloid;
                        cmd.Parameters.Add("@local", SqlDbType.Char, 3).Value = BE.local;
                        cmd.Parameters.Add("@perianio", SqlDbType.Char, 4).Value = BE.perianio;
                        cmd.Parameters.Add("@perimes", SqlDbType.Char, 2).Value = BE.perimes;
                    }

                    try
                    {
                        cnx.Open();
                        using (SqlDataAdapter da = new SqlDataAdapter(cmd))
                        {
                            da.Fill(ds);
                        }
                        return ds;
                    }
                    catch (Exception ex)
                    {
                        throw new Exception(ex.Message);
                    }
                }
            }
        }
 public DataSet GetAll_paginacion(string empresaid, tb_ad_movimientos BE)
 {
     return tablaDA.GetAll_paginacion(empresaid, BE);
 }
Exemplo n.º 7
0
        private void Update()
        {
            _cal_Igv();
            try
            {
                if (cabecera_valida())
                {
                    #region Datos de Cabecera
                    var BL = new tb_ad_movimientosBL();
                    var BE = new tb_ad_movimientos();

                    var Detalle = new tb_ad_movimientos.Item();
                    var ListaItems = new List<tb_ad_movimientos.Item>();

                    var Detalle2 = new tb_ad_movimientos.Tarjetas();
                    var ListaTarjetas = new List<tb_ad_movimientos.Tarjetas>();

                    BE.moduloid = modulo;
                    BE.local = local;
                    BE.tipodoc = tipodoc.SelectedValue.ToString();
                    BE.serdoc = serdoc.Text.Trim();
                    BE.numdoc = numdoc.Text.ToString();
                    BE.fechdoc = Convert.ToDateTime(fechdoc.Text);
                    BE.moneda = moneda.SelectedValue.ToString().Trim();
                    BE.tcamb = Convert.ToDecimal(tcamb.Text.Trim());

                    if (tipguia.Text.Trim().Length > 0 && serguia.Text.Trim().Length > 0 && numguia.Text.Trim().Length > 0)
                    {
                        almacaccionid = "21";
                        BE.almacaccionid = almacaccionid.ToString();
                    }
                    else
                    {
                        BE.almacaccionid = almacaccionid.Trim();
                    }

                    BE.tipoperacionid = tip_operacion.ToString();
                    BE.ctacteaccionid = string.Empty;
                    BE.ctacte = ctacte.Text.Trim().ToUpper();
                    BE.nmruc = nmruc.Text.Trim();
                    BE.ctactename = ctactename.Text.Trim().ToUpper();
                    BE.direcnume = direcnume.Trim().ToUpper();
                    BE.vendorid = vendperid.Text.ToString();

                    if (serfac.Text.Trim().Length > 0 && numfac.Text.Trim().Length > 0)
                    {
                        BE.tipfac = tipfac.SelectedItem.ToString();
                        BE.serfac = serfac.Text.Trim().ToString().PadLeft(4, '0');
                        BE.numfac = numfac.Text.Trim().ToString().PadLeft(10, '0');
                        if (!fechfac.IsEmpty)
                        {
                            BE.fechfac = Convert.ToDateTime(fechfac.Text.Trim());
                        }

                        //BE.recep_name = recep_name.Text.Trim();
                        //BE.recep_dni = recep_dni.Text.Trim();
                        //if (!recep_fecha.IsEmpty)
                        //{
                        //    BE.recep_fecha = Convert.ToDateTime(recep_fecha.Text.Trim());
                        //}
                    }

                    if (serguia.Text.Trim().Length > 0 && numguia.Text.Trim().Length > 0)
                    {
                        BE.tipguia = tipguia.Text.Trim();
                        BE.serguia = serguia.Text.Trim().ToString().PadLeft(4, '0');
                        BE.numguia = numguia.Text.Trim().ToString().PadLeft(10, '0');
                        if (!fechguia.IsEmpty)
                        {
                            BE.fechguia = Convert.ToDateTime(fechguia.Text.Trim());
                        }
                    }

                    if (sernotac.Text.Trim().Length > 0 && numnotac.Text.Trim().Length > 0)
                    {
                        BE.tipnotac = tipnotac.Text.Trim();
                        BE.sernotac = sernotac.Text.Trim().ToString().PadLeft(4, '0');
                        BE.numnotac = numnotac.Text.Trim().ToString().PadLeft(10, '0');
                        if (!fechnotac.IsEmpty)
                        {
                            BE.fechnotac = Convert.ToDateTime(fechnotac.Text.Trim());
                        }
                    }

                    BE.tipimptoid = tipimptotasa.SelectedValue.ToString().Trim();
                    BE.incprec = Equivalencias.Left(cbo_incprec.Text.Trim(), 1);
                    BE.items = Convert.ToDecimal(itemsT.Text.Trim());
                    BE.totpzas = Convert.ToDecimal(totpzas.Text.Trim());
                    BE.tasaigv = igv;
                    BE.totimpto = Convert.ToDecimal(totimpto.Text.Trim());
                    BE.valventa = Convert.ToDecimal(valventa.Text.Trim());
                    BE.totimporte = Convert.ToDecimal(totimporte.Text.Trim());
                    BE.glosa = glosa.Text.Trim().ToUpper().ToString();
                    // Venta en Combo
                    // BE.princombo = princombo.Checked;
                    // BE.cantcombo = Convert.ToInt32(canticombo.Text.ToString());
                    // BE.preccombo = Convert.ToDecimal(preccombo.Text.ToString());
                    //
                    //try
                    //{
                    //    BE.fechcancel = Convert.ToDateTime("01/01/1900");
                    //}
                    //catch
                    //{
                    //    BE.fechcancel = Convert.ToDateTime("01/01/1900");
                    //}

                    BE.tipdid = string.Empty;
                    //BE.statborrado = string.Empty;
                    //BE.clientetipo = string.Empty;
                    //BE.modofactu = string.Empty;
                    //BE.tipodocmanejaserie = tipodocmanejaserie;
                    BE.ncaja = _cajanume.ToString();
                    BE.perianio = fechdoc.Value.Year.ToString();
                    BE.perimes = fechdoc.Value.Month.ToString().PadLeft(2, '0');
                    BE.status = "0";
                    BE.usuar = VariablesPublicas.Usuar;

                    // Agregando Datos de Cabecera
                    if (TablaTarjetas.Rows.Count > 0)
                    {
                        //BE.Tarjetaid = Convert.ToInt32(TablaTarjetas.Rows[0]["tarjetaid"].ToString());
                        //BE.Tarjnumoper = TablaTarjetas.Rows[0]["tarjetanume"].ToString();
                        BE.tarjimporte = Convert.ToDecimal(importtarj.Text);
                    }

                    if (txtefectivo.Text.Length > 0)
                    { BE.efectivo = Convert.ToDecimal(txtefectivo.Text); }
                    else { BE.efectivo = 0; }
                    #endregion

                    /*****************************************************/

                    #region Movimientos - Detalle

                    var item = 0;
                    foreach (DataRow fila in Tabladetallemov.Rows)
                    {
                        Detalle = new tb_ad_movimientos.Item();
                        item++;
                        Detalle.fechdoc = Convert.ToDateTime(fechdoc.Text);
                        Detalle.tipoperacionid = "01";
                        Detalle.ctacte = ctacte.Text.Trim().ToUpper();
                        Detalle.direcnume = direcnume.Trim().ToUpper();
                        Detalle.itemref = fila["itemref"].ToString();
                        Detalle.productid = fila["productid"].ToString();
                        Detalle.productname = fila["productname"].ToString();
                        Detalle.ubicacion = fila["ubicacion"].ToString();
                        Detalle.unmed = fila["unmed"].ToString();

                        Detalle.cantidad = Convert.ToDecimal(fila["cantidad"].ToString());

                        Detalle.valor = Convert.ToDecimal(fila["valor"].ToString());
                        Detalle.importe = Convert.ToDecimal(fila["importe"].ToString());

                        Detalle.precioanterior = Convert.ToDecimal(fila["precioanterior"].ToString());

                        Detalle.precunit = Convert.ToDecimal(fila["precunit"].ToString());
                        Detalle.importfac = Convert.ToDecimal(fila["importfac"].ToString());
                        Detalle.totimpto = Convert.ToDecimal(fila["totimpto"].ToString());

                        Detalle.almacaccionid = almacaccionid;
                        Detalle.statcostopromed = statcostopromed.Trim();
                        Detalle.tasaigv = igv;

                        Detalle.status = "0";
                        Detalle.usuar = VariablesPublicas.Usuar;

                        if (fila["productid"].ToString().Trim().Length == 13
                            && Convert.ToDecimal(fila["cantidad"]) > 0
                            && Convert.ToDecimal(fila["importfac"]) > 0)
                        {
                            ListaItems.Add(Detalle);
                        }
                        else
                        {
                            if (Convert.ToBoolean(fila["nostock"]) == true)
                            {
                                ListaItems.Add(Detalle);
                            }
                            else
                            {
                                MessageBox.Show("Documento DETALLE EN FORMATO INCORRECTO !!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                return;
                            }
                        }
                    }

                    if (ListaItems.Count == 0)
                    {
                        MessageBox.Show("DOCUMENTO SIN DETALLE Y/O DETALLE INCORRECTO !!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }

                    #endregion

                    BE.ListaItems = ListaItems;

                    #region Detalle - Tarjetas
                    foreach (DataRow fila in TablaTarjetas.Rows)
                    {
                        Detalle2 = new tb_ad_movimientos.Tarjetas();
                        Detalle2.tarjetaid = Convert.ToInt32(fila["tarjetaid"].ToString());
                        Detalle2.tarjnumoper = fila["tarjetanume"].ToString();
                        Detalle2.moneda = moneda.SelectedValue.ToString();
                        Detalle2.tcamb = Convert.ToDecimal(tcamb.Text);
                        Detalle2.tarjimporte = Convert.ToDecimal(fila["tarjetaimpo"].ToString());
                        Detalle2.status = "0";
                        Detalle2.usuar = VariablesPublicas.Usuar.ToString();

                        if (Convert.ToInt32(fila["tarjetaimpo"]) > 0)
                        {
                            ListaTarjetas.Add(Detalle2);
                        }
                        else
                        {
                            MessageBox.Show("Documento DETALLE TARJETAS EN FORMATO INCORRECTO ...!!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return;
                        }
                    }

                    BE.ListaTarjetas = ListaTarjetas;

                    #endregion

                    if (BL.Update(EmpresaID, BE))
                    {
                        SEGURIDAD_LOG("M");
                        NIVEL_FORMS();
                        MessageBox.Show("Datos Modificados Correctamente !!!", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information);

                        form_bloqueado(false);
                        Blanquear();
                        tipodoc.Enabled = false;
                        btn_nuevo.Enabled = true;
                        btn_imprimir.Enabled = true;
                        btnImprimirNoval.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);
            }
        }
Exemplo n.º 8
0
        private void ObtenemosCab()
        {
            if (tipguia.Text.Trim().Length > 0)
            {
                var BL = new tb_ad_movimientosBL();
                var BE = new tb_ad_movimientos();

                var dt = new DataTable();
                BE.moduloid = modulo;
                BE.local = local;
                BE.tipodoc = tipguia.Text.ToString();
                BE.serdoc = serguia.Text.Trim();
                BE.numdoc = numguia.Text;

                dt = BL.GetOne(EmpresaID, BE).Tables[0];
                if (dt.Rows.Count > 0)
                {
                    dt.Rows[0]["numdoc"].ToString().Trim();
                    fechguia.Value = Convert.ToDateTime(dt.Rows[0]["fechdoc"]);
                    ctacte.Text = dt.Rows[0]["ctacte"].ToString().Trim();
                    nmruc.Text = dt.Rows[0]["nmruc"].ToString().Trim();
                    ctactename.Text = dt.Rows[0]["ctactename"].ToString().Trim();
                    var BL2 = new clienteBL();
                    var BE2 = new tb_cliente();
                    var dt2 = new DataTable();
                    BE2.ctacte = ctacte.Text;
                    dt2 = BL2.GetAll(EmpresaID, BE2).Tables[0];
                    direc.Text = dt2.Rows[0]["direc"].ToString().Trim();

                    moneda.SelectedValue = dt.Rows[0]["moneda"].ToString().Trim();
                }
            }
        }
 public DataSet Sunat141_RegVentas(string empresaid, tb_ad_movimientos BE)
 {
     return tablaDA.Sunat141_RegVentas(empresaid, BE);
 }
 public bool Update(string empresaid, tb_ad_movimientos BE)
 {
     return tablaDA.Update(empresaid, BE);
 }
 public bool Insert(string empresaid, tb_ad_movimientos BE)
 {
     return tablaDA.Insert(empresaid, BE);
 }
 public DataSet GetReportDetalle(string empresaid, tb_ad_movimientos BE)
 {
     return tablaDA.GetReportDetalle(empresaid, BE);
 }
 public DataSet GetOne2(string empresaid, tb_ad_movimientos BE)
 {
     return tablaDA.GetOne2(empresaid, BE);
 }
Exemplo n.º 14
0
        private void Delete()
        {
            try
            {
                if (ctacte.Text.Trim().Length == 0)
                {
                    MessageBox.Show("Ingrese Proveedor/Cliente !!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                else
                {
                    if (Tabladetallemov.Rows.Count == 0)
                    {
                        MessageBox.Show("Documento no tiene Items !!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    else
                    {
                        if (numdoc.Text.Trim().Length == 10)
                        {
                            var BL = new tb_ad_movimientosBL();
                            var BE = new tb_ad_movimientos();

                            //BE.dominioid = dominio;
                            BE.moduloid = modulo;
                            BE.local = local;
                            BE.tipodoc = tipodoc.SelectedValue.ToString();
                            BE.serdoc = serdoc.Text.Trim();
                            BE.numdoc = numdoc.Text.Trim();
                            BE.status = "9";
                            BE.usuar = VariablesPublicas.Usuar;

                            if (BL.Delete(EmpresaID, BE))
                            {
                                SEGURIDAD_LOG("E");
                                NIVEL_FORMS();
                                MessageBox.Show("Datos eliminados correctamente !!!", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                limpiar_documento();
                                form_bloqueado(false);
                                tipodoc.Enabled = false;
                                numdoc.Enabled = false;

                                btn_nuevo.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);
            }
        }
 public DataSet GetReport(string empresaid, tb_ad_movimientos BE)
 {
     using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid)))
     {
         using (SqlCommand cmd = new SqlCommand("gspTbAdMovimientos_PRINTDOC", cnx))
         {
             DataSet ds = new DataSet();
             {
                 cmd.CommandType = CommandType.StoredProcedure;
                 cmd.Parameters.Add("@moduloid", SqlDbType.Char, 4).Value = BE.moduloid;
                 cmd.Parameters.Add("@local", SqlDbType.Char, 3).Value = BE.local;
                 cmd.Parameters.Add("@tipodoc", SqlDbType.Char, 2).Value = BE.tipodoc;
                 cmd.Parameters.Add("@serdoc", SqlDbType.Char, 4).Value = BE.serdoc;
                 cmd.Parameters.Add("@numdoc", SqlDbType.Char, 10).Value = BE.numdoc;
                 cmd.Parameters.Add("@convalor", SqlDbType.Char, 1).Value = BE.Convalor;
             }
             try
             {
                 cnx.Open();
                 using (SqlDataAdapter da = new SqlDataAdapter(cmd))
                 {
                     da.Fill(ds);
                 }
                 return ds;
             }
             catch (Exception ex)
             {
                 throw new Exception(ex.Message);
             }
         }
     }
 }
Exemplo n.º 16
0
        private void form_cargar_datos_referencia(String posicion)
        {
            try
            {
                ControlName();
                limpiar_documento_referencia();
                var BL = new tb_ad_movimientosBL();
                var BE = new tb_ad_movimientos();
                var dt = new DataTable();

                BE.moduloid = modulo;
                BE.local = local;
                BE.tipodoc = tipfac.Text.ToString().Trim();

                if (serfac.Text.Trim().Length > 0)
                {
                    BE.serdoc = serfac.Text.Trim().PadLeft(4, '0');
                    BE.numdoc = numfac.Text.Trim().PadLeft(10, '0');
                }
                else
                {
                    if (posicion.Trim().Length > 0)
                    {
                        MessageBox.Show("Seleccionar el Tipo de Documento de Referencia !!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    return;
                }
                if (numfac.Text.Trim().Length > 0)
                {
                    BE.numdoc = numfac.Text.Trim().PadLeft(10, '0');
                }
                BE.posicion = posicion.Trim();

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

                if (dt.Rows.Count > 0)
                {
                    if (dt.Rows[0]["status"].ToString().Trim() == "9")
                    {
                        MessageBox.Show("Documento de Referencia ANULADO!!...verifique", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        dt.Clear();
                        return;
                    }
                    //ssModo = "EDIT";
                    serfac.Text = dt.Rows[0]["serdoc"].ToString().Trim();
                    numfac.Text = dt.Rows[0]["numdoc"].ToString().Trim();
                    //fechfac.Checked = true;
                    fechfac.Text = dt.Rows[0]["fechdoc"].ToString().Trim();

                    recep_name.Text = dt.Rows[0]["recep_name"].ToString().Trim();
                    recep_dni.Text = dt.Rows[0]["recep_dni"].ToString().Trim();
                    recep_fecha.Text = dt.Rows[0]["recep_fecha"].ToString().Trim();

                    tipimptoid = dt.Rows[0]["tipimptoid"].ToString().Trim();
                    direcnume = dt.Rows[0]["direcnume"].ToString().Trim();
                    incprec = dt.Rows[0]["incprec"].ToString().Trim();
                    if (incprec.ToString() == "N")
                    {
                        cbo_incprec.SelectedIndex = 1;
                    }
                    else
                    {
                        cbo_incprec.SelectedIndex = 0;
                    }

                    moneda.SelectedValue = dt.Rows[0]["moneda"].ToString().Trim();
                    tcamb.Text = dt.Rows[0]["tcamb"].ToString().Trim();

                    if (dt.Rows[0]["tipimptoid"].ToString().Trim().Length > 0)
                    {
                        tipimptotasa.SelectedValue = dt.Rows[0]["tipimptoid"].ToString().Trim();
                    }
                    else
                    {
                        tipimptotasa.SelectedIndex = 0;
                    }
                    ctacte.Text = dt.Rows[0]["ctacte"].ToString().Trim();
                    nmruc.Text = dt.Rows[0]["nmruc"].ToString().Trim();
                    ctactename.Text = dt.Rows[0]["ctactename"].ToString().Trim();
                    direc.Text = dt.Rows[0]["direc"].ToString().Trim();

                    vendperid.Text = dt.Rows[0]["vendorid"].ToString().Trim();
                    vendpername.Text = dt.Rows[0]["vendorname"].ToString().Trim();

                    //if (dt.Rows[0]["serfac"].ToString().Trim().Length > 0 && dt.Rows[0]["numfac"].ToString().Trim().Length > 0)
                    //{
                    //    tipfac.Text = dt.Rows[0]["tipfac"].ToString().Trim();
                    //    serfac.Text = dt.Rows[0]["serfac"].ToString().Trim();
                    //    numfac.Text = dt.Rows[0]["numfac"].ToString().Trim();
                    //    fechfac.Format = DateTimePickerFormat.Short;
                    //    fechfac.Text = dt.Rows[0]["fechfac"].ToString().Trim();
                    //}
                    //else
                    //{
                    //    tipfac.SelectedIndex = 0;
                    //}

                    //if (dt.Rows[0]["serguia"].ToString().Trim().Length > 0 && dt.Rows[0]["numguia"].ToString().Trim().Length > 0)
                    //{
                    //    serguia.Text = dt.Rows[0]["serguia"].ToString().Trim();
                    //    numguia.Text = dt.Rows[0]["numguia"].ToString().Trim();
                    //    fechguia.Format = DateTimePickerFormat.Short;
                    //    fechguia.Text = dt.Rows[0]["fechguia"].ToString().Trim();
                    //}

                    //if (dt.Rows[0]["sernotac"].ToString().Trim().Length > 0 && dt.Rows[0]["numnotac"].ToString().Trim().Length > 0)
                    //{
                    //    sernotac.Text = dt.Rows[0]["sernotac"].ToString().Trim();
                    //    numnotac.Text = dt.Rows[0]["numnotac"].ToString().Trim();
                    //    fechnotac.Format = DateTimePickerFormat.Short;
                    //    fechnotac.Text = dt.Rows[0]["fechnotac"].ToString().Trim();
                    //}

                    tip_operacion = "05"; //dt.Rows[0]["tipoperacionid"].ToString().Trim();

                    itemsT.Text = dt.Rows[0]["items"].ToString().Trim();
                    totpzas.Text = dt.Rows[0]["totpzas"].ToString().Trim();
                    bruto.Text = dt.Rows[0]["bruto"].ToString().Trim();
                    totdscto1.Text = dt.Rows[0]["totdscto1"].ToString().Trim();
                    valventa.Text = dt.Rows[0]["valventa"].ToString().Trim();
                    totimpto.Text = dt.Rows[0]["totimpto"].ToString().Trim();
                    totimporte.Text = dt.Rows[0]["totimporte"].ToString().Trim();
                    glosa.Text = dt.Rows[0]["glosa"].ToString().Trim();
                    // Venta en Combo
                    princombo.Checked = Convert.ToBoolean(dt.Rows[0]["princombo"].ToString() == "True" ? 1 : 0);
                    canticombo.Value = Convert.ToInt32(dt.Rows[0]["cantcombo"].ToString() == "" ? "0" : dt.Rows[0]["cantcombo"].ToString()) == 0 ? 1 : Convert.ToInt32(dt.Rows[0]["cantcombo"].ToString() == "" ? "0" : dt.Rows[0]["cantcombo"].ToString());
                    preccombo.Text = Convert.ToDecimal(dt.Rows[0]["preccombo"].ToString() == "" ? "0" : dt.Rows[0]["preccombo"].ToString()).ToString("###,##0.00");
                    //
                    importtarj.Text = dt.Rows[0]["tarjimporte1"].ToString().Trim();
                    txtefectivo.Text = dt.Rows[0]["efectivo"].ToString().Trim();

                    if (dt.Rows[0]["tarjetaid"].ToString() != "")
                    { _xtarjetaid = Convert.ToInt32(dt.Rows[0]["tarjetaid"].ToString()); }

                    if (dt.Rows[0]["tarjnumoper"].ToString() != "")
                    { _xtarjnumoper = dt.Rows[0]["tarjnumoper"].ToString().Trim(); }

                    data_Tabladetallemovmov_referencia();
                    //data_TablaTarjetas();

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

                    //    btn_primero.Enabled = true;
                    //    btn_anterior.Enabled = true;
                    //    btn_siguiente.Enabled = true;
                    //    btn_ultimo.Enabled = true;

                    //    btn_salir.Enabled = true;
                    //    griddetallemov.Focus();
                    //    griddetallemov.Rows[0].Selected = false;
                    //    pdtimagen.Visible = false;

                    //    princombo.Enabled = false;
                    //    canticombo.Enabled = false;
                    //}
                    //else
                    //{
                    //    ssModo = "ANULADO";
                    //    pdtimagen.Visible = true;
                    //    btn_editar.Enabled = false;
                    //    btn_eliminar.Enabled = false;
                    //    btn_imprimir.Enabled = true;
                    //    btnImprimirNoval.Enabled = true;

                    //    btn_primero.Enabled = true;
                    //    btn_anterior.Enabled = true;
                    //    btn_siguiente.Enabled = true;
                    //    btn_ultimo.Enabled = true;
                    //    btn_salir.Enabled = true;

                    //    princombo.Enabled = false;
                    //    canticombo.Enabled = false;
                    //}
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
 public DataSet GetReportDetalle(string empresaid, tb_ad_movimientos BE)
 {
     using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid)))
     {
         using (SqlCommand cmd = new SqlCommand("gspTbAdMovimientos_SEARCH_DetalleVentas", cnx))
         {
             DataSet ds = new DataSet();
             {
                 cmd.CommandType = CommandType.StoredProcedure;
                 cmd.Parameters.Add("@moduloid", SqlDbType.Char, 4).Value = BE.moduloid;
                 cmd.Parameters.Add("@local", SqlDbType.Char, 3).Value = BE.local;
                 //cmd.Parameters.Add("@tipodoc", SqlDbType.Char, 2).Value = BE.tipodoc;
                 //cmd.Parameters.Add("@serdoc", SqlDbType.Char, 4).Value = BE.serdoc;
                 //cmd.Parameters.Add("@numdoc", SqlDbType.Char, 10).Value = BE.numdoc;
                 //cmd.Parameters.Add("@fechdocini", SqlDbType.DateTime).Value = BE.fechdocini;
                 //cmd.Parameters.Add("@fechdocfin", SqlDbType.DateTime).Value = BE.fechdocfin;
                 //cmd.Parameters.Add("@numdocini", SqlDbType.Char, 10).Value = BE.xnumdoc1;
                 //cmd.Parameters.Add("@numdocfin", SqlDbType.Char, 10).Value = BE.xnumdoc2;
                 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);
             }
         }
     }
 }
Exemplo n.º 18
0
        private void Tabla_DetGuia()
        {
            Decimal xxprecventa = 0, xxcostoultimo = 0, xxstock = 0, xxcostopromed = 0;
            griddetallemov.AutoGenerateColumns = false;

            var BL = new tb_ad_movimientosBL();
            var BE = new tb_ad_movimientos();
            var dt = new DataTable();

            BE.moduloid = modulo;
            BE.local = local;
            BE.tipodoc = tipguia.Text.ToString();
            BE.serdoc = serguia.Text.Trim();
            BE.numdoc = numguia.Text;

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

            if (dt.Rows.Count > 0)
            {
                foreach (DataRow fila in dt.Rows)
                {
                    var BL2 = new tb_ad_local_stockBL();
                    var BE2 = new tb_ad_local_stock();
                    var dt2 = new DataTable();

                    BE2.moduloid = modulo;
                    BE2.local = local;
                    BE2.productid = fila["productid"].ToString();

                    dt2 = BL2.GetAll(EmpresaID, BE2).Tables[0];

                    if (dt2.Rows.Count > 0)
                    {
                        if (almacaccionid.Trim() == "20" || almacaccionid.Trim() == "21")
                        {
                            lbl_valor.Text = "Cost.Prom";
                            xxprecventa = Convert.ToDecimal(dt2.Rows[0]["precventa"]);
                            xxcostopromed = Convert.ToDecimal(dt2.Rows[0]["costopromed"]);
                        }
                        else
                        {
                            if (almacaccionid.Trim() == "10" || almacaccionid.Trim() == "11")
                            {
                                lbl_valor.Text = "Cost.Ultm";
                                xxcostoultimo = Convert.ToDecimal(dt2.Rows[0]["costoultimo"]);
                            }
                        }
                        xxstock = Convert.ToDecimal(dt2.Rows[0]["stock"]);
                        if (xxstock == 0)
                        {
                            xxstock = Convert.ToDecimal(dt2.Rows[0]["stockini"]);
                        }
                    }

                    row = Tabladetallemov.NewRow();
                    row["itemref"] = fila["itemref"].ToString();
                    row["items"] = fila["items"].ToString();
                    row["productid"] = fila["productid"].ToString().Trim();
                    row["productname"] = fila["productname"].ToString().Trim();

                    var cantidad = Math.Round(Convert.ToDecimal(fila["cantidad"]), 4);

                    row["stock"] = xxstock;

                    row["precventa"] = xxprecventa;
                    row["costoultimo"] = xxcostoultimo;
                    row["costopromed"] = xxcostopromed;

                    row["cantidad"] = cantidad;
                    row["cantidad_old"] = Math.Round(Convert.ToDecimal(fila["cantidad"]), 4);
                    row["precunit"] = Math.Round(Convert.ToDecimal(Convert.ToDecimal(fila["precunit"]).ToString("###,###,##0.000000")), 6);
                    var precunit = Math.Round(Convert.ToDecimal(Convert.ToDecimal(fila["precunit"]).ToString("###,###,##0.000000")), 6);
                    Decimal importe;
                    importe = cantidad * precunit;

                    row["importfac"] = importe;
                    row["valor"] = Math.Round(Convert.ToDecimal(fila["valor"]), 6);
                    row["importe"] = Math.Round(Convert.ToDecimal(fila["importe"]), 6);
                    row["totimpto"] = Math.Round(Math.Round(Convert.ToDecimal(fila["importe"]), 6) * (Convert.ToDecimal(18) / 100), 6);
                    row["almacaccionid"] = almacaccionid.Trim();
                    Tabladetallemov.Rows.Add(row);
                    griddetallemov.DataSource = Tabladetallemov;
                }

                _RecalculoGrid();
            }
            else
            {
                return;
            }
        }
        public bool Insert_old(string empresaid, tb_ad_movimientos BE)
        {
            using (SqlConnection cnx = new SqlConnection(conex.empConexion(empresaid)))
            {
                SqlTransaction tr = default(SqlTransaction);
                Boolean TransaExito = false;

                using (SqlCommand cmd = new SqlCommand("gspTbAdMovimientoscab_INSERT", cnx))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add("@moduloid", SqlDbType.Char, 4).Value = BE.moduloid;
                    cmd.Parameters.Add("@local", SqlDbType.Char, 3).Value = BE.local;
                    cmd.Parameters.Add("@tipodoc", SqlDbType.Char, 2).Value = BE.tipodoc;
                    cmd.Parameters.Add("@serdoc", SqlDbType.Char, 4).Value = BE.serdoc;
                    cmd.Parameters.Add("@numdoc", SqlDbType.Char, 10).Value = BE.numdoc;
                    cmd.Parameters.Add("@status", SqlDbType.Char, 1).Value = BE.status;
                    cmd.Parameters.Add("@almacaccionid", SqlDbType.Char, 2).Value = BE.almacaccionid;
                    cmd.Parameters.Add("@tipoperacionid", SqlDbType.Char, 2).Value = BE.tipoperacionid;
                    cmd.Parameters.Add("@ctacteaccionid", SqlDbType.Char, 2).Value = BE.ctacteaccionid;
                    cmd.Parameters.Add("@fechdoc", SqlDbType.DateTime).Value = BE.fechdoc;
                    cmd.Parameters.Add("@ctacte", SqlDbType.Char, 7).Value = BE.ctacte;
                    cmd.Parameters.Add("@ctactename", SqlDbType.VarChar, 70).Value = BE.ctactename;
                    cmd.Parameters.Add("@direcnume", SqlDbType.Char, 6).Value = BE.direcnume;
                    cmd.Parameters.Add("@direcname", SqlDbType.VarChar, 25).Value = BE.direcname;
                    cmd.Parameters.Add("@direcdeta", SqlDbType.VarChar, 70).Value = BE.direcdeta;
                    cmd.Parameters.Add("@tipdid", SqlDbType.Char, 1).Value = BE.tipdid;
                    cmd.Parameters.Add("@nmruc", SqlDbType.Char, 11).Value = BE.nmruc;
                    cmd.Parameters.Add("@tipref", SqlDbType.Char, 2).Value = BE.tipref;
                    cmd.Parameters.Add("@serref", SqlDbType.Char, 4).Value = BE.serref;
                    cmd.Parameters.Add("@numref", SqlDbType.Char, 10).Value = BE.numref;
                    cmd.Parameters.Add("@fechref", SqlDbType.DateTime).Value = BE.fechref;
                    cmd.Parameters.Add("@tipfac", SqlDbType.Char, 2).Value = BE.tipfac;
                    cmd.Parameters.Add("@serfac", SqlDbType.Char, 4).Value = BE.serfac;
                    cmd.Parameters.Add("@numfac", SqlDbType.Char, 10).Value = BE.numfac;
                    cmd.Parameters.Add("@fechfac", SqlDbType.DateTime).Value = BE.fechfac;
                    cmd.Parameters.Add("@tipguia", SqlDbType.Char, 2).Value = BE.tipguia;
                    cmd.Parameters.Add("@serguia", SqlDbType.Char, 4).Value = BE.serguia;
                    cmd.Parameters.Add("@numguia", SqlDbType.Char, 10).Value = BE.numguia;
                    cmd.Parameters.Add("@fechguia", SqlDbType.DateTime).Value = BE.fechguia;
                    cmd.Parameters.Add("@tipnotac", SqlDbType.Char, 2).Value = BE.tipnotac;
                    cmd.Parameters.Add("@sernotac", SqlDbType.Char, 4).Value = BE.sernotac;
                    cmd.Parameters.Add("@numnotac", SqlDbType.Char, 10).Value = BE.numnotac;
                    cmd.Parameters.Add("@fechnotac", SqlDbType.DateTime).Value = BE.fechnotac;
                    cmd.Parameters.Add("@vendorid", SqlDbType.Char, 4).Value = BE.vendorid;
                    cmd.Parameters.Add("@cencosid", SqlDbType.Char, 5).Value = BE.cencosid;
                    cmd.Parameters.Add("@condpago", SqlDbType.Char, 4).Value = BE.condpago;
                    cmd.Parameters.Add("@tipimptoid", SqlDbType.Char, 1).Value = BE.tipimptoid;
                    cmd.Parameters.Add("@incprec", SqlDbType.Char, 1).Value = BE.incprec;
                    cmd.Parameters.Add("@totimpto", SqlDbType.Decimal).Value = BE.totimpto;
                    cmd.Parameters.Add("@valventa", SqlDbType.Decimal).Value = BE.valventa;
                    cmd.Parameters.Add("@totimporte", SqlDbType.Decimal).Value = BE.totimporte;
                    cmd.Parameters.Add("@tcamb", SqlDbType.Decimal).Value = BE.tcamb;
                    cmd.Parameters.Add("@glosa", SqlDbType.VarChar, 300).Value = BE.glosa;
                    cmd.Parameters.Add("@totpzas", SqlDbType.Decimal).Value = BE.totpzas;
                    cmd.Parameters.Add("@moneda", SqlDbType.Char).Value = BE.moneda;
                    cmd.Parameters.Add("@transpid", SqlDbType.Char, 5).Value = BE.transpid;
                    cmd.Parameters.Add("@transpname", SqlDbType.VarChar, 40).Value = BE.transpname;
                    cmd.Parameters.Add("@motivotrasladoid", SqlDbType.Char, 2).Value = BE.motivotrasladoid;
                    cmd.Parameters.Add("@mottrasladointid", SqlDbType.Char, 2).Value = BE.mottrasladointid;
                    cmd.Parameters.Add("@items", SqlDbType.Decimal).Value = BE.items;
                    cmd.Parameters.Add("@perianio", SqlDbType.Char, 4).Value = BE.perianio;
                    cmd.Parameters.Add("@perimes", SqlDbType.Char, 2).Value = BE.perimes;
                    cmd.Parameters.Add("@usuar", SqlDbType.Char, 15).Value = BE.usuar;
                    cmd.Parameters.Add("@usuar", SqlDbType.Char, 15).Value = BE.usuar;

                    using (SqlCommand cmd2 = new SqlCommand("gspTbAdMovimientosdet_INSERT_xml", cnx))
                    {
                        cmd2.CommandType = CommandType.StoredProcedure;
                        cmd2.Parameters.Add("@moduloid", SqlDbType.Char, 4).Value = BE.moduloid;
                        cmd2.Parameters.Add("@local", SqlDbType.Char, 3).Value = BE.local;
                        cmd2.Parameters.Add("@tipodoc", SqlDbType.Char, 2).Value = BE.tipodoc;
                        cmd2.Parameters.Add("@serdoc", SqlDbType.Char, 4).Value = BE.serdoc;
                        cmd2.Parameters.Add("@numdoc", SqlDbType.Char, 10).Value = BE.numdoc;
                        cmd2.Parameters.Add("@XML", SqlDbType.Xml).Value = BE.GetItemXML();

                        try
                        {
                            cnx.Open();
                            tr = cnx.BeginTransaction(IsolationLevel.Serializable);
                            cmd.Transaction = tr;

                            if (cmd.ExecuteNonQuery() > 0)
                            {
                                cmd2.Transaction = tr;

                                if (cmd2.ExecuteNonQuery() > 0)
                                {
                                    TransaExito = true;
                                }
                            }

                            if (TransaExito == true)
                            {
                                tr.Commit();
                                return true;
                            }
                            else
                            {
                                tr.Rollback();
                                return false;
                            }

                        }
                        catch (Exception ex)
                        {
                            tr.Rollback();
                            throw new Exception(ex.Message);
                        }
                    }
                }
            }
        }
Exemplo n.º 20
0
        private void ValidaDocref()
        {
            if (tipfac.SelectedIndex != -1)
            {
                var BL = new tb_ad_movimientosBL();
                var BE = new tb_ad_movimientos();

                var dt = new DataTable();
                BE.moduloid = modulo;
                BE.local = local;
                BE.tipodoc = tipfac.Text.ToString();
                BE.serdoc = serfac.Text.Trim();
                BE.numdoc = numfac.Text;
                dt = BL.GetOne(EmpresaID, BE).Tables[0];
                if (dt.Rows.Count > 0)
                {
                    dt.Rows[0]["numdoc"].ToString().Trim();

                    fechfac.Value = Convert.ToDateTime(dt.Rows[0]["fechdoc"]);
                    ctacte.Text = dt.Rows[0]["ctacte"].ToString().Trim();
                    nmruc.Text = dt.Rows[0]["nmruc"].ToString().Trim();
                    ctactename.Text = dt.Rows[0]["ctactename"].ToString().Trim();
                    direc.Text = dt.Rows[0]["direc"].ToString().Trim();
                    moneda.SelectedValue = dt.Rows[0]["moneda"].ToString().Trim();
                }
            }
        }
 public DataSet GetAll_datosdetalle(string empresaid, tb_ad_movimientos BE)
 {
     return tablaDA.GetAll_datosdetalle(empresaid, BE);
 }