protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string projectId = Request["projectId"]; if (projectId == null || projectId.Trim().Length == 0) { Javascript.Alert("您未指定项目不能进行此操作!", Page); Javascript.RefreshParentWindowReload(Page); } else { DalOperationAboutProject dalProject = new DalOperationAboutProject(); Project project = dalProject.GetProject(int.Parse(projectId)); if (project == null) { Javascript.Alert("未找到指定项目!", Page); Javascript.RefreshParentWindowReload(Page); } else { this.literal_ProjectName.Text = project.name; this.hf_ProjectId.Value = project.id.ToString(); BindDataItemReim(); } } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string projectId = Request["projectId"]; if (string.IsNullOrWhiteSpace(projectId)) { Javascript.Alert("您未指定要查看的项目!", Page); Javascript.RefreshParentWindowReload(Page); } else { DalOperationAboutProject dalProject = new DalOperationAboutProject(); Project project = dalProject.GetProject(int.Parse(projectId)); if (project == null) { Javascript.Alert("您查看的项目不存在!", Page); Javascript.RefreshParentWindowReload(Page); } else { UserCookiesInfo userCookiesInfo = BllOperationAboutUser.GetUserCookiesInfo(); string cookieUserNo = userCookiesInfo.userNo; if (project.userNo == cookieUserNo || isAuth(cookieUserNo)) { this.literal_ViewProjectName.Text = project.name; this.literal_UserName.Text = project.userName; DalOperationAboutProjectCategory dalProCate = new DalOperationAboutProjectCategory(); List<ProjectCategory> categoryList = dalProCate.GetProjectCategoryPathById(project.category.id); string categoryPath = ""; bool hasPrefix = false; foreach (ProjectCategory category in categoryList) { categoryPath += ((hasPrefix ? " -> " : "") + category.name); hasPrefix = true; } this.literal_ViewProjectCategory.Text = categoryPath; this.literal_CreatedTime.Text = project.createdTime.ToString(); this.literal_ProjectMemo.Text = project.memo; } else { Javascript.Alert("您无权查看此页面!", Page); Javascript.RefreshParentWindowReload(Page); } } } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string projectId = Request["projectId"]; if (string.IsNullOrWhiteSpace(projectId)) { Javascript.Alert("请指定您要添加报销规则的项目!", Page); Javascript.RefreshParentWindowReload(Page); } else { DalOperationAboutProject dalProject = new DalOperationAboutProject(); DalOperationAboutReim dalReim = new DalOperationAboutReim(); Project project = dalProject.GetProject(int.Parse(projectId.Trim())); List<Reim> reimList = dalReim.GetAllReims(); if (project == null || reimList.Count == 0) { Javascript.Alert("您要添加报销规则的项目不存在或者您未添加任何报销项,请核对后再次操作!", Page); Javascript.RefreshParentWindowReload(Page); } else { this.literal_ProjectName.Text = project.name; this.hf_ProjectId.Value = project.id.ToString(); foreach (Reim reim in reimList) { this.ddlReimLists.Items.Add(new ListItem(reim.name, reim.id.ToString())); } } } } }
public void ProcessRequest(HttpContext context) { string projectName = context.Request["pname"].Trim(); string userName = context.Request["uname"].Trim(); string rootCategoryId = context.Request["rc"].Trim(); string subCategoryId = context.Request["sc"].Trim(); string thirdCategoryId = context.Request["tc"].Trim(); HSSFWorkbook workbook = new HSSFWorkbook(); HSSFSheet projectSheet = workbook.CreateSheet("项目汇总"); List<ProjectCategory> queryCategoryList = new List<ProjectCategory>(); DalOperationAboutProject dalProject = new DalOperationAboutProject(); DalOperationAboutProjectCategory dalProCate = new DalOperationAboutProjectCategory(); if (!(string.IsNullOrWhiteSpace(thirdCategoryId) || "0" == thirdCategoryId.Trim())) { queryCategoryList.Add(dalProCate.GetProjectCategoryById(int.Parse(thirdCategoryId.Trim()))); } else if (!(string.IsNullOrWhiteSpace(subCategoryId) || "0" == subCategoryId.Trim())) { queryCategoryList.AddRange(dalProCate.GetAllLastProjectCategoryByParentId(int.Parse(subCategoryId.Trim()))); } else if (!(string.IsNullOrWhiteSpace(rootCategoryId) || "0" == rootCategoryId.Trim())) { queryCategoryList.AddRange(dalProCate.GetAllLastProjectCategoryByParentId(int.Parse(rootCategoryId.Trim()))); } string categoryIds = null; if (queryCategoryList.Count != 0) { List<int> categoryIdList = new List<int>(); foreach (ProjectCategory category in queryCategoryList) { categoryIdList.Add(category.id); } categoryIds = string.Join(",", categoryIdList.ToArray()); } List<Project> projectList; if (string.IsNullOrWhiteSpace(projectName) && string.IsNullOrWhiteSpace(userName) && string.IsNullOrWhiteSpace(categoryIds)) { projectList = dalProject.GetAllProjects(); } else { projectList = dalProject.GetPrjects(categoryIds, userName.Trim(), projectName.Trim()); } SetProjectSheet(projectSheet, projectList); string fileName = "项目汇总"; System.IO.FileStream file = new System.IO.FileStream(HttpContext.Current.Server.MapPath(fileName + ".xls"), System.IO.FileMode.Create); workbook.Write(file); file.Dispose(); ////插入值 FileInfo DownloadFile = new FileInfo(context.Server.MapPath(fileName + ".xls")); context.Response.Clear(); context.Response.ClearHeaders(); context.Response.Buffer = false; Encoding code = Encoding.GetEncoding("gb2312"); context.Response.ContentEncoding = Encoding.UTF8; context.Response.HeaderEncoding = code;//这句很重要 context.Response.ContentType = "application/octet-stream"; context.Response.AppendHeader("Content-Disposition", "attachment;filename=" + fileName + ".xls"); context.Response.AppendHeader("Content-Length", DownloadFile.Length.ToString()); context.Response.WriteFile(DownloadFile.FullName); if (File.Exists(context.Server.MapPath(fileName + ".xls"))) { File.Delete(context.Server.MapPath(fileName + ".xls")); } context.Response.Flush(); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string projectId = Request["projectId"]; string reimId = Request["reimId"]; if (string.IsNullOrWhiteSpace(projectId) || string.IsNullOrWhiteSpace(reimId)) { Javascript.Alert("您未指定要查看的报销记录!", Page); Javascript.RefreshParentWindowReload(Page); } else { DalOperationAboutReim dalReim = new DalOperationAboutReim(); DalOperationAboutProject dalProject = new DalOperationAboutProject(); DalOperationAboutReimItem dalReimItem = new DalOperationAboutReimItem(); Project project = dalProject.GetProject(int.Parse(projectId.Trim())); Reim reim = dalReim.GetReim(int.Parse(reimId.Trim())); if (project == null || reim == null) { Javascript.Alert("您指定的项目或报销项不存在!", Page); Javascript.RefreshParentWindowReload(Page); } else { this.ReimEntry_ProjectValue.Text = dalReimItem.GetReimItemValue(int.Parse(projectId), 0).ToString(); this.ReimEntry_ProjectReimValue.Text = dalReimItem.GetReimItemValue(int.Parse(projectId.Trim()), int.Parse(reimId.Trim())).ToString(); UserCookiesInfo userCookiesInfo = BllOperationAboutUser.GetUserCookiesInfo(); string cookieUserNo = userCookiesInfo.userNo; if (project.userNo == cookieUserNo || isAuth(cookieUserNo)) { List<ReimItem> reimItems = dalReimItem.GetReimItemsForProjectAndReim(int.Parse(projectId.Trim()), int.Parse(reimId.Trim())); this.ReimEntry_ProjectName.Text = project.name; this.ReimEntry_ReimName.Text = reim.name; if (reimItems == null || reimItems.Count == 0) { this.ReimEntry_ReimItemList.ShowFooter = true; } else { this.ReimEntry_ReimItemList.DataSource = reimItems; this.ReimEntry_ReimItemList.DataBind(); this.ReimEntry_ReimItemList.ShowFooter = false; } } else { Javascript.Alert("您无权查看此页面!", Page); Javascript.RefreshParentWindowReload(Page); } } } } }