Example #1
0
        /// <summary>
        /// 批量审核
        /// </summary>
        /// <param name="ids"></param>
        /// <param name="datas"></param>
        /// <param name="stuffinfoid"></param>
        /// <returns></returns>
        public ActionResult SiloMultiAudit(string[] ids, string datas, string stuffinfoid)
        {
            string  StockPactID = "";
            string  UnitPrice   = "";
            string  Guige       = "";
            string  SupplyNum   = "";
            decimal price       = 0;
            decimal supplyNum   = 0;

            foreach (string a in datas.Split('&'))
            {
                string[] b = a.Split('=');
                if (b.Count() == 2)
                {
                    if (b[0] == "StockPactID_S")
                    {
                        StockPactID = b[1];
                    }
                    else if (b[0] == "UnitPrice")
                    {
                        UnitPrice = b[1];
                    }
                    else if (b[0] == "Guige")
                    {
                        Guige = b[1];
                    }
                    else if (b[0] == "SupplyNum")
                    {
                        SupplyNum = b[1];
                    }
                }
            }
            try
            {
                price = Convert.ToDecimal(UnitPrice);
                if (SupplyNum != "")
                {
                    supplyNum = Convert.ToDecimal(SupplyNum);
                }
            }
            catch
            {
                return(OperateResult(false, "单价数量不合法", Lang.Error_ParameterRequired));
            }
            if (ids != null && StockPactID != "" && price != 0)
            {
                StockPact sp = this.service.GetGenericService <StockPact>().Get(StockPactID);
                foreach (string id in ids)
                {
                    this.service.StuffIn.Audit(id, sp, price, Guige, supplyNum, stuffinfoid);
                }
                return(OperateResult(true, "已跳过不符入库单,对和合同对应的入库单进行审核。(注意同名的不同原材料,最好将所有原材料名称改为不同)", ids));
            }
            else
            {
                return(OperateResult(false, Lang.Msg_Operate_Failed, Lang.Error_ParameterRequired));
            }
        }
Example #2
0
        /// <summary>
        /// 审核
        /// </summary>
        /// <param name="id"></param>
        /// <param name="sp"></param>
        /// <param name="price"></param>
        /// <param name="Guige"></param>
        /// <param name="supplyNum"></param>
        /// <param name="stuffid"></param>
        public void Audit(string id, StockPact sp, decimal price, string Guige, decimal supplyNum, string stuffid)
        {
            using (IGenericTransaction tx = this.m_UnitOfWork.BeginTransaction())
            {
                try
                {
                    StuffIn obj = this.Get(id);
                    if (obj.Lifecycle == 0)
                    {
                        //if (obj.StuffID == sp.StuffID && obj.SupplyID == sp.SupplyID)
                        if (obj.StuffID == stuffid && obj.SupplyID == sp.SupplyID)
                        {
                            if (Guige != "")
                            {
                                obj.Guige = Guige;
                            }
                            obj.Proportion = (obj.Proportion == 0 ? 1 : obj.Proportion);
                            obj.FootNum    = obj.InNum / obj.Proportion;
                            obj.SupplyNum  = supplyNum * 1000;
                            decimal bc = obj.SupplyNum - Convert.ToDecimal(obj.FootNum);
                            obj.Bangcha      = bc;
                            obj.FinalFootNum = obj.FootNum;
                            if (sp.BangchaRate > 0)
                            {
                                if (sp.BangchaRate * obj.FootNum >= bc)
                                {
                                    obj.FinalFootNum = obj.SupplyNum;
                                }
                            }
                            obj.UnitPrice   = price;
                            obj.TotalPrice  = price * obj.FinalFootNum / 1000;
                            obj.StockPactID = sp.ID;
                            obj.Lifecycle   = 1;
                            base.Update(obj, null);
                        }
                    }

                    tx.Commit();
                }
                catch (Exception ex)
                {
                    tx.Rollback();
                    logger.Error(ex.Message);
                    throw;
                }
            }
        }
Example #3
0
        public ActionResult AddFapiao(StockPact sp)
        {
            StockPactChildChild spcc = sp.StockPactChildChild;

            spcc.StockPactID = sp.ID;
            spcc.StuffID     = sp.StuffID;
            try
            {
                StockPactChildChild saveEntity = m_ServiceBase.Add(spcc);
                return(OperateResult(true, Lang.Msg_Operate_Success, saveEntity.GetId()));
            }
            catch (Exception ex)
            {
                if (ex.InnerException != null)
                {
                    ex = ex.InnerException;
                }
                log.Error(ex.Message, ex);
                return(HandleExceptionResult(ex));
            }
        }
