/// <summary> /// Adds an Item to the item definitions /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void AddButton_Click(object sender, RoutedEventArgs e) { try { ItemCodeTextBox.IsReadOnly = false; AddEditItemGrpbx.Visibility = Visibility.Visible; ViewModel.SelectedItem = null; ItemCodeTextBox.Focus(); } catch (Exception ex) { Error.HandleError(MethodInfo.GetCurrentMethod().DeclaringType.Name, MethodInfo.GetCurrentMethod().Name, ex); } }
protected void OKButton_Click(object sender, EventArgs e) { DateTime valueDate = DateTime.MinValue; int storeId = 0; string transactionType = string.Empty; string partyCode = string.Empty; partyCode = PartyDropDownList.SelectedItem.Value; if (DateTextBox != null) { valueDate = MixERP.Net.Common.Conversion.TryCastDate(DateTextBox.Text); } if (StoreDropDownList.SelectedItem != null) { storeId = MixERP.Net.Common.Conversion.TryCastInteger(StoreDropDownList.SelectedItem.Value); } if (TransactionTypeRadioButtonList.SelectedItem != null) { transactionType = TransactionTypeRadioButtonList.SelectedItem.Value; } if (string.IsNullOrWhiteSpace(partyCode)) { MixERP.Net.BusinessLayer.Helpers.FormHelper.MakeDirty(PartyCodeTextBox); MixERP.Net.BusinessLayer.Helpers.FormHelper.MakeDirty(PartyDropDownList); PartyCodeTextBox.Focus(); return; } if (valueDate.Equals(DateTime.MinValue)) { ErrorLabelTop.Text = Resources.Warnings.InvalidDate; DateTextBox.CssClass = "dirty"; DateTextBox.Focus(); return; } if (this.Book == Common.Models.Transactions.TranBook.Sales) { if (StoreDropDownList.Visible) { if (!MixERP.Net.BusinessLayer.Office.Stores.IsSalesAllowed(storeId)) { ErrorLabelTop.Text = Resources.Warnings.SalesNotAllowedHere; MixERP.Net.BusinessLayer.Helpers.FormHelper.MakeDirty(StoreDropDownList); return; } } if (TransactionTypeRadioButtonList.Visible) { if (transactionType.Equals(Resources.Titles.Credit)) { if (!MixERP.Net.BusinessLayer.Core.Parties.IsCreditAllowed(partyCode)) { ErrorLabelTop.Text = Resources.Warnings.CreditNotAllowed; return; } } } } ModeHiddenField.Value = "Started"; this.SetControlStates(); ItemCodeTextBox.Focus(); }
protected void AddButton_Click(object sender, EventArgs e) { string itemCode = ItemCodeTextBox.Text; string itemName = ItemDropDownList.SelectedItem.Text; int quantity = MixERP.Net.Common.Conversion.TryCastInteger(QuantityTextBox.Text); string unit = UnitDropDownList.SelectedItem.Text; int unitId = MixERP.Net.Common.Conversion.TryCastInteger(UnitDropDownList.SelectedItem.Value); decimal itemInStock = 0; decimal price = MixERP.Net.Common.Conversion.TryCastDecimal(PriceTextBox.Text); decimal discount = MixERP.Net.Common.Conversion.TryCastDecimal(DiscountTextBox.Text); decimal taxRate = MixERP.Net.Common.Conversion.TryCastDecimal(TaxRateTextBox.Text); decimal tax = MixERP.Net.Common.Conversion.TryCastDecimal(TaxTextBox.Text); int storeId = 0; if (StoreDropDownList.SelectedItem != null) { storeId = MixERP.Net.Common.Conversion.TryCastInteger(StoreDropDownList.SelectedItem.Value); } #region Validation if (string.IsNullOrWhiteSpace(itemCode)) { MixERP.Net.BusinessLayer.Helpers.FormHelper.MakeDirty(ItemCodeTextBox); return; } else { MixERP.Net.BusinessLayer.Helpers.FormHelper.RemoveDirty(ItemCodeTextBox); } if (!MixERP.Net.BusinessLayer.Core.Items.ItemExistsByCode(itemCode)) { MixERP.Net.BusinessLayer.Helpers.FormHelper.MakeDirty(ItemCodeTextBox); return; } else { MixERP.Net.BusinessLayer.Helpers.FormHelper.RemoveDirty(ItemCodeTextBox); } if (quantity < 1) { MixERP.Net.BusinessLayer.Helpers.FormHelper.MakeDirty(QuantityTextBox); return; } else { MixERP.Net.BusinessLayer.Helpers.FormHelper.RemoveDirty(QuantityTextBox); } if (!MixERP.Net.BusinessLayer.Core.Units.UnitExistsByName(unit)) { MixERP.Net.BusinessLayer.Helpers.FormHelper.MakeDirty(UnitDropDownList); return; } else { MixERP.Net.BusinessLayer.Helpers.FormHelper.RemoveDirty(UnitDropDownList); } if (price <= 0) { MixERP.Net.BusinessLayer.Helpers.FormHelper.MakeDirty(PriceTextBox); return; } else { MixERP.Net.BusinessLayer.Helpers.FormHelper.RemoveDirty(PriceTextBox); } if (discount < 0) { MixERP.Net.BusinessLayer.Helpers.FormHelper.MakeDirty(DiscountTextBox); return; } else { if (discount > (price * quantity)) { MixERP.Net.BusinessLayer.Helpers.FormHelper.MakeDirty(DiscountTextBox); return; } else { MixERP.Net.BusinessLayer.Helpers.FormHelper.RemoveDirty(DiscountTextBox); } } if (tax < 0) { MixERP.Net.BusinessLayer.Helpers.FormHelper.MakeDirty(TaxTextBox); return; } else { MixERP.Net.BusinessLayer.Helpers.FormHelper.RemoveDirty(TaxTextBox); } if (this.VerifyStock) { if (this.Book == Common.Models.Transactions.TranBook.Sales) { if (MixERP.Net.BusinessLayer.Core.Items.IsStockItem(itemCode)) { itemInStock = MixERP.Net.BusinessLayer.Core.Items.CountItemInStock(itemCode, unitId, storeId); if (quantity > itemInStock) { MixERP.Net.BusinessLayer.Helpers.FormHelper.MakeDirty(QuantityTextBox); ErrorLabel.Text = String.Format(System.Threading.Thread.CurrentThread.CurrentCulture, Resources.Warnings.InsufficientStockWarning, itemInStock.ToString("G29", System.Threading.Thread.CurrentThread.CurrentCulture), UnitDropDownList.SelectedItem.Text, ItemDropDownList.SelectedItem.Text); return; } } } } #endregion this.AddRowToTable(itemCode, itemName, quantity, unit, price, discount, taxRate, tax); this.BindGridView(); ItemCodeTextBox.Text = ""; QuantityTextBox.Text = "1"; PriceTextBox.Text = ""; DiscountTextBox.Text = ""; TaxTextBox.Text = ""; ItemCodeTextBox.Focus(); }