private void btnDeleteQuatity_Click(object sender, RoutedEventArgs e) { if (dtGrid.Rows.Count > 0) { string InventoryID = GridVoucherInventory.GetFocusedRowCellValue(COL_InventoryID).ToString(); int n = BLVoucher.GetCurrentRowIndex(GridVoucherInventory, "InventoryID"); int value_Old = L3ConvertType.L3Int(GridVoucherInventory.GetCellValue(n, COL_Quantity)); int stock_Old = L3ConvertType.L3Int(GridVoucherInventory.GetCellValue(n, COL_InStock)); if (value_Old > 1) { GridVoucherInventory.SetCellValue(n, "Quantity", value_Old - 1); GridVoucherInventory.SetCellValue(n, "InStock", stock_Old + 1); CalAmountGrid(n); } else if (value_Old == 1) { GridVoucherInventory.DeleteRowFocusEvent(); } CalAmount(); btnSave.IsEnabled = true; } if (GridVoucherInventory.VisibleRowCount == 0) { btnAddQuatity.IsEnabled = false; btnDeleteQuatity.IsEnabled = false; btnAdd10Quatity.IsEnabled = false; } }
private void lbeSuggestion_EditValueChanged(object sender, DevExpress.Xpf.Editors.EditValueChangedEventArgs e) { string sInventoryID = lbeSuggestion.EditValue.ToString(); DataTable dt = BLTable.SelectInventoryID(sInventoryID); string sInventoryName = ""; if (dt.Rows.Count > 0 && Convert.ToDecimal(dt.Rows[0]["InStock"]) > 0) { btnPay.IsEnabled = true; sInventoryName = L3ConvertType.L3String(dt.Rows[0]["InventoryName"]); int irow = GridVoucherInventory.FindRowByValue("InventoryID", sInventoryID); if (irow >= 0) { int value_Old = L3ConvertType.L3Int(GridVoucherInventory.GetCellValue(irow, COL_Quantity)); int stock_Old = L3ConvertType.L3Int(GridVoucherInventory.GetCellValue(irow, COL_InStock)); if (stock_Old > 0) { GridVoucherInventory.SetCellValue(irow, "Quantity", value_Old + 1); GridVoucherInventory.SetCellValue(irow, "InStock", stock_Old - 1); } CalAmountGrid(irow); } else { DataRow dr = dtGrid.NewRow(); dr["InventoryID"] = sInventoryID; dr["InventoryName"] = dt.Rows[0]["InventoryName"]; dr["UnitID"] = dt.Rows[0]["UnitID"]; dr["InStock"] = Convert.ToDecimal(dt.Rows[0]["InStock"]) - 1; dr["Quantity"] = 1; dr["Price"] = dt.Rows[0]["Price"]; dr["VAT"] = dt.Rows[0]["VAT"]; dr["Amount"] = L3ConvertType.Number(dr["Quantity"]) * L3ConvertType.Number(dr["Price"]) * (1 - L3ConvertType.Number(dr["VAT"])); dtGrid.Rows.Add(dr); } btnSave.IsEnabled = true; btnDeleteQuatity.IsEnabled = true; btnAddQuatity.IsEnabled = true; btnAdd10Quatity.IsEnabled = true; } else { MessageBox.Show("Đã hết hàng!"); } CalAmount(); txtItem.Text = ""; lbeSuggestion.Visibility = Visibility.Collapsed; lbeSuggestion.EditValue = null; }
private void btnAdd10Quatity_Click(object sender, RoutedEventArgs e) { int n = BLVoucher.GetCurrentRowIndex(GridVoucherInventory, "InventoryID"); try { int value_Old = L3ConvertType.L3Int(GridVoucherInventory.GetCellValue(n, COL_Quantity)); int stock_Old = L3ConvertType.L3Int(GridVoucherInventory.GetCellValue(n, COL_InStock)); if (stock_Old >= 10) { GridVoucherInventory.SetCellValue(n, "Quantity", value_Old + 10); GridVoucherInventory.SetCellValue(n, "InStock", stock_Old - 10); } CalAmountGrid(n); } catch (Exception) { MessageBox.Show("Lỗi!"); } CalAmount(); btnSave.IsEnabled = true; }