private void frmBillInfo_Load(object sender, EventArgs e)
        {
            db = new CitiZoneDataContext();
            var bill = (from p in db.billInfos
                        join x in db.foods
                        on p.foodID equals(x.foodID)
                        where p.billID == Convert.ToInt32(lblBillID.Text.ToString())
                        select new
            {
                FoodName = x.foodName,
                Amount = p.amount,
                TotalPrice = x.price
            }).ToList();

            dgvBill.DataSource = bill;
            int totalpc = 0;

            for (int i = 0; i < dgvBill.RowCount; i++)
            {
                int prc = Convert.ToInt32(dgvBill.Rows[i].Cells[2].Value.ToString());
                int amt = Convert.ToInt32(dgvBill.Rows[i].Cells[1].Value.ToString());
                totalpc += prc * amt;
            }
            txtTotal.Text            = totalpc.ToString();
            dgvBill.Rows[0].Selected = false;
        }
        private void ptbFoodNamesDelete_Click(object sender, EventArgs e)
        {
            MC = new CitiZoneDataContext();
            int    FoodID = Int32.Parse(dgvFoods.SelectedCells[0].OwningRow.Cells[2].Value.ToString());
            string Food   = dgvFoods.SelectedCells[0].OwningRow.Cells[0].Value.ToString();

            if (check(FoodID))
            {
                MessageBox.Show("You must delete all bill contains this food first", "Notification");
            }
            else
            {
                if (MessageBox.Show("Food " + FoodID + " - " + Food + " will be permanently DELETED", "Notification",
                                    MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    food food = new food();
                    food.foodID = FoodID;
                    foodServices.deleteFood(food);
                    ptbFoodDelete.Visible = false;
                }
                string CategoryID = dgvCategories.SelectedCells[0].OwningRow.Cells[0].Value.ToString();
                var    dgv        = (from s in MC.foods
                                     where s.categoryID == CategoryID
                                     select new
                {
                    Food = s.foodName,
                    Price = s.price,
                    ID = s.foodID
                }).ToList();
                dgvFoods.DataSource = dgv;
            }
        }
        //thêm 1 billinfo
        public void addBillinfo(billInfo billInfo)
        {
            db = new CitiZoneDataContext();
            billInfo bifo = new billInfo();

            bifo = billInfo;
            db.billInfos.InsertOnSubmit(bifo);
            db.SubmitChanges();
        }
示例#4
0
 //lấy dữ liệu từ database
 public BillImpl()
 {
     db = new CitiZoneDataContext();
     using (db)
     {
         var bl = from x in db.bills select x;
         bills = bl.ToList();
     }
 }
示例#5
0
        //thêm bill
        public void addBill(bill bill)
        {
            db = new CitiZoneDataContext();
            bill bl = new bill();

            bl = bill;
            db.bills.InsertOnSubmit(bl);
            db.SubmitChanges();
        }
示例#6
0
        private void frmAddFood_Load(object sender, EventArgs e)
        {
            add = new CitiZoneDataContext();
            var cbC = (from s in add.categories
                       select s.categoryName).ToList();

            cbCategories.DataSource   = cbC;
            cbCategories.SelectedItem = ct;
        }
 //lấy dữ liệu từ database
 public FoodImpl()
 {
     db = new CitiZoneDataContext();
     using (db)
     {
         var fd = from x in db.foods select x;
         foods = fd.ToList();
     }
 }
示例#8
0
 public TableImpl()
 {
     db = new CitiZoneDataContext();
     using (db)
     {
         var tbl = from x in db.coffeeTables select x;
         tables = tbl.ToList();
     }
 }
        //thêm một nhân viên mới
        public void addAccount(account account)
        {
            db = new CitiZoneDataContext();
            account acc = new account();

            acc = account;
            db.accounts.InsertOnSubmit(acc);
            db.SubmitChanges();
        }
        //thêm món mới
        public void addFood(food food)
        {
            db = new CitiZoneDataContext();
            food fd = new food();

            fd = food;
            db.foods.InsertOnSubmit(fd);
            db.SubmitChanges();
        }
 //lấy database từ csdl
 public AccountImpl()
 {
     db = new CitiZoneDataContext();
     using (db)
     {
         var account = from ac in db.accounts select ac;
         accounts = account.ToList();
     }
 }
        //thêm danh mục
        public void addCategory(category category)
        {
            db = new CitiZoneDataContext();
            category ct = new category();

            ct = category;
            db.categories.InsertOnSubmit(ct);
            db.SubmitChanges();
        }
 //đổ dữ liệu từ database vào
 public CategoryImpl()
 {
     db = new CitiZoneDataContext();
     using (db)
     {
         var category = from ct in db.categories select ct;
         categories = category.ToList();
     }
 }
        //xoá nhân viên
        public void deleteAccount(account account)
        {
            db = new CitiZoneDataContext();
            account acc = new account();

            acc = account;
            acc = db.accounts.Single(x => x.username == account.username);
            db.accounts.DeleteOnSubmit(acc);
            db.SubmitChanges();
        }
        //cập nhật danh mục
        public void updateCategory(category category)
        {
            db = new CitiZoneDataContext();
            category ct = new category();

            ct = category;
            ct = db.categories.Single(x => x.categoryID == category.categoryID);
            setUpdateCategory(ct, category);
            db.SubmitChanges();
        }
        //xoá danh mục
        public void deleteCategory(category category)
        {
            db = new CitiZoneDataContext();
            category ct = new category();

            ct = category;
            ct = db.categories.Single(x => x.categoryID == category.categoryID);
            db.categories.DeleteOnSubmit(ct);
            db.SubmitChanges();
        }
示例#17
0
        //xoá bill
        public void deleteBill(bill bill)
        {
            db = new CitiZoneDataContext();
            bill bl = new bill();

            bl = bill;
            bl = db.bills.Single(x => x.billID == bill.billID);
            db.bills.DeleteOnSubmit(bl);
            db.SubmitChanges();
        }
        //cập nhật món
        public void updateFood(food food)
        {
            db = new CitiZoneDataContext();
            food fd = new food();

            fd = food;
            fd = db.foods.Single(x => x.foodID == food.foodID);
            setUpdateFood(fd, food);
            db.SubmitChanges();
        }
示例#19
0
        //cập nhật bàn
        public void updateTable(coffeeTable table)
        {
            db = new CitiZoneDataContext();
            coffeeTable tab = new coffeeTable();

            tab = table;
            tab = db.coffeeTables.Single(x => x.tableID == table.tableID);
            setUpdateTable(tab, table);
            db.SubmitChanges();
        }
        //xoá món
        public void deleteFood(food food)
        {
            db = new CitiZoneDataContext();
            food fd = new food();

            fd = food;
            fd = db.foods.Single(x => x.foodID == food.foodID);
            db.foods.DeleteOnSubmit(fd);
            db.SubmitChanges();
        }
 private void frmManageAccount_Load(object sender, EventArgs e)
 {
     MA = new CitiZoneDataContext();
     dgvQLTK.DataSource = from q in MA.accounts
                          orderby q.position ascending
                          select new
     {
         usn      = q.username,
         Fullname = q.fullname,
         quyen    = q.position,
         pw       = q.password
     };
 }
        private void frmManageCategories_Load(object sender, EventArgs e)
        {
            MC = new CitiZoneDataContext();
            var dgv = (from s in MC.categories
                       select new
            {
                CategoryID = s.categoryID,
                CategoryName = s.categoryName
            }).ToList();

            dgvCategories.DataSource = dgv;
            dgvFN();
        }
        private void ptbCategoriesDelete_Click(object sender, EventArgs e)
        {
            MC = new CitiZoneDataContext();
            string ctgID   = dgvCategories.SelectedCells[0].OwningRow.Cells[0].Value.ToString();
            string ctgName = dgvCategories.SelectedCells[0].OwningRow.Cells[1].Value.ToString();

            if (dgvCategories.RowCount > 0)
            {
                bool chk = true;
                if (dgvFoods.RowCount > 0)
                {
                    for (int i = 0; i < dgvFoods.RowCount; i++)
                    {
                        int fID = Int32.Parse(dgvFoods.Rows[i].Cells[2].Value.ToString());
                        if (check(fID))
                        {
                            chk = false;
                            break;
                        }
                    }
                }
                if (chk == true)
                {
                    if (dgvFoods.RowCount < 1)
                    {
                        if (MessageBox.Show("Category " + ctgID + " - " + ctgName + " will be permanently DELETED", "Notification",
                                            MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                        {
                            MC.deleteCategories(ctgID);
                            ptbCategoriesDelete.Visible = false;
                            frmManageCategories_Load(sender, e);
                        }
                    }
                    else
                    {
                        if (MessageBox.Show("All Food in Category " + ctgName + " will be permanently DELETED", "Notification",
                                            MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                        {
                            MC.deleteFoodsByCategories(ctgID);
                            MC.deleteCategories(ctgID);
                            frmManageCategories_Load(sender, e);
                        }
                    }
                }
                else
                {
                    MessageBox.Show("You must delete all bill contains foods of this category first", "Notification");
                }
            }
        }
        private bool checkName(string ctgName)
        {
            add = new CitiZoneDataContext();
            var c = from p in add.categories
                    where p.categoryName == ctgName
                    select p.categoryName;

            if (c.Any())
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#25
0
        private bool check(string usn)
        {
            db = new CitiZoneDataContext();
            var q = from p in db.accounts
                    where p.username == usn
                    select p;

            if (q.Any())
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
        private bool checkID(string ctgID)
        {
            add = new CitiZoneDataContext();
            var q = from p in add.categories
                    where p.categoryID == ctgID
                    select p;

            if (q.Any())
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#27
0
        private bool check(string fn)
        {
            add = new CitiZoneDataContext();
            var chk = (from p in add.foods
                       where p.foodName == fn
                       select p.foodName);

            if (chk.Any())
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        private bool check(int fid)
        {
            MC = new CitiZoneDataContext();
            var c = from p in MC.billInfos
                    where p.foodID == fid
                    select p.foodID;

            if (c.Any())
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
 void dgvFN()
 {
     if (dgvCategories.RowCount > 0)
     {
         MC = new CitiZoneDataContext();
         string CategoryID = dgvCategories.SelectedCells[0].OwningRow.Cells[0].Value.ToString();
         var    dgv        = (from s in MC.foods
                              where s.categoryID == CategoryID
                              select new
         {
             Food = s.foodName,
             Price = s.price,
             ID = s.foodID
         }).ToList();
         dgvFoods.DataSource = dgv;
     }
 }
        //cập nhật thông tin của nhân viên
        public void updateAccount(account account)
        {
            db = new CitiZoneDataContext();
            account acc = new account();

            acc = account;
            acc = db.accounts.Single(x => x.username == account.username);
            setAccountUpdate(acc, account);

            /*acc = db.accounts.Where(ac => ac.username == account.username).Single();
             * acc.password = account.password;
             * acc.fullname = account.fullname;
             * acc.birthday = account.birthday;
             * acc.address = account.address;
             * acc.phone = account.phone;
             * acc.pictureLocation = account.pictureLocation;
             */
            db.SubmitChanges();
        }