public List <BEPeriodoEmpresa_Mant> GET_PERIODOSEMPRESA_LOCALANIO(Int64 Anio, Int64 Local) { try { List <BEPeriodoEmpresa_Mant> lstPeriodosEmpresa = new List <BEPeriodoEmpresa_Mant>(); BEPeriodoEmpresa_Mant bePeriodo = new BEPeriodoEmpresa_Mant(); using (DbCommand dbCmd = dbSQL.GetStoredProcCommand("SP_GET_PERIODOSEMPRESA_ANIO")) { dbSQL.AddInParameter(dbCmd, "@anio", DbType.Int64, Anio); dbSQL.AddInParameter(dbCmd, "@Local", DbType.Int64, Local); using (IDataReader dataReader = dbSQL.ExecuteReader(dbCmd)) { int index1 = dataReader.GetOrdinal("codPeriodoEmpresa"); int index2 = dataReader.GetOrdinal("codLocal"); int index3 = dataReader.GetOrdinal("codEstado"); int index4 = dataReader.GetOrdinal("anioProces"); int index5 = dataReader.GetOrdinal("Descripcion"); int index6 = dataReader.GetOrdinal("mes"); int index7 = dataReader.GetOrdinal("Estado"); int index8 = dataReader.GetOrdinal("Local"); object[] values = new object[dataReader.FieldCount]; while (dataReader.Read()) { dataReader.GetValues(values); bePeriodo = new BEPeriodoEmpresa_Mant(); bePeriodo.descPeriodo = values[index1] == DBNull.Value ? string.Empty : values[index1].ToString(); bePeriodo.codLocal = values[index2] == DBNull.Value ? string.Empty : values[index2].ToString(); bePeriodo.codEstado = values[index3] == DBNull.Value ? string.Empty : values[index3].ToString(); bePeriodo.anioProces = values[index4] == DBNull.Value ? string.Empty : values[index4].ToString(); bePeriodo.descPeriodo = values[index5] == DBNull.Value ? string.Empty : values[index5].ToString(); bePeriodo.mes = values[index6] == DBNull.Value ? string.Empty : values[index6].ToString(); bePeriodo.descripcion = values[index7] == DBNull.Value ? string.Empty : values[index7].ToString(); bePeriodo.Hotel = values[index8] == DBNull.Value ? string.Empty : values[index8].ToString(); lstPeriodosEmpresa.Add(bePeriodo); } } return(lstPeriodosEmpresa); } } catch (Exception ex) { ExceptionManager.SaveError("Ocurrio un error al obtener los periodos", string.Empty, string.Empty, ex, "GetPeriodos", true, false); return(null); } finally { } }
public String GetExportacion_venta(BEPeriodoEmpresa_Mant Perido) { return(DA.GetVentas_Exportacion(Perido)); }
public String GetExportacion_Compra(BEPeriodoEmpresa_Mant Perido) { return(DA.GetCompra_Exportacion(Perido)); }
public String GetExportacion_Hotel(BEPeriodoEmpresa_Mant Perido) { return(DA.GetHoteles_Exportacion(Perido)); }
public string IExporVenta(BEPeriodoEmpresa_Mant Perido) { return(BL.GetExportacion_venta(Perido)); }
// //Modificaciones realizadas por renzo laureano 29/11/2012 // public string IExporHotel(BEPeriodoEmpresa_Mant Perido) { return(BL.GetExportacion_Hotel(Perido)); }
// //Modificaciones realizadas por renzo laureano 29/11/2012 // public String GetHoteles_Exportacion(BEPeriodoEmpresa_Mant Perido) { string respuesta = string.Empty; try { List <BEExportacion> Exportaciones = new List <BEExportacion>(); BEExportacion Exportar = new BEExportacion(); using (DbCommand dbCmd = dbSQL.GetStoredProcCommand("SP_Exportacion_Hospedaje")) { dbSQL.AddInParameter(dbCmd, "@Per_empresa", DbType.String, Perido.codPeriodo); if (string.IsNullOrEmpty(Perido.codLocal)) { dbSQL.AddInParameter(dbCmd, "@codLocal", DbType.String, DBNull.Value); } else { dbSQL.AddInParameter(dbCmd, "@codLocal", DbType.String, Perido.codLocal); } if (string.IsNullOrEmpty(Perido.anioProces)) { dbSQL.AddInParameter(dbCmd, "@Anio", DbType.Int32, DBNull.Value); } else { dbSQL.AddInParameter(dbCmd, "@Anio", DbType.Int32, Perido.anioProces); } if (string.IsNullOrEmpty(Perido.anioProces)) { dbSQL.AddInParameter(dbCmd, "@Mes", DbType.Int32, DBNull.Value); } else { dbSQL.AddInParameter(dbCmd, "@Mes", DbType.Int32, Perido.mes); } using (IDataReader dataReader = dbSQL.ExecuteReader(dbCmd)) { int Resul = dataReader.GetOrdinal("Sunat"); object[] values = new object[dataReader.FieldCount]; while (dataReader.Read()) { dataReader.GetValues(values); StreamWriter sw = new StreamWriter(Path.GetFullPath(@Perido.Ruta), true); //StreamWriter sw = new StreamWriter(Path.GetFullPath(@"d:/20114803228.hos"), true); sw.WriteLine(values[Resul] == DBNull.Value ? string.Empty : values[Resul].ToString()); sw.Close(); } } return("Exportacion Exitosa"); } } catch (Exception ex) { throw ex; //ExceptionManager.SaveError("Ocurrio un error en el logo", string.Empty, string.Empty, ex, "validateLoginUser", true, false); //return null; } finally { } }
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; } }