public DepartmentStockTemp Add(DepartmentStockTemp data)
 {
     DepartmentStockTempDAO.Add(data);
     return data;
 }
 public void Delete(DepartmentStockTemp data)
 {
     DepartmentStockTempDAO.Delete(data);
 }
 public void Update(DepartmentStockTemp data)
 {
     DepartmentStockTempDAO.Update(data);
 }
 /// <summary>
 /// Delete DepartmentStockTemp from database.
 /// </summary>
 /// <param name="data"></param>
 /// <returns></returns>
 public void Delete(DepartmentStockTemp data)
 {
     HibernateTemplate.Delete(data);
 }
 /// <summary>
 /// Add DepartmentStockTemp to database.
 /// </summary>
 /// <param name="data"></param>
 /// <returns></returns>
 public DepartmentStockTemp Add(DepartmentStockTemp data)
 {
     HibernateTemplate.Save(data);
     return data;
 }
 private void AutoFixing(DepartmentStockTemp stock, ref long errorQuantity, ref long damageQuantity, ref long lostQuantity, ref long unconfirmQuantity)
 {
     if (errorQuantity > 0)
     {
         if (stock.GoodQuantity >= errorQuantity)
         {
             stock.ErrorQuantity = errorQuantity;
             stock.GoodQuantity -= errorQuantity;
             errorQuantity = 0;
         }
         else
         {
             stock.ErrorQuantity = stock.GoodQuantity;
             stock.GoodQuantity = 0;
             errorQuantity -= stock.ErrorQuantity;
         }
     }
     if (lostQuantity > 0)
     {
         if (stock.GoodQuantity >= lostQuantity)
         {
             stock.LostQuantity = lostQuantity;
             stock.GoodQuantity -= lostQuantity;
             lostQuantity = 0;
         }
         else
         {
             stock.LostQuantity = stock.GoodQuantity;
             stock.GoodQuantity = 0;
             lostQuantity -= stock.LostQuantity;
         }
     }
     if (damageQuantity > 0)
     {
         if (stock.GoodQuantity >= damageQuantity)
         {
             stock.DamageQuantity = damageQuantity;
             stock.GoodQuantity -= damageQuantity;
             damageQuantity = 0;
         }
         else
         {
             stock.DamageQuantity = stock.GoodQuantity;
             stock.GoodQuantity = 0;
             damageQuantity -= stock.DamageQuantity;
         }
     }
     if (unconfirmQuantity > 0)
     {
         if (stock.GoodQuantity >= unconfirmQuantity)
         {
             stock.UnconfirmQuantity = unconfirmQuantity;
             stock.GoodQuantity -= unconfirmQuantity;
             unconfirmQuantity = 0;
         }
         else
         {
             stock.UnconfirmQuantity = stock.GoodQuantity;
             stock.GoodQuantity = 0;
             unconfirmQuantity -= stock.UnconfirmQuantity;
         }
     }
 }
        private bool HasInList(DepartmentStockTemp temp, IList list, out int index)
        {
            bool hasInList = false;
            index = 0;
            for(int i = 0;i < list.Count; i++)
            {
                index = i;
                DepartmentStockTempView view = (DepartmentStockTempView)list[i];
                if(view.ProductMaster.ProductMasterId.Equals(
                                    temp.ProductMaster.ProductMasterId))
                {
                    hasInList = true;
                    break;
                }
            }

            return hasInList;
        }