Пример #1
0
        /// <summary>
        /// 写台帐
        /// </summary>
        /// <typeparam name="THead">头实体类</typeparam>
        /// <typeparam name="TDetail">明细实体类</typeparam>
        /// <param name="billHead">单据头</param>
        /// <param name="billDetails">单据明细</param>
        /// <param name="storeResult">库存结果信息</param>
        public void WriteAccount <THead, TDetail>(THead billHead, TDetail billDetails, MWStoreResult storeResult)
        {
            MW_InStoreDetail detail = billDetails as MW_InStoreDetail;
            MW_InStoreHead   head   = billHead as MW_InStoreHead;
            int    actYear;
            int    actMonth;
            string errMsg;

            if (!GetAccountTime(head.DeptID, out errMsg, out actYear, out actMonth))
            {
                throw new Exception(errMsg);
            }

            MW_Account account = NewObject <MW_Account>();

            account.BalanceYear  = actYear;
            account.BalanceMonth = actMonth;
            account.AccountType  = 0;
            account.BalanceFlag  = 0;
            account.BatchNO      = detail.BatchNo;
            account.BusiType     = head.BusiType;
            account.DeptID       = head.DeptID;
            account.DetailID     = detail.InDetailID;
            account.MaterialID   = detail.MaterialID;
            account.UnitID       = detail.UnitID;
            account.UnitName     = detail.UnitName;
            account.LendAmount   = detail.Amount;
            account.BillNO       = detail.BillNo;
            account.RegTime      = DateTime.Now;
            if (head.BusiType == MWConstant.OP_MW_BACKSTORE)
            {
                account.StockPrice    = storeResult.BatchAllot[0].StockPrice;
                account.RetailPrice   = storeResult.BatchAllot[0].RetailPrice;
                account.LendAmount    = detail.Amount;
                account.LendRetailFee = account.LendAmount * account.RetailPrice;
                account.LendStockFee  = account.LendAmount * account.StockPrice;

                account.OverAmount    = storeResult.BatchAllot[0].StoreAmount;
                account.OverRetailFee = storeResult.BatchAllot[0].StoreAmount * account.RetailPrice;
                account.OverStockFee  = storeResult.BatchAllot[0].StoreAmount * account.StockPrice;
            }
            else
            {
                account.StockPrice    = detail.StockPrice;
                account.RetailPrice   = detail.RetailPrice;
                account.LendAmount    = detail.Amount;
                account.LendRetailFee = detail.RetailFee;
                account.LendStockFee  = detail.StockFee;

                account.OverAmount    = storeResult.BatchAllot[0].StoreAmount;
                account.OverRetailFee = storeResult.BatchAllot[0].StoreAmount * account.RetailPrice;
                account.OverStockFee  = storeResult.BatchAllot[0].StoreAmount * account.StockPrice;
            }

            account.save();
        }
Пример #2
0
        public void SaveBill(string frmName)
        {
            Action <ClientRequestData> requestAction = null;
            ServiceResponseData        retdata       = null;

            RefreshHead(frmName);
            currentHead.StockFee  = 0;
            currentHead.RetailFee = 0;
            List <MW_InStoreDetail> lstDetails = new List <MW_InStoreDetail>();

            for (int index = 0; index < currentDetails.Rows.Count; index++)
            {
                MW_InStoreDetail detail  = ConvertExtend.ToObject <MW_InStoreDetail>(currentDetails, index);
                decimal          pAmount = 0;
                if (currentDetails.Rows[index]["pAmount"] != DBNull.Value)
                {
                    pAmount = Convert.ToDecimal(currentDetails.Rows[index]["pAmount"].ToString());
                }

                detail.Amount          = pAmount;
                currentHead.StockFee  += detail.StockFee;
                currentHead.RetailFee += detail.RetailFee;
                lstDetails.Add(detail);
            }

            requestAction = ((ClientRequestData request) =>
            {
                request.AddData(MWConstant.MW_IN_SYSTEM);
                request.AddData(currentHead.BusiType);
                request.AddData(currentHead);
                request.AddData <List <MW_InStoreDetail> >(lstDetails);
                request.AddData <List <int> >(ifrmInstoreDetail.GetDeleteDetails());
            });

            retdata = InvokeWcfService("DrugProject.Service", "MaterialInStoreController", "SaveBill", requestAction);
            DGBillResult result = retdata.GetData <DGBillResult>(0);

            if (result.Result == 0)
            {
                MessageBoxShowSimple("单据已经保存成功,如果没有配置自动审核.请及时审核单据");
                if (billStatus == MWEnum.BillEditStatus.ADD_STATUS)
                {
                    ifrmInstoreDetail.NewBillClear();
                }
                else
                {
                    ifrmInstoreDetail.CloseCurrentWindow();
                }
            }
            else
            {
                string rtnMsg = result.ErrMsg;
                MessageBoxShowSimple("单据保存失败:" + result.ErrMsg);
            }
        }
