private void LoadItemInformation() { if (txtitemcode.Text != "") { stockid = ""; query = "select ItemInformation.Description, Inventory.Cost, Inventory.SellPrice, Inventory.ID, Inventory.ItemCode from ItemInformation, Inventory where ItemInformation.ItemCode=Inventory.ItemCode and Inventory.Quantity>0 and Inventory.ItemCode='" + txtitemcode.Text + "' or Inventory.BarcodeText='" + txtitemcode.Text + "'"; tb = db.Search(query); if (tb.Rows.Count > 0) { stockid = tb.Rows[0][3].ToString(); itemcode = tb.Rows[0][4].ToString(); txtdescription.Text = tb.Rows[0][0].ToString(); txtcostprice.Text = tb.Rows[0][1].ToString(); if (chkreturn.Checked) { txtsellprice.Text = "-" + tb.Rows[0][2].ToString(); tempsellprice = txtsellprice.Text; } else { txtsellprice.Text = tb.Rows[0][2].ToString(); tempsellprice = txtsellprice.Text; } txtsubtotal.Text = (double.Parse(txtquantity.Text) * double.Parse(txtsellprice.Text)).ToString(); if (tb.Rows.Count > 1) { Clipboard.Clear(); Choose_Items cr = new Choose_Items(); cr.ItemCode = txtitemcode.Text; cr.ShowDialog(); if (Clipboard.GetText() != "") { query = "select Cost, SellPrice,ID from Inventory where ID='" + Clipboard.GetText() + "'"; tb = db.Search(query); if (tb.Rows.Count > 0) { stockid = tb.Rows[0][2].ToString(); txtcostprice.Text = tb.Rows[0][0].ToString(); if (chkreturn.Checked && !txtsellprice.Text.Contains('-')) { txtsellprice.Text = "-" + tb.Rows[0][1].ToString(); } else { txtsellprice.Text = tb.Rows[0][1].ToString(); } txtsubtotal.Text = (double.Parse(txtquantity.Text) * double.Parse(txtsellprice.Text)).ToString(); txtsellprice.Focus(); } else { txtdescription.Clear(); txtitemcode.Focus(); txtsellprice.Clear(); txtcostprice.Clear(); tempsellprice = ""; stockid = ""; } } else { txtdescription.Clear(); txtitemcode.ResetText(); txtsellprice.Clear(); txtcostprice.Clear(); tempsellprice = ""; stockid = ""; txtitemcode.Focus(); } } else { stockid = tb.Rows[0][3].ToString(); txtsellprice.Focus(); } } else { txtdescription.Clear(); txtcostprice.Clear(); txtsellprice.Clear(); stockid = ""; tempsellprice = ""; } } else { txtdescription.Clear(); txtcostprice.Clear(); txtsellprice.Clear(); tempsellprice = ""; stockid = ""; } }
private void Choose() { stockid = ""; Clipboard.Clear(); Find_Products fr = new Find_Products(); fr.ShowDialog(); if (Clipboard.GetText() != "") { stockid = Clipboard.GetText(); query = "select Inventory.ItemCode, ItemInformation.Description, Inventory.Cost, Inventory.SellPrice, Inventory.Alert, Inventory.Category, Inventory.ID from Inventory, ItemInformation where ItemInformation.ItemCode=Inventory.ItemCode and Inventory.ItemCode='" + stockid + "'"; tb = db.Search(query); if (tb.Rows.Count > 0) { stockid = tb.Rows[0][6].ToString(); txtitemcode.Text = tb.Rows[0][0].ToString(); txtdesciption.Text = tb.Rows[0][1].ToString(); txtalert.Text = tb.Rows[0][4].ToString(); txtcategory.Text = tb.Rows[0][5].ToString(); if (tb.Rows.Count > 1) { Clipboard.Clear(); Choose_Items cr = new Choose_Items(); cr.ItemCode = txtitemcode.Text; cr.ShowDialog(); if (Clipboard.GetText() != "") { query = "select Cost, SellPrice,ID from Inventory where ID='" + Clipboard.GetText() + "'"; tb = db.Search(query); if (tb.Rows.Count > 0) { stockid = tb.Rows[0][2].ToString(); txtcost.Text = tb.Rows[0][0].ToString(); txtsell.Text = tb.Rows[0][1].ToString(); } else { lblitem.Text = "--Click Here To Choose Item--"; stockid = ""; txtitemcode.Clear(); txtdesciption.Clear(); txtcategory.ResetText(); txtcost.Clear(); txtalert.Clear(); txtsell.Clear(); lblitem.Focus(); } } else { lblitem.Text = "--Click Here To Choose Item--"; stockid = ""; txtitemcode.Clear(); txtdesciption.Clear(); txtcategory.ResetText(); txtcost.Clear(); txtalert.Clear(); txtsell.Clear(); lblitem.Focus(); } } else { txtitemcode.Text = tb.Rows[0][0].ToString(); txtdesciption.Text = tb.Rows[0][1].ToString(); txtalert.Text = tb.Rows[0][4].ToString(); txtcategory.Text = tb.Rows[0][5].ToString(); txtcost.Text = tb.Rows[0][2].ToString(); txtsell.Text = tb.Rows[0][3].ToString(); } lblitem.Text = "SELECTED: " + txtitemcode.Text + " | " + txtdesciption.Text + " | " + txtsell.Text; } } else { lblitem.Text = "--Click Here To Choose Item--"; stockid = ""; txtitemcode.Clear(); txtdesciption.Clear(); txtcategory.ResetText(); txtcost.Clear(); txtalert.Clear(); txtsell.Clear(); lblitem.Focus(); } }