Ejemplo n.º 1
0
        int C;                                  //CANTIDAD A AÑADIR/RESAR AL PRODUCTO



        protected void Page_Load(object sender, EventArgs e)
        {
            IDLO.Value = Data2.Statics.Conversion.ObtenerLocal(UserId).ToString();

            try
            {
            }
            catch (Exception exc) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }

            //SE FIJA SI TODOS LOS PARÁMETROS TIENEN VALOR
            if (Request["LO"] != null &&
                Request["LD"] != null &&
                Request["PO"] != null &&
                Request["PD"] != null &&
                Request["C"] != null)
            {
                //GUARDA LOS VALORES EN LAS VARIABLES DE C#
                LO = int.Parse(Request["LO"]);
                LD = int.Parse(Request["LD"]);
                PO = int.Parse(Request["PO"]);
                PD = int.Parse(Request["PD"]);
                C  = int.Parse(Request["C"]);


                //LLENA LOS OBJETOS
                SPO = Data2.Class.Struct_Producto.Get_SingleArticle(LO, PO);
                SPD = Data2.Class.Struct_Producto.Get_SingleArticle(LD, PD);

                //LLAMA A LA FUNCION DE ACTUALIZAR CANTIDAD
                actualizarCant();
            }
        }
Ejemplo n.º 2
0
        public HttpResponseMessage UpdateStock(int UID, int PID, string cant, int unit, string key)
        {
            Data2.Class.Struct_Producto PD = Data2.Class.Struct_Producto.Get_SingleArticle(UID, PID);

            if (PD != null && Conversion.ObtenerLocal(UserInfo.UserID) == UID)
            {
                Data2.Class.Struct_Unidades U = new Data2.Class.Struct_Unidades(PD.IdUnidad);

                if (PD.IdUnidad != unit)
                {
                    Data2.Connection.D_StaticWebService SWS = new Data2.Connection.D_StaticWebService();

                    if (UID != 0)
                    {
                        PD.IdUnidad = unit;
                        PD.Actualizar(UID);
                    }
                }



                if (PD.UpdateStock(cant) == true)
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, "ok"));
                }
                else
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, "error"));
                }
            }
            else
            {
                return(Request.CreateResponse(HttpStatusCode.OK, "error"));
            }
        }
Ejemplo n.º 3
0
 private void addprod(int idprod)
 {
     Data2.Class.Struct_Producto P = Data2.Class.Struct_Producto.Get_SingleArticle(Data2.Statics.Conversion.ObtenerLocal(UserId), idprod);
     if (P != null)
     {
         P.AgregarAlerta(1m);
     }
 }
