Esempio n. 1
0
        public static void DeleteMiscellaneousTransactionDetail(MiscellaneousTransactionDetailModel model)
        {
            MiscellaneousTransactionModel       miscellaneousTransaction       = SessionHelper.MiscellaneousTransaction;
            MiscellaneousTransactionDetailModel miscellaneousTransactionDetail = miscellaneousTransaction.MiscellaneousTransactionDetail.FirstOrDefault(x => x.Id == model.Id);

            miscellaneousTransaction.MiscellaneousTransactionDetail.Remove(miscellaneousTransactionDetail);
        }
Esempio n. 2
0
        public ActionResult Create()
        {
            MiscellaneousTransactionModel model = SessionHelper.MiscellaneousTransaction;

            if (model == null)
            {
                model = new MiscellaneousTransactionModel();
                model = new MiscellaneousTransactionModel
                {
                    SOBId           = SessionHelper.SOBId,
                    CodeCombination = getCodeCombinationList(SessionHelper.SOBId),
                    CompanyId       = AuthenticationHelper.CompanyId.Value,
                    TransactionDate = DateTime.Now
                };
                model.CodeCombinationId     = model.CodeCombination != null && model.CodeCombination.Count > 0 ? Convert.ToInt64(model.CodeCombination.FirstOrDefault().Value) : 0;
                model.CodeCombinationString = model.CodeCombination != null && model.CodeCombination.Count > 0 ? model.CodeCombination.FirstOrDefault().Text : "";
                ViewBag.SOBName             = SetOfBookHelper.GetSetOfBook(SessionHelper.SOBId.ToString()).Name;

                SessionHelper.MiscellaneousTransaction = model;
                if (SessionHelper.MiscellaneousTransaction.MiscellaneousTransactionDetail == null)
                {
                    SessionHelper.MiscellaneousTransaction.MiscellaneousTransactionDetail = new List <MiscellaneousTransactionDetailModel>();
                }
            }
            else
            {
                model.CodeCombination = getCodeCombinationList(SessionHelper.SOBId);
            }

            return(View(model));
        }
Esempio n. 3
0
        public ActionResult Edit(string id)
        {
            MiscellaneousTransactionModel model = MiscellaneousTransactionHelper.GetMiscellaneousTransaction(id);

            SessionHelper.MiscellaneousTransaction = model;

            model.SOBId = SessionHelper.SOBId;
            model.MiscellaneousTransactionDetail = MiscellaneousTransactionHelper.GetMiscellaneousTransactionDetail(model.SOBId, model.TransactionType, model.CodeCombinationId, model.TransactionDate).ToList();
            model.CompanyId = AuthenticationHelper.CompanyId.Value;

            model.CodeCombination = getCodeCombinationList(model.SOBId);
            SessionHelper.MiscellaneousTransaction = model;

            return(View("Create", model));
        }
Esempio n. 4
0
        public static void UpdateMiscellaneousTransactionDetail(MiscellaneousTransactionDetailModel model)
        {
            MiscellaneousTransactionModel miscellaneousTransaction = SessionHelper.MiscellaneousTransaction;

            miscellaneousTransaction.MiscellaneousTransactionDetail.FirstOrDefault(x => x.Id == model.Id).CodeCombinationId = model.CodeCombinationId;
            miscellaneousTransaction.MiscellaneousTransactionDetail.FirstOrDefault(x => x.Id == model.Id).CompanyId         = model.CompanyId;
            miscellaneousTransaction.MiscellaneousTransactionDetail.FirstOrDefault(x => x.Id == model.Id).Cost            = model.Cost;
            miscellaneousTransaction.MiscellaneousTransactionDetail.FirstOrDefault(x => x.Id == model.Id).Id              = model.Id;
            miscellaneousTransaction.MiscellaneousTransactionDetail.FirstOrDefault(x => x.Id == model.Id).ItemId          = model.ItemId;
            miscellaneousTransaction.MiscellaneousTransactionDetail.FirstOrDefault(x => x.Id == model.Id).LocatorId       = model.LocatorId;
            miscellaneousTransaction.MiscellaneousTransactionDetail.FirstOrDefault(x => x.Id == model.Id).LotNo           = model.LotNo;
            miscellaneousTransaction.MiscellaneousTransactionDetail.FirstOrDefault(x => x.Id == model.Id).Quantity        = model.Quantity;
            miscellaneousTransaction.MiscellaneousTransactionDetail.FirstOrDefault(x => x.Id == model.Id).SerialNo        = model.SerialNo;
            miscellaneousTransaction.MiscellaneousTransactionDetail.FirstOrDefault(x => x.Id == model.Id).SOBId           = model.SOBId;
            miscellaneousTransaction.MiscellaneousTransactionDetail.FirstOrDefault(x => x.Id == model.Id).TransactionDate = model.TransactionDate;
            miscellaneousTransaction.MiscellaneousTransactionDetail.FirstOrDefault(x => x.Id == model.Id).TransactionType = model.TransactionType;
            miscellaneousTransaction.MiscellaneousTransactionDetail.FirstOrDefault(x => x.Id == model.Id).WarehouseId     = model.WarehouseId;
        }
