public ActionResult EditDailyList(DailyList dailyList)
        {
            var dao = new DailyListDao();

            SetViewDepartment();
            SetViewTicket();
            SetViewCustomer();
            SetViewBag();
            SetViewVoucher();
            SetViewRoom();
            var session = (UserLogin)Session[CommonConstants.USER_SESSION];

            long id = dao.Update(dailyList, session.UserName);

            if (id > 0)
            {
                SetAlert("Sửa thông tin bảng kê thành công", "success");
                return(RedirectToAction("Index", "DailyList"));
            }
            else
            {
                SetAlert("Error!", "error");
                return(RedirectToAction("Index", "DailyList"));
            }
        }
Exemple #2
0
    public DailyList Add()
    {
        var newItem = new DailyList();

        if (head != null)
        {
            head.next = newItem;
        }
        head = newItem;
        return(newItem);
    }
    public DailyList Add()
    {
        var dailyList = new DailyList();

        if (head != null)
        {
            head.next = dailyList;
        }
        head = dailyList;
        return(dailyList);
    }
Exemple #4
0
 public void Add(DailyList newItem)
 {
     if (current != null)
     {
         current.next = newItem;
     }
     current = newItem;
     if (head == null)
     {
         head = current;
     }
 }
Exemple #5
0
    public IEnumerable <DailyList> GetAllNodes()
    {
        DailyList        current = head;
        List <DailyList> lst     = new List <DailyList>();

        while (current != null)
        {
            lst.Add(current);
            current = current.next;
        }
        return(lst);
    }
        public void NoDups()
        {
            var sut = new DailyList<TestStruct>();
            sut.AllocateMemory(new DateTime(2015, 12, 1));

            var s1 = new TestStruct(1, 2, 3, 4);
            var s2 = new TestStruct(1, 2, 3, 4);

            Assert.Null(sut[2015, 12, 1]);

            sut[2015, 12, 1] = new HashSet<TestStruct>();
            sut[2015, 12, 1].Add(s1).MustBe(true);
            sut[2015, 12, 1].Add(s2).MustBe(false);

            sut[2015, 12, 1].Count.MustBe(1);
        }
Exemple #7
0
        public long Insert(DailyList list, OrderDetail order)
        {
            if (list.Voucher_ID == 0 || list.Taxi == null)
            {
                list.Status = true;
            }
            else
            {
                list.Status = false;
            }

            db.DailyLists.Add(list);
            db.OrderDetails.Add(order);
            db.SaveChanges();

            return(list.ID);
        }
Exemple #8
0
        public void NoDups()
        {
            var sut = new DailyList <TestStruct>();

            sut.AllocateMemory(new DateTime(2015, 12, 1));

            var s1 = new TestStruct(1, 2, 3, 4);
            var s2 = new TestStruct(1, 2, 3, 4);

            Assert.Null(sut[2015, 12, 1]);

            sut[2015, 12, 1] = new HashSet <TestStruct>();
            sut[2015, 12, 1].Add(s1).MustBe(true);
            sut[2015, 12, 1].Add(s2).MustBe(false);

            sut[2015, 12, 1].Count.MustBe(1);
        }
Exemple #9
0
        public long Update(DailyList entity, string username)
        {
            var dailyList = db.DailyLists.Find(entity.ID);


            if (entity.Voucher_ID != dailyList.Voucher_ID)
            {
                dailyList.Voucher_ID = entity.Voucher_ID;
                var order   = db.OrderDetails.Where(x => x.DailyList_ID == entity.ID);
                var voucher = db.Vouchers.Find(entity.Voucher_ID);
                foreach (var item in order)
                {
                    var O      = db.OrderDetails.Find(item.ID);
                    var ticket = db.Tickets.Find(item.Ticket_ID);
                    if (entity.Voucher_ID == 0)
                    {
                        O.Amount = ticket.Price;
                    }
                    else
                    {
                        O.Amount = ticket.Price * (1 - voucher.DiscountPercent / 100);
                    }
                }
                db.SaveChanges();
            }

            if (entity.Taxi.Price != 0 && dailyList.Taxi_ID == null)
            {
                Taxi taxi = new Taxi();
                taxi.Code = entity.Taxi.Code;
                taxi.Name = entity.Taxi.Name;
                taxi.NumberOfCustomers = entity.Taxi.NumberOfCustomers;
                taxi.Price             = entity.Taxi.Price;
                taxi.Phone             = entity.Taxi.Phone;
                taxi.Description       = entity.Taxi.Description;
                db.Taxis.Add(taxi);
                db.SaveChanges();
                dailyList.Taxi_ID = taxi.ID;
            }
            else if (entity.Taxi.Price != 0 && dailyList.Taxi_ID != null)
            {
                var taxi = db.Taxis.Find(dailyList.Taxi_ID);
                taxi.Code = entity.Taxi.Code;
                taxi.Name = entity.Taxi.Name;
                taxi.NumberOfCustomers = entity.Taxi.NumberOfCustomers;
                taxi.Price             = entity.Taxi.Price;
                taxi.Phone             = entity.Taxi.Phone;
                taxi.Description       = entity.Taxi.Description;
                db.SaveChanges();
            }
            else if (entity.Taxi.Price == 0 && dailyList.Taxi_ID != null)
            {
                var taxi = db.Taxis.Find(dailyList.Taxi_ID);
                db.Taxis.Remove(taxi);
                db.SaveChanges();
                dailyList.Taxi_ID = null;
            }
            dailyList.Total = db.OrderDetails.Where(x => x.DailyList_ID == entity.ID).Sum(x => x.Amount);

            dailyList.ModifiedBy   = username;
            dailyList.ModifiedDate = DateTime.Now;
            db.SaveChanges();
            return(entity.ID);
        }
