コード例 #1
0
        private static InvoiceType getEntityByModel(InvoiceTypeModel model)
        {
            if (model == null)
            {
                return(null);
            }

            InvoiceType entity = new InvoiceType();

            if (model.Id == 0)
            {
                entity.CreateBy   = AuthenticationHelper.UserId;
                entity.CreateDate = DateTime.Now;
                entity.CompanyId  = AuthenticationHelper.CompanyId.Value;
            }
            else
            {
                entity.CreateBy   = model.CreateBy;
                entity.CreateDate = model.CreateDate;
                entity.CompanyId  = model.CompanyId;
            }

            entity.Meaning     = model.Meaning;
            entity.SOBId       = model.SOBId;
            entity.Invoicetype = model.InvoiceType;
            entity.Id          = model.Id;
            entity.Description = model.Description;
            entity.DateTo      = model.DateTo;
            entity.DateFrom    = model.DateFrom;
            entity.UpdateBy    = AuthenticationHelper.UserId;
            entity.UpdateDate  = DateTime.Now;
            return(entity);
        }
コード例 #2
0
 public static string Save(InvoiceTypeModel model)
 {
     if (model.Id > 0)
     {
         return(service.Update(getEntityByModel(model)));
     }
     else
     {
         return(service.Insert(getEntityByModel(model)));
     }
 }
コード例 #3
0
        public ActionResult Edit(string id, long periodId)
        {
            PayableInvoiceModel model = PayableInvoiceHelper.GetInvoice(id);

            SessionHelper.Calendar = CalendarHelper.GetCalendar(PayablePeriodHelper.GetPayablePeriod(periodId.ToString()).CalendarId.ToString());

            model.InvoiceDetail = PayableInvoiceHelper.GetInvoiceDetail(id);
            model.SOBId         = SessionHelper.SOBId;
            model.PeriodId      = periodId;
            model.Periods       = PayablePeriodHelper.GetPeriodList(SessionHelper.SOBId);

            VendorModel      vendors      = VendorHelper.GetSingle(model.VendorId.ToString());
            VendorSiteModel  vendorSites  = VendorHelper.GetSingle(model.VendorSiteId);
            InvoiceTypeModel invoiceTypes = InvoiceTypeHelper.GetInvoiceType(model.InvoiceTypeId.ToString());

            ///TODO: Plz do the code audit.
            model.Vendors = new List <SelectListItem>();
            model.Vendors.Add(new SelectListItem
            {
                Value = vendors.Id.ToString(),
                Text  = vendors.Name
            });
            model.VendorSites = new List <SelectListItem>();
            model.VendorSites.Add(new SelectListItem
            {
                Value = vendorSites.Id.ToString(),
                Text  = vendorSites.Name
            });

            model.WHTaxes = new List <SelectListItem>();
            if (model.WHTaxId != null)
            {
                WithholdingModel withHoldingTaxes = WithholdingHelper.GetWithholding(model.WHTaxId.ToString());
                model.WHTaxes.Add(new SelectListItem
                {
                    Value = withHoldingTaxes.Id.ToString(),
                    Text  = withHoldingTaxes.Description
                });
            }

            model.InvoiceTypes = new List <SelectListItem>();
            model.InvoiceTypes.Add(new SelectListItem
            {
                Value = invoiceTypes.Id.ToString(),
                Text  = invoiceTypes.Description
            });

            SessionHelper.PayableInvoice = model;
            return(View(model));
        }
コード例 #4
0
 public ActionResult DeleteInline(InvoiceTypeModel model)
 {
     if (ModelState.IsValid)
     {
         try
         {
             InvoiceTypeHelper.Delete(model.Id.ToString());
             return(PartialView("_List", InvoiceTypeHelper.GetInvoiceTypes(SessionHelper.SOBId)));
         }
         catch (Exception e)
         {
             ViewData["EditError"] = e.Message;
         }
     }
     else
     {
         ViewData["EditError"] = "Please, correct all errors.";
     }
     return(PartialView("_List", InvoiceTypeHelper.GetInvoiceTypes(SessionHelper.SOBId)));
 }