private void btnSave_Click(object sender, EventArgs e) { try { sup.sqlselect = "SELECT * From tblsupplier WHERE SupplierId=" + supplierid; sup.Single_Select(sup.sqlselect); if (sup.dt.Rows.Count > 0) { sup.sqledit = "UPDATE tblsupplier SET Supplier='" + txtSupplier.Text + "',ContactNo='" + txtContactNo.Text + "',Company='" + txtCompany.Text + "',CompanyAddress = '" + txtCompanyAddress.Text + "' WHERE SupplierId=" + supplierid; sup.SaveDataMsg(sup.sqledit, "Supplier has been updated in the database."); } else { sup.sqladd = "INSERT INTO tblsupplier (Supplier,ContactNo,Company,CompanyAddress) " + " VALUES ('" + txtSupplier.Text + "','" + txtContactNo.Text + "','" + txtCompany.Text + "','" + txtCompanyAddress.Text + "')"; sup.SaveDataMsg(sup.sqladd, "New Supplier has been saved in the database."); } frmSupplier_Load(sender, e); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void txtBarcode_TextChanged(object sender, EventArgs e) { try { //int maxrow = 0; //string itemid = txtBarcode.Text; double vat = 0.0; double totvat = 0.0; double tot = 0.0; if (txtBarcode.Text.Length == 11) { pro.sqlselect = "SELECT * FROM tblcategory c, tblproduct p WHERE p.CategoryId=c.CategoryId AND ProductQty > 0 And Barcode Like '%" + txtBarcode.Text + "%'"; pro.Single_Select(pro.sqlselect); if (pro.dt.Rows.Count > 0) { decimal markup = pro.dt.Rows[0].Field <decimal>("MarkupPrice"); string[] r = new string[] { pro.dt.Rows[0].Field <string>("Barcode"), pro.dt.Rows[0].Field <string>("ProductName"), pro.dt.Rows[0].Field <string>("Description"), markup.ToString("N2"), "1", markup.ToString("N2") }; dtgList.Rows.Add(r); txtBarcode.Clear(); txtBarcode.Focus(); for (int i = 0; i < dtgList.Rows.Count; i++) { tot += double.Parse(dtgList.Rows[i].Cells[5].Value.ToString()); } txtSubTotal.Text = tot.ToString("N2"); vat = tot * 0.12; //totvat = tot - vat; totvat = tot; txtTotalAmount.Text = totvat.ToString("N2"); // for(int i = 0;i<0;i++){ // } //For i = 0 To dtgCart.Rows.Count - 1 // tot += dtgCart.Rows(i).Cells(5).Value //Next } } } catch (Exception ex) { } }
private void txtBarcode_TextChanged(object sender, EventArgs e) { try { if (txtBarcode.Text != "") { if (txtBarcode.Text.Length >= 10) { pro.sqlselect = "SELECT * FROM tblcategory c, tblproduct p WHERE p.CategoryId=c.CategoryId And Barcode Like '%" + txtBarcode.Text + "%'"; pro.Single_Select(pro.sqlselect); if (pro.dt.Rows.Count > 0) { decimal price; txtProduct.Text = pro.dt.Rows[0].Field <string>("ProductName"); txtDescription.Text = pro.dt.Rows[0].Field <string>("Description"); txtCategory.Text = pro.dt.Rows[0].Field <string>("Category"); price = pro.dt.Rows[0].Field <decimal>("OriginalPrice"); txtPrice.Text = price.ToString("N2"); } else { txtProduct.Clear(); txtDescription.Clear(); txtPrice.Clear(); txtCategory.Clear(); txtQty.Clear(); txtBarcode.Focus(); } } else { txtProduct.Clear(); txtDescription.Clear(); txtPrice.Clear(); txtCategory.Clear(); txtQty.Clear(); txtBarcode.Focus(); } } else { txtProduct.Clear(); txtDescription.Clear(); txtPrice.Clear(); txtCategory.Clear(); txtQty.Clear(); txtBarcode.Focus(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
//FILL BAR CODE private void txtBarCode_TextChanged(object sender, EventArgs e) { try { double vat = 0.0; double tot = 0.0; if (txtBarCode.Text.Length == 13) { pro.sqlselect = " SELECT Item_Name, Bar_Code, Units, Avg_SP FROM Stock_Items_View WHERE Bar_Code LIKE '%" + txtBarCode.Text + "%' "; pro.Single_Select(pro.sqlselect); if (pro.dt.Rows.Count > 0) { decimal unitPrice = pro.dt.Rows[0].Field <decimal>("Avg_SP"); string[] r = new string[] { pro.dt.Rows[0].Field <string>("Bar_Code"), pro.dt.Rows[0].Field <string>("Item_Name"), unitPrice.ToString("N2"), "1" }; dataGridList.Rows.Add(r); txtBarCode.Clear(); txtBarCode.Focus(); for (int i = 0; i < dataGridList.Rows.Count; i++) { tot += double.Parse(dataGridList.Rows[i].Cells[2].Value.ToString()); } label_SubTotal.Text = tot.ToString("N2"); label_Tax.Text = vat.ToString(); label_Total.Text = tot.ToString("N2"); label_ToPay.Text = tot.ToString("N2"); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void dtgList_Click(object sender, EventArgs e) { int qty; //MessageBox.Show("true"); prolist.sqlselect = "SELECT * FROM tblproduct WHERE Barcode = " + dtgList.CurrentRow.Cells[0].Value; prolist.Single_Select(prolist.sqlselect); qty = prolist.dt.Rows[0].Field <int>("ProductQty"); if (qty <= 5) { DialogResult result = MessageBox.Show("Product quantity is in critical level. Do you want to re-order this product?", "Re-Order", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result == DialogResult.Yes) { //frmPurchaseOrder frm = new frmPurchaseOrder(dtgList.CurrentRow.Cells[0].Value.ToString()); //frm.Show(); //frm.Focus(); LoadData(); txtBarcode.Text = dtgList.CurrentRow.Cells[0].Value.ToString(); pnlReorder.Visible = true; txtQty.Focus(); } } else if (qty <= 10) { DialogResult result = MessageBox.Show("Product quantity is in warning level. Do you want to re-order this product?", "Re-Order", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result == DialogResult.Yes) { //frmPurchaseOrder frm = new frmPurchaseOrder(dtgList.CurrentRow.Cells[0].Value.ToString()); //frm.Show(); //frm.Focus(); LoadData(); txtBarcode.Text = dtgList.CurrentRow.Cells[0].Value.ToString(); pnlReorder.Visible = true; txtQty.Focus(); } } }
private void txtBarcode_TextChanged(object sender, EventArgs e) { try { decimal price, markup; if (txtBarcode.Text != "") { if (txtBarcode.Text.Length >= 11) { pro.sqlselect = "SELECT ProductId,ProductName,Description,OriginalPrice,MarkupPrice,Category + '[' + CategoryType + ']' as 'Category' FROM tblcategory c, tblproduct p WHERE p.CategoryId=c.CategoryId And Barcode = '" + txtBarcode.Text + "'"; pro.Single_Select(pro.sqlselect); if (pro.dt.Rows.Count > 0) { lblProductId.Text = pro.dt.Rows[0].Field <string>("ProductId"); txtProduct.Text = pro.dt.Rows[0].Field <string>("ProductName"); txtDescription.Text = pro.dt.Rows[0].Field <string>("Description"); price = pro.dt.Rows[0].Field <decimal>("OriginalPrice"); markup = pro.dt.Rows[0].Field <decimal>("MarkupPrice"); txtPrice.Text = price.ToString("N2"); txtMarkupPrice.Text = markup.ToString("N2"); cboCategory.Text = pro.dt.Rows[0].Field <string>("Category"); } else { clearProduct(); } } else { clearProduct(); } } else { clearProduct(); } } catch (Exception ex) { //MessageBox.Show(ex.Message); } }