예제 #1
0
        public void CopyChildEntities(int ParentID)
        {
            string con = ConfigurationHelper.GetsmARTDBContextConnectionString();

            PurchaseOrderItemLibrary poItemLib = new PurchaseOrderItemLibrary();

            poItemLib.Initialize(con);
            IEnumerable <PurchaseOrderItem> poItems = poItemLib.GetAllByParentID(ParentID, new string[] { "PurchaseOrder", "Item" });

            Session["PurchaseOrderItem"] = poItems;

            PurchaseOrderNotesLibrary poNotesLib = new PurchaseOrderNotesLibrary();

            poNotesLib.Initialize(con);
            IEnumerable <PurchaseOrderNotes> poNotess = poNotesLib.GetAllByParentID(ParentID);

            Session["PurchaseOrderNotes"] = poNotess;

            PurchaseOrderAttachmentsLibrary poAttachmentsLib = new PurchaseOrderAttachmentsLibrary();

            poAttachmentsLib.Initialize(con);
            IEnumerable <PurchaseOrderAttachments> poAttachmentss = poAttachmentsLib.GetAllByParentID(ParentID);

            Session["PurchaseOrderAttachments"] = poAttachmentss;
        }
예제 #2
0
 private void ValidatePOItem(Scale scale, ScaleDetails scaleItem)
 {
     if (scale.Purchase_Order != null && scale.Purchase_Order.ID > 0)
     {
         PurchaseOrderItemLibrary        poItemLib = new PurchaseOrderItemLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString());
         IEnumerable <PurchaseOrderItem> poItems   = poItemLib.GetAllByParentID(scale.Purchase_Order.ID, new string[] { "Item" });
         var isPOItem = (from i in poItems
                         where i.Item.ID == scaleItem.Item_Received.ID
                         select i).FirstOrDefault();
         if (isPOItem == null)
         {
             ModelState.AddModelError("Item_Received", string.Format("Scale details item {0} mismatch to selected purchase order items.", scaleItem.Item_Received.Short_Name));
         }
     }
 }
예제 #3
0
        protected override void DeleteChildEntities(string[] childEntityList, string parentID)
        {
            foreach (string ChildEntity in childEntityList)
            {
                switch (ChildEntity)
                {
                    #region /* Case Statements - All child grids */
                case "PurchaseOrderItem":
                    if (Session[ChildEntity] != null)
                    {
                        PurchaseOrderItemLibrary        PurchaseorderItemLibrary = new PurchaseOrderItemLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString());
                        IEnumerable <PurchaseOrderItem> resultList = (IList <PurchaseOrderItem>)Session[ChildEntity];
                        foreach (PurchaseOrderItem item in resultList)
                        {
                            PurchaseorderItemLibrary.Delete(item.ID.ToString());
                        }
                    }
                    break;

                case "PurchaseOrderNotes":
                    if (Session[ChildEntity] != null)
                    {
                        PurchaseOrderNotesLibrary        PurchaseorderNotesLibrary = new PurchaseOrderNotesLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString());
                        IEnumerable <PurchaseOrderNotes> resultList = (IList <PurchaseOrderNotes>)Session[ChildEntity];
                        foreach (PurchaseOrderNotes notes in resultList)
                        {
                            PurchaseorderNotesLibrary.Delete(notes.ID.ToString());
                        }
                    }
                    break;

                case "PurchaseOrderAttachments":
                    if (Session[ChildEntity] != null)
                    {
                        PurchaseOrderAttachmentsLibrary        PurchaseorderLibrary = new PurchaseOrderAttachmentsLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString());
                        IEnumerable <PurchaseOrderAttachments> resultList           = (IList <PurchaseOrderAttachments>)Session[ChildEntity];
                        foreach (PurchaseOrderAttachments attachments in resultList)
                        {
                            PurchaseorderLibrary.Delete(attachments.ID.ToString());
                        }
                    }
                    break;

                    #endregion
                }
            }
        }
