// them 1 bill vs ban
        public async void insertBill(int idTable, DateTime d)
        {
            HttpClient    client = new HttpClient();
            StringBaseAdd s      = new StringBaseAdd();

            client.BaseAddress = new Uri(s.url);
            client.DefaultRequestHeaders.Accept.Clear();
            client.DefaultRequestHeaders.Accept.Add(
                new MediaTypeWithQualityHeaderValue("application/json"));
            Bill b = new Bill();

            b.IdTable     = idTable;
            b.DateCheckin = d;
            try
            {
                HttpResponseMessage responsePost = await client.PostAsJsonAsync("api/Bill", b);

                if (responsePost.IsSuccessStatusCode)
                {
                    MessageBox.Show("ok", "ok");
                }
            }
            catch
            {
            }
        }
Esempio n. 2
0
        public void doiMatKhau(string username, string oldpassword, string newpassword)
        {
            HttpClient    client = new HttpClient();
            StringBaseAdd s      = new StringBaseAdd();

            client.BaseAddress = new Uri(s.url);
            HttpResponseMessage response = client.GetAsync(String.Format("api/Account?username={0}&&oldpassword={1}&&newpassword={2}", username, oldpassword, newpassword)).Result;
        }
        // goi proc thanh toan

        public async void ThanhToan(int idTable, int idBill)
        {
            List <Table>  lsTable = new List <Table>();
            HttpClient    client  = new HttpClient();
            StringBaseAdd s       = new StringBaseAdd();

            client.BaseAddress = new Uri(s.url);
            HttpResponseMessage response = await client.GetAsync(string.Format("api/Table?idTable={0}&&idBill={1}", idTable, idBill));
        }
        public async void deleteTableMenu(int id)
        {
            HttpClient    client = new HttpClient();
            StringBaseAdd s      = new StringBaseAdd();

            client.BaseAddress = new Uri(s.url);

            client.DefaultRequestHeaders.Accept.Add(
                new MediaTypeWithQualityHeaderValue("application/json"));
        }
        // hiển thị menu theo category
        public List <Menu> getListMenuByIdCategory(int idCategory)
        {
            HttpClient    client = new HttpClient();
            StringBaseAdd s      = new StringBaseAdd();

            client.BaseAddress = new Uri(s.url);
            HttpResponseMessage response = client.GetAsync("api/Menu/" + idCategory).Result;
            List <Menu>         data     = response.Content.ReadAsAsync <List <Menu> >().Result;

            return(data);
        }
Esempio n. 6
0
        public DataTable GetAccount()
        {
            HttpClient    client = new HttpClient();
            StringBaseAdd s      = new StringBaseAdd();

            client.BaseAddress = new Uri(s.url);
            HttpResponseMessage response = client.GetAsync("api/Account").Result;
            List <Account>      data     = response.Content.ReadAsAsync <List <Account> >().Result;

            return(ToDataTable(data));
        }
        // lấy nhân viên có tên = ""
        public List <Employee> searchEmployee(string name)
        {
            List <Employee> lsEmployee = new List <Employee>();
            HttpClient      client     = new HttpClient();
            StringBaseAdd   s          = new StringBaseAdd();

            client.BaseAddress = new Uri(s.url);
            HttpResponseMessage respone = client.GetAsync("api/Employee?name=" + name).Result;
            List <Employee>     data    = respone.Content.ReadAsAsync <List <Employee> >().Result;

            return(data);
        }
        // tra về một bảng với id cho  trước

        public Table getTableById(int id)
        {
            List <Table>  lsTable = new List <Table>();
            HttpClient    client  = new HttpClient();
            StringBaseAdd s       = new StringBaseAdd();

            client.BaseAddress = new Uri(s.url);
            HttpResponseMessage response = client.GetAsync("api/Table/" + id).Result;
            Table data = response.Content.ReadAsAsync <Table>().Result;

            return(data);
        }
        //internal object LoadDSMenuByCate(object idCate)
        //{
        //    throw new NotImplementedException();
        //}

        public async void deleteMenu(int id)
        {
            HttpClient    client = new HttpClient();
            StringBaseAdd s      = new StringBaseAdd();

            client.BaseAddress = new Uri(s.url);
            client.DefaultRequestHeaders.Accept.Clear();
            client.DefaultRequestHeaders.Accept.Add(
                new MediaTypeWithQualityHeaderValue("application/json"));

            HttpResponseMessage responsePost = await client.DeleteAsync("api/Menu/" + id);
        }
        // lấy danh sách category

        public DataTable getListCategory()
        {
            HttpClient    client = new HttpClient();
            StringBaseAdd s      = new StringBaseAdd();

            client.BaseAddress = new Uri(s.url);
            HttpResponseMessage response = client.GetAsync("api/MenuCategory").Result;
            String a = response.Content.ReadAsStringAsync().Result;
            List <MenuCategory> data = response.Content.ReadAsAsync <List <MenuCategory> >().Result;

            return(ToDataTable(data));
        }
        public DataTable searchMenuCate(string name)
        {
            HttpClient    client = new HttpClient();
            StringBaseAdd s      = new StringBaseAdd();

            client.BaseAddress = new Uri(s.url);
            HttpResponseMessage response = client.GetAsync("api/MenuCategory?name=" + name).Result;
            DataSet             data     = response.Content.ReadAsAsync <DataSet>().Result;
            string datwa = response.Content.ReadAsStringAsync().Result;;

            return(data.Tables[0]);
        }
        // them 1 mon vao hoa don tai ban A

        public DataTable getBillInfoByIdBill(int id)
        {
            HttpClient    client = new HttpClient();
            StringBaseAdd s      = new StringBaseAdd();

            client.BaseAddress = new Uri(s.url);
            HttpResponseMessage response = client.GetAsync("api/BillInFo/" + id).Result;
            DataSet             data     = response.Content.ReadAsAsync <DataSet>().Result;
            string datwa = response.Content.ReadAsStringAsync().Result;;

            return(data.Tables[0]);
        }
