protected void cmdStorageCheckClose_ServerClick(object sender, EventArgs e)
        {
            if (_WarehouseFacade == null)
            {
                _WarehouseFacade = new BenQGuru.eMES.Material.WarehouseFacade(base.DataProvider);
            }
            BenQGuru.eMES.Material.StockCheckDetailOp[] ops = this._WarehouseFacade.GetPortionStockCheckOpsNoPager(txtStockCheckCodeQuery.Text);

            foreach (BenQGuru.eMES.Material.StockCheckDetailOp op in ops)
            {
                if (op.STORAGEQTY != op.Qty)
                {
                    if (string.IsNullOrEmpty(op.DiffDesc))
                    {
                        WebInfoPublish.Publish(this, "存在数量不一致请填写盘点差异原因!", this.languageComponent1); return;
                    }
                }
            }
            BenQGuru.eMES.Domain.Warehouse.StockCheck s = (BenQGuru.eMES.Domain.Warehouse.StockCheck)_WarehouseFacade.GetStockCheck(txtStockCheckCodeQuery.Text);
            s.STATUS = "Close";
            _WarehouseFacade.UpdateStockCheck(s);
            WebInfoPublish.Publish(this, "盘点关闭成功!", this.languageComponent1); return;

            this.txtStockCheckCodeEdit.Text = string.Empty;
            txtDQMCODEEdit.Text             = string.Empty;
            txtStorageCodeEdit.Text         = string.Empty;
            txtLocationCodeEdit.Text        = string.Empty;
            txtLocationCodeEdit.Text        = string.Empty;
            txtCARTONNOEdit.Text            = string.Empty;
            txtCheckQtyEdit.Text            = string.Empty;
            txtDiffDescEdit.Text            = string.Empty;
        }
        protected void cmdStorageCheckClose_ServerClick(object sender, EventArgs e)
        {
            if (!HasAuthority())
            {
                WebInfoPublish.Publish(this, "没有权限操作!", this.languageComponent1); return;
            }

            if (_WarehouseFacade == null)
            {
                _WarehouseFacade = new BenQGuru.eMES.Material.WarehouseFacade(base.DataProvider);
            }

            BenQGuru.eMES.Domain.Warehouse.StockCheck s = (BenQGuru.eMES.Domain.Warehouse.StockCheck)_WarehouseFacade.GetStockCheck(txtStockCheckCodeQuery.Text);
            s.STATUS = "Close";
            _WarehouseFacade.UpdateStockCheck(s);
            WebInfoPublish.Publish(this, "盘点关闭成功!", this.languageComponent1); return;
        }
Exemple #3
0
        //导入按钮
        protected void Button1_Click(object sender, EventArgs e)
        {
            if (_WarehouseFacade == null)
            {
                _WarehouseFacade = new BenQGuru.eMES.Material.WarehouseFacade(base.DataProvider);
            }
            ArrayList array = this.gridHelper.GetCheckedRows();

            if (array == null)
            {
                return;
            }

            if (array.Count != 1)
            {
                WebInfoPublish.Publish(this, "只能选择一行!", this.languageComponent1); return;
            }
            try
            {
                GridRecord row1    = (GridRecord)array[0];
                string     checkNo = row1.Items.FindItemByKey("CheckNo").Text;

                BenQGuru.eMES.Domain.Warehouse.StockCheck ssss = (BenQGuru.eMES.Domain.Warehouse.StockCheck)_WarehouseFacade.GetStockCheck(checkNo);
                if (ssss == null)
                {
                    WebInfoPublish.Publish(this, "只有盘点单不存在!", this.languageComponent1); return;
                }
                if (ssss.CheckType != "All")
                {
                    WebInfoPublish.Publish(this, "只有盘点类型为全盘时可用!", this.languageComponent1); return;
                }
                if (ssss.STATUS == "Close")
                {
                    WebInfoPublish.Publish(this, "盘点单已经关闭!", this.languageComponent1); return;
                }


                System.IO.Stream ss       = FileUpload1.PostedFile.InputStream;
                string           fileName = FileUpload1.PostedFile.FileName;
                IWorkbook        workbook = null;



                if (string.IsNullOrEmpty(fileName) || System.IO.Path.GetExtension(fileName).ToLower() != ".xls") // 2007版本
                {
                    WebInfoPublish.Publish(this, "必须是.xls文件!", this.languageComponent1); return;
                }

                try
                {
                    workbook = new HSSFWorkbook(ss);
                }
                catch (Exception ex)
                {
                    WebInfoPublish.Publish(this, "未处理的异常!" + ex.Message, this.languageComponent1); return;
                }
                ISheet sheet = workbook.GetSheetAt(0);
                if (sheet == null)
                {
                    WebInfoPublish.Publish(this, "Excel文件为空!", this.languageComponent1); return;
                }
                IRow row = null;
                row = sheet.GetRow(0);
                ICell  cellFirst   = row.GetCell(1);
                string cellCheckNo = cellFirst.ToString();
                if (string.IsNullOrEmpty(cellCheckNo) || cellCheckNo != checkNo)
                {
                    WebInfoPublish.Publish(this, "xls文件中的盘点单号必须与所选的盘点单号一致!", this.languageComponent1); return;
                }



                int           rowNum     = 2;
                int           lastRowNum = sheet.LastRowNum;
                List <string> list       = new List <string>();
                for (row = sheet.GetRow(2); rowNum <= lastRowNum; rowNum++, row = sheet.GetRow(rowNum))
                {
                    ICell  cell2   = row.GetCell(1);
                    string dqmCode = cell2.StringCellValue.Trim();

                    if (string.IsNullOrEmpty(dqmCode))
                    {
                        WebInfoPublish.Publish(this, "xls文件中的鼎桥物料编号不能为空!", this.languageComponent1); return;
                    }
                    if (list.Contains(dqmCode))
                    {
                        WebInfoPublish.Publish(this, "xls文件中的鼎桥物料编号" + dqmCode + "不能重复!", this.languageComponent1); return;
                    }
                    list.Add(dqmCode);
                }

                rowNum     = 2;
                lastRowNum = sheet.LastRowNum;

                this.DataProvider.BeginTransaction();

                int date = FormatHelper.TODateInt(DateTime.Now);
                int time = FormatHelper.TOTimeInt(DateTime.Now);
                for (row = sheet.GetRow(2); rowNum <= lastRowNum; rowNum++, row = sheet.GetRow(rowNum))
                {
                    ICell cell1 = row.GetCell(0);
                    ICell cell2 = row.GetCell(1);
                    ICell cell3 = row.GetCell(2);
                    if (cell1 != null && cell2 != null && cell3 != null)
                    {
                        string  storageCode = cell1.StringCellValue;
                        string  dqmCode     = cell2.StringCellValue;
                        decimal checkQty    = 0;
                        decimal.TryParse(cell3.ToString(), out checkQty);



                        _WarehouseFacade.UpdateStockCheckDetailIfTypeIsCheckALL(checkNo, dqmCode, (int)checkQty, date, time);
                    }
                }
                this.DataProvider.CommitTransaction();
                WebInfoPublish.Publish(this, "导入成功!", this.languageComponent1); return;
            }
            catch (Exception ex)
            {
                this.DataProvider.RollbackTransaction();
                WebInfoPublish.Publish(this, "未处理的异常!" + ex.Message, this.languageComponent1); return;
            }
        }