Пример #1
0
        /// <summary>
        /// 将库存某物料的一些数量,标记为某生产计划单所使用,并在生产计划单的已有库存中,增加该数量
        /// </summary>
        /// <param name="ID">库存ID</param>
        /// <param name="DemandID">物料计划表ID</param>
        /// <param name="TaskID">生产计划单ID</param>
        /// <param name="Amount">变更数量</param>
        /// <param name="DepotID">仓库</param>
        /// <param name="MListID">物料</param>
        public void UpTaskUseRepertoryAmount(byte[] bb, int DepotID)
        {
            DataSet ds = BaseFile.ZipDt.Byte2Ds(bb);

            if (ds.Tables[0].Rows.Count > 0)
            {
                Hownet.BLL.PlanUseRep          bllPUR = new PlanUseRep();
                List <Hownet.Model.PlanUseRep> liPUR  = bllPUR.DataTableToList(ds.Tables[0]);
                Hownet.Model.Repertory         modRep;
                Hownet.BLL.MaterielDemand      bllMD = new MaterielDemand();
                Hownet.Model.MaterielDemand    modMD;
                for (int i = 0; i < liPUR.Count; i++)
                {
                    if (liPUR[i].A == 1)
                    {
                        modRep         = GetModel(liPUR[i].RelatedID);
                        modMD          = bllMD.GetModel(liPUR[i].DemandID);
                        modRep.Amount -= liPUR[i].Amount;//扣减以前的数量
                        Update(modRep);
                        List <Hownet.Model.Repertory> lirep = GetModelList("(PlanID=" + liPUR[i].TaskID + ") And (MListID=" + liPUR[i].MListID + ") And (DepartmentID=" + DepotID + ")");
                        if (lirep.Count == 0)//查找是否有需要转入的记录,没有就以变更数量插入记录
                        {
                            modRep = new Hownet.Model.Repertory();
                            Hownet.BLL.MaterielList   bllML = new MaterielList();
                            Hownet.Model.MaterielList modML = bllML.GetModel(liPUR[i].MListID);
                            modRep.MListID      = liPUR[i].MListID;
                            modRep.Amount       = liPUR[i].Amount;
                            modRep.MeasureID    = modML.MeasureID;
                            modRep.DepartmentID = DepotID;
                            modRep.MaterielID   = modML.MaterielID;
                            modRep.ColorID      = modML.ColorID;
                            modRep.ColorOneID   = modML.ColorOneID;
                            modRep.ColorTwoID   = modML.ColorTwoID;
                            modRep.SizeID       = modML.SizeID;
                            modRep.BrandID      = modML.BrandID;
                            modRep.CompanyID    = 0;
                            modRep.PlanID       = liPUR[i].TaskID;
                            Add(modRep);
                        }
                        else//有记录则加上该数量
                        {
                            lirep[0].Amount += liPUR[i].Amount;
                            Update(lirep[0]);
                        }

                        bllMD.Update(modMD);
                    }
                }
            }
        }
Пример #2
0
        /// <summary>
        /// 领料后更新
        /// </summary>
        /// <param name="MainID"></param>
        /// <param name="t">真为领料,假为退料</param>
        public void UpDemand(int MainID, bool t)
        {
            Hownet.BLL.StockBackInfo          bllSBI = new StockBackInfo();
            Hownet.BLL.MaterielDemand         bllMD  = new MaterielDemand();
            Hownet.Model.MaterielDemand       modMD;
            List <Hownet.Model.StockBackInfo> li = bllSBI.DataTableToList(bllSBI.GetList("(MainID=" + MainID + ")").Tables[0]);

            for (int i = 0; i < li.Count; i++)
            {
                modMD = bllMD.GetModel(li[i].StockInfoID);
                if (t)
                {
                    modMD.NotAllotAmount -= li[i].Amount;
                }
                else
                {
                    modMD.NotAllotAmount += li[i].Amount;
                }
                bllMD.Update(modMD);
            }
        }
