private void grdItemDetail_PreviewKeyDown(object sender, KeyEventArgs e) { try { var uiElement = e.OriginalSource as UIElement; if (e.Key == Key.Enter && uiElement != null) { e.Handled = true; ViewModel.BarcodeNo = ViewModel.SelectedItemProfile.Barcode; ViewModel.CustomerQuantity = ViewModel.SelectedItemProfile.ItemQuantity; object item = ItemGrid.SelectedItem; //TxtBarcode.Text = ((POSItemAC)item).Barcode; //txtQuantity.Text = ((POSItemAC)item).ItemQuantiy.ToString(); ViewModel.SelectedItemProfile = (POSItemDetail)ItemGrid.SelectedItem; SettingHelpers.CurrentPosItemId = ViewModel.SelectedItemProfile.PosItemId; // ViewModel.CurrentItemProfile = item as POSItemAC; ViewModel.ItemName = ViewModel.SelectedItemProfile.ItemName; TxtQuantity.SelectAll(); TxtQuantity.Focus(); SettingHelpers.IsItemSelected = true; } } catch (Exception) { throw; } }
private void button1_Click_1(object sender, EventArgs e) { bool isValidNumeric3 = ValidateNumber(TxtQuantity.Text); if (txttrantype.Text != "") { if (Convert.ToInt32(TxtQuantity.Text) > Convert.ToInt32(lblStock.Text)) { MessageBox.Show("Invalid Quantity", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); TxtQuantity.Focus(); return; } } if (isValidNumeric3 == false) { MessageBox.Show("Invalid Format", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); TxtQuantity.Focus(); } else if (lblItemCode.Text == "-----") { MessageBox.Show("Please select Item.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); cboCategory1.Focus(); } else if (TxtQuantity.Text == "") { MessageBox.Show("Input Quantity", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); TxtQuantity.Focus(); } else if (cboUOM.SelectedValue == "" || cboUOM.SelectedValue == null) { MessageBox.Show("Input UOM.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); cboUOM.Focus(); } else { this.dataGridView1.Rows.Add("Remove", TxtQuantity.Text, cboUOM.SelectedValue.ToString(), lblItemCode.Text, lblCategory1.Text, lblCategory2.Text, lblCategory3.Text, LBLSpecs1.Text, lblSpecs2.Text, lblSpecs3.Text, lblCurrency.Text, lblCostCode.Text, lblDefaultPrice.Text, txtItemMasterID.Text); productAttr.Quantity = decimal.Parse(TxtQuantity.Text); ProductAttributes.Add(productAttr); ClearFields(); } }
private void btnAddToCart_Click(object sender, RoutedEventArgs e) { if (TxtQuantity.Text == "") { MessageBox.Show("Fill column quantity please", "Alert", MessageBoxButton.OK); TxtQuantity.Focus(); } else { try { var dataItem = GridTransItem.SelectedItem; var itemFK = myContext.Items.FirstOrDefault(data => data.Id == itemid); var transFK = myContext.Transactions.FirstOrDefault(data => data.Id.ToString() == TxtTransId.Text); var transitem = myContext.TransactionItems.FirstOrDefault(data => data.TransactionFK.Id.ToString() == TxtTransId.Text); var iditems = TransDetail.Find(a => a.ItemFK.Id == itemid); if (iditems == null) { if (Convert.ToInt32(TxtQuantity.Text) <= itemFK.Stock) { itemFK.Stock -= Convert.ToInt32(TxtQuantity.Text); TransDetail.Add(new TransactionItem { TransactionFK = transFK, ItemFK = itemFK, Quantity = Convert.ToInt32(TxtQuantity.Text), SubTotal = getTotal() }); GridTransItem.Items.Add(new { NameItem = itemFK.Name.ToString(), Quantity = TxtQuantity.Text, SubTotal = getTotal() }); grandTotal += getTotal(); TxtTotal.Text = Convert.ToString(grandTotal); Load(); } else { MessageBox.Show("Quantity exceeds stock limit"); } } else { if (iditems.ItemFK.Id == itemid) { if (Convert.ToInt32(TxtQuantity.Text) <= itemFK.Stock) { itemFK.Stock -= Convert.ToInt32(TxtQuantity.Text); int Qty = iditems.Quantity + Convert.ToInt32(TxtQuantity.Text); int subTotal = iditems.SubTotal + getTotal(); GridTransItem.SelectedIndex = iditems.ItemFK.Id; var index = Convert.ToInt32(iditems.Id); GridTransItem.Items.RemoveAt(index); //GridTransItem.Items.Remove(GridTransItem.SelectedItem); GridTransItem.Items.Add(new { NameItem = itemFK.Name.ToString(), Quantity = Qty, SubTotal = subTotal }); TransDetail.Add(new TransactionItem { TransactionFK = transFK, ItemFK = itemFK, Quantity = Qty, SubTotal = subTotal }); TransDetail.Remove(iditems); grandTotal += getTotal(); TxtTotal.Text = Convert.ToString(grandTotal); Load(); } else { MessageBox.Show("Quantity exceeds stock limit"); } } } } catch (Exception x) { MessageBox.Show(x.Message); } //comboBoxItem.Text = "--Choose Item--"; TxtPay.IsEnabled = true; btnAddToCart.IsEnabled = true; btnDeleteTrans.IsEnabled = true; btnCancel.IsEnabled = true; } }