Exemplo n.º 1
0
        private bool CheckFields()
        {
            decimal amt = FncFilter.GetDecimalValue(tbPrice.Text);

            if (amt == 0)
            {
                FncFilter.Alert(globalvariables.warning_invalid_amount);
                tbPrice.Focus();
                tbPrice.SelectAll();
                return(false);
            }

            tbProductName.Text.Trim();
            if (tbProductName.Text == "")
            {
                FncFilter.Alert(globalvariables.warning_invalid_product);
                tbProductName.Focus();
                tbProductName.SelectAll();
                return(false);
            }

            tbStockNo.Text.Trim();
            if (tbStockNo.Text == "")
            {
                FncFilter.Alert(globalvariables.warning_invalid_stockno);
                tbStockNo.Focus();
                tbStockNo.SelectAll();
                return(false);
            }

            return(true);
        }
Exemplo n.º 2
0
        private void btnPayment_Click(object sender, EventArgs e)
        {
            decimal tendered  = FncFilter.GetDecimalValue(tbPrice.Text);
            decimal amountdue = FncFilter.GetDecimalValue(lblDueAmount.Text);

            SaveTransaction(amountdue, tendered);
        }
Exemplo n.º 3
0
        private void bgwSearchProduct_DoWork(object sender, DoWorkEventArgs e)
        {
            string SQLSearch = "";

            e.Result = false;
            string str_input = "";

            string[] words = this.txtKeyword.Text.Split(' ');
            foreach (string word in words)
            {
                if (word.Length > 0)
                {
                    str_input += "%" + word;
                }
            }
            str_input += "%";
            SQLSearch  = string.Format(@"SELECT * 
                                FROM Product 
                                WHERE (productname LIKE '{0}' OR
                                    barcode LIKE '{1}' OR
                                    stockno LIKE '{2}')", str_input, str_input, str_input);



            DataTable productDataTable = DataBaseHelper.GetDB(SQLSearch);

            products.Clear();
            this.bgwSearchProduct.ReportProgress(0);
            //dgvProduct.DataSource = result;
            foreach (DataRow productDataRow in productDataTable.Rows)
            {
                decimal actualPrice = Convert.ToDecimal(productDataRow["price"].ToString());
                products.Add(
                    new Product
                {
                    ID      = Convert.ToInt64(productDataRow["id"]),
                    Name    = productDataRow["productname"].ToString(),
                    Barcode = productDataRow["barcode"].ToString(),
                    StockNo = productDataRow["stockno"].ToString(),
                    Price   = actualPrice,
                    Qty     = FncFilter.GetDecimalValue(productDataRow["inventory"].ToString()),
                    Show    = Convert.ToInt32(productDataRow["discontinued"].ToString())
                }
                    );
            }
            longestProductName = null;
            List <string> productNames = new List <string>();

            if (products.Count != 0)
            {
                products.ForEach(x => productNames.AddRange(x.Name.Split(' ')));
                int    textLength  = productNames.Max(s => s.Length);
                string productName = productNames.FirstOrDefault(s => s.Length == textLength);
                longestProductName = products.FirstOrDefault(s => s.Name.Contains(productName));
            }
            this.bgwSearchProduct.ReportProgress(1);
        }
Exemplo n.º 4
0
        private void btnAddProduct_Click(object sender, EventArgs e)
        {
            if (!CheckFields())
            {
                return;
            }

            if (!forUpdate)
            {
                decimal price   = FncFilter.GetDecimalValue(tbPrice.Text);
                string  name    = tbProductName.Text;
                string  stockno = tbStockNo.Text;

                Product newproduct = new Product()
                {
                    Name    = name,
                    StockNo = stockno,
                    Price   = price
                };
                if (!DataHandler.SaveProduct(newproduct))
                {
                    FncFilter.Alert(globalvariables.saving_failed);
                    return;
                }
                else
                {
                    FncFilter.Alert(globalvariables.saving_success);
                    newProduct = true;
                    this.Close();
                }
            }
            else
            {
                decimal price   = FncFilter.GetDecimalValue(tbPrice.Text);
                string  name    = tbProductName.Text;
                string  stockno = tbStockNo.Text;

                product.Name    = name;
                product.Price   = price;
                product.StockNo = stockno;
                product.Show    = cbProductStatus.Checked ? 1 : 0;

                if (!DataHandler.UpdateProduct(product))
                {
                    FncFilter.Alert(globalvariables.saving_failed);
                    return;
                }
                else
                {
                    FncFilter.Alert(globalvariables.saving_success);
                    newProduct = true;
                    this.Close();
                }
            }
        }
Exemplo n.º 5
0
        private void btnChangeQty_Click(object sender, EventArgs e)
        {
            if (dgvAdjustments.SelectedRows.Count <= 0)
            {
                return;
            }

            int     index = dgvAdjustments.SelectedRows[0].Index;
            decimal qty   = FncFilter.GetDecimalValue(lblQtyD.Text);

            adjustments[index].Quantity = qty;

            dgvAdjustments.Refresh();
            RefreshDetails();
        }
Exemplo n.º 6
0
        private void btnChangeQty_Click(object sender, EventArgs e)
        {
            if (dgvTransactionProduct.SelectedRows.Count <= 0)
            {
                return;
            }

            int     index = dgvTransactionProduct.SelectedRows[0].Index;
            decimal qty   = FncFilter.GetDecimalValue(lblQtyD.Text);

            transaction.productlist[index].Qty = qty;

            dgvTransactionProduct.Refresh();
            RefreshTransactionDetails();
        }