Exemplo n.º 1
0
 // GET: Dokument Dokument/Index
 public ActionResult Index()
 {
     using (LocalDBEntities dbEntity = new LocalDBEntities())
     {
         return(View(dbEntity.DokumentFaktures.ToList()));
     }
 }
        private List<DailyItemsReport> LoadDailyItemsReport()
        {
            List<DailyItemsReport> items = new List<DailyItemsReport>();
            using (LocalDBEntities ctx = new LocalDBEntities())
            {
                var fromDate = dtDate.Value.Date;
                var toDate = dtDate.Value.Date.AddDays(1);

                var dbItems = from i in ctx.OrderItems
                              where i.OrderItemGroup.Order.Date >= fromDate &&
                                    i.OrderItemGroup.Order.Date < toDate
                              group i by new { i.Name, i.OrderItemGroup.Order.Date} into g
                              select new
                              {
                                  Name = g.Key.Name,
                                  Date = g.Key.Date,
                                  Qty = g.Sum(i=> i.OrderItemGroup.Quantity)
                              };

                foreach (var i in dbItems)
                {
                    DailyItemsReport item = new DailyItemsReport();
                    item.Name = i.Name;
                    item.Date = i.Date;
                    item.Quantity = i.Qty;
                    items.Add(item);
                }
            }
            return items;
        }
Exemplo n.º 3
0
        private List <DailyItemsReport> LoadDailyItemsReport()
        {
            List <DailyItemsReport> items = new List <DailyItemsReport>();

            using (LocalDBEntities ctx = new LocalDBEntities())
            {
                var fromDate = dtDate.Value.Date;
                var toDate   = dtDate.Value.Date.AddDays(1);

                var dbItems = from i in ctx.OrderItems
                              where i.OrderItemGroup.Order.Date >= fromDate &&
                              i.OrderItemGroup.Order.Date < toDate
                              group i by new { i.Name, i.OrderItemGroup.Order.Date } into g
                    select new
                {
                    Name = g.Key.Name,
                    Date = g.Key.Date,
                    Qty  = g.Sum(i => i.OrderItemGroup.Quantity)
                };

                foreach (var i in dbItems)
                {
                    DailyItemsReport item = new DailyItemsReport();
                    item.Name     = i.Name;
                    item.Date     = i.Date;
                    item.Quantity = i.Qty;
                    items.Add(item);
                }
            }
            return(items);
        }
Exemplo n.º 4
0
 // GET: Dokument/Edit
 public ActionResult Edit(string id)
 {
     using (LocalDBEntities dBEntity = new LocalDBEntities())
     {
         return(View(dBEntity.DokumentFaktures.Where(x => x.RedniBroj == id).FirstOrDefault()));
     }
 }
Exemplo n.º 5
0
 void InitializeData()
 {
     context = new LocalDBEntities();
     grdReceipts.DataSource = context.Receipts.OrderByDescending(r => r.Id)
                              .Select(p =>
                                      new { Id       = p.Id,
                                            Customer = p.Bill.Order.Customer.Name,
                                            Amount   = p.Amount });
 }
Exemplo n.º 6
0
 private void btnNew_Click(object sender, EventArgs e)
 {
     //lose the previous changes
     context = new LocalDBEntities();
     bill = new Bill();
     bill.Date = DateTime.Now.Date;
     context.Bills.AddObject(bill);
     bindBillToUI(bill);
     cmbOrderNo.Text = "";
     loadUnbilledOrders();
 }
Exemplo n.º 7
0
 private void btnNew_Click(object sender, EventArgs e)
 {
     //lose the previous changes
     context   = new LocalDBEntities();
     bill      = new Bill();
     bill.Date = DateTime.Now.Date;
     context.Bills.AddObject(bill);
     bindBillToUI(bill);
     cmbOrderNo.Text = "";
     loadUnbilledOrders();
 }
Exemplo n.º 8
0
 private void InitializeData()
 {
     //Initilize the object context
     context             = new LocalDBEntities();
     grdBills.DataSource = context.Bills.OrderByDescending(p => p.Id)
                           .Select(p => new
     {
         p.Id,
         Customer = p.Order.Customer.Name,
         Total    = p.BillLines.Count == 0? 0: p.BillLines.Select(b => b.Amount).Sum()
     });
 }
