public void ProcessRequest(HttpContext context)
        {
            string projectName = context.Request["pname"].Trim();

            HSSFWorkbook workbook = new HSSFWorkbook();

            HSSFSheet projectSheet = workbook.CreateSheet("项目各报销项汇总");
            HSSFSheet projectReimSummarySheet = workbook.CreateSheet("项目报销项金额汇总");
            HSSFSheet projectSummarySheet = workbook.CreateSheet("项目报销总金额汇总");

            List<ProjectCategory> queryCategoryList = new List<ProjectCategory>();

            DalOperationAboutReimItem dalReimItem = new DalOperationAboutReimItem();

            List<ReimItem> reimItemList;
            if (!string.IsNullOrWhiteSpace(projectName))
            {
                reimItemList = dalReimItem.GetReimItems(projectName.Trim(), 0, 0);
            }
            else
            {
                reimItemList = dalReimItem.GetAllDistinctReimItems();
            }

            List<ReimItem> reimItemSummaryList = dalReimItem.GetReimItemSummaryValues(projectName, 0, 0, null);

            List<ReimItem> projectReimSummaryList = dalReimItem.GetProjectReimItems(projectName, 0);

            SetProjectReimSheet(projectSheet, reimItemList);

            SetProjectReimSummarySheet(projectReimSummarySheet, reimItemSummaryList);
            SetProjectSummarySheet(projectSummarySheet, projectReimSummaryList);

            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();
        }
Beispiel #2
0
        protected void ReimEntry_Click(object sender, EventArgs e)
        {
            string reimIdString = this.ddl_ReimList.SelectedValue;
            if (reimIdString == null || reimIdString == "0")
            {
                Javascript.Alert("您未指定报销项,请核对后再完成此操作!", Page);
            }
            else
            {
                int projectId = int.Parse(this.hf_ProjectId.Value);
                int reimId = int.Parse(reimIdString);
                float reimingValue = CommonUtility.ConvertFormatedFloat("{0:F2}", this.tb_ReimValue.Text.Trim());
                DalOperationAboutReimItem dalReimItem = new DalOperationAboutReimItem();
                DalOperationAboutProjectReimRule dalRule = new DalOperationAboutProjectReimRule();

                float reimedValue = dalReimItem.GetReimItemValue(projectId, reimId);

                ProjectReimRule projectRule = dalRule.GetProjectReimRule(projectId, reimId);

                bool isError = false;
                if (projectRule != null)
                {
                    if (reimingValue > projectRule.reimValue)
                    {
                        isError = true;
                        Javascript.Alert("该项目选择的报销项单次最大金额不超过" + projectRule.reimValue+ "元", Page);
                    }
                    else if (reimingValue + reimedValue > projectRule.maxReimValue)
                    {
                        isError = true;
                        Javascript.Alert("该项目选择的报销项最大报销总金额不超过" + projectRule.maxReimValue + "元,当前您已报销了" + reimedValue + "元", Page);
                    }
                }

                if (!isError) {
                    ReimItem reimItem = new ReimItem()
                    {
                        project = new Project() { id = projectId },
                        reim = new Reim() { id = reimId },
                        value = reimingValue,
                        memo = this.ReimEntryMemo.Text.Trim()
                    };

                    dalReimItem.AddReimItem(reimItem);

                    Javascript.Alert("操作成功!", Page);
                    Javascript.RefreshParentWindowReload(Page);
                }
            }
        }
Beispiel #3
0
        protected void ReimItemList_Command(object source, DataListCommandEventArgs e)
        {
            int reimItemSelected = int.Parse(this.ReimEntry_ReimItemList.DataKeys[e.Item.ItemIndex].ToString()); //取选中行报销记录
            DalOperationAboutReimItem dalReimItem = new DalOperationAboutReimItem();
            ReimItem reimItem = dalReimItem.GetReimItem(reimItemSelected);
            if (reimItem == null)
            {
                Javascript.Alert("您所操作的数据不存在!", Page);
            }
            else {
                if (e.CommandName == "delReimItem")
                {

                    dalReimItem.DelReimItem(reimItemSelected);
                    Javascript.JavaScriptLocationHref("/Teacher/ViewReimEntry.aspx?projectId=" + reimItem.project.id + "&reimId=" + reimItem.reim.id, Page);
                }
            }
        }
Beispiel #4
0
        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);
                        }
                    }
                }

            }
        }