Example #1
0
 public static bool SavePO(PurchaseOrder PO)
 {
     if (PO.Id == Guid.Empty)
     {
         Guid newPOId = PurchaseDataManager.CreatePO(POMap.reMapPOData(PO));
         PO.Id = newPOId;
     }
     else
     {
         PurchaseDataManager.UpdatePO(POMap.reMapPOData(PO));
     }
     foreach (PODetail pod in PO.PODetailsList)
     {
         if (pod.Id == Guid.Empty)
         {
             pod.PO = new Reference()
             {
                 Id = PO.Id, Name = PO.PONumber
             };
             Guid newPODId = PurchaseDataManager.CreatePODetail(POMap.reMapPODetailData(pod));
             pod.Id = newPODId;
         }
         else
         {
             PurchaseDataManager.UpdatePODetail(POMap.reMapPODetailData(pod));
         }
     }
     ResetCache();
     return(true);
 }
Example #2
0
 public static bool CreatePO(PurchaseOrder PO)
 {
     try
     {
         Guid poid = PurchaseDataManager.CreatePO(POMap.reMapPOData(PO));
         if (poid != Guid.Empty)
         {
             PO.Id = poid;
             foreach (PODetail pod in PO.PODetailsList)
             {
                 if (pod.Id == Guid.Empty)
                 {
                     pod.PO = new Reference()
                     {
                         Id = PO.Id, Name = PO.PONumber
                     };
                     Guid newPODId = PurchaseDataManager.CreatePODetail(POMap.reMapPODetailData(pod));
                     pod.Id = newPODId;
                 }
                 else
                 {
                     PurchaseDataManager.UpdatePODetail(POMap.reMapPODetailData(pod));
                 }
             }
         }
         ResetCache();
         return(true);
     }
     catch (Exception ex)
     {
         ExceptionHandler.Error("Something went wrong. Details: " + ex.Message, ex);
     }
     return(false);
 }
Example #3
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 #4
0
        public static List <PurchaseOrder> ReadAllPO()
        {
            DataTable            DTpo          = PurchaseDataManager.GetAllPOs();
            DataTable            DTpod         = PurchaseDataManager.GetAllPODs();
            DataTable            DTgrn         = PurchaseDataManager.GetAllGRNs();
            DataTable            DTdcl         = PurchaseDataManager.GetAllDCLs();
            List <PurchaseOrder> allPOs        = POMap.MapPOData(DTpo, DTpod, DTgrn, DTdcl);
            List <PurchaseOrder> calculatedPOs = new List <PurchaseOrder>();

            foreach (PurchaseOrder PO in allPOs)
            {
                PurchaseOrder po = PurchaseDataManager.CalculatePO(PO);
                calculatedPOs.Add(po);
            }
            HttpContext.Current.Session.Add(SessionManager.POSession, calculatedPOs);
            _AllPOs = calculatedPOs;
            return(calculatedPOs);
        }
