コード例 #1
0
ファイル: Logic.cs プロジェクト: smakkerz/Develop-.Net
        public static ResultModel <string> GenerateInvoice()
        {
            string Y         = DateTime.Now.Year.ToString().Substring(2);
            string NoInvoice = Y + "0001";

            var data = ManageInvoice.GetAll().OrderByDescending(x => x.Createddate).FirstOrDefault();

            if (data != null)
            {
                if (data.Createddate.Value.Year == DateTime.Now.Year)
                {
                    int d = Convert.ToInt32(data.ID) + 1;
                    NoInvoice = d.ToString();
                }
                //// Mengambil 4 karakter kanan terakhir dari field nomor lalu menambahkan dengan 1
                //hitung = Convert.ToInt64(rd["nomor"]) + 1;
                //string joinstr = "0000" + hitung;
                //// Mengambil 4 karakter kanan terakhir dari string joinstr
                //urut = joinstr.Substring(joinstr.Length - 4, 4);
            }

            end.StatusCode = (int)HttpStatusCode.OK; end.Value = NoInvoice;

            return(end);
        }
コード例 #2
0
        public ResultModel <List <InvoiceModel> > GetAll()
        {
            ResultModel <List <InvoiceModel> > res = new ResultModel <List <InvoiceModel> >();

            var ret   = ManageInvoice.GetAll();
            var datas = (from a in ret
                         join b in ManageUser.GetAll() on a.UsersID equals b.ID
                         select new InvoiceModel
            {
                ID = a.ID,
                UsersID = a.UsersID,
                UserName = b.Username,
                Name = b.Name,
                TransactionDate = a.TransactionDate,
                TotalPrice = a.TotalPrice
            }).ToList();

            res.StatusCode = (int)HttpStatusCode.NotFound;
            if (datas != null && datas.Count >= 1)
            {
                res.StatusCode = (int)HttpStatusCode.OK; res.Value = datas;
            }
            return(res);
        }