Esempio n. 5
0
        public ActionResult Save(MiscellaneousTransactionModel model)
        {
            string message = "";

            try
            {
                bool saved = false;
                if (SessionHelper.MiscellaneousTransaction != null)
                {
                    SessionHelper.MiscellaneousTransaction.CodeCombinationId = model.CodeCombinationId;
                    SessionHelper.MiscellaneousTransaction.CompanyId         = model.CompanyId;
                    SessionHelper.MiscellaneousTransaction.Id              = model.Id;
                    SessionHelper.MiscellaneousTransaction.SOBId           = SessionHelper.SOBId;
                    SessionHelper.MiscellaneousTransaction.TransactionDate = model.TransactionDate;
                    SessionHelper.MiscellaneousTransaction.TransactionType = model.TransactionType;

                    //Setting the parent fields..
                    foreach (var item in SessionHelper.MiscellaneousTransaction.MiscellaneousTransactionDetail)
                    {
                        item.TransactionType   = model.TransactionType;
                        item.CodeCombinationId = model.CodeCombinationId;
                        item.CompanyId         = AuthenticationHelper.CompanyId.Value;
                        item.SOBId             = SessionHelper.SOBId;
                        item.TransactionDate   = model.TransactionDate;
                    }

                    MiscellaneousTransactionHelper.Save(SessionHelper.MiscellaneousTransaction);
                    SessionHelper.MiscellaneousTransaction = null;
                    saved = true;
                }
                else
                {
                    message = "No Miscellaneous Transaction information available!";
                }
                return(Json(new { success = saved, message = message }));
            }
            catch (Exception e)
            {
                message = e.Message;
                return(Json(new { success = false, message = message }));
            }
        }
Esempio n. 6
0
 public ActionResult DeletePartial(MiscellaneousTransactionDetailModel model)
 {
     if (ModelState.IsValid)
     {
         try
         {
             model.SOBId = SessionHelper.SOBId;
             MiscellaneousTransactionModel MiscellaneousTransaction = SessionHelper.MiscellaneousTransaction;
             MiscellaneousTransactionHelper.DeleteMiscellaneousTransactionDetail(model);
             SessionHelper.MiscellaneousTransaction = MiscellaneousTransaction;
             IList <MiscellaneousTransactionDetailModel> MiscellaneousTransactionDetail = MiscellaneousTransactionHelper.GetMiscellaneousTransactionDetail(model.SOBId, model.TransactionType, model.CodeCombinationId, model.TransactionDate);
             return(PartialView("createPartial", MiscellaneousTransactionDetail));
         }
         catch (Exception e)
         {
             ViewData["EditError"] = e.Message;
         }
     }
     else
     {
         ViewData["EditError"] = "Please, correct all errors.";
     }
     return(PartialView("createPartial"));
 }
Esempio n. 7
0
        public static MiscellaneousTransactionModel GetMiscellaneousTransaction(string id)
        {
            MiscellaneousTransactionModel model = new MiscellaneousTransactionModel(service.GetSingle(id, AuthenticationHelper.CompanyId.Value));

            return(model);
        }