Esempio n. 13
0
        //***************************
        // tim nhan vien theo account

        public Employee getEmployeeByAccount(string username)
        {
            List <Table>  lsTable = new List <Table>();
            HttpClient    client  = new HttpClient();
            StringBaseAdd s       = new StringBaseAdd();

            client.BaseAddress = new Uri(s.url);
            HttpResponseMessage response = client.GetAsync("api/Employee?username=" + username).Result;
            Employee            data     = response.Content.ReadAsAsync <Employee>().Result;

            return(data);
        }
        // binh

        public DataTable LoadDSByTime(DateTime date1, DateTime date2)
        {
            string        d1     = date1.Year + "-" + date1.Month + "-" + date1.Day;
            string        d2     = date2.Year + "-" + date2.Month + "-" + date2.Day;
            HttpClient    client = new HttpClient();
            StringBaseAdd s      = new StringBaseAdd();

            client.BaseAddress = new Uri(s.url);
            HttpResponseMessage response = client.GetAsync(String.Format("api/Bill?date1={0}&&date2={1}", d1, d2)).Result;
            DataSet             data     = response.Content.ReadAsAsync <DataSet>().Result;
            string datwa = response.Content.ReadAsStringAsync().Result;;

            return(data.Tables[0]);
        }
        // update total bill
        public async void updateTotalBill(int id, int total)
        {
            HttpClient    client = new HttpClient();
            StringBaseAdd s      = new StringBaseAdd();

            client.BaseAddress = new Uri(s.url);
            client.DefaultRequestHeaders.Accept.Clear();
            client.DefaultRequestHeaders.Accept.Add(
                new MediaTypeWithQualityHeaderValue("application/json"));
            Bill b = new Bill();

            b.Id    = id;
            b.Total = total;
            HttpResponseMessage responsePost = await client.PutAsJsonAsync("api/Bill", b);
        }
        public async void DeleteBillInfo(int idBill, int idMenu)
        {
            HttpClient    client = new HttpClient();
            StringBaseAdd s      = new StringBaseAdd();

            client.BaseAddress = new Uri(s.url);
            client.DefaultRequestHeaders.Accept.Clear();
            client.DefaultRequestHeaders.Accept.Add(
                new MediaTypeWithQualityHeaderValue("application/json"));
            BillInfo b = new BillInfo();

            b.IdBill = idBill;
            b.IdMenu = idMenu;
            HttpResponseMessage responsePost = await client.DeleteAsync(String.Format("api/BillInfo?idBill={0}&&idMenu={1}", idBill, idMenu));
        }
        public async void insertMenuCate(string name)
        {
            HttpClient    client = new HttpClient();
            StringBaseAdd s      = new StringBaseAdd();

            client.BaseAddress = new Uri(s.url);
            client.DefaultRequestHeaders.Accept.Clear();
            client.DefaultRequestHeaders.Accept.Add(
                new MediaTypeWithQualityHeaderValue("application/json"));
            MenuCategory mnc = new MenuCategory();

            mnc.Name = name;


            HttpResponseMessage responsePost = await client.PostAsJsonAsync("api/MenuCategory", mnc);
        }
        public async void editBillInfo(int idBill, int idMenu, int count)
        {
            HttpClient    client = new HttpClient();
            StringBaseAdd s      = new StringBaseAdd();

            client.BaseAddress = new Uri(s.url);
            client.DefaultRequestHeaders.Accept.Clear();
            client.DefaultRequestHeaders.Accept.Add(
                new MediaTypeWithQualityHeaderValue("application/json"));
            BillInfo b = new BillInfo();

            b.IdBill = idBill;
            b.IdMenu = idMenu;
            b.Count  = count;
            HttpResponseMessage responsePost = await client.PutAsJsonAsync("api/BillInfo", b);
        }
        public async void UpdateMenu(string name, int price, string status, int idMenu)
        {
            HttpClient    client = new HttpClient();
            StringBaseAdd s      = new StringBaseAdd();

            client.BaseAddress = new Uri(s.url);
            client.DefaultRequestHeaders.Accept.Clear();
            client.DefaultRequestHeaders.Accept.Add(
                new MediaTypeWithQualityHeaderValue("application/json"));
            ENTITY.Menu mn = new ENTITY.Menu();
            mn.Name   = name;
            mn.Price  = price;
            mn.Status = status;
            mn.Id     = idMenu;


            HttpResponseMessage responsePost = await client.PutAsJsonAsync("api/Menu", mn);
        }
        //**********************************************************************
        //an


        public List <Table> getTableMenu_Area(string area)
        {
            List <Table>  lsTable = new List <Table>();
            HttpClient    client  = new HttpClient();
            StringBaseAdd s       = new StringBaseAdd();

            client.BaseAddress = new Uri(s.url);
            HttpResponseMessage response = client.GetAsync("api/Table").Result;
            List <Table>        data     = response.Content.ReadAsAsync <List <Table> >().Result;

            foreach (Table t in data)
            {
                if (t.Area == area)
                {
                    lsTable.Add(t);
                }
            }
            return(lsTable);
        }
        // kiểm tra nhân viên đã có tài khaorn chưa



        // tim kiem

        public bool CheckHaveAccount(int idEmp)
        {
            List <Account> lsAccount = new List <Account>();
            HttpClient     client    = new HttpClient();
            StringBaseAdd  s         = new StringBaseAdd();

            client.BaseAddress = new Uri(s.url);
            HttpResponseMessage respone = client.GetAsync("api/Account").Result;
            List <Account>      data    = respone.Content.ReadAsAsync <List <Account> >().Result;

            // chọn từng dòng trong bảng dữ liệu
            foreach (Account item in data)
            {
                if (idEmp == item.IdEmployee)
                {
                    return(false);
                }
                // bên class table đã khởi tạo contructor
            }
            return(true);
        }
        // lấy danh sách table từ csdl
        public List <Table> getListTable(int tt) //1 co nguoi , 0 ko có ngươi , 2 all
        {
            List <Table>  lsTable = new List <Table>();
            HttpClient    client  = new HttpClient();
            StringBaseAdd s       = new StringBaseAdd();

            client.BaseAddress = new Uri(s.url);
            HttpResponseMessage response = client.GetAsync("api/Table").Result;
            List <Table>        data     = response.Content.ReadAsAsync <List <Table> >().Result;

            switch (tt)
            {
            case 0:
                foreach (Table t in data)
                {
                    if (t.Status == 0)
                    {
                        lsTable.Add(t);
                    }
                }
                return(lsTable);

            case 1:
                foreach (Table t in data)
                {
                    if (t.Status != 0)
                    {
                        lsTable.Add(t);
                    }
                }
                return(lsTable);

            case 2:

                return(data);
            }

            return(lsTable);
        }
        public async void insertEmployee(Employee employee)
        {
            HttpClient    client = new HttpClient();
            StringBaseAdd s      = new StringBaseAdd();

            client.BaseAddress = new Uri(s.url);
            client.DefaultRequestHeaders.Accept.Clear();
            client.DefaultRequestHeaders.Accept.Add(
                new MediaTypeWithQualityHeaderValue("application/json"));
            try
            {
                HttpResponseMessage responsePost = await client.PostAsJsonAsync("api/Employee", employee);

                if (responsePost.IsSuccessStatusCode)
                {
                    Console.WriteLine("insert Employee success");
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
        public async void editTableMenu(int id, Table table)
        {
            HttpClient    client = new HttpClient();
            StringBaseAdd s      = new StringBaseAdd();

            client.BaseAddress = new Uri(s.url);
            client.DefaultRequestHeaders.Accept.Clear();
            client.DefaultRequestHeaders.Accept.Add(
                new MediaTypeWithQualityHeaderValue("application/json"));
            try
            {
                HttpResponseMessage responsePut = await client.PutAsJsonAsync("api/Table/" + id, table);

                if (responsePut.IsSuccessStatusCode)
                {
                    Console.WriteLine("Update TableMenu success");
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }