Example #1
0
        public static bool CreateGRN(GRN grn)
        {
            try
            {
                if (grn.PO != null && grn.PO.Id != Guid.Empty && grn.PODetail != null && grn.PODetail.Id != Guid.Empty)
                {
                    PurchaseDataManager.CreateGRN(POMap.reMapGRNData(grn));
                    ResetCache();

                    /*PurchaseOrder PO = GetPO(grn.PO.Name);
                     * PODetail POD = null;
                     * foreach (PODetail pod in PO.PODetailsList)
                     * {
                     *  if (pod.Id == grn.PODetail.Id)
                     *      POD = pod;
                     * }
                     * if (POD != null)
                     * {
                     *  GRN Grn = NewGRN();
                     *  Grn.PO = new Reference() { Id = PO.Id, Name = PO.PONumber };
                     *  Grn.PODetail = new Reference() { Id = POD.Id, Name = PO.PONumber };
                     *  Grn.GRNDate = keyvalues.ContainsKey("GRNDate") ? DateTime.Parse(keyvalues["GRNDate"]) : DateTime.Now;
                     *  if (keyvalues.ContainsKey("Store"))
                     *      Grn.Store = StoreManager.GetStoreRef(keyvalues["Store"].ToString());
                     *  Grn.Quantity = keyvalues.ContainsKey("Quantity") ? decimal.Parse(keyvalues["Quantity"]) : 0;
                     *  Grn.InvoiceNo = keyvalues.ContainsKey("Invoice") ? keyvalues["Invoice"] : "";
                     *  Grn.AdjPrice = keyvalues.ContainsKey("Price") ? decimal.Parse(keyvalues["Price"]) : 0;
                     *  Grn.Remarks = keyvalues.ContainsKey("Remarks") ? keyvalues["Remarks"] : "";
                     *
                     *  POD.GRNsList.Add(Grn);
                     *  PurchaseDataManager.CalculatePO(PO);
                     *  if (PO.isValid)
                     *      PurchaseDataManager.CreateGRN(POMap.reMapGRNData(Grn));
                     *  else
                     *  {
                     *      ExceptionHandler.Error("Something went wrong! PO Quantity is not valid.");
                     *      PurchaseDataManager.ResetCache();
                     *      return null;
                     *  }
                     *  PurchaseDataManager.ResetCache();
                     *  return Grn;
                     * }*/
                }
                return(true);
            }
            catch (Exception ex)
            {
                ExceptionHandler.Error("Something went wrong. Details: " + ex.Message, ex);
            }
            return(false);
        }
Example #2
0
        public static bool UpdateGRN(GRN grn)
        {
            try
            {
                if (grn.Id != Guid.Empty && grn.PO != null && grn.PO.Id != Guid.Empty && grn.PODetail != null && grn.PODetail.Id != Guid.Empty)
                {
                    PurchaseDataManager.UpdateGRN(POMap.reMapGRNData(grn));
                    ResetCache();
                }
                return(true);
            }
            catch (Exception ex)
            {
                ExceptionHandler.Error("Something went wrong. Details: " + ex.Message, ex);
            }
            return(false);

            /* string PONumber = keyvalues["ponumber"];
             * string GRNNumber = keyvalues["grnnumber"];
             * string GRNId = keyvalues["grnid"];
             *
             * PurchaseOrder PO = GetPO(PONumber);
             * GRN Grn = GetGRN(GRNNumber);
             * if (PO != null && Grn != null)
             * {
             *   Grn.GRNDate = keyvalues.ContainsKey("GRNDate") ? DateTime.Parse(keyvalues["GRNDate"]) : DateTime.Now;
             *   Grn.PODetail = new Reference() { Id = new Guid(keyvalues["Customer"]), Name = PO.PONumber };
             *   Grn.Store = StoreManager.GetStoreRef(keyvalues["Store"]);
             *   Grn.Quantity = keyvalues.ContainsKey("Quantity") ? decimal.Parse(keyvalues["Quantity"]) : 0;
             *   Grn.InvoiceNo = keyvalues.ContainsKey("Invoice") ? keyvalues["Invoice"] : "";
             *   Grn.AdjPrice = keyvalues.ContainsKey("Price") ? decimal.Parse(keyvalues["Price"]) : 0;
             *   Grn.Remarks = keyvalues.ContainsKey("Remarks") ? keyvalues["Remarks"] : "";
             *   Grn.ModifiedOn = DateTime.Now;
             *   Grn.ModifiedBy = UserManager.GetUserRef(Common.CurrentUser.Id.ToString());
             *   foreach (PODetail pod in PO.PODetailsList)
             *   {
             *       foreach (GRN grn in pod.GRNsList)
             *           if (grn.Id.ToString() == GRNId || grn.GRNNumber == GRNNumber)
             *           {
             *               pod.GRNsList.Remove(grn);
             *               break;
             *           }
             *       if (pod.Id == Grn.PODetail.Id)
             *       {
             *           pod.GRNsList.Add(Grn);
             *           break;
             *       }
             *   }
             *   PurchaseDataManager.CalculatePO(PO);
             *   if (PO.isValid)
             *       PurchaseDataManager.UpdateGRN(POMap.reMapGRNData(Grn));
             *   else
             *   {
             *       ExceptionHandler.Error("Something went wrong! PO Quantity is not valid.");
             *       return null;
             *   }
             *   ResetCache();
             *
             *   return Grn;
             * }
             * return null;*/
        }