Пример #1
0
        public IHttpActionResult Putproduct(Products objProducts)
        {
            string resp   = string.Empty;
            long   result = 0;

            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest("Not a valid model"));
                }
                Products    objproducts    = new Products();
                BLInventory objBLInventory = new BLInventory();
                result = objBLInventory.UpdateProduct(objProducts);
                if (result > 0)
                {
                    resp = "{\"status\":\"SUCCESS\",\"data\":\"Item has been updated successfully\"}";  // TEST !!!!!
                }
                else
                {
                    resp = "{\"status\":\"FAIL\"}";  // TEST !!!!!
                }
                return(Ok(JsonConvert.SerializeObject(resp)));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #2
0
 private void tsbDelete_ItemClick(object sender, DevExpress.Xpf.Bars.ItemClickEventArgs e)
 {
     try
     {
         InventoryID = GridListItem.GetFocusedRowCellValue("InventoryID").ToString();
         BLInventory.DeleteInventory(InventoryID);
         LoadItemGrid();
         GridListItem.FocusRowHandle(GridListItem.ReturnVisibleRowCount - 1);
     }
     catch (NullReferenceException)
     {
         MessageBox.Show("Lỗi không thể xóa được bảng trống");
     }
 }
Пример #3
0
 public IEnumerable <Products> GetAllProducts()
 {
     //List<Products> objProductsList = new List<Products>();
     try
     {
         BLInventory objBLInventory  = new BLInventory();
         var         objProductsList = objBLInventory.GetAllProducts();
         return(objProductsList);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Пример #4
0
        public IHttpActionResult GetProduct(int id)
        {
            try
            {
                Products    objproducts    = new Products();
                BLInventory objBLInventory = new BLInventory();
                objproducts = objBLInventory.GetProduct(id);

                if (objproducts == null)
                {
                    return(NotFound());
                }
                else
                {
                    return(Ok(objproducts));
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #5
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            DataTable dt1 = BLInventory.LoadUnitID();

            lkeUnitID.ItemsSource = dt1;
            item.ImageLocation    = "addnewimage.png";
            sePrice.InputNumber288("n0", false, false);
            seVAT.InputNumber288("n0", false, false);
            seVAT.InputPercent(false, false, 28, 8);
            if (D00F1040.IsAddItem == false)
            {
                DataTable dt = BLInventory.LoadInventory(D00F1040.InventoryID);
                txtInventoryName.Text = dt.Rows[0]["InventoryName"].ToString();
                lkeUnitID.EditValue   = dt.Rows[0]["UnitID"];
                sePrice.Value         = Convert.ToDecimal(dt.Rows[0]["Price"]);
                txtNotes.Text         = dt.Rows[0]["Notes"].ToString();
                seVAT.Value           = Convert.ToDecimal(dt.Rows[0]["VAT"]) * 100;
                txtBarcode.Text       = dt.Rows[0]["BarCode"].ToString();
                var uriSource = new Uri(@"/Mita_Coffee;component/Images/" + dt.Rows[0]["ImageLocation"], UriKind.Relative);
                ieImage.Source     = new BitmapImage(uriSource);
                item.ImageLocation = dt.Rows[0]["ImageLocation"].ToString();
            }
        }
Пример #6
0
        public IHttpActionResult DeleteProduct(int id)
        {
            string resp = string.Empty;

            if (id <= 0)
            {
                return(BadRequest("Not a valid product id"));
            }

            BLInventory objBLInventory = new BLInventory();
            var         objresult      = objBLInventory.DeleteProduct(id);

            if (objresult > 0)
            {
                resp = "{\"status\":\"SUCCESS\",\"data\":\"Item has been deleted successfully\"}";  // TEST !!!!!
            }
            else
            {
                resp = "{\"status\":\"FAIL\"}";  // TEST !!!!!
            }

            return(Ok(JsonConvert.SerializeObject(resp)));
        }
Пример #7
0
        public void LoadItemGrid()
        {
            DataTable dt = BLInventory.LoadItem();

            GridListItem.ItemsSource = dt;
        }
Пример #8
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            item.InventoryName = txtInventoryName.Text;
            try
            {
                item.UnitID = lkeUnitID.EditValue.ToString();
            }
            catch (NullReferenceException)
            {
                item.UnitID = "";
                MessageBox.Show("Không được để trống đơn vị tính!", "Lỗi");
            }
            item.Price   = sePrice.Value;
            item.Notes   = txtNotes.Text;
            item.VAT     = Decimal.Divide(seVAT.Value, 100);
            item.BarCode = txtBarcode.Text;
            switch (D00F1040.IsAddItem)
            {
            case true:
                if (txtInventoryName.Text != "")
                {
                    bool add = BLInventory.AddNewItem(item.InventoryName, item.UnitID, L3SQLClient.SQLMoney(item.Price, "n0"), item.Notes, L3SQLClient.SQLMoney(item.VAT, "n4"), item.BarCode, L3.UserID, item.ImageLocation);
                    if (add)
                    {
                        MessageBox.Show("Thêm mới thành công!", "Yeah!");

                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("Thêm mới thất bại!", "Lỗi");
                    }
                }
                else
                {
                    MessageBox.Show("Không được để trống tên hàng hóa!", "Lỗi");
                }
                break;

            case false:
                if (txtInventoryName.Text != "")
                {
                    bool edit = BLInventory.EditItem(D00F1040.InventoryID, item.InventoryName, item.UnitID, L3SQLClient.SQLMoney(item.Price, "n0"), item.Notes, L3SQLClient.SQLMoney(item.VAT, "n4"), item.BarCode, L3.UserID, item.ImageLocation);
                    if (edit)
                    {
                        MessageBox.Show("Sửa thành công!", "Yeah!");

                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("Sửa thất bại!", "Lỗi");
                    }
                }
                else
                {
                    MessageBox.Show("Không được để trống tên hàng hóa!", "Lỗi");
                }
                break;
            }
        }