예제 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                try
                {
                    try
                    {
                        planningADM = this.Session["AdmProd"].ToString().Trim();
                    }
                    catch
                    {
                    }
                    string sUser     = this.Session["sUser"].ToString();
                    string sPassw    = this.Session["sPassw"].ToString();
                    string sNameUser = this.Session["nameuser"].ToString();

                    //string sUser = "******";
                    //string sPassw = "sPassw";
                    //string sNameUser = "******";

                    planningADM = "NO";

                    if (sUser != null && sPassw != null)
                    {
                        lblUsuario.Text = sNameUser;
                        if (planningADM == "SI")
                        {
                            ImgBtnPais.Visible       = false;
                            ImgBtnUsuario.Visible    = false;
                            ImgBtnProducto.Visible   = false;
                            ImgBtnPdv.Visible        = false;
                            ImgBtnInformes.Visible   = false;
                            ImgBtnGeneral.Visible    = false;
                            Iframe.Attributes["src"] = "GestiónProducto.aspx";
                            //inicializa_botones();
                            //ImgBtnProducto.Enabled = false;
                        }
                        else
                        {
                            inicializa_botones();
                        }
                        // TxtSolicitante.Text = this.Session["smail"].ToString();
                        //TxtEmail.Text = "*****@*****.**";
                    }
                }
                catch (Exception ex)
                {
                    string error   = "";
                    string mensaje = "";
                    error   = Convert.ToString(ex.Message);
                    mensaje = ConfigurationManager.AppSettings["ErrorConection"];
                    if (error == mensaje)
                    {
                        Lucky.CFG.Exceptions.Exceptions exs = new Lucky.CFG.Exceptions.Exceptions(ex);
                        string errMessage = "";
                        errMessage = mensaje;
                        errMessage = new Lucky.CFG.Util.Functions().preparaMsgError(ex.Message);
                        this.Response.Redirect("../../../err_mensaje.aspx?msg=" + errMessage, true);
                    }
                    else
                    {
                        this.Session.Abandon();
                        Response.Redirect("~/err_mensaje_seccion.aspx", true);
                    }
                }
            }
        }
예제 #2
0
        protected void btnloadproduct0_Click(object sender, EventArgs e)
        {
            if ((FileUpProducto0.PostedFile != null) && (FileUpProducto0.PostedFile.ContentLength > 0))
            {
                string fn = System.IO.Path.GetFileName(FileUpProducto0.PostedFile.FileName);

                string SaveLocation = Server.MapPath("Busquedas") + "\\" + fn;
                try
                {
                    FileUpProducto0.PostedFile.SaveAs(SaveLocation);
                    DataSet   ds         = new DataSet();
                    DataTable sourceData = new DataTable();
                    if (SaveLocation != string.Empty)
                    {
                        ds.ReadXml(SaveLocation);
                        FileUpProducto0.PostedFile.SaveAs(MapPath("../../Modulos/Administrativo/Busquedas/" + FileUpProducto0.FileName));
                        sourceData = ds.Tables[0];
                        using (SqlBulkCopy bulkCopy = new SqlBulkCopy(oCoon.GetConnection()))
                        {
                            bulkCopy.ColumnMappings.Clear();
                            foreach (DataColumn dc in sourceData.Columns)
                            {
                                bulkCopy.ColumnMappings.Add(dc.ColumnName.Trim(), dc.ColumnName.Trim());
                            }
                            bulkCopy.DestinationTableName = "Product_Packing";
                            bulkCopy.WriteToServer(sourceData, DataRowState.Added);
                        }
                        LblVacio.Text             = "Los productos y empaquetamientos estan almacenados";
                        LblCargarArchivo.Visible  = true;
                        FileUpProducto.Visible    = true;
                        btnloadproduct.Visible    = true;
                        LblCargarArchivo0.Visible = false;
                        FileUpProducto0.Visible   = false;
                        btnloadproduct0.Visible   = false;
                    }
                    else
                    {
                        LblVacio.Text             = "Seleccione Archivo con EMPAQUETAMIENTO DE PRODUCTOS.";
                        LblCargarArchivo.Visible  = false;
                        FileUpProducto.Visible    = false;
                        btnloadproduct.Visible    = false;
                        LblCargarArchivo0.Visible = true;
                        FileUpProducto0.Visible   = true;
                        btnloadproduct0.Visible   = true;
                    }
                }

                catch (Exception ioex)
                {
                    string errMessage = "";
                    Lucky.CFG.Exceptions.Exceptions exs = new Lucky.CFG.Exceptions.Exceptions(ioex);
                    exs.Country = "SIGE(" + ConfigurationManager.AppSettings["COUNTRY"] + ") - Usuario " + this.Session["sUser"].ToString();
                    errMessage  = Convert.ToString(ioex);
                    exs.errorWebsite(this.Session["scountry"].ToString().Trim());
                    errMessage                = new Lucky.CFG.Util.Functions().preparaMsgError(ioex.Message);
                    LblVacio.Text             = "Se ha producido un error en la carga del Archivo.";
                    LblCargarArchivo.Visible  = false;
                    FileUpProducto.Visible    = false;
                    btnloadproduct.Visible    = false;
                    LblCargarArchivo0.Visible = true;
                    FileUpProducto0.Visible   = true;
                    btnloadproduct0.Visible   = true;
                }
                //}
                //catch (Exception ex)
                //{
                //    Response.Write("Error: " + ex.Message);
                //    //Nota: Exception.Message devuelve un mensaje detallado que describe la excepción actual.
                //    //Por motivos de seguridad, no se recomienda devolver Exception.Message a los usuarios finales de
                //    //entornos de producción. Sería más aconsejable poner un mensaje de error genérico.
                //}
            }
            else
            {
                LblVacio.Text             = "Seleccione Archivo con EMPAQUETAMIENTO DE PRODUCTOS.";
                LblCargarArchivo.Visible  = false;
                FileUpProducto.Visible    = false;
                btnloadproduct.Visible    = false;
                LblCargarArchivo0.Visible = true;
                FileUpProducto0.Visible   = true;
                btnloadproduct0.Visible   = true;
            }
        }