/// <summary>
 /// Create a new stationery retrieval form
 /// </summary>
 /// <param name="stationeryRetrievalForm">stationeryRetrievalForm object</param>
 public void CreateStationeryRetrievalForm(StationeryRetrievalForm stationeryRetrievalForm)
 {
     try
     {
         context.AddToStationeryRetrievalForms(stationeryRetrievalForm);
         context.SaveChanges();
     }
     catch (Exception)
     {
         throw;
     }
 }
 public List<Disbursement> CreateDisbursementBySRF(User CreatedBy, StationeryRetrievalForm stationeryRetrievalForm)
 {
     return disbursementDAO.CreateDisbursementBySRF(CreatedBy, stationeryRetrievalForm.StationeryRetrievalFormID);
 }
 //validate SRF
 private bool ValidateStationeryRetrievalForm(StationeryRetrievalForm SRF, DisbursementMethod SRFMethod)
 {
     string errMsg = "";
     try
     {
         if (SRF != null)
         {
             if (SRFMethod == DisbursementMethod.CreateBySRF)
             {
                 errMsg = "Create disbursement By SRF failed. Please try again later";
                 if ((SRF.StationeryRetrievalNumber != null || SRF.StationeryRetrievalNumber != "") &&
                     (SRF.RetrievedBy != 0 || SRF.RetrievedByUser != null) &&
                     (SRF.DateRetrieved != null))
                 {
                     return true;
                 }
             }
         }
         return false;
     }
     catch (Exception)
     {
         throw new Exceptions.DisbursmentException(errMsg);
     }
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the StationeryRetrievalForms EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToStationeryRetrievalForms(StationeryRetrievalForm stationeryRetrievalForm)
 {
     base.AddObject("StationeryRetrievalForms", stationeryRetrievalForm);
 }
 /// <summary>
 /// Create a new StationeryRetrievalForm object.
 /// </summary>
 /// <param name="stationeryRetrievalFormID">Initial value of the StationeryRetrievalFormID property.</param>
 /// <param name="stationeryRetrievalNumber">Initial value of the StationeryRetrievalNumber property.</param>
 /// <param name="retrievedBy">Initial value of the RetrievedBy property.</param>
 /// <param name="dateRetrieved">Initial value of the DateRetrieved property.</param>
 public static StationeryRetrievalForm CreateStationeryRetrievalForm(global::System.Int32 stationeryRetrievalFormID, global::System.String stationeryRetrievalNumber, global::System.Int32 retrievedBy, global::System.DateTime dateRetrieved)
 {
     StationeryRetrievalForm stationeryRetrievalForm = new StationeryRetrievalForm();
     stationeryRetrievalForm.StationeryRetrievalFormID = stationeryRetrievalFormID;
     stationeryRetrievalForm.StationeryRetrievalNumber = stationeryRetrievalNumber;
     stationeryRetrievalForm.RetrievedBy = retrievedBy;
     stationeryRetrievalForm.DateRetrieved = dateRetrieved;
     return stationeryRetrievalForm;
 }
 public StationeryRetrievalForm UpdateReceivedQuantity(StationeryRetrievalForm stationeryRetrievalForm)
 {
     return stationeryRetrievalDAO.UpdateReceivedQuantity(stationeryRetrievalForm);
 }
 public StationeryRetrievalForm UpdateActualQuantity(StationeryRetrievalForm stationeryRetrievalForm)
 {
     return stationeryRetrievalDAO.UpdateActualQuantity(stationeryRetrievalForm);
 }
 public void CreateStationeryRetrievalForm(StationeryRetrievalForm stationeryRetrievalForm)
 {
     stationeryRetrievalDAO.CreateStationeryRetrievalForm(stationeryRetrievalForm);
 }
        /// <summary>
        /// Update Received Quantity in stationery retrieval form
        /// </summary>
        /// <param name="stationeryRetrievalForm">stationeryRetrievalForm object</param>
        public StationeryRetrievalForm UpdateReceivedQuantity(StationeryRetrievalForm stationeryRetrievalForm)
        {
            try
            {
                using (TransactionScope ts = new TransactionScope())
                {
                    var temp = (from srf in context.StationeryRetrievalForms
                                where srf.StationeryRetrievalFormID == stationeryRetrievalForm.StationeryRetrievalFormID
                                select srf).FirstOrDefault<StationeryRetrievalForm>();
                    temp.IsRetrieved = true;
                    context.ObjectStateManager.ChangeObjectState(temp, EntityState.Modified);
                    context.SaveChanges();
                    foreach (StationeryRetrievalFormItem srfi in temp.StationeryRetrievalFormItems)
                    {
                        UpdateStationeryRetrievalFormItem(srfi);
                    }
                    ts.Complete();
                    return temp;
                }

            }
            catch (Exception e)
            {
                throw e;
            }
        }
 /// <summary>
 /// Update Actual Quantity in stationery retrieval form
 /// </summary>
 /// <param name="stationeryRetrievalForm">stationeryRetrievalForm object</param>
 public StationeryRetrievalForm UpdateActualQuantity(StationeryRetrievalForm stationeryRetrievalForm)
 {
     try
     {
         using (TransactionScope ts = new TransactionScope())
         {
             var temp = (from srf in context.StationeryRetrievalForms
                         where srf.StationeryRetrievalFormID == stationeryRetrievalForm.StationeryRetrievalFormID
                         select srf).FirstOrDefault<StationeryRetrievalForm>();
             temp.IsCollected = true;
             context.SaveChanges();
             foreach (StationeryRetrievalFormItem srfi in temp.StationeryRetrievalFormItems)
             {
                 foreach (StationeryRetrievalFormItemByDept srfid in srfi.StationeryRetrievalFormItemByDepts)
                 {
                     UpdateStationeryRetrievalFormItemByDept(srfid);
                 }
             }
             ts.Complete();
             return temp;
         }
     }
     catch (Exception e)
     {
         throw e;
     }
 }