Example #1
0
        private void btnAddProductNumber_Click(object sender, EventArgs e)
        {
            tbMsg.EditValue = null;
            if (TBBarcode.EditValue == null || tbQuiNumber.EditValue == null || tbPriceNumber.EditValue == null)//check if informations aren't complate
            {
                tbMsg.EditValue = Properties.Resources.BillItemInfoNotComplate;
                return;
            }

            DataSources.dsTinyData ds = new DataSources.dsTinyData();
            billProductsInfoTableAdapter.FillByProductNumber(ds.BillProductsInfo, TBBarcode.EditValue.ToString());
            DataSources.dsTinyData.BillProductsInfoRow row = (DataSources.dsTinyData.BillProductsInfoRow)ds.BillProductsInfo.Rows[0];

            DataSources.dsTinyData.BillDetailsRow NewItem = dsTinyData.BillDetails.NewBillDetailsRow();
            NewItem.ProductID = row.ProductID;
            NewItem.UnitPrice = Convert.ToDouble(tbPriceNumber.EditValue);
            NewItem.Quantity = Convert.ToInt32(tbQuiNumber.EditValue);

            if (Convert.ToInt32(tbQuiNumber.EditValue) > NewItem.BillProductsInfoRow.ItemCount && ToStorage() == false)//check if item count avilable
            {
                tbMsg.EditValue = Properties.Resources.ProductInsufficient;
                return;
            }
            for (int i = 0; i < dsTinyData.BillDetails.Rows.Count; i++)//check if item already exists
            {
                DataSources.dsTinyData.BillDetailsRow item = (DataSources.dsTinyData.BillDetailsRow)dsTinyData.BillDetails.Rows[i];
                if (item.RowState == DataRowState.Deleted)
                    continue;
                if (item.ProductID == NewItem.ProductID)
                {
                    tbMsg.EditValue = Properties.Resources.BillItemDuplicate;
                    return;
                }
            }
            dsTinyData.BillDetails.AddBillDetailsRow(NewItem);
            TBBarcode.Focus();
        }
Example #2
0
        private void TBBarcode_KeyDown(object sender, KeyEventArgs e)
        {
            if (TBBarcode.EditValue == null)
                return;
            if (e.KeyCode != Keys.Enter)
                return;
            try
            {
                DataSources.dsTinyData ds = new DataSources.dsTinyData();
                billProductsInfoTableAdapter.FillByProductNumber(ds.BillProductsInfo, TBBarcode.EditValue.ToString());
                if (ds.BillProductsInfo.Count == 0)
                {
                    tbMsg.EditValue = Properties.Resources.ProductNotFound;
                    TBBarcode.Text = string.Empty;
                    TBBarcode.Focus();
                    return;
                }
                DataSources.dsTinyData.BillProductsInfoRow row = (DataSources.dsTinyData.BillProductsInfoRow)ds.BillProductsInfo.Rows[0];
                tbQuiNumber.EditValue = 1;
                switch (_row.BillTypeID)
                {
                    case (int)misc.BillType.Tawreed:
                    case (int)misc.BillType.Hawaleek:
                        tbPriceNumber.EditValue = row.BuyPrice;
                        break;
                    case (int)misc.BillType.Baye3:
                    case (int)misc.BillType.Mortaga3:
                        tbPriceNumber.EditValue = row.SellPrice;
                        break;
                }
                btnAddProductNumber_Click(btnAddProductNumber, EventArgs.Empty);
            }
            catch { }

            TBBarcode.Text = string.Empty;
            TBBarcode.Focus();
        }