Пример #3
0
        /// <summary>
        /// 获取头表信息
        /// </summary>
        /// <param name="opType">业务类型</param>
        /// <param name="deptId">科室Id</param>
        /// <param name="detailID">明细Id</param>
        /// <returns>头表信息</returns>
        public BillMasterShower GetBillHeadInfo(string opType, int deptId, int detailID)
        {
            BillMasterShower shower = new BillMasterShower();

            switch (opType)
            {
            case "211":    //采购入库
            case "212":    //期初入库
            case "213":    //物资库退货
                MW_InStoreDetail inStoreDetail = (MW_InStoreDetail)NewObject <MW_InStoreDetail>().getmodel(detailID);
                if (inStoreDetail != null)
                {
                    MW_InStoreHead instoreHead = (MW_InStoreHead)NewObject <MW_InStoreHead>().getmodel(inStoreDetail.InHeadID);
                    if (instoreHead != null)
                    {
                        shower.RegTime          = instoreHead.RegTime;
                        shower.AuditTime        = instoreHead.AuditTime;
                        shower.BillNo           = instoreHead.BillNo.ToString();
                        shower.RelationPeopleNo = instoreHead.OpEmpID.ToString();
                        shower.RelationPeople   = GetEmpName(instoreHead.OpEmpID);
                        shower.RelationUnit     = instoreHead.SupplierName;
                        shower.RetailFee        = instoreHead.RetailFee;
                        shower.StockFee         = instoreHead.StockFee;
                        shower.OpType           = GetBusiTypeName(opType);
                        shower.RegPeople        = instoreHead.RegEmpName;
                        shower.Remark           = instoreHead.Remark;
                    }
                }

                break;

            case "221":    //流通出库
            case "222":    //内耗出库
            case "223":    //物资库报损
            case "224":    //物资库退库
                MW_OutStoreDetail outStoreDetail = (MW_OutStoreDetail)NewObject <MW_OutStoreDetail>().getmodel(detailID);
                if (outStoreDetail != null)
                {
                    MW_OutStoreHead outStoreHead = (MW_OutStoreHead)NewObject <MW_OutStoreHead>().getmodel(outStoreDetail.OutHeadID);
                    if (outStoreHead != null)
                    {
                        shower.RegTime          = outStoreHead.RegTime;
                        shower.AuditTime        = outStoreHead.AuditTime;
                        shower.BillNo           = outStoreHead.BillNO.ToString();
                        shower.RelationPeopleNo = "暂无";
                        shower.RelationPeople   = "暂无";
                        shower.RelationUnit     = outStoreHead.ToDeptName;
                        shower.RetailFee        = outStoreHead.RetailFee;
                        shower.StockFee         = outStoreHead.StockFee;
                        shower.OpType           = GetBusiTypeName(opType);
                        shower.RegPeople        = outStoreHead.RegEmpName;
                        shower.Remark           = outStoreHead.Remark;
                    }
                }

                break;

            case "242":    //盘点审核
                MW_AuditDetail auditDetail = (MW_AuditDetail)NewObject <MW_AuditDetail>().getmodel(detailID);
                if (auditDetail != null)
                {
                    MW_AuditHead auditHead = (MW_AuditHead)NewObject <MW_AuditHead>().getmodel(auditDetail.AuditHeadID);
                    if (auditHead != null)
                    {
                        shower.RegTime          = auditHead.AuditTime;
                        shower.AuditTime        = auditHead.AuditTime;
                        shower.BillNo           = auditHead.BillNO.ToString();
                        shower.RelationPeopleNo = auditHead.EmpID.ToString();
                        shower.RelationPeople   = auditHead.EmpName;
                        shower.RelationUnit     = GetDeptName(auditHead.DeptID);
                        shower.RetailFee        = auditHead.CheckRetailFee;
                        shower.StockFee         = auditHead.CheckStockFee;
                        shower.OpType           = GetBusiTypeName(opType);
                        shower.RegPeople        = auditHead.EmpName;
                        shower.Remark           = string.Empty;
                    }
                }

                break;

            case "251":    //物资库调价
                DG_AdjDetail adjDetail = (DG_AdjDetail)NewObject <DG_AdjDetail>().getmodel(detailID);
                if (adjDetail != null)
                {
                    DG_AdjHead adjHead = (DG_AdjHead)NewObject <DG_AdjHead>().getmodel(adjDetail.AdjHeadID);
                    if (adjHead != null)
                    {
                        shower.RegTime          = adjHead.RegTime;
                        shower.AuditTime        = adjHead.ExecTime;
                        shower.BillNo           = adjHead.BillNO.ToString();
                        shower.RelationPeopleNo = adjHead.RegEmpID.ToString();
                        shower.RelationPeople   = GetEmpName(adjHead.RegEmpID);
                        shower.RelationUnit     = GetDeptName(adjHead.DeptID);
                        shower.RetailFee        = 0;
                        shower.StockFee         = 0;
                        shower.OpType           = GetBusiTypeName(opType);
                        shower.RegPeople        = GetEmpName(adjHead.RegEmpID);
                        shower.Remark           = adjHead.Remark;
                    }
                }

                break;
            }

            return(shower);
        }