public List <CTHoaDonBan_DTO> SearchCTHD(int id, string str)
        {
            List <CTHoaDonBan_DTO> CTHDList = new List <CTHoaDonBan_DTO>();
            DataTable data = DataProvider.Instance.ExecuteQuery("EXEC proc_searchCTHoaDonBan  @id , @str", new object[] { id, str });

            foreach (DataRow item in data.Rows)
            {
                CTHoaDonBan_DTO cthoadonban = new CTHoaDonBan_DTO(item);
                CTHDList.Add(cthoadonban);
            }
            return(CTHDList);
        }
        public List <CTHoaDonBan_DTO> GetCTHoaDonBan(int ID)
        {
            List <CTHoaDonBan_DTO> ListCTHoaDonBan = new List <CTHoaDonBan_DTO>();
            DataTable data = DataProvider.Instance.ExecuteQuery("proc_GetListCTHD  @ID", new object[] { ID });

            foreach (DataRow item in data.Rows)
            {
                CTHoaDonBan_DTO cthoadonban = new CTHoaDonBan_DTO(item);
                ListCTHoaDonBan.Add(cthoadonban);
            }
            return(ListCTHoaDonBan);
        }
Example #3
0
        public IHttpActionResult Post(CTHoaDonBan_DTO x)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest("Not a valid model"));
                }

                CTHoaDonBan_DAO.Instance.Insert_CTHoaDonBan(x.MaGiay, x.TenGiay, x.SoLuong);
            }
            catch (Exception)
            {
            }
            return(Ok());
        }
Example #4
0
        private void btnThemCTKM_Click(object sender, EventArgs e)
        {
            if (txtMaHD.Text == "" || txtSoLuong.Text == "")
            {
                MessageBox.Show("Sai hoặc thiếu thông tin");
                Load();
            }
            else
            {
                int MaHD;
                Int32.TryParse(txtMaHD.Text, out MaHD);
                int MaGiay;
                Int32.TryParse(txtMaGiay.Text, out MaGiay);
                int SoLuong;
                Int32.TryParse(txtSoLuong.Text, out SoLuong);


                CTHoaDonBan_DTO HD = new CTHoaDonBan_DTO(MaHD, MaGiay, SoLuong);
                using (var client = new HttpClient())
                {
                    client.BaseAddress = new Uri(baseAddress);

                    //HTTP POST api/HoaDonBan?hoadon={hoadon}
                    var postTask = client.PostAsJsonAsync <CTHoaDonBan_DTO>("CTHoaDonBan", HD);
                    postTask.Wait();

                    var result = postTask.Result;
                    if (result.IsSuccessStatusCode)
                    {
                        MessageBox.Show("Thêm CTHD thành công", "Thông báo", MessageBoxButtons.OK);
                    }
                    else
                    {
                        MessageBox.Show("Thêm CTHD không thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    Load();
                }
            }
        }