Ejemplo n.º 4
0
        protected void btnProcesar_Click(object sender, EventArgs e)
        {
            List <Data2.Class.Struct_Unidades> t_unidades = Data2.Class.Struct_Unidades.GetAll();
            int UnidadPorDefecto = 0;

            if (t_unidades.Count > 0)
            {
                UnidadPorDefecto = t_unidades[0].Id;
            }

            if (CmbFileList.Items.Count > 0)
            {
                string FileName = CmbFileList.SelectedItem.Text;
                Data2.Statics.Log.ADD("Examinando:" + FileName, this);
                System.IO.StreamReader file = new System.IO.StreamReader(PortalSettings.HomeDirectoryMapPath + "\\" + "UsersUpdate\\" + UserId.ToString() + "\\" + FileName, System.Text.Encoding.Default);
                bool failure = false;


                string firstLine = "";
again:
                if (!file.EndOfStream)
                {
                    firstLine = file.ReadLine().ToLower();

                    /*firstLine = firstLine.Replace("\u001a", "");
                    *  firstLine = firstLine.Replace("\u0011", "");
                    *  firstLine = firstLine.Replace("\u0007", "");
                    *  firstLine = firstLine.Replace("\u0000", "");
                    *  firstLine = firstLine.Replace("\u0016", "");
                    *  firstLine = firstLine.Replace("\u001d", "");*/
                    if (!firstLine.Contains("codigo"))
                    {
                        goto again;
                    }
                    Data2.Statics.Log.ADD(firstLine, this);
                }



                //firstLine = firstLine.Replace("\u001a", "");
                //firstLine = firstLine.Replace("\u0007", "");
                //firstLine = firstLine.Replace("\u0000", "");



                if (!firstLine.Contains("codigo"))
                {
                    failure = true;
                }
                if (!firstLine.Contains("precioneto"))
                {
                    failure = true;
                }
                if (!firstLine.Contains("iva"))
                {
                    failure = true;
                }
                if (!firstLine.Contains("preciocompra"))
                {
                    failure = true;
                }
                if (!firstLine.Contains("porcentajeganancia"))
                {
                    failure = true;
                }
                if (!firstLine.Contains("preciofinal"))
                {
                    failure = true;
                }
                Data2.Statics.Log.ADD("Primera Linea:" + firstLine, this);
                if (failure == false)
                {
                    int      indexcodigo             = -1;
                    int      indexprecioneto         = -1;
                    int      indexiva                = -1;
                    int      indexpreciocompra       = -1;
                    int      indexporcentajeganancia = -1;
                    int      indexpreciofinal        = -1;
                    int      indexdescripcion        = -1;
                    int      indexcodigodebarra      = -1;
                    string[] splitter                = { "\t" };
                    string[] fields = firstLine.Split(splitter, StringSplitOptions.None);

                    for (int a = 0; a < fields.Length; a++)
                    {
                        if (fields[a] == "codigo")
                        {
                            indexcodigo = a;
                        }
                        if (fields[a] == "precioneto")
                        {
                            indexprecioneto = a;
                        }
                        if (fields[a] == "iva")
                        {
                            indexiva = a;
                        }
                        if (fields[a] == "preciocompra")
                        {
                            indexpreciocompra = a;
                        }
                        if (fields[a] == "porcentajeganancia")
                        {
                            indexporcentajeganancia = a;
                        }
                        if (fields[a] == "preciofinal")
                        {
                            indexpreciofinal = a;
                        }
                        if (fields[a] == "descripcion")
                        {
                            indexdescripcion = a;
                        }
                        if (fields[a] == "codigobarra")
                        {
                            indexcodigodebarra = a;
                        }
                    }


                    int UpdateSucces = 0;
                    int UpdateError  = 0;
                    int NewSucces    = 0;
                    int NewError     = 0;

                    string line;
                    while ((line = file.ReadLine()) != null)
                    {
                        Console.WriteLine(line);

                        string[] separatevalues = line.Split(splitter, StringSplitOptions.None);
                        if (separatevalues.Length >= 5)
                        {
                            string  artcod             = separatevalues[indexcodigo];
                            decimal precioneto         = Data2.Statics.Conversion.GetDecimal(separatevalues[indexprecioneto]);
                            decimal iva                = Data2.Statics.Conversion.GetDecimal(separatevalues[indexiva]);
                            decimal preciocompra       = Data2.Statics.Conversion.GetDecimal(separatevalues[indexpreciocompra]);
                            decimal porcentajeganancia = Data2.Statics.Conversion.GetDecimal(separatevalues[indexporcentajeganancia]);
                            decimal preciofinal        = Data2.Statics.Conversion.GetDecimal(separatevalues[indexpreciofinal]);
                            string  descripcion        = artcod;
                            string  codigobarra        = artcod;
                            if (indexdescripcion != -1)
                            {
                                descripcion = separatevalues[indexdescripcion];
                                descripcion = descripcion.Replace("\"\"", "*");
                                descripcion = descripcion.Replace("\"", "");
                                descripcion = descripcion.Replace("*", "\"");
                            }
                            if (indexcodigodebarra != -1)
                            {
                                codigobarra = separatevalues[indexcodigodebarra];
                            }
                            int IdProveddor    = int.Parse(CmbUpdateProviders.SelectedValue);
                            int IdMateriaPrima = int.Parse(cmbMateriaPrima.SelectedValue);
                            Data2.Class.Struct_Producto MyProduct = Data2.Class.Struct_Producto.SelectSingleArticle(UserId, IdProveddor, artcod);
                            if (MyProduct != null)
                            {
                                MyProduct.PrecioNeto         = precioneto;
                                MyProduct.IVA                = iva;
                                MyProduct.PorcentajeGanancia = porcentajeganancia;
                                MyProduct.PrecioFinal        = preciofinal;

                                if (MyProduct.ActualizarPrecios() == true)
                                {
                                    UpdateSucces++;
                                }
                                else
                                {
                                    UpdateError++;
                                }
                            }
                            else
                            {
                                bool esmateriaprima = false;
                                if (ChkMateriaPrima.Checked == true)
                                {
                                    esmateriaprima = true;
                                }
                                MyProduct = new Data2.Class.Struct_Producto(UserId, IdProveddor, artcod, codigobarra, descripcion, precioneto, iva, preciocompra, porcentajeganancia, preciofinal, UnidadPorDefecto, esmateriaprima, IdMateriaPrima);
                                if (MyProduct.Guardar() == true)
                                {
                                    NewSucces++;
                                }
                                else
                                {
                                    NewError++;
                                }
                            }
                        }
                    }

                    string RESVALUE = NewSucces.ToString() + "-" + NewError.ToString() + "-" + UpdateSucces.ToString() + "-" + UpdateError.ToString();
                    Data2.Statics.Log.ADD("NUEVOS EXITOSOS:" + NewSucces.ToString() + "NUEVOS ERROR:" + NewError.ToString() + "UPDATES EXITOSOS:" + UpdateSucces.ToString() + "NUEVOS EXITOSOS:" + UpdateError.ToString(), this);
                    file.Close();
                    //Fin de recorrido...
                    Response.Redirect("~/MyManager/Articulos?Message=Success3&Res=" + RESVALUE);
                }
                else
                {
                    Data2.Statics.Log.ADD("Campos Incorrectos", this);
                    file.Close();
                    Response.Redirect("~/MyManager/Articulos?Message=Error3");
                }
            }
        }