Exemplo n.º 9
0
 public ActionResult Edit(int id, DokumentFakture dokument)
 {
     try
     {
         // TODO: Add update logic here
         using (LocalDBEntities dbEntity = new LocalDBEntities())
         {
             string idStr = id.ToString();
             dbEntity.Entry(dokument).State = System.Data.EntityState.Modified;
             dbEntity.SaveChanges();
         }
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
Exemplo n.º 10
0
 public ActionResult Create(DokumentFakture dokument)
 {
     // TODO: Add insert logic here
     try
     {
         using (LocalDBEntities dBEntity = new LocalDBEntities())
         {
             dBEntity.DokumentFaktures.Add(dokument);
             dBEntity.SaveChanges();
         }
         return(RedirectToAction("Index"));
     }
     catch
     {
         System.Windows.Forms.MessageBox.Show("Faktura nije dodata!");
         return(View());
     }
 }
Exemplo n.º 11
0
        private void InitializeData()
        {
            //Initilize the object context
            context = new LocalDBEntities();
            grdOrders.DataSource = context.Orders.OrderByDescending(p => p.Id)
                                   .Select(p => new
            {
                p.Id,
                p.Customer.Name,
                p.Customer.ContactNo,
                p.Date,
                p.Venue
            });

            //load the dropdowns
            cmbCustomerName.DataSource    = context.Customers;
            cmbCustomerName.DisplayMember = "Name";
        }
Exemplo n.º 12
0
 public ActionResult Delete(string id, FormCollection collection)
 {
     try
     {
         // TODO: Add delete logic here
         using (LocalDBEntities dbEntity = new LocalDBEntities())
         {
             DokumentFakture dokument = dbEntity.DokumentFaktures.Where(x => x.RedniBroj == id).FirstOrDefault();
             dbEntity.DokumentFaktures.Remove(dokument);
             dbEntity.SaveChanges();
         }
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
Exemplo n.º 13
0
        public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context)
        {
            var identity = new ClaimsIdentity(context.Options.AuthenticationType);

            LocalDBEntities obj      = new LocalDBEntities();
            var             userdata = obj.Users.SingleOrDefault(u => u.UserName == context.UserName && u.Password == context.Password);

            if (userdata != null)
            {
                identity.AddClaim(new Claim(ClaimTypes.Name, userdata.UserName));
                context.Validated(identity);
            }
            else
            {
                context.SetError("invalid_grant", "Provided username and password is incorrect");
                context.Rejected();
            }
        }
Exemplo n.º 14
0
        // GET: Dokument/Details/5
        public ActionResult Details(string id)
        {
            using (LocalDBEntities dbmodel = new LocalDBEntities())
            {
                var rezultat = new Faktura
                {
                    FK_DokumetFakture = dbmodel.DokumentFaktures.FirstOrDefault(x => x.RedniBroj.Equals(id)).RedniBroj,
                    DatumFakture      = dbmodel.DokumentFaktures.FirstOrDefault(x => x.RedniBroj.Equals(id)).DatumFakture,
                    BrojFakture       = dbmodel.DokumentFaktures.FirstOrDefault(x => x.RedniBroj.Equals(id)).RedniBroj,

                    S = (from s in dbmodel.StavkaFaktures join d in dbmodel.DokumentFaktures
                         on s.FK_DokumentFakture equals d.RedniBroj
                         where s.FK_DokumentFakture.Equals(id)
                         select new { s.RedniBroj, s.Kolicina, s.Cena, s.Ukupno })
                        .ToDictionary(k => k.RedniBroj, v => Tuple.Create(v.Kolicina, v.Cena, v.Ukupno))
                };

                return(View(rezultat));
            }
        }
Exemplo n.º 15
0
 void InitializeData()
 {
     context = new LocalDBEntities();
     grdReceipts.DataSource = context.Receipts.OrderByDescending(r => r.Id)
                                 .Select(p =>
                                     new { Id = p.Id,
                                           Customer = p.Bill.Order.Customer.Name,
                                           Amount = p.Amount
                                     });
 }
Exemplo n.º 16
0
 private void InitializeData()
 {
     //Initilize the object context
     context = new LocalDBEntities();
     grdBills.DataSource = context.Bills.OrderByDescending(p => p.Id)
                                     .Select(p => new
                                     {
                                         p.Id,
                                         Customer = p.Order.Customer.Name,
                                         Total = p.BillLines.Count == 0? 0: p.BillLines.Select(b => b.Amount).Sum()
                                     });
 }
Exemplo n.º 17
0
        private void InitializeData()
        {
            //Initilize the object context
            context = new LocalDBEntities();
            grdOrders.DataSource = context.Orders.OrderByDescending(p => p.Id)
                                            .Select(p => new
                                            {
                                                p.Id,
                                                p.Customer.Name,
                                                p.Customer.ContactNo,
                                                p.Date,
                                                p.Venue
                                            });

            //load the dropdowns
            cmbCustomerName.DataSource = context.Customers;
            cmbCustomerName.DisplayMember = "Name";
        }