/// <summary> /// 根据物品编码与批次号加入入库退库信息 /// </summary> /// <param name="itemCode"></param> /// <param name="stockNO"></param> /// <returns></returns> protected virtual int AddInData(string itemCode, int stockNO) { if (this.hsInData.ContainsKey(itemCode + stockNO.ToString())) { MessageBox.Show("该物品已添加"); return(0); } List <Neusoft.HISFC.Models.Material.StoreDetail> alDetail = this.storeManager.QueryStoreList(this.matInManager.DeptInfo.ID, itemCode, stockNO.ToString(), true); if (alDetail == null || alDetail.Count == 0) { MessageBox.Show("未获取有效的库存明细信息" + this.storeManager.Err); return(-1); } Neusoft.HISFC.Models.Material.StoreDetail storeDetail = alDetail[0]; Neusoft.HISFC.Models.Material.Input input = new Neusoft.HISFC.Models.Material.Input(); input.StoreBase = storeDetail.StoreBase; //库存基本信息 input.StoreBase.Quantity = storeDetail.StoreBase.StoreQty; //入库量 = 库存量 input.Memo = storeDetail.Memo; if (this.AddDataToTable(input) == 1) { this.hsInData.Add(itemCode + stockNO.ToString(), input); } this.SetFormat(); this.SetFocusSelect(); return(1); }
/// <summary> /// 初始化库存 /// </summary> private void AddStock() { if (this.ValidCheck() < 0) { return; } List <Neusoft.HISFC.Models.Material.MaterialStorage> alDept = this.tvDeptTree1.SelectNodes; if (alDept.Count == 0) { MessageBox.Show(Language.Msg("请选择要添加的库房"), Language.Msg("提示")); return; } if (!this.isHavePriv) { bool isAllowEdit = false; foreach (Neusoft.HISFC.Models.Material.MaterialStorage dept in alDept) { if (dept.ID == this.privDept.ID) { isAllowEdit = true; } } if (!isAllowEdit) { MessageBox.Show(Language.Msg("您的权限不能对其他库存科室进行库存初始化! 请添加药品基本信息维护权限"), Language.Msg("提示")); return; } } //定义数据库处理事务 Neusoft.FrameWork.Management.PublicTrans.BeginTransaction(); this.matManager.SetTrans(Neusoft.FrameWork.Management.PublicTrans.Trans); try { string matCode = ""; decimal quantity = Neusoft.FrameWork.Function.NConvert.ToDecimal(this.txtSum.Text); bool IsUpdate = false; bool check = false; Neusoft.HISFC.Models.Material.StoreDetail storeDetail = new Neusoft.HISFC.Models.Material.StoreDetail(); storeDetail.StoreBase.StockNO = this.matManager.GetNewStockNO(); storeDetail.StoreBase.BatchNO = "1"; storeDetail.StoreBase.ValidTime = this.matManager.GetDateTimeFromSysDateTime().AddYears(5); storeDetail.StoreBase.Quantity = quantity; storeDetail.StoreBase.StoreQty = quantity; storeDetail.StoreBase.PlaceNO = "0"; storeDetail.StoreBase.ID = "0"; storeDetail.StoreBase.SerialNO = 0; storeDetail.StoreBase.SystemType = "01"; storeDetail.StoreBase.PrivType = "00"; storeDetail.StoreBase.Class2Type = "0510"; storeDetail.Memo = "库存初始化"; storeDetail.StoreBase.Item.ValidState = true; storeDetail.StoreBase.Operation.Oper.OperTime = this.matManager.GetDateTimeFromSysDateTime(); foreach (Neusoft.HISFC.Models.Material.MaterialStorage dept in alDept) { for (int i = 0; i < this.neuSpread1_Sheet1.RowCount; i++) { Neusoft.FrameWork.WinForms.Classes.Function.ShowWaitForm(i, this.neuSpread1_Sheet1.RowCount); Application.DoEvents(); //如果没有选中,则不处理此条数据 check = Neusoft.FrameWork.Function.NConvert.ToBoolean(this.neuSpread1_Sheet1.Cells[i, 0].Value); if (!check) { continue; } matCode = this.neuSpread1_Sheet1.Cells[i, 7].Text; storeDetail.StoreBase.StockDept.ID = dept.ID; storeDetail.StoreBase.TargetDept.ID = dept.ID; storeDetail.StoreBase.Item = this.matItemManager.GetMetItemByMetID(matCode); if (storeDetail.StoreBase.Item == null) { Neusoft.FrameWork.Management.PublicTrans.RollBack(); MessageBox.Show(Language.Msg("无法转化为storeDetail.StoreBase.Item类型")); return; } if (storeDetail.StoreBase.Quantity == 0) { continue; } storeDetail.StoreBase.PriceCollection.PurchasePrice = storeDetail.StoreBase.Item.UnitPrice; storeDetail.StoreBase.PriceCollection.RetailPrice = storeDetail.StoreBase.PriceCollection.PurchasePrice; storeDetail.StoreBase.StoreCost = quantity * storeDetail.StoreBase.PriceCollection.PurchasePrice; #region 写入有效性状态 {EBFFA2FC-9E48-4b6e-BB0B-2910C6E98501} storeDetail.StoreBase.State = Neusoft.FrameWork.Function.NConvert.ToInt32(storeDetail.StoreBase.Item.ValidState).ToString(); #endregion if (this.matManager.SetStorage(storeDetail) != 1) { Neusoft.FrameWork.Management.PublicTrans.RollBack(); MessageBox.Show(this.matManager.Err, Language.Msg("保存错误提示")); return; } IsUpdate = true; } } if (IsUpdate) { Neusoft.FrameWork.Management.PublicTrans.Commit(); MessageBox.Show(Language.Msg("保存成功!")); } else { //如果没有更新的数据,则回滚事务. Neusoft.FrameWork.Management.PublicTrans.RollBack(); } } catch (System.Exception ex) { Neusoft.FrameWork.Management.PublicTrans.RollBack(); MessageBox.Show(ex.Message); return; } //显示全部药品 this.dvMatList.RowFilter = "1=1"; this.SetFormat(); //取消选中 this.SelectMat(false); }