예제 #4
0
        public ActionResult SelectOpenPOItem(int?id)
        {
            if (id.HasValue)
            {
                PurchaseOrderItem poItem = new PurchaseOrderItemLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString())
                                           .GetByID(id.ToString(),
                                                    new string[] { "PurchaseOrder", "PurchaseOrder.Party", "PurchaseOrder.Contact", "Item" }
                                                    );
                if (poItem != null)
                {
                    ClearChildEntities(new string[] { "ScaleDetails", "ScaleNotes", "ScaleAttachments", "ScaleExpense" });

                    // Update Scale
                    Scale result = new Scale();
                    result.Ticket_Type    = "Receiving Ticket";
                    result.Purchase_Order = poItem.PurchaseOrder;
                    result.Party_ID       = poItem.PurchaseOrder.Party;


                    // Update Scale Items
                    List <ScaleDetails> scaleDetails = new List <ScaleDetails>()
                    {
                        new ScaleDetails()
                        {
                            ID = 1, Item_Received = poItem.Item, Apply_To_Item = poItem.Item, Split_Value = 100, Scale = new Scale(), Created_By = HttpContext.User.Identity.Name, Updated_By = HttpContext.User.Identity.Name, Created_Date = DateTime.Now, Last_Updated_Date = DateTime.Now
                        }
                    };
                    Session["ScaleDetails"] = scaleDetails;

                    ViewBag.IsFromOpnePOItem = true;
                    result.ID = 0;
                    return(Display(result));
                }
            }
            return(RedirectToAction("New"));
        }
예제 #5
0
        protected override void SaveChildEntities(string[] childEntityList, PurchaseOrder entity)
        {
            foreach (string ChildEntity in childEntityList)
            {
                switch (ChildEntity)
                {
                    #region /* Case Statements - All child grids */
                case "PurchaseOrderItem":
                    if (Session[ChildEntity] != null)
                    {
                        PurchaseOrderItemLibrary        PurchaseorderItemLibrary = new PurchaseOrderItemLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString());
                        IEnumerable <PurchaseOrderItem> resultList = (IList <PurchaseOrderItem>)Session[ChildEntity];
                        foreach (PurchaseOrderItem PurchaseorderItem in resultList)
                        {
                            PurchaseorderItem.PurchaseOrder = new PurchaseOrder {
                                ID = entity.ID
                            };
                            //itemNote.Notes = System.Web.HttpUtility.HtmlDecode(itemNote.Notes);
                            PurchaseorderItemLibrary.Add(PurchaseorderItem);
                        }
                    }
                    break;

                case "PurchaseOrderNotes":
                    if (Session[ChildEntity] != null)
                    {
                        PurchaseOrderNotesLibrary        PurchaseorderNotesLibrary = new PurchaseOrderNotesLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString());
                        IEnumerable <PurchaseOrderNotes> resultList = (IList <PurchaseOrderNotes>)Session[ChildEntity];
                        foreach (PurchaseOrderNotes PurchaseorderNote in resultList)
                        {
                            PurchaseorderNote.Parent = new PurchaseOrder {
                                ID = entity.ID
                            };
                            //itemNote.Notes = System.Web.HttpUtility.HtmlDecode(itemNote.Notes);
                            PurchaseorderNotesLibrary.Add(PurchaseorderNote);
                        }
                    }
                    break;

                case "PurchaseOrderAttachments":
                    if (Session[ChildEntity] != null)
                    {
                        PurchaseOrderAttachmentsLibrary        PurchaseorderLibrary = new PurchaseOrderAttachmentsLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString());
                        IEnumerable <PurchaseOrderAttachments> resultList           = (IList <PurchaseOrderAttachments>)Session[ChildEntity];
                        string      destinationPath;
                        string      sourcePath;
                        FilelHelper fileHelper = new FilelHelper();
                        foreach (PurchaseOrderAttachments Purchaseorder in resultList)
                        {
                            destinationPath             = fileHelper.GetSourceDirByFileRefId(Purchaseorder.Document_RefId.ToString());     // Path.Combine(Configuration.GetsmARTDocPath(), PurchaseOrder.Document_RefId.ToString());
                            sourcePath                  = fileHelper.GetTempSourceDirByFileRefId(Purchaseorder.Document_RefId.ToString()); // Path.Combine(Configuration.GetsmARTTempDocPath(), PurchaseOrder.Document_RefId.ToString());
                            Purchaseorder.Document_Path = fileHelper.GetFilePath(sourcePath);
                            fileHelper.MoveFile(Purchaseorder.Document_Name, sourcePath, destinationPath);

                            Purchaseorder.Parent = new PurchaseOrder {
                                ID = entity.ID
                            };
                            PurchaseorderLibrary.Add(Purchaseorder);
                        }
                    }
                    break;

                    #endregion
                }
            }
        }