예제 #1
0
        /// <summary>
        /// 移库右键菜单
        /// </summary>
        /// <param name="sender">sender内含tag属性为warehousezone对象</param>
        /// <param name="e"></param>
        private void DrugInventoryMoveClick(object sender, EventArgs e)
        {
            WarehouseZone wz = ((ToolStripDropDownItem)sender).Tag as WarehouseZone;

            if (wz.Name == this.comboBox1.SelectedText)
            {
                return;
            }

            ApprovalFlowType aft = this.PharmacyDatabaseService.GetApprovalFlowTypeByBusiness(out msg, ApprovalType.drugsInventoryMove).FirstOrDefault();

            if (aft == null)
            {
                MessageBox.Show("请先通知管理员设定移库审批,并设定其审批节点!"); return;
            }

            if (MessageBox.Show("确定需要申请该药品移库至:" + wz.Name + "吗?", "提示", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
            {
                return;
            }
            Guid InventoryID        = storage[this.dataGridView1.SelectedCells[0].RowIndex].InventoryID;
            DrugInventoryRecord dir = this.PharmacyDatabaseService.GetDrugInventoryRecord(out msg, InventoryID);

            if (dir == null)
            {
                MessageBox.Show("读取库存表失败!");
                return;
            }

            DrugsInventoryMove dim = new DrugsInventoryMove();

            dim.Id = Guid.NewGuid();
            dim.ApprovalStatusValue = 1;
            dim.batchNo             = dir.BatchNumber;
            dim.createTime          = DateTime.Now;
            dim.createUID           = BugsBox.Pharmacy.AppClient.Common.AppClientContext.currentUser.Id;
            dim.Deleted             = false;
            dim.Description         = "移库至" + wz.Name;
            dim.drugName            = dir.DrugInfo.ProductGeneralName;
            dim.flowID            = Guid.NewGuid();
            dim.inventoryRecordID = dir.Id;
            dim.OriginWareHouseID = dir.WarehouseZoneId;
            dim.quantity          = dir.CanSaleNum;
            dim.updateTime        = DateTime.Now;
            dim.WareHouseID       = wz.Id;
            bool b = this.PharmacyDatabaseService.AddDrugsInventoryMoveByFlowID(dim, aft.Id, "新增移库审批", out msg);

            if (b)
            {
                this.PharmacyDatabaseService.WriteLog(dim.createUID, "成功提交移库申请信息:" + dim.drugName + "被成功申请移至" + dim.OriginWareHouseID);
                if (MessageBox.Show("成功申请移库信息" + wz.Name + ",请至右键菜单->移库记录查询界面查询!需要打开移库记录查询窗口吗?", "提示", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
                {
                    return;
                }
                Form_DrugInventoryMove frm = new Form_DrugInventoryMove();
                frm.ShowDialog();
            }
        }
예제 #2
0
        private void search()
        {
            Models.DrugsInventoryMove dm = new DrugsInventoryMove();
            dm.createTime          = this.dateTimePicker1.Value.AddHours(-DateTime.Now.Hour);
            dm.updateTime          = this.dateTimePicker2.Value.AddDays(1).AddHours(-DateTime.Now.Hour);
            dm.ApprovalStatusValue = this.comboBox1.SelectedIndex == 3 ? 4 : this.comboBox1.SelectedIndex;
            var c = this.PharmacyDatabaseService.GetMoveRecords(dm, out msg).OrderBy(r => r.CreateTime).ToList();

            int index = 0;

            foreach (var i in c)
            {
                index++;
                i.Index     = index;
                i.StatusStr = i.Status == 1 ? "正在审批" : i.Status == 2 ? "审批通过" : i.Status == 4 ? "审批被拒" : "异常状态";
            }

            this.dataGridView1.DataSource = c;
            this.HideFields();
        }
        public bool AddDrugsInventoryMoveByFlowID(DrugsInventoryMove value, Guid flowTypeID, string changeNote)
        {
            try
            {
                value.createTime = DateTime.Now;
                value.updateTime = DateTime.Now;
                this.Add(value);

                //增加审批流程
                ApprovalFlow af = BusinessHandlerFactory.ApprovalFlowBusinessHandler.GetApproveFlowInstance(flowTypeID, value.flowID, value.createUID, changeNote);
                BusinessHandlerFactory.ApprovalFlowBusinessHandler.Add(af);

                //增加审批流程记录
                ApprovalFlowRecord afr = BusinessHandlerFactory.ApprovalFlowRecordBusinessHandler.GetApproveFlowRecordInstance(af, value.createUID, changeNote);
                BusinessHandlerFactory.ApprovalFlowRecordBusinessHandler.Add(afr);
                this.Save();
                return(true);
            }
            catch (Exception e)
            {
                this.HandleException("新增移库药品审批流程记录失败", e);
                return(false);
            }
        }
예제 #4
0
        /// <summary>
        /// GetObjectEntityInstance
        /// </summary>
        /// <returns></returns>
        object GetObjectEntityInstance(int ApproveCategory, Guid flowid, ApprovalStatus action)
        {
            string msg = string.Empty;

            switch (ApproveCategory)
            {
            case (int)ApprovalType.SupplyUnitApproval:
            case (int)ApprovalType.SupplyUnitEditApproval:
            case (int)ApprovalType.SupplyUnitLockApproval:
                SupplyUnit su = BusinessHandlerFactory.SupplyUnitBusinessHandler.GetSupplyUnitByFlowID(flowid);
                if (su != null)    //测试时可能为NULL
                {
                    su.ApprovalStatus = action;
                }
                return(su);

            case (int)ApprovalType.DrugInfoApproval:
            case (int)ApprovalType.DrugInfoEditApproval:
            case (int)ApprovalType.DrugInfoLockApproval:
                DrugInfo di = BusinessHandlerFactory.DrugInfoBusinessHandler.GetDrugInfoByFlowID(flowid);
                if (di != null)    //测试时可能为NULL
                {
                    di.ApprovalStatus = action;
                }
                return(di);

            case (int)ApprovalType.PurchaseUnitApproval:
            case (int)ApprovalType.PurchaseUnitEditApproval:
            case (int)ApprovalType.PurchaseUnitLockApproval:
                PurchaseUnit pu = BusinessHandlerFactory.PurchaseUnitBusinessHandler.GetPurchaseUnitByFlowID(flowid);
                if (pu != null)    //测试时可能为NULL
                {
                    pu.ApprovalStatus = action;
                }
                return(pu);

            case (int)ApprovalType.drugsUnqualityApproval:
                drugsUnqualificationCondition dc = new drugsUnqualificationCondition();
                dc.FlowID = flowid;
                dc.dtFrom = DateTime.MinValue;
                dc.dtTo   = DateTime.MaxValue;
                DrugsUnqualication du = BusinessHandlerFactory.DrugsUnqualicationBusinessHandler.GetDrugsUnqualificationByCondition(dc).FirstOrDefault();
                if (du != null)
                {
                    du.ApprovalStatus = action;
                }
                return(du);

            case (int)ApprovalType.drugsBreakageApproval:
                DrugsBreakage db = BusinessHandlerFactory.DrugsBreakageBusinessHandler.GetDrugsBreakageByFlowID(flowid);
                if (db != null)
                {
                    db.ApprovalStatus = action;
                    if (action == ApprovalStatus.Reject)
                    {
                        var c = BusinessHandlerFactory.DrugsUnqualicationBusinessHandler.Get(db.DrugUnqualityId);
                        if (c != null)
                        {
                            c.unqualificationType = 0;
                            BusinessHandlerFactory.DrugsUnqualicationBusinessHandler.Save(c);
                        }
                    }
                }
                return(db);

            case (int)ApprovalType.drugsInventoryMove:
                DrugsInventoryMove dim = BusinessHandlerFactory.DrugsInventoryMoveBusinessHandler.GetDrugsInventoryMoveByFlowID(flowid);
                if (dim != null)
                {
                    dim.ApprovalStatus = action;
                }
                return(dim);

            case (int)ApprovalType.VehicleApproval:
                Vehicle v = BusinessHandlerFactory.VehicleBusinessHandler.GetVehicleByFlowID(flowid);
                if (v != null)
                {
                    v.ApprovalStatusValue = (int)action;
                }
                return(v);

            case (int)ApprovalType.DirectSalesApproval:
                Models.DirectSalesOrder dso = BusinessHandlerFactory.DirectSalesOrderBusinessHandler.GetDirectSalesOrderByFlowId(flowid);
                dso.ApprovalStatusValue = (int)action;
                return(dso);
            }
            return(null);
        }
예제 #5
0
        /// <summary>
        /// 根据审核结果更新实体审核信息
        /// 对业务表的操作:审批同意且审批节点流完,需要更新业务表 后者审批拒绝需要更新业务表
        /// </summary>
        /// <param name="flowTypeIndex"></param>
        /// <param name="flowId"></param>
        /// <param name="status"></param>
        private void UpdateEntityByApprovalStatus(int flowTypeIndex, Guid flowId, ApprovalStatus status)
        {
            try
            {
                switch (flowTypeIndex)
                {
                case (int)ApprovalType.SupplyUnitApproval:
                case (int)ApprovalType.SupplyUnitEditApproval:
                case (int)ApprovalType.SupplyUnitLockApproval:
                    SupplyUnit su = new SupplyUnit();
                    su = (SupplyUnit)GetObjectEntityInstance(flowTypeIndex, flowId, status);
                    if (su == null)     //测试时可能为NULL
                    {
                        BusinessHandlerFactory.SupplyUnitBusinessHandler.Save(su);
                    }
                    break;

                case (int)ApprovalType.DrugInfoApproval:
                case (int)ApprovalType.DrugInfoEditApproval:
                case (int)ApprovalType.DrugInfoLockApproval:
                    DrugInfo di = new DrugInfo();
                    di = (DrugInfo)GetObjectEntityInstance(flowTypeIndex, flowId, status);
                    if (di == null)     //测试时可能为NULL
                    {
                        BusinessHandlerFactory.DrugInfoBusinessHandler.Save(di);
                    }
                    break;

                case (int)ApprovalType.PurchaseUnitApproval:
                case (int)ApprovalType.PurchaseUnitEditApproval:
                case (int)ApprovalType.PurchaseUnitLockApproval:
                    PurchaseUnit pu = new PurchaseUnit();
                    pu = (PurchaseUnit)GetObjectEntityInstance(flowTypeIndex, flowId, status);
                    if (pu == null)     //测试时可能为NULL
                    {
                        BusinessHandlerFactory.PurchaseUnitBusinessHandler.Save(pu);
                    }
                    break;

                case (int)ApprovalType.drugsUnqualityApproval:
                    DrugsUnqualication du = (DrugsUnqualication)GetObjectEntityInstance(flowTypeIndex, flowId, status);
                    BusinessHandlerFactory.DrugsUnqualicationBusinessHandler.Save(du);
                    break;

                case (int)ApprovalType.drugsBreakageApproval:
                    DrugsBreakage db = (DrugsBreakage)GetObjectEntityInstance(flowTypeIndex, flowId, status);
                    if (db == null)     //测试时可能为NULL
                    {
                        if (status == ApprovalStatus.Reject)
                        {
                            db.Deleted        = true;
                            db.DeleteTime     = DateTime.Now;
                            db.ApprovalStatus = ApprovalStatus.Reject;
                        }
                        BusinessHandlerFactory.DrugsBreakageBusinessHandler.Save(db);
                    }
                    break;

                case (int)ApprovalType.drugsInventoryMove:
                    DrugsInventoryMove dim = (DrugsInventoryMove)GetObjectEntityInstance(flowTypeIndex, flowId, status);
                    if (status == ApprovalStatus.Approvaled)
                    {
                        DrugInventoryRecord dir = BusinessHandlerFactory.DrugInventoryRecordBusinessHandler.Get(dim.inventoryRecordID);
                        dir.WarehouseZoneId = dim.WareHouseID;
                        BusinessHandlerFactory.DrugInventoryRecordBusinessHandler.Save(dir);
                    }
                    BusinessHandlerFactory.DrugsInventoryMoveBusinessHandler.Save(dim);
                    break;

                case (int)ApprovalType.VehicleApproval:
                    Vehicle v = (Vehicle)GetObjectEntityInstance(flowTypeIndex, flowId, status);
                    BusinessHandlerFactory.VehicleBusinessHandler.Save(v);
                    break;

                case (int)ApprovalType.DirectSalesApproval:
                    DirectSalesOrder dso = (Models.DirectSalesOrder)GetObjectEntityInstance(flowTypeIndex, flowId, status);
                    BusinessHandlerFactory.DirectSalesOrderBusinessHandler.Save(dso);
                    break;
                }
            }
            catch (Exception ex)
            {
                this.HandleException("根据审核结果更新实体审核信息失败", ex);
            }
        }