Exemple #10
0
 private void DailySummary_Tapped(object sender, Windows.UI.Xaml.Input.TappedRoutedEventArgs e)
 {
     DailyList.ScrollToIndex(0);
 }
Exemple #11
0
        public ActionResult SaveOrder(
            long Voucher_ID, string Request, string Description,
            string Code, string Name, int NumberOfCustomers, decimal Price, string Phone, string Taxi_Description,
            OrderDetail[] order)
        {
            string    result  = "Error! Order Is Not Complete!";
            var       session = (UserLogin)Session[CommonConstants.USER_SESSION];
            DailyList model   = new DailyList();

            model.Status = true;
            foreach (var item in order)
            {
                if (item.Room_ID == 0 || item.Ticket_ID == 0)
                {
                    SetAlert("Lỗi khi tạo phòng và vé", "error");
                    return(RedirectToAction("Index"));
                }
            }
            if (Voucher_ID != 0)
            {
                model.Status = false;
            }
            model.Voucher_ID = Voucher_ID;
            var voucher = db.Vouchers.Find(Voucher_ID);

            if (Voucher_ID != 0 && Voucher_ID >= 100)
            {
                voucher.Status = false;
                db.SaveChanges();
            }
            model.Request          = Request;
            model.Description      = Description;
            model.PricewithVoucher = 0;
            model.Total            = 0;

            if (Price != 0)
            {
                model.Status = false;
                Taxi taxi = new Taxi();
                taxi.Code = Code;
                taxi.Name = Name;
                taxi.NumberOfCustomers = NumberOfCustomers;
                taxi.Price             = Price;
                taxi.Phone             = Phone;
                taxi.Description       = Taxi_Description;
                db.Taxis.Add(taxi);
                db.SaveChanges();

                model.Taxi_ID = taxi.ID;
            }

            model.Department_ID = session.DepartmentID;
            model.CreatedDate   = DateTime.Now;
            model.CreatedBy     = session.UserName;
            db.DailyLists.Add(model);
            db.SaveChanges();

            foreach (var item in order)
            {
                OrderDetail O = new OrderDetail();
                O.Room_ID = item.Room_ID;
                var room = db.Rooms.Find(O.Room_ID);
                room.Status = false;
                db.SaveChanges();
                O.Ticket_ID = item.Ticket_ID;
                var      ticket = db.Tickets.Find(item.Ticket_ID);
                DateTime dt     = DateTime.Today;
                string   date   = dt.ToString("yyyy-MM-dd");
                if (db.OrderDetails.Where(x => DbFunctions.TruncateTime(x.TimeIn) == dt).Count() == 0)
                {
                    O.No = date.Replace("-", "") + "-" + session.DepartmentID.ToString()
                           + 1.ToString("D3");
                }
                else
                {
                    string Str = null;
                    foreach (var temp in db.OrderDetails.Where(x => DbFunctions.TruncateTime(x.TimeIn) == dt).OrderByDescending(x => x.ID).Take(1))
                    {
                        Str = temp.No;
                    }
                    string Str1 = Str.Substring(11);
                    O.No = date.Replace("-", "") + "-" + session.DepartmentID.ToString()
                           + (Int32.Parse(Str1) + 1).ToString("D3");
                }

                string[] arrEmpId = string.Join(",", item.SelectedIDArray).Replace(" ", "").Split(',');
                O.empId = string.Join(",", item.SelectedIDArray);

                List <string> emplist = new List <string>();

                foreach (var temp in arrEmpId)
                {
                    int id = Convert.ToInt32(temp);
                    var e  = db.Employees.Find(id);
                    e.OnAir = true;
                    db.SaveChanges();
                    emplist.Add(e.Code);
                }

                O.Employee_ID = string.Join(",", emplist).Replace(" ", "");

                if (model.Voucher_ID == 0)
                {
                    O.Amount = ticket.Price;
                }
                else
                {
                    O.Amount = ticket.Price * (1 - voucher.DiscountPercent / 100);
                }
                O.TimeIn               = DateTime.Now;
                O.TimeOut              = DateTime.Now.AddMinutes(ticket.TimeTotal);
                O.DailyList_ID         = model.ID;
                model.PricewithVoucher = model.PricewithVoucher + O.Amount;
                db.OrderDetails.Add(O);
                db.SaveChanges();
                foreach (var temp in arrEmpId)
                {
                    DailyEmployee emp = new DailyEmployee();
                    emp.Order_ID    = O.ID;
                    emp.Employee_ID = long.Parse(temp);
                    emp.Date        = DateTime.Now.Date;
                    emp.Clean       = 0;
                    emp.Tour        = 0;
                    emp.Tour        = 0;
                    db.DailyEmployees.Add(emp);
                    db.SaveChanges();
                }
            }
            model.Total = model.PricewithVoucher;
            db.SaveChanges();
            result = "Success! Order Is Complete!";

            return(Json(result, JsonRequestBehavior.AllowGet));
        }