예제 #1
0
        protected void UploadDocument(object sender, EventArgs e)
        {
            if (DDFabricante.SelectedValue == "0")
            {
                string menssajeScript = "<script type='text/javascript'>"
                                        + " swal({" +

                                        "title: 'Seleccione Fabricante'," +
                                        " icon: 'warning'," +
                                        "  dangerMode: true," +
                                        "   })  </script>";
                ScriptManager.RegisterStartupScript(this, typeof(Page), "mensaje", menssajeScript, false);
                return;
            }

            DataTable dt = new DataTable();

            dt.Columns.Add("Codigo_Almacen");
            dt.Columns.Add("Codigo_ProductoTxt");
            dt.Columns.Add("Stock");
            dt.Columns.Add("Fabricante");
            try {
                string csvPath = Server.MapPath("~/Archivos/") + Path.GetFileName(FileUpload1.PostedFile.FileName);
                FileUpload1.SaveAs(csvPath);
                string[] allLines = File.ReadAllLines(csvPath);
                {
                    for (int i = 0; i < allLines.Length; i++)
                    {
                        string[] items = allLines[i].Split(new char[] { '|' });
                        DataRow  row   = dt.NewRow();
                        row["Codigo_Almacen"]     = items[0].ToString();
                        row["Codigo_ProductoTxt"] = items[1].ToString();
                        row["Stock"]      = items[2].ToString();
                        row["Fabricante"] = DDFabricante.SelectedItem;
                        dt.Rows.Add(row);
                    }
                }
            }catch (Exception ex)
            {
                StackTrace st    = new StackTrace(ex, true);
                StackFrame frame = st.GetFrames().Where(f => !String.IsNullOrEmpty(f.GetFileName()) &&
                                                        f.GetILOffset() != StackFrame.OFFSET_UNKNOWN &&
                                                        f.GetNativeOffset() != StackFrame.OFFSET_UNKNOWN &&
                                                        !f.GetMethod().Module.Assembly.GetName().Name.Contains("mscorlib")).First();

                string        MachineName = System.Environment.MachineName;
                string        UserName    = System.Environment.UserName.ToUpper();
                string        Mensaje     = ex.Message;
                StringBuilder builder     = new StringBuilder(Mensaje);
                builder.Replace("'", "");
                int    LineaError     = frame.GetFileLineNumber();
                string Proyecto       = frame.GetMethod().Module.Assembly.GetName().Name;
                string Clase          = frame.GetMethod().DeclaringType.Name;
                string metodo         = frame.GetMethod().Name;
                string menssajeScript = "<script type='text/javascript'>"
                                        + " swal({" +

                                        "title: '" + "Error en el Txt: " + builder.ToString() + "'," +
                                        " icon: 'warning'," +
                                        "  dangerMode: false," +
                                        "   })  </script>";
                ScriptManager.RegisterStartupScript(this, typeof(Page), "mensaje", menssajeScript, false);
                return;
            }
            GvStock.DataSource = dt;
            GvStock.DataBind();
            LblTotal.Text = "Total Stock: " + GvStock.Rows.Count.ToString();
        }
