protected void cmdLotSave_ServerClick(object sender, EventArgs e) { try { _WarehouseFacade = new BenQGuru.eMES.Material.WarehouseFacade(this.DataProvider); BenQGuru.eMES.Domain.Warehouse.Pick p = (BenQGuru.eMES.Domain.Warehouse.Pick)_WarehouseFacade.GetPick(txtPickNoQuery.Text); if (p.Status != Pick_STATUS.Status_Release) { WebInfoPublish.Publish(this, p.PickNo + "拣货任务令的状态必须是初始化才能修改!", this.languageComponent1); return; } StringBuilder sb = new StringBuilder(300); this.DataProvider.BeginTransaction(); List <string> pickLineGtQty = new List <string>(); for (int i = 0; i < this.gridWebGrid.Rows.Count; i++) { string pickLine = this.gridWebGrid.Rows[i].Items.FindItemByKey("PICKLINE").Value.ToString(); BenQGuru.eMES.Domain.Warehouse.PickDetail d = (BenQGuru.eMES.Domain.Warehouse.PickDetail)_WarehouseFacade.GetPickdetail(txtPickNoQuery.Text, pickLine); decimal qty = d.QTY; BenQGuru.eMES.Domain.MOModel.Material m = (BenQGuru.eMES.Domain.MOModel.Material)_WarehouseFacade.GetMaterialFromDQMCode(d.DQMCode); if (m == null) { WebInfoPublish.Publish(this, d.DQMCode + "物料号不存在!", this.languageComponent1); this.DataProvider.RollbackTransaction(); return; } string qtyStr = this.gridWebGrid.Rows[i].Items.FindItemByKey("QTY").Value.ToString(); decimal decqty = 0; if (!decimal.TryParse(qtyStr, out decqty)) { WebInfoPublish.Publish(this, txtPickNoQuery.Text + ":" + pickLine + "数量必须是数字!", this.languageComponent1); this.DataProvider.RollbackTransaction(); return; } string invno = FormatHelper.CleanString(txtInvNoEidt.Text); decimal pickqty = _WarehouseFacade.GetPickDetailQty(invno, d.InvLine, m.MCode); decimal wwpoqty = _WarehouseFacade.GetWWPOQty(invno, d.InvLine, m.MCode); bool isFalse = (decqty + pickqty - qty > wwpoqty); d.QTY = decqty; if (isFalse) { sb.Append(string.Format(@"拣货任务令号:{0},SAP单据号:{1},状态:{2},下发人:{3},鼎桥物料编码:{4},描述:{5},领取数量:{6},超领数量:{7} \r\n", p.PickNo, txtInvNoEidt.Text, p.Status, GetUserCode(), m.DqmCode, m.MenshortDesc, decqty, decqty + pickqty - qty - wwpoqty)); pickLineGtQty.Add(pickLine); } _WarehouseFacade.UpdatePickdetail(d); } this.DataProvider.CommitTransaction(); if (pickLineGtQty.Count == 0) { WebInfoPublish.Publish(this, "保存成功", this.languageComponent1); } else { GenWWPOMail(sb.ToString(), GetUserCode()); WebInfoPublish.Publish(this, "保存成功 - " + txtPickNoQuery.Text + "行项目" + string.Join(",", pickLineGtQty.ToArray()) + " 的领料数大于SAP物料数量", this.languageComponent1); } } catch (Exception ex) { this.DataProvider.RollbackTransaction(); throw ex; } this.gridHelper.RequestData(); this.buttonHelper.PageActionStatusHandle(PageActionType.Save); }
protected void cmdDelete_ServerClick(object sender, EventArgs e) { if (_WarehouseFacade == null) { _WarehouseFacade = new BenQGuru.eMES.Material.WarehouseFacade(base.DataProvider); } if (inventoryFacade == null) { inventoryFacade = new BenQGuru.eMES.Material.InventoryFacade(base.DataProvider); } ArrayList array = this.gridHelper.GetCheckedRows(); if (array == null) { return; } List <BenQGuru.eMES.Domain.Warehouse.PickDetail> ll = new List <BenQGuru.eMES.Domain.Warehouse.PickDetail>(); foreach (GridRecord row in array) { BenQGuru.eMES.Domain.Warehouse.PickDetail obj = (BenQGuru.eMES.Domain.Warehouse.PickDetail)_WarehouseFacade.GetPickdetail(txtPickNoQuery.Text, row.Items.FindItemByKey("PICKLINE").Text); if (obj.Status != "Release") { WebInfoPublish.Publish(this, obj.PickNo + "状态不为初始化!", this.languageComponent1); return; } if (inventoryFacade.GetPickDetailMaterialsCount(obj.PickNo, obj.PickLine) > 0) { WebInfoPublish.Publish(this, obj.PickNo + ":" + obj.PickLine + "正在拣料中,不能删除!", this.languageComponent1); return; } ll.Add(obj); } try { this.DataProvider.BeginTransaction(); foreach (BenQGuru.eMES.Domain.Warehouse.PickDetail p in ll) { _WarehouseFacade.DeletePickToPo(p.PickNo, p.PickLine); //add by sam _WarehouseFacade.DeletePickdetail(p); } this.DataProvider.CommitTransaction(); } catch (Exception ex) { this.DataProvider.RollbackTransaction(); throw ex; } }