Ejemplo n.º 5
0
        private void InterpretarModo()
        {
            string mode = "";

            if (Request["mode"] != null)
            {
                mode = Request["mode"].ToString();
            }

            if (mode.ToLower() == "edt")
            {
                if (Request["art"] != null)
                {
                    int articleid = int.Parse(Request["art"]);
                    if (articleid != 0)
                    {
                        Data2.Class.Struct_Producto prod = Data2.Class.Struct_Producto.Get_SingleArticle(UserId, articleid);
                        if (prod != null)
                        {
                            Mode.Value  = "edt";
                            IdArt.Value = prod.Id.ToString();

                            txtCodigo.Text             = prod.CodigoInterno;
                            txtCodigoDeBarra.Text      = prod.CodigoBarra;
                            txtNombre.Text             = prod.Descripcion;
                            txtPorcentajeGanancia.Text = prod.PorcentajeGanancia.ToString();
                            txtPorcentajeIVA.Text      = prod.IVA.ToString();
                            txtPrecioCompra.Text       = prod.PrecioCompra.ToString();
                            txtPrecioFinal.Text        = prod.PrecioFinal.ToString();
                            txtPrecioNeto.Text         = prod.PrecioNeto.ToString();
                            ChkMateriaPrima.Checked    = prod.EsMateriaPrima;

                            for (int a = 0; a < cmbMateriaPrima.Items.Count; a++)
                            {
                                if (prod.MateriaPrima.ToString() == cmbMateriaPrima.Items[a].Value)
                                {
                                    ;
                                }
                                {
                                    cmbMateriaPrima.SelectedIndex = a;
                                    break;
                                }
                            }

                            for (int a = 0; a < cmbProveedor.Items.Count; a++)
                            {
                                if (prod.IdProveedor.ToString() == cmbProveedor.Items[a].Value)
                                {
                                    cmbProveedor.SelectedIndex = a;
                                    break;
                                }
                            }

                            for (int a = 0; a < cmbUnidades.Items.Count; a++)
                            {
                                if (prod.IdUnidad.ToString() == cmbUnidades.Items[a].Value)
                                {
                                    cmbUnidades.SelectedIndex = a;
                                    break;
                                }
                            }
                        }
                    }
                }
            }
            else if (mode.ToLower() == "del")
            {
                if (Request["art"] != null)
                {
                    int IdArt = int.Parse(Request["art"].ToString());
                    Data2.Class.Struct_Producto PRD = Data2.Class.Struct_Producto.Get_SingleArticle(UserId, IdArt);
                    if (PRD != null)
                    {
                        PRD.Borrar(UserId);
                        Response.Redirect("/MyManager/Articulos");
                    }
                }
            }
        }