Example #4
0
        /// <summary>
        /// 取得合同材料对应的价格
        /// </summary>
        /// <param name="textField"></param>
        /// <param name="valueField"></param>
        /// <param name="orderBy"></param>
        /// <param name="ascending"></param>
        /// <param name="condition"></param>
        /// <returns></returns>
        public string getStuffInfoPrice(string StockPactId, string StuffInfoId)
        {
            StockPact         data           = null;
            IList <StuffInfo> _data          = new List <StuffInfo>();
            string            StuffInfoPrice = "0";

            if (StockPactId != "")
            {
                data = this.service.StockPact.Query().Where(m => m.ID == StockPactId).FirstOrDefault();
                string stuffid  = data.StuffID;
                string stuffid1 = data.StuffID1;
                string stuffid2 = data.StuffID2;
                string stuffid3 = data.StuffID3;
                string stuffid4 = data.StuffID4;
                if (data != null)
                {
                    if (StuffInfoId == stuffid)
                    {
                        StuffInfoPrice = data.StockPrice.ToString();
                    }
                    if (StuffInfoId == stuffid1)
                    {
                        StuffInfoPrice = data.StockPrice1.ToString();
                    }
                    if (StuffInfoId == stuffid2)
                    {
                        StuffInfoPrice = data.StockPrice2.ToString();
                    }
                    if (StuffInfoId == stuffid3)
                    {
                        StuffInfoPrice = data.StockPrice3.ToString();
                    }
                    if (StuffInfoId == stuffid4)
                    {
                        StuffInfoPrice = data.StockPrice4.ToString();
                    }
                }
            }
            return(StuffInfoPrice);
        }
Example #5
0
        public override void Update(StockPlan entity, System.Collections.Specialized.NameValueCollection form)
        {
            StockPact         stockpact = this.m_UnitOfWork.GetRepositoryBase <StockPact>().Get(entity.StockPactID);
            IList <StockPlan> list      = stockpact.StockPlans.Where(c => c.ID != entity.ID).ToList();
            decimal           count     = 0;

            foreach (StockPlan plan in list)
            {
                count += (decimal)plan.PlanAmount;
            }
            if ((stockpact.ValidFrom != null && entity.PlanDate < stockpact.ValidFrom) || (stockpact.ValidTo != null && entity.PlanDate > stockpact.ValidTo))
            {
                throw new Exception("计划时间不在合同限定范围内");
            }
            if (count + entity.PlanAmount > stockpact.Amount)
            {
                throw new Exception(String.Format("此次计划{0}超过了采购合同结余数量{1}", entity.PlanAmount, stockpact.Amount - count));
            }
            else
            {
                base.Update(entity, form);
            }
        }
Example #6
0
        public override StockPlan Add(StockPlan entity)
        {
            StockPact         stockpact = this.m_UnitOfWork.GetRepositoryBase <StockPact>().Get(entity.StockPactID);
            IList <StockPlan> list      = stockpact.StockPlans;
            decimal           count     = 0;

            foreach (StockPlan plan in list)
            {
                count += (decimal)plan.PlanAmount;
            }
            if ((stockpact.ValidFrom != null && entity.PlanDate < stockpact.ValidFrom) || (stockpact.ValidTo != null && entity.PlanDate > stockpact.ValidTo))
            {
                throw new Exception("计划时间不在合同限定范围内");
            }
            if (count + entity.PlanAmount > stockpact.Amount)
            {
                throw new Exception(String.Format("此次计划{0}超过了采购合同结余数量{1}", entity.PlanAmount, stockpact.Amount - count));
            }
            else
            {
                return(base.Add(entity));
            }
        }
Example #7
0
        /// <summary>
        /// 取得下拉列表数据
        /// </summary>
        /// <param name="textField"></param>
        /// <param name="valueField"></param>
        /// <param name="orderBy"></param>
        /// <param name="ascending"></param>
        /// <param name="condition"></param>
        /// <returns></returns>
        public virtual JsonResult ListDataStuffInfo(string id, string textField, string valueField, string orderBy = "ID",
                                                    bool ascending   = false,
                                                    string condition = "")
        {
            StockPact         data  = null;
            IList <StuffInfo> _data = new List <StuffInfo>();

            if (id != "")
            {
                data = this.service.StockPact.Query().Where(m => m.ID == id).FirstOrDefault();
                string stuffid  = data.StuffID;
                string stuffid1 = data.StuffID1;
                string stuffid2 = data.StuffID2;
                string stuffid3 = data.StuffID3;
                string stuffid4 = data.StuffID4;

                string stuffname  = data.StuffName;
                string stuffname1 = data.StuffName1;
                string stuffname2 = data.StuffName2;
                string stuffname3 = data.StuffName3;
                string stuffname4 = data.StuffName4;


                StuffInfo info = new StuffInfo();
                if (!string.IsNullOrEmpty(stuffid))
                {
                    info.ID        = stuffid;
                    info.StuffName = stuffname;
                    _data.Add(info);
                }
                if (!string.IsNullOrEmpty(stuffid1))
                {
                    info           = new StuffInfo();
                    info.ID        = stuffid1;
                    info.StuffName = stuffname1;
                    _data.Add(info);
                }
                if (!string.IsNullOrEmpty(stuffid2))
                {
                    info           = new StuffInfo();
                    info.ID        = stuffid2;
                    info.StuffName = stuffname2;
                    _data.Add(info);
                }
                if (!string.IsNullOrEmpty(stuffid3))
                {
                    info           = new StuffInfo();
                    info.ID        = stuffid3;
                    info.StuffName = stuffname3;
                    _data.Add(info);
                }
                if (!string.IsNullOrEmpty(stuffid4))
                {
                    info           = new StuffInfo();
                    info.ID        = stuffid4;
                    info.StuffName = stuffname4;
                    _data.Add(info);
                }
                return(Json(new SelectList(_data, valueField, textField)));
            }
            else//ID为空返回所有材料列表
            {
                IEnumerable <SelectListItem> StuffList = HelperExtensions.SelectListData <StuffInfo>("StuffName", "ID", "IsUsed=1", "OrderNum", true, null);

                return(Json(StuffList));
            }
        }