protected override object[] LoadDataSource(int inclusive, int exclusive)
        {
            if (facade == null)
            {
                facade = new PauseFacade(this.DataProvider);
            }

            return(facade.QueryPauseSequence(
                       FormatHelper.CleanString(this.txtStorageCodeQuery.Text),
                       FormatHelper.CleanString(this.txtStackCodeQuery.Text),
                       FormatHelper.CleanString(this.txtPalletCodeQuery.Text),
                       FormatHelper.CleanString(this.txtItemCodeQuery.Text),
                       FormatHelper.CleanString(this.txtPauseCodeQuery.Text),
                       FormatHelper.CleanString(this.txtCancelPauseQuery.Text), true,
                       inclusive, exclusive));
        }
Example #2
0
        protected override void Grid_ClickCell(GridRecord row, string commandName)
        {
            //base.Grid_ClickCell(cell);

            if (commandName == "DetailsMore")
            {
                this.Response.Redirect(this.MakeRedirectUrl("./FPauseSequenceQueryNew.aspx",
                                                            new string[] { "storageCode", "stackCode", "palletCode", "itemCode", "pauseCode", "cancelCode" },
                                                            new string[] { "", "", "",
                                                                           "", row.Items.FindItemByKey("PauseCode").Value.ToString().Trim(), "" }));
            }

            if (commandName == "Download")
            {
                string pauseCode = row.Items.FindItemByKey("PauseCode").Value.ToString();
                string pauseQty  = row.Items.FindItemByKey("PauseCount").Value.ToString();

                if (facade == null)
                {
                    facade = new PauseFacade(base.DataProvider);
                }
                object[] pauseObj = facade.QueryPauseSequence("", "", "", "", pauseCode, "", false, 0, 100000);
                if (pauseObj == null)
                {
                    ExceptionManager.Raise(this.GetType(), "停发通知单不存在");
                }

                PauseQuery pauseQuery = pauseObj[0] as PauseQuery;

                string originalFilePath = this.Request.PhysicalApplicationPath + @"download\PauseCode.htm";
                if (!File.Exists(originalFilePath))
                {
                    ExceptionManager.Raise(this.GetType(), "文件[PauseCode.htm]不存在");
                }

                string fileContent = File.ReadAllText(originalFilePath, Encoding.GetEncoding("GB2312"));
                fileContent = fileContent.Replace("$$PauseCode$$", pauseCode);
                fileContent = fileContent.Replace("$$ModelCode$$", pauseQuery.MModelCode == "" ? " " : pauseQuery.MModelCode);
                fileContent = fileContent.Replace("$$BOMVersion$$", pauseQuery.BOM == "" ? " " : pauseQuery.BOM);
                fileContent = fileContent.Replace("$$ItemCode$$", pauseQuery.MCode == "" ? " " : pauseQuery.MCode);
                fileContent = fileContent.Replace("$$ItemDescription$$", pauseQuery.MDesc == "" ? " " : pauseQuery.MDesc);
                fileContent = fileContent.Replace("$$PauseQty$$", pauseQty == "" ? " " : pauseQty);
                fileContent = fileContent.Replace("$$PauseReason$$", pauseQuery.PauseReason == "" ? " " : pauseQuery.PauseReason);

                string downloadPhysicalPath = this.Request.PhysicalApplicationPath + @"upload\";
                if (!Directory.Exists(downloadPhysicalPath))
                {
                    Directory.CreateDirectory(downloadPhysicalPath);
                }

                string filename = string.Format("{0}_{1}_{2}", row.Items.FindItemByKey("PauseCode").Value.ToString(), FormatHelper.TODateInt(System.DateTime.Now).ToString(), FormatHelper.TOTimeInt(System.DateTime.Now).ToString());
                string filepath = string.Format(@"{0}{1}{2}", downloadPhysicalPath, filename, ".xls");

                while (File.Exists(filepath))
                {
                    filename = string.Format("{0}_{1}", filename, "0");
                    filepath = string.Format(@"{0}{1}{2}", downloadPhysicalPath, filename, ".xls");
                }

                StreamWriter writer = new StreamWriter(filepath, false, System.Text.Encoding.GetEncoding("GB2312"));
                writer.Write(fileContent);
                writer.Flush();
                writer.Close();

                this.DownloadFile(filename);
            }
        }