Example #1
0
        public ActionResult InvoiceSearch(string status = null, string recevied = null, string ztopcompany = null, string department = null, string time = null, string otherside = null, double?minMoney = null, double?maxMoney = null, int page = 1)
        {
            var parameter = new InvoiceParameter()
            {
                Department = department,
                Time       = time,
                OtherSide  = otherside,
                Page       = new PageParameter(page, 20),
                MinMoney   = minMoney,
                MaxMoney   = maxMoney,
                Instance   = true
            };

            if (!string.IsNullOrEmpty(status))
            {
                parameter.Status = EnumHelper.GetEnum <InvoiceState>(status);
            }
            if (!string.IsNullOrEmpty(recevied))
            {
                parameter.Recevied = EnumHelper.GetEnum <Recevied>(recevied);
            }
            if (!string.IsNullOrEmpty(ztopcompany))
            {
                parameter.ZtopCompany = EnumHelper.GetEnum <ZtopCompany>(ztopcompany);
            }
            ViewBag.Results    = Core.InvoiceManager.Search(parameter);
            ViewBag.Department = Core.UserManager.GetUserGroups().Select(e => e.Name).ToList();
            ViewBag.Parameter  = parameter;
            ViewBag.Page       = parameter.Page;
            return(View());
        }
Example #2
0
 public ActionResult InvoiceList(InvoiceParameter param)
 {
     param.KeyWord = HttpUtility.UrlDecode(param.KeyWord);
     return(View(
                new InternalDataTransferToView
     {
         List = InvoiceProvider.List(param),
         Data = param
     }));
 }
Example #3
0
        public ActionResult InvoiceEdit(InvoiceParameter param)
        {
            if ((0L < param.Entity.Id))
            {
                param.Entity = InvoiceProvider.GetRecordById(param);
            }

            return(View(new InternalDataTransferToView
            {
                List = InvoiceProvider.GetDetail(param),
                //InvoiceProvider.GetDetail(param),
                Data = param
            }));
        }
Example #4
0
        public ActionResult AjaxInvoiceDelete(InvoiceParameter param)
        {
            var result = new JsonNetResult();
            var r      = new GeneralResponse();

            try
            {
                r.Code = InvoiceProvider.Delete(param).ToString(Section.Get.Common.Culture);
            }
            catch (Exception ex)
            {
                Log.Error(ex.Message, ex);
                r.Code = "-11";
            }
            result.Data = r;
            return(result);
        }
Example #5
0
        public ActionResult AjaxInvoiceEdit(InvoiceParameter param)
        {
            var result = new JsonNetResult();
            var r      = new GeneralResponse();

            try
            {
                r.Code = (0L < param.Entity.Id
                    ? InvoiceProvider.Update(param)
                    : InvoiceProvider.Create(param)).ToString(Section.Get.Common.Culture);
            }
            catch (Exception ex)
            {
                Log.Error(ex.Message, ex);
                r.Code = "-11" + ex.Message;
            }
            result.Data = r;
            return(result);
        }
Example #6
0
        public List <Invoice> Search(InvoiceParameter parameter)
        {
            using (var db = GetDbContext())
            {
                var query = db.Invoices.Where(e => e.Deleted == false).AsQueryable();
                if (!string.IsNullOrEmpty(parameter.Key))
                {
                    query = query.Where(e => e.GroupName.Contains(parameter.Key) || e.OtherSideCompany.Contains(parameter.Key));
                }
                if (!string.IsNullOrEmpty(parameter.Department))
                {
                    query = query.Where(e => e.GroupName == parameter.Department);
                }
                if (parameter.Status.HasValue)
                {
                    query = query.Where(e => e.State == parameter.Status.Value);
                }
                if (!string.IsNullOrEmpty(parameter.OtherSide))//对方单位
                {
                    query = query.Where(e => e.OtherSideCompany.Contains(parameter.OtherSide));
                }
                if (parameter.MinMoney.HasValue)
                {
                    query = query.Where(e => e.Money >= parameter.MinMoney.Value);
                }
                if (parameter.MaxMoney.HasValue)
                {
                    query = query.Where(e => e.Money <= parameter.MaxMoney.Value);
                }
                if (parameter.ZtopCompany.HasValue)
                {
                    query = query.Where(e => e.ZtopCompany == parameter.ZtopCompany.Value);
                }
                if (parameter.Recevied.HasValue)
                {
                    switch (parameter.Recevied.Value)
                    {
                    case Recevied.ALL:
                        query = query.Where(e => e.BAID > 0);
                        break;

                    case Recevied.None:
                        query = query.Where(e => e.BAID == 0);
                        break;
                    }
                    //query = query.Where(e => e.Recevied == parameter.Recevied.Value);
                }
                if (!string.IsNullOrEmpty(parameter.Time))
                {
                    DateTime compareTime = DateTime.Now;
                    switch (parameter.Time)
                    {
                    case "本周":
                        compareTime = compareTime.AddDays(7);
                        break;

                    case "本月":
                        compareTime = compareTime.AddMonths(1);
                        break;

                    case "本年":
                        compareTime = compareTime.AddYears(1);
                        break;
                    }
                    query = query.Where(e => (DateTime.Compare(compareTime, e.Time) > 0));
                }

                query = query.OrderByDescending(e => e.Time);
                query = query.SetPage(parameter.Page);
                if (parameter.Instance)
                {
                    foreach (var invoice in query)
                    {
                        invoice.Contract = db.Contracts.Find(invoice.CID);
                    }
                }

                return(query.ToList());
            }
        }
Example #7
0
 private void ReloadListFromDashboard(InvoiceParameter param)
 {
     ReloadList(param.Invoice == null ? -1 : param.Invoice.InvoiceId);
 }