Esempio n. 8
0
        public static void Save(MiscellaneousTransactionModel miscellaneousTransactionModel)
        {
            var savedDetail = getMiscellaneousTransaction(miscellaneousTransactionModel.SOBId, miscellaneousTransactionModel.TransactionType, miscellaneousTransactionModel.CodeCombinationId, miscellaneousTransactionModel.TransactionDate);

            if (SessionHelper.MiscellaneousTransaction != null)
            {
                if (savedDetail.Count() > miscellaneousTransactionModel.MiscellaneousTransactionDetail.Count())
                {
                    var tobeDeleted = savedDetail.Take(savedDetail.Count() - miscellaneousTransactionModel.MiscellaneousTransactionDetail.Count());
                    foreach (var item in tobeDeleted)
                    {
                        service.Delete(item.Id.ToString(), AuthenticationHelper.CompanyId.Value);
                        IEnumerable <LotNumber> lotNum = lotNumService.CheckLotNumAvailability(AuthenticationHelper.CompanyId.Value, item.LotNo, item.ItemId, SessionHelper.SOBId);
                        if (lotNum.Any())
                        {
                            LotNumberHelper.Delete(lotNum.FirstOrDefault().Id.ToString());
                        }

                        //IEnumerable<SerialNumber> serialNum = lotNumService.CheckSerialNumAvailability(AuthenticationHelper.CompanyId.Value, item.LotNo, item.SerialNo);
                        //if (serialNum.Any())
                        //{
                        //    LotNumberHelper.DeleteSerialNumber(serialNum.FirstOrDefault().Id.ToString());
                        //}
                    }
                    savedDetail = getMiscellaneousTransaction(miscellaneousTransactionModel.SOBId, miscellaneousTransactionModel.TransactionType, miscellaneousTransactionModel.CodeCombinationId, miscellaneousTransactionModel.TransactionDate);
                }

                foreach (var detail in miscellaneousTransactionModel.MiscellaneousTransactionDetail)
                {
                    MiscellaneousTransaction detailEntity = GetEntityByModel(detail, savedDetail.Count());
                    if (detailEntity.IsValid())
                    {
                        if (savedDetail.Count() > 0)
                        {
                            detailEntity.Id = savedDetail.FirstOrDefault().Id;
                            savedDetail.Remove(savedDetail.FirstOrDefault(rec => rec.Id == detailEntity.Id));
                            service.Update(detailEntity);
                            IEnumerable <LotNumber> lotNum = lotNumService.CheckLotNumAvailability(AuthenticationHelper.CompanyId.Value, detailEntity.LotNo, detailEntity.ItemId, SessionHelper.SOBId);
                            if (lotNum.Any())
                            {
                                LotNumberHelper.Update(lotNum.FirstOrDefault());
                            }

                            //IEnumerable<SerialNumber> serialNum = lotNumService.CheckSerialNumAvailability(AuthenticationHelper.CompanyId.Value, detailEntity.LotNo, detailEntity.SerialNo);
                            //if (serialNum.Any())
                            //{
                            //    LotNumberHelper.UpdateSerialNumber(serialNum.FirstOrDefault());
                            //}
                        }
                        else
                        {
                            service.Insert(detailEntity);
                            IEnumerable <LotNumber> lotNum = lotNumService.CheckLotNumAvailability(AuthenticationHelper.CompanyId.Value, detailEntity.LotNo, detailEntity.ItemId, SessionHelper.SOBId);
                            if (!lotNum.Any())
                            {
                                LotNumberHelper.Insert(new MiscellaneousTransactionDetailModel(detailEntity));
                            }

                            //IEnumerable<SerialNumber> serialNum = lotNumService.CheckSerialNumAvailability(AuthenticationHelper.CompanyId.Value, detailEntity.LotNo, detailEntity.SerialNo);
                            //if (!serialNum.Any())
                            //{
                            //    LotNumberHelper.InsertSerialNumber(new MiscellaneousTransactionDetailModel(detailEntity));
                            //}
                        }
                    }
                }
            }
        }
Esempio n. 9
0
        public static void InsertMiscellaneousTransactionDetail(MiscellaneousTransactionDetailModel model)
        {
            MiscellaneousTransactionModel moveOrder = SessionHelper.MiscellaneousTransaction;

            moveOrder.MiscellaneousTransactionDetail.Add(model);
        }