private void button1_Click(object sender, EventArgs e) { c.fname = namebox.Text.Trim(); c.company = cnamebox.Text.Trim(); c.amount = packagebox.Text.Trim(); c.quantity = Int32.Parse(quantitybox.Text.Trim()); c.cost_price = float.Parse(costbox.Text.Trim()); c.selling_price = float.Parse(sellingbox.Text.Trim()); c.barcode = barcodebox.Text.Trim(); c.exp_date = dateTimePicker1.Value; c.mfg_date = dateTimePicker2.Value; bool ok = cf.Insert(c); if (ok == true) { MessageBox.Show("PRODUCT ADDED SUCCESSFULLY!"); DataTable dt = cf.Select(); productlist.DataSource = dt; idbox.Text = ""; namebox.Text = ""; cnamebox.Text = ""; packagebox.Text = ""; quantitybox.Text = ""; costbox.Text = ""; sellingbox.Text = ""; barcodebox.Text = ""; DateTime localDate = DateTime.Now; dateTimePicker1.Value = localDate; dateTimePicker2.Value = localDate; } else { MessageBox.Show("FAILED TO ADD!"); } }
private void GenerateBill_Load(object sender, EventArgs e) { tcf.Clear(); discountbox.Text = "0"; amountbox.Text = "0"; SqlConnection conn = new SqlConnection(myconnstrng); try { string query = "select max(bill_id) from bill"; SqlCommand cmd = new SqlCommand(query, conn); SqlDataAdapter adapter = new SqlDataAdapter(cmd); conn.Open(); billid = (int)cmd.ExecuteScalar(); billid++; } catch (Exception ex) { MessageBox.Show(ex.Message); } bidbox.Text = billid.ToString(); DataTable dt = new DataTable(); dt = sf.Select(); stocklist.DataSource = dt; DataTable dt2 = new DataTable(); dt2 = tcf.Select(); cartlist.DataSource = dt2; //quantitybox; quantitybox.Text = quantity.ToString(); }