Пример #3
0
 public int MDPP(int MainID)
 {
     try
     {
         Hownet.BLL.MaterielDemand bllMD  = new MaterielDemand();
         Hownet.BLL.Repertory      bllRep = new Repertory();
         DataTable dt = dal.GetPPMDList(MainID).Tables[0];
         List <Hownet.Model.MaterielDemand> li = bllMD.DataTableToList(bllMD.GetList("(ProduceTaskID=" + MainID + ") And (TableTypeID=41)").Tables[0]);
         for (int i = 0; i < li.Count; i++)
         {
             for (int j = 0; j < dt.Rows.Count; j++)
             {
                 if (li[i].MListID == Convert.ToInt32(dt.Rows[j]["MListID"]))
                 {
                     li[i].RepertoryAmount += Convert.ToDecimal(dt.Rows[j]["RepertoryAmount"]);
                     bllMD.Update(li[i]);
                     break;
                 }
             }
         }
         dal.UpPPMDList(MainID);
         List <Hownet.Model.Repertory> liRe = bllRep.DataTableToList(bllRep.GetList("(PlanID=" + MainID + ")").Tables[0]);
         DataTable dtRep = bllRep.GetPPList(MainID).Tables[0];
         Hownet.Model.Repertory modRe = new Hownet.Model.Repertory();
         bool t = false;
         for (int i = 0; i < dtRep.Rows.Count; i++)
         {
             t = false;
             for (int j = 0; j < liRe.Count; j++)
             {
                 if (liRe[j].MListID == Convert.ToInt32(dtRep.Rows[i]["MListID"]) && liRe[j].DepartmentID == Convert.ToInt32(dtRep.Rows[i]["DepartmentID"]))
                 {
                     liRe[j].Amount += Convert.ToDecimal(dtRep.Rows[i]["Amount"]);
                     t = true;
                     break;
                 }
             }
             if (!t)
             {
                 modRe              = new Hownet.Model.Repertory();
                 modRe.A            = 3;
                 modRe.Amount       = Convert.ToDecimal(dtRep.Rows[i]["Amount"]);
                 modRe.BrandID      = Convert.ToInt32(dtRep.Rows[i]["BrandID"]);
                 modRe.ColorID      = Convert.ToInt32(dtRep.Rows[i]["ColorID"]);
                 modRe.ColorOneID   = Convert.ToInt32(dtRep.Rows[i]["ColorOneID"]);
                 modRe.ColorTwoID   = Convert.ToInt32(dtRep.Rows[i]["ColorTwoID"]);
                 modRe.CompanyID    = 0;
                 modRe.DepartmentID = Convert.ToInt32(dtRep.Rows[i]["DepartmentID"]);
                 modRe.ID           = 0;
                 modRe.MaterielID   = Convert.ToInt32(dtRep.Rows[i]["MaterielID"]);
                 modRe.MeasureID    = Convert.ToInt32(dtRep.Rows[i]["MeasureID"]);
                 modRe.MListID      = Convert.ToInt32(dtRep.Rows[i]["MListID"]);
                 modRe.PlanID       = MainID;
                 modRe.Remark       = string.Empty;
                 modRe.SizeID       = Convert.ToInt32(dtRep.Rows[i]["SizeID"]);
                 modRe.ID           = bllRep.Add(modRe);
                 liRe.Add(modRe);
             }
         }
         bllRep.DelPPList(MainID);
         return(1);
     }
     catch
     {
         return(0);
     }
 }
Пример #4
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="MListID"></param>
 /// <param name="DemandID"></param>
 /// <param name="StockInfoID"></param>
 /// <param name="Amount"></param>
 /// <param name="TypeID"></param>
 /// <param name="TaskID"></param>
 /// <param name="RelatedID"></param>
 /// <param name="t">真的添加记录,假为删除记录</param>
 public void UpAmount(int MListID, int DemandID, int StockInfoID, decimal Amount, int TypeID, int TaskID, int RelatedID, bool t, int DepotID)
 {
     #region 使用原仓存
     if (TypeID == (int)Hownet.BLL.BaseFile.MaterielDemandClass.PlanUseRep.使用原仓存)
     {
         if (t)
         {
             //查看之前使用库存的记录,将本次使用原仓存的数更新到数据表。
             Hownet.BLL.Repertory        bllRep = new Repertory();
             Hownet.BLL.MaterielDemand   bllMD  = new MaterielDemand();
             Hownet.Model.Repertory      modRep = bllRep.GetModel(RelatedID); //需要转出的空闲物料
             Hownet.Model.MaterielDemand modMD  = bllMD.GetModel(DemandID);
             modRep.Amount = modRep.Amount - Amount;                          //扣掉有使用的空余数量
             bllRep.Update(modRep);
             modMD.RepertoryAmount += Amount;                                 //更新物料拆分表的已备料数量
             bllMD.Update(modMD);
             //是否此前有本计划单的备料
             DataTable dt = bllRep.GetList("(MListID=" + MListID + ") And  (PlanID=" + TaskID + ") And (DepartmentID=" + DepotID + ")").Tables[0];
             if (dt.Rows.Count > 0)
             {
                 //已有,则加上本次数量
                 dt.Rows[0]["Amount"] = Convert.ToDecimal(dt.Rows[0]["Amount"]) + Amount;
                 bllRep.UpdateByDt(dt);
             }
             else
             {
                 //没有则插入此数量
                 modRep.Amount       = Amount;
                 modRep.PlanID       = TaskID;
                 modRep.DepartmentID = DepotID;
                 bllRep.Add(modRep);
             }
         }
         else
         {
         }
     }
     #endregion
     #region 已申购数量
     else if (TypeID == (int)Hownet.BLL.BaseFile.MaterielDemandClass.PlanUseRep.已申购数量)
     {
         if (t)
         {
             //更新这个生产计划中该物料的已申购数量
             DataTable dt = GetList("(StockInfoID=" + StockInfoID + ") And (TypeID=" + (int)Hownet.BLL.BaseFile.MaterielDemandClass.PlanUseRep.已申购数量 + ")").Tables[0];
             if (dt.Rows.Count > 0)
             {
                 dt.Rows[0]["Amount"]    = Convert.ToDecimal(dt.Rows[0]["Amount"]) + Amount;
                 dt.Rows[0]["NotAmount"] = Convert.ToDecimal(dt.Rows[0]["NotAmount"]) + Amount;
                 UpdateByDt(dt);
             }
             else
             {
                 DataRow dr = dt.NewRow();
                 dr["RelatedID"]   = RelatedID;
                 dr["Amount"]      = Amount;
                 dr["DemandID"]    = DemandID;
                 dr["TypeID"]      = (int)Hownet.BLL.BaseFile.MaterielDemandClass.PlanUseRep.已申购数量;
                 dr["MListID"]     = MListID;
                 dr["TaskID"]      = TaskID;
                 dr["StockInfoID"] = 0;
                 dr["NotAmount"]   = Amount;
                 dr["IsEnd"]       = 0;
                 dr["A"]           = 1;
                 dt.Rows.Add(dr);
                 AddByDt(dt);
             }
         }
         else
         {
         }
     }
     #endregion
     #region 已采购数量
     else if (TypeID == (int)BLL.BaseFile.MaterielDemandClass.PlanUseRep.已采购数量)
     {
     }
     #endregion
 }