Ejemplo n.º 1
0
        public string ConfirmInComing(List <Apply_Info> applyInfos)
        {
            List <BuyInComing_Apply>     buyInComingApplies = new List <BuyInComing_Apply>();
            List <Material_Base_Company> baseCompanies      = new List <Material_Base_Company>();

            foreach (var applyInfo in applyInfos)
            {
                BuyInComing_Apply buyInComingApply = _buyInComingApplyBll.Find(applyInfo.Apply_Id);
                buyInComingApply.Is_InComed = true;
                Material_Base_Company materialBaseCompany =
                    _baseCompanyBll.GetEntity(m => m.Material_Id == buyInComingApply.Material_Id);
                materialBaseCompany.Material_RemainCont += applyInfo.Apply_Count;
                if (materialBaseCompany.Material_RemainCont > materialBaseCompany.Material_Count)
                {
                    materialBaseCompany.Material_Count = materialBaseCompany.Material_RemainCont;
                }
                baseCompanies.Add(materialBaseCompany);
                buyInComingApplies.Add(buyInComingApply);
            }

            return(_buyInComingApplyBll.UpdateEntities(buyInComingApplies) &&
                   _baseCompanyBll.UpdateEntities(baseCompanies)
                ? "OK"
                : "Error");
        }
Ejemplo n.º 2
0
        public string SelfApplyInComing(Material_Info materialInfo, int applyCount)
        {
            if (_baseInfoBll.GetEntities(m => m.Material_Id == materialInfo.Material_Id) == null)
            {
                materialInfo.Material_Count      = 0;
                materialInfo.Material_RemainCont = 0;
                materialInfo.Is_Show             = false;
                if (_baseInfoBll.AddBaseInfo(materialInfo) != "添加成功")
                {
                    return("Error");
                }
            }
            BuyInComing_Apply buyInComingApply = new BuyInComing_Apply()
            {
                Material_Id = materialInfo.Material_Id,
                Is_InComed  = false,
                Is_Bought   = false,
                Last_Time   = DateTime.MaxValue
            };

            if (_buyInComingApplyBll.AddEntities(new List <BuyInComing_Apply>()
            {
                buyInComingApply
            }))
            {
                Apply_Info applyInfo = new Apply_Info
                {
                    Apply_Id     = buyInComingApply.Id,
                    ApplyType_Id = "002",
                    Apply_Count  = applyCount,
                    Apply_Status = 0
                };
                if (_applyInfoBll.AddEntities(new List <Apply_Info> {
                    applyInfo
                }))
                {
                    return("OK");
                }
            }

            return("Error");
        }
Ejemplo n.º 3
0
        public string ApplyInComing(List <Apply_Info> applyInfos)
        {
            if (applyInfos == null)
            {
                return("OK");
            }

            List <Apply_Info> newApplyInfos = new ListStack <Apply_Info>();

            foreach (Apply_Info applyInfo in applyInfos)
            {
                if (newApplyInfos.Count(m => m.ApplyType_Id == applyInfo.ApplyType_Id && m.Apply_Id == applyInfo.Apply_Id) == 0)
                {
                    newApplyInfos.Add(applyInfo);
                }
                else
                {
                    Apply_Info apply = newApplyInfos.FirstOrDefault(m =>
                                                                    m.ApplyType_Id == applyInfo.ApplyType_Id && m.Apply_Id == applyInfo.Apply_Id);
                    if (apply != null)
                    {
                        apply.Apply_Count = apply.Apply_Count + applyInfo.Apply_Count;
                    }
                }
            }

            List <BuyInComing_Apply> buyInComingApplies = new List <BuyInComing_Apply>();

            foreach (Apply_Info applyInfo in newApplyInfos)
            {
                BuyInComing_Apply buyInComingApply = _buyInComingApplyBll.Find(applyInfo.Apply_Id);
                buyInComingApply.Is_Bought = true;
                buyInComingApplies.Add(buyInComingApply);
            }
            return(_applyInfoBll.AddEntities(newApplyInfos) && _buyInComingApplyBll.UpdateEntities(buyInComingApplies) ? "OK" : "Error");
        }