public bool DownOutBillMaster(string beginDate, string endDate, out string errorInfo)
        {
            errorInfo = string.Empty;
            bool   result           = false;
            string outBillStr       = "";
            string outBillMasterStr = "";

            try
            {
                var outBillNos = OutBillMasterRepository.GetQueryable().Where(i => i.BillNo == i.BillNo).Select(i => new { i.BillNo }).ToArray();

                for (int i = 0; i < outBillNos.Length; i++)
                {
                    outBillStr += outBillNos[i].BillNo + ",";
                }
                OutBillMaster[] outBillMasterList = OutBillMasterDownService.GetOutBillMaster(outBillStr);
                foreach (var master in outBillMasterList)
                {
                    var outBillMaster = new OutBillMaster();
                    outBillMaster.BillNo        = master.BillNo;
                    outBillMaster.BillDate      = master.BillDate;
                    outBillMaster.BillTypeCode  = master.BillTypeCode;
                    outBillMaster.WarehouseCode = master.WarehouseCode;
                    outBillMaster.Status        = "1";
                    outBillMaster.IsActive      = master.IsActive;
                    outBillMaster.UpdateTime    = DateTime.Now;
                    OutBillMasterRepository.Add(outBillMaster);
                    outBillMasterStr += master.BillNo + ",";
                }
                if (outBillMasterStr != string.Empty)
                {
                    OutBillDetail[] outBillDetailList = OutBillMasterDownService.GetOutBillDetail(outBillMasterStr);
                    foreach (var detail in outBillDetailList)
                    {
                        var outBillDetail = new OutBillDetail();
                        outBillDetail.BillNo        = detail.BillNo;
                        outBillDetail.ProductCode   = detail.ProductCode;
                        outBillDetail.UnitCode      = detail.UnitCode;
                        outBillDetail.Price         = detail.Price;
                        outBillDetail.BillQuantity  = detail.BillQuantity;
                        outBillDetail.AllotQuantity = detail.AllotQuantity;
                        outBillDetail.RealQuantity  = detail.RealQuantity;
                        outBillDetail.Description   = detail.Description;
                        OutBillDetailRepository.Add(outBillDetail);
                    }
                }
                OutBillMasterRepository.SaveChanges();
                result = true;
            }
            catch (Exception e)
            {
                errorInfo = "出错,原因:" + e.Message;
            }
            return(result);
        }
Beispiel #2
0
        public OutBillMaster CreateOutBillMaster(string warehouseCode, string billTypeCode, string operatePersonID)
        {
            //添加移库单主单
            string        billNo        = CreateOutBillNo();
            OutBillMaster outBillMaster = new OutBillMaster();

            outBillMaster.BillNo          = billNo;
            outBillMaster.BillDate        = DateTime.Now;
            outBillMaster.BillTypeCode    = billTypeCode;
            outBillMaster.Origin          = "1";
            outBillMaster.WarehouseCode   = warehouseCode;
            outBillMaster.OperatePersonID = Guid.Parse(operatePersonID);
            outBillMaster.Status          = "1";;
            outBillMaster.IsActive        = "1";
            outBillMaster.UpdateTime      = DateTime.Now;
            OutBillMasterRepository.Add(outBillMaster);
            return(outBillMaster);
        }
        public bool Add(OutBillMaster outBillMaster, string userName, out string errorInfo)
        {
            errorInfo = string.Empty;
            var outbm    = new OutBillMaster();
            var employee = EmployeeRepository.GetQueryable().FirstOrDefault(i => i.UserName == userName);

            if (employee != null)
            {
                try
                {
                    outbm.BillNo          = outBillMaster.BillNo;
                    outbm.BillDate        = outBillMaster.BillDate;
                    outbm.BillTypeCode    = outBillMaster.BillTypeCode;
                    outbm.WarehouseCode   = outBillMaster.WarehouseCode;
                    outbm.OperatePersonID = employee.ID;
                    outbm.Status          = "1";
                    outbm.VerifyPersonID  = outBillMaster.VerifyPersonID;
                    outbm.VerifyDate      = outBillMaster.VerifyDate;
                    outbm.Description     = outBillMaster.Description;
                    //outbm.IsActive = outBillMaster.IsActive;
                    outbm.IsActive       = "1";
                    outbm.UpdateTime     = DateTime.Now;
                    outbm.Origin         = "1";
                    outbm.TargetCellCode = outBillMaster.TargetCellCode;

                    OutBillMasterRepository.Add(outbm);
                    OutBillMasterRepository.SaveChanges();
                    return(true);
                }
                catch (Exception e)
                {
                    errorInfo = "添加失败!原因:" + e.Message;
                    return(false);
                }
            }
            else
            {
                errorInfo = "找不到当前登陆用户!请重新登陆!";
                return(false);
            }
        }