/// <summary>
 /// Delete DepartmentStockDefect from database.
 /// </summary>
 /// <param name="data"></param>
 /// <returns></returns>
 public void Delete(DepartmentStockHistory data)
 {
     HibernateTemplate.Delete(data);
 }
Example #2
0
 private bool HasInDeptList(DepartmentStockHistory defect, DepartmentStockOutDetailCollection list)
 {
     foreach (DepartmentStockOutDetail detail in list)
     {
         if (detail.Product.ProductId == defect.Product.ProductId)
         {
             return true;
         }
     }
     return false;
 }
 /// <summary>
 /// Add DepartmentStockDefect to database.
 /// </summary>
 /// <param name="data"></param>
 /// <returns></returns>
 public DepartmentStockHistory Add(DepartmentStockHistory data)
 {
     HibernateTemplate.Save(data);
     return data;
 }
 public void Delete(DepartmentStockHistory data)
 {
     DepartmentStockHistoryDAO.Delete(data);
 }
 public DepartmentStockHistory Add(DepartmentStockHistory data)
 {
     DepartmentStockHistoryDAO.Add(data);
     return data;
 }
 public void Update(DepartmentStockHistory data)
 {
     DepartmentStockHistoryDAO.Update(data);
 }
        public void Process(DepartmentStockHistory defect)
        {
            // find exist stock base on productid
            ObjectCriteria objectCriteria = new ObjectCriteria();
            objectCriteria.AddEqCriteria("Product.ProductId", defect.Product.ProductId);
            objectCriteria.AddEqCriteria("DepartmentStockDefectPK.DepartmentId", CurrentDepartment.Get().DepartmentId);
            IList existList = DepartmentStockHistoryDAO.FindAll(objectCriteria);

            if (existList.Count > 0) // exist stock ?
            {
                DepartmentStockHistory existDefect = (DepartmentStockHistory)existList[0];
                existDefect.DamageCount = defect.DamageCount;
                existDefect.Description = defect.Description;
                existDefect.ErrorCount = defect.ErrorCount;
                existDefect.LostCount = defect.LostCount;
                existDefect.GoodCount = defect.GoodCount;
                existDefect.Product = defect.Product;
                existDefect.ProductMaster = defect.ProductMaster;
                existDefect.Quantity = defect.Quantity;
                existDefect.DepartmentStock = defect.DepartmentStock;
                existDefect.UnconfirmCount = defect.UnconfirmCount;
                existDefect.UpdateDate = defect.UpdateDate;
                existDefect.UpdateId = defect.UpdateId;

                existDefect.ExclusiveKey = existDefect.ExclusiveKey + 1;
                defect.DepartmentStockHistoryPK.DepartmentStockHistoryId = existDefect.DepartmentStockHistoryPK.DepartmentStockHistoryId;
                defect.DepartmentStockHistoryPK.DepartmentId = CurrentDepartment.Get().DepartmentId;

                DepartmentStockHistoryDAO.Update(existDefect);
            }
            else
            {
                DepartmentStockHistoryDAO.Add(defect);
            }
        }