예제 #2
0
        public void subir()
        {
            if (GvStock.Rows.Count < 1)
            {
                String mensajeScriptnm = @"<script type='text/javascript'>
                swal({
                title: ""Seleccione Stock Txt"",
                icon: ""warning"",
                dangerMode: false,
                })
                </script>";
                ScriptManager.RegisterStartupScript(this, typeof(Page), "mensaje", mensajeScriptnm, false);
                FileUpload1.Focus();
                return;
            }

            Int32 IdUsuario = Convert.ToInt32(Request.Cookies["WebNestle"]["DLIdUsuario"]);
            //obj.CambiarEstadoStock(Convert.ToInt32(DDFabricante.SelectedValue), IdUsuario);
            DataTable DtLis = new DataTable();

            DtLis.Columns.Add("IdAlmacen", typeof(string));
            DtLis.Columns.Add("IdProductoTxt", typeof(string));
            DtLis.Columns.Add("Stock", typeof(Int32));

            foreach (GridViewRow row in GvStock.Rows)
            {
                DataRow drog = DtLis.NewRow();

                drog["IdAlmacen"]     = row.Cells[0].Text.ToString();
                drog["IdProductoTxt"] = row.Cells[1].Text.ToString();
                drog["Stock"]         = Convert.ToInt32(row.Cells[2].Text.ToString());
                DtLis.Rows.Add(drog);
            }

            String Msj = "";

            Msj = obj.SubirStockAlmacen(IdUsuario, Convert.ToInt32(DDFabricante.SelectedValue), 1, DtLis);
            //foreach (GridViewRow row in GvStock.Rows)
            //{


            //    obj.InsertarStock(row.Cells[0].Text.ToString(),row.Cells[1].Text.ToString(),Convert.ToInt32(row.Cells[2].Text.ToString()),
            //    IdUsuario, 1,Convert.ToInt32(DDFabricante.SelectedValue));

            //}
            if (Msj != "")
            {
                string menssajeScript = "<script type='text/javascript'>"
                                        + " swal({" +

                                        "title: '" + Msj + "'," +
                                        " icon: 'success'," +
                                        "  dangerMode: false," +
                                        "   })  </script>";
                ScriptManager.RegisterStartupScript(this, typeof(Page), "mensaje", menssajeScript, false);
            }
            else
            {
                string menssajeScript = "<script type='text/javascript'>"
                                        + " swal({" +

                                        "title: 'ocurrio un error'," +
                                        " icon: 'warning'," +
                                        "  dangerMode: true," +
                                        "   })  </script>";
                ScriptManager.RegisterStartupScript(this, typeof(Page), "mensaje", menssajeScript, false);
            }
            DataTable dt = new DataTable();

            GvStock.DataSource = dt;
            GvStock.DataBind();
            DtLis.Rows.Clear();
        }
예제 #3
0
    protected void getReports()
    {
        // pfc.AddFontFile("../Fonts/madfont.ttf");

        objbe.month = DateTime.Now.Month.ToString();


        lblyear.Text   = objbe.year;
        lblSeason.Text = objbe.season;
        dt             = new DataTable();

        dt = sr.ViewRequest(objbe, con);
        if (dt.Rows.Count > 0)
        {
            lbltitle.Visible     = true;
            gvrequest.DataSource = dt;
            gvrequest.DataBind();
        }
        else
        {
            lbltitle.Visible     = false;
            gvrequest.DataSource = null;
            gvrequest.DataBind();
        }

        dt           = new DataTable();
        objbe.year   = cf.getCurrentFinancialYear();
        objbe.season = objm.GetSeasonByMonth(objbe, con);
        objbe.distcd = dist;

        objbe.Action = "Alotmnt";
        dt           = rprt.GetDetails(objbe, con);
        if (dt.Rows.Count > 0)
        {
            gvAllotment.DataSource = dt;
            gvAllotment.DataBind();
        }

        objbe.Action = "unfrzdAdmin";
        dt           = rprt.GetDetails(objbe, con);
        if (dt.Rows.Count > 0)
        {
            gvUnfrzStk.DataSource = dt;
            gvUnfrzStk.DataBind();
        }

        dt           = new DataTable();
        objbe.Action = "stock";
        dt           = rprt.GetDetails(objbe, con);
        if (dt.Rows.Count > 0)
        {
            GvStock.DataSource = dt;
            GvStock.DataBind();
        }

        objbe.Action = "unfrzdDao";
        dt           = rprt.GetDetails(objbe, con);
        if (dt.Rows.Count > 0)
        {
            gvUnfrzAllot.DataSource = dt;
            gvUnfrzAllot.DataBind();
        }
    }