protected void loadDropLocal(string cCodLocal)
        {
            ILocal  IService = new ILocal();
            BELocal BE       = new BELocal();

            BE.codLocal               = cCodLocal;
            ddlLocales.DataSource     = IService.IGetLocal(BE);
            ddlLocales.DataValueField = "codLocal";
            ddlLocales.DataTextField  = "nomLocal";
            ddlLocales.DataBind();
        }
Ejemplo n.º 2
0
        public List <BELocal> GetLocal(BELocal local)
        {
            try
            {
                List <BELocal> lstLocal = new List <BELocal>();
                BELocal        beLocal  = new BELocal();
                using (DbCommand dbCmd = dbSQL.GetStoredProcCommand("SP_GET_LOCAL"))
                {
                    if (string.IsNullOrEmpty(local.codLocal))
                    {
                        dbSQL.AddInParameter(dbCmd, "@codLocal", DbType.String, DBNull.Value);
                    }
                    else
                    {
                        dbSQL.AddInParameter(dbCmd, "@codLocal", DbType.String, local.codLocal);
                    }

                    using (IDataReader dataReader = dbSQL.ExecuteReader(dbCmd))
                    {
                        int index0 = dataReader.GetOrdinal("respuesta");
                        int index1 = dataReader.GetOrdinal("codLocal");
                        int index2 = dataReader.GetOrdinal("nomLocal");

                        object[] values = new object[dataReader.FieldCount];
                        while (dataReader.Read())
                        {
                            dataReader.GetValues(values);
                            beLocal          = new BELocal();
                            beLocal.codLocal = values[index1] == DBNull.Value ? string.Empty : values[index1].ToString();
                            beLocal.nomLocal = values[index2] == DBNull.Value ? string.Empty : values[index2].ToString();
                            lstLocal.Add(beLocal);
                        }
                    }
                    return(lstLocal);
                }
            }
            catch (Exception ex)
            {
                ExceptionManager.SaveError("Ocurrio un error al obtener los locales", string.Empty, string.Empty, ex, "GetPeriodos", true, false);
                return(null);
            }
            finally
            {
            }
        }
Ejemplo n.º 3
0
        protected void loadDropLocal(string cCodLocal)
        {
            ILocal  IService = new ILocal();
            BELocal BE       = new BELocal();
            BEUser  BEuser   = new BEUser();

            BEuser = (BEUser)Session["LoginUser"];
            if (BEuser.codRol == "3")
            {
                BE.codLocal = string.Empty;
            }
            else
            {
                BE.codLocal = cCodLocal;
            }
            ddlLocales.DataSource     = IService.IGetLocal(BE);
            ddlLocales.DataValueField = "codLocal";
            ddlLocales.DataTextField  = "nomLocal";
            ddlLocales.DataBind();
        }
Ejemplo n.º 4
0
        public List <BELocal> GetLocalBL(BELocal local)
        {
            LocalDA DA = new LocalDA();

            return(DA.GetLocal(local));
        }
Ejemplo n.º 5
0
        public List <BELocal> IGetLocal(BELocal local)
        {
            LocalBL getLocalBL = new LocalBL();

            return(getLocalBL.GetLocalBL(local));
        }
Ejemplo n.º 6
0
        protected void Btn_Compras_Click(object sender, EventArgs e)
        {
            try
            {
                ILocal         IService2 = new ILocal();
                BELocal        BE        = new BELocal();
                BEUser         beh       = new BEUser();
                List <BELocal> lstLocal  = new List <BELocal>();
                beh         = (BEUser)Session["LoginUser"];
                BE.codLocal = beh.codLocal;

                BEPeriodoEmpresa_Mant beExport = new BEPeriodoEmpresa_Mant();
                string[] fecha = DevolverAnioMes(this.ddlPeriodos.SelectedItem.Text);
                if (beh.codRol != "3")
                {
                    beExport.codLocal = beh.codLocal;
                    lstLocal          = IService2.IGetLocal(BE);
                }
                else
                {
                    beExport.mes        = fecha[0];
                    beExport.anioProces = fecha[1];
                }

                string nomlocal = string.Empty;
                foreach (BELocal localUser in lstLocal)
                {
                    nomlocal = localUser.nomLocal;
                }

                IExportar IService = new IExportar();

                beExport.codPeriodo = this.ddlPeriodos.SelectedValue;
                //beExport.x = this.ddlPeriodos.SelectedItem.Text;
                //beExport.nombre = nomlocal;
                beExport.Ruta = "C:/C" + "20114803228" + devolverFecha(this.ddlPeriodos.SelectedItem.Text) + ".txt";

                File.Delete("C:/C" + "20114803228" + devolverFecha(this.ddlPeriodos.SelectedItem.Text) + ".txt");

                this.Lbl_Compras.Text = IService.IExporCompra(beExport);
                Lbl_Compras.Visible   = true;

                String FileName = "C" + "20114803228" + devolverFecha(this.ddlPeriodos.SelectedItem.Text) + ".txt";
                String FilePath = "C:/C" + "20114803228" + devolverFecha(this.ddlPeriodos.SelectedItem.Text) + ".txt"; //Replace this
                System.Web.HttpResponse response = System.Web.HttpContext.Current.Response;
                response.ClearContent();
                response.Clear();
                response.ContentType = "text/plain";
                response.AddHeader("Content-Disposition", "attachment; filename=" + FileName + ";");
                response.TransmitFile(FilePath);

                response.Flush();
                response.End();


                string path = "C:/C" + "20114803228" + devolverFecha(this.ddlPeriodos.SelectedItem.Text) + ".txt"; //get physical file path from server
                string name = Path.GetFileName(path);                                                              //get file name
                string ext  = Path.GetExtension(path);                                                             //get file extension
                string type = "";

                // set known types based on file extension
                if (ext != null)
                {
                    switch (ext.ToLower())
                    {
                    case ".htm":
                    case ".html":
                        type = "text/HTML";
                        break;

                    case ".txt":
                        type = "text/plain";
                        break;

                    case ".GIF":
                        type = "image/GIF";
                        break;

                    case ".pdf":
                        type = "Application/pdf";
                        break;

                    case ".doc":
                    case ".rtf":
                        type = "Application/msword";
                        break;

Default:
                        type = "";
                        break;
                    }
                }

                Response.AppendHeader("content-disposition", "attachment; filename=" + name);

                if (type != "")
                {
                    Response.ContentType = type;
                }
                Response.WriteFile(path);
                Response.End(); //give POP to user for file downlaod
            }
            catch (Exception ex)
            {
                lblError.Text = ex.Message;
            }
        }