Example #5
0
        public static bool UpdateDCL(DutyClear dcl)
        {
            try
            {
                if (dcl.Id != Guid.Empty && dcl.PO != null && dcl.PO.Id != Guid.Empty && dcl.PODetail != null && dcl.PODetail.Id != Guid.Empty)
                {
                    PurchaseDataManager.UpdateDCL(POMap.reMapDCLData(dcl));
                    ResetCache();
                }
                return(true);
            }
            catch (Exception ex)
            {
                ExceptionHandler.Error("Something went wrong. Details: " + ex.Message, ex);
            }
            return(false);

            /*string PONumber = keyvalues["ponumber"];
             * string DCLNumber = keyvalues["dclnumber"];
             * string DCLId = keyvalues["dclid"];
             *
             * PurchaseOrder PO = GetPO(PONumber);
             * DutyClear Dcl = GetDCL(DCLNumber);
             * if (PO != null && Dcl != null)
             * {
             *  Dcl.DCLDate = keyvalues.ContainsKey("DCLDate") ? DateTime.Parse(keyvalues["DCLDate"]) : DateTime.Now;
             *  Dcl.PODetail = new Reference() { Id = new Guid(keyvalues["Customer"]), Name = PO.PONumber };
             *  Dcl.Store = StoreManager.GetStoreRef(keyvalues["Store"]);
             *  Dcl.Quantity = keyvalues.ContainsKey("Quantity") ? decimal.Parse(keyvalues["Quantity"]) : 0;
             *  Dcl.Remarks = keyvalues.ContainsKey("Remarks") ? keyvalues["Remarks"] : "";
             *  Dcl.ModifiedOn = DateTime.Now;
             *  Dcl.ModifiedBy = UserManager.GetUserRef(Common.CurrentUser.Id.ToString());
             *  foreach (PODetail pod in PO.PODetailsList)
             *  {
             *      foreach (DutyClear dcl in pod.DutyClearsList)
             *          if (dcl.Id.ToString() == DCLId || dcl.DCLNumber == DCLNumber)
             *          {
             *              pod.DutyClearsList.Remove(dcl);
             *              break;
             *          }
             *      if (pod.Id == Dcl.PODetail.Id)
             *      {
             *          pod.DutyClearsList.Add(Dcl);
             *          break;
             *      }
             *  }
             *
             *  PurchaseDataManager.CalculatePO(PO);
             *  if (PO.isValid)
             *      PurchaseDataManager.UpdateDCL(POMap.reMapDCLData(Dcl));
             *  else
             *  {
             *      ExceptionHandler.Error("Something went wrong! PO Quantity is not valid.");
             *      return null;
             *  }
             *  ResetCache();
             *
             *
             *  return Dcl;
             * }
             * return null;*/
        }
Example #6
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;*/
        }
Example #7
0
        public static bool CreateDutyClear(DutyClear dcl)
        {
            try
            {
                if (dcl.PO != null && dcl.PO.Id != Guid.Empty && dcl.PODetail != null && dcl.PODetail.Id != Guid.Empty)
                {
                    Guid dclId = PurchaseDataManager.CreateDCL(POMap.reMapDCLData(dcl));
                    dcl.Id = dclId;
                    PurchaseOrder po = GetPO(dcl.PO.Name);
                    StoreDataManager.CreateStockMovement(StoreMap.reMapStockMovementData(po, dcl)); //TODO
                    ResetCache();
                }
                return(true);
            }
            catch (Exception ex)
            {
                ExceptionHandler.Error("Something went wrong. Details: " + ex.Message, ex);
            }
            return(false);


            /*string poNumber = keyvalues.ContainsKey("PO") ? keyvalues["PO"] : "";
             * string cusId = keyvalues.ContainsKey("Customer") ? keyvalues["Customer"] : "";
             *
             * if (poNumber != "" && cusId != "")
             * {
             *  PurchaseOrder PO = GetPO(poNumber);
             *  PODetail POD = null;
             *  foreach (PODetail pod in PO.PODetailsList)
             *  {
             *      if (pod.Customer.Id == new Guid(cusId))
             *          POD = pod;
             *  }
             *  if (POD != null)
             *  {
             *      if (POD.DutyClearsList == null)
             *          POD.DutyClearsList = new List<DutyClear>();
             *      DutyClear Dcl = NewDCL();
             *      Dcl.PO = new Reference() { Id = PO.Id, Name = PO.PONumber };
             *      Dcl.PODetail = new Reference() { Id = POD.Id, Name = PO.PONumber };
             *      if (keyvalues.ContainsKey("Store"))
             *          Dcl.Store = StoreManager.GetStoreRef(keyvalues["Store"].ToString());
             *      Dcl.Quantity = keyvalues.ContainsKey("Quantity") ? decimal.Parse(keyvalues["Quantity"]) : 0;
             *      Dcl.Remarks = keyvalues.ContainsKey("Remarks") ? keyvalues["Remarks"] : "";
             *      POD.DutyClearsList.Add(Dcl);
             *
             *      PurchaseDataManager.CalculatePO(PO);
             *      if (PO.isValid)
             *      {
             *          PurchaseDataManager.CreateDCL(POMap.reMapDCLData(Dcl));
             *          //todo stock movement
             *      }
             *      else
             *      {
             *          ExceptionHandler.Error("Something went wrong! PO Quantity is not valid.");
             *          PurchaseDataManager.ResetCache();
             *          return null;
             *      }
             *      PurchaseDataManager.ResetCache();
             *      return Dcl;
             *  }
             * }
             * return null;*/
        }