Ejemplo n.º 6
0
        protected void btnGuardar_Click(object sender, EventArgs e)
        {
            CheckFields();
            if (isOk == true)
            {
                if (Mode.Value.ToLower() == "none")
                {
                    bool materiaprima = false;
                    if (ChkMateriaPrima.Checked == true)
                    {
                        materiaprima = true;
                    }
                    Data2.Class.Struct_Producto t_PRD = new Data2.Class.Struct_Producto(
                        UserId,
                        int.Parse(cmbProveedor.SelectedValue),
                        txtCodigo.Text,
                        txtCodigoDeBarra.Text,
                        txtNombre.Text,
                        Data2.Statics.Conversion.GetDecimal(txtPrecioNeto.Text),
                        Data2.Statics.Conversion.GetDecimal(txtPorcentajeIVA.Text),
                        Data2.Statics.Conversion.GetDecimal(txtPrecioCompra.Text),
                        Data2.Statics.Conversion.GetDecimal(txtPorcentajeGanancia.Text),
                        Data2.Statics.Conversion.GetDecimal(txtPrecioFinal.Text),
                        int.Parse(cmbUnidades.SelectedValue),
                        materiaprima,
                        int.Parse(cmbMateriaPrima.SelectedValue));
                    if (t_PRD.Guardar() == true)
                    {
                        Response.Redirect("~/MyManager/Articulos?Message=Success1");
                    }
                    else
                    {
                        Response.Redirect("~/MyManager/Articulos?Message=Error1");
                    };
                }
                else if (Mode.Value.ToLower() == "fedt")
                {
                    if (IdArt.Value != "0")
                    {
                        int IDART = int.Parse(IdArt.Value);

                        Data2.Class.Struct_Producto PRD = Data2.Class.Struct_Producto.Get_SingleArticle(UserId, IDART);
                        if (PRD != null)
                        {
                            PRD.IdProveedor        = int.Parse(cmbProveedor.SelectedValue);
                            PRD.CodigoInterno      = txtCodigo.Text;
                            PRD.CodigoBarra        = txtCodigoDeBarra.Text;
                            PRD.Descripcion        = txtNombre.Text;
                            PRD.PrecioNeto         = Data2.Statics.Conversion.GetDecimal(txtPrecioNeto.Text);
                            PRD.IVA                = Data2.Statics.Conversion.GetDecimal(txtPorcentajeIVA.Text);
                            PRD.PrecioCompra       = Data2.Statics.Conversion.GetDecimal(txtPrecioCompra.Text);
                            PRD.PorcentajeGanancia = Data2.Statics.Conversion.GetDecimal(txtPorcentajeGanancia.Text);
                            PRD.PrecioFinal        = Data2.Statics.Conversion.GetDecimal(txtPrecioFinal.Text);
                            PRD.IdUnidad           = int.Parse(cmbUnidades.SelectedValue);
                            PRD.EsMateriaPrima     = ChkMateriaPrima.Checked;

                            if (PRD.Actualizar(UserId))
                            {
                                Response.Redirect("~/MyManager/Articulos?Message=Success1");
                            }
                            else
                            {
                                Response.Redirect("~/MyManager/Articulos?Message=Error1");
                            }
                        }
                    }
                }
            }
        }