private void button1_Click(object sender, EventArgs e) { if ((Fname1.Text == "") || (lname1.Text == "") || (uname1.Text == "") || (pass1.Text == "")) { MessageBox.Show("Please Fill-up form completely to Register Account!!!"); } else { String id, fname, lname, uname, pass, type; id = txtID.Text; fname = Fname1.Text; lname = lname1.Text; uname = uname1.Text; pass = pass1.Text; type = type1.Text; try { connDB connect = new connDB(); connect.addAcc(id, fname, lname, uname, pass, type); MessageBox.Show("New Account Registered!"); Fname1.Text = ""; lname1.Text = ""; uname1.Text = ""; pass1.Text = ""; idtxt(); } catch (Exception Exception) { MessageBox.Show(Exception.Message); } } }
void idtxt() { connDB gnum = new connDB(); gnum.nextid(); recentID = Int32.Parse(loginfo.id) + 1; txtID.Text = recentID.ToString(); }
void custId() { connDB gnum = new connDB(); gnum.nexcust(); int nextCust = Int32.Parse(loginfo.custId) + 1; loginfo.custId2 = loginfo.custId1; }
void idtxt() { connDB gnum = new connDB(); gnum.npid(); int recentID = Int32.Parse(loginfo.pid) + 1; id.Text = recentID.ToString(); }
// UPDATE CART // //private void button4_Click_1(object sender, EventArgs e) //{ // cntr++; // switch (cntr) // { // case 1: // cqty.Visible = true; // // button4.Text = "SAVE"; // cntr++; // break; // case 2: // int q1, q2, ans; // q1 = Convert.ToInt32(label14.Text); // q2 = Convert.ToInt32(cqty.Text); // if (q2 < q1) // add to db - less to transac // { // ans = q2 + q1; // MySqlConnection connection = new MySqlConnection("dataSource = localhost; Initial Catalog = pos; username = root; Password = "******"update pos.products set pqty =@pqty1 where pid= @pid1 "; // MySqlConnection myCon = new MySqlConnection(mycon.conn); // MySqlCommand myComm = new MySqlCommand(query, myCon); // try // { // connection.Open(); // command = new MySqlCommand(query, connection); // command.Parameters.Add("@pid1", MySqlDbType.Int32, 11); // command.Parameters.Add("@pqty1", MySqlDbType.Int32, 11); // command.Parameters["@pid1"].Value = label14.Text; // command.Parameters["@pqty1"].Value = ans; // if (command.ExecuteNonQuery() == 1) // { // MessageBox.Show("Data Inserted"); // } // connection.Close(); // } // catch (Exception ex) // { // MessageBox.Show(ex.ToString()); // } // } // else if (q2 > q1) // less to db add to transact // { // ans = q1 - q2; // MySqlConnection connection = new MySqlConnection("dataSource = localhost; Initial Catalog = pos; username = root; Password = "******"update pos.products set pqty =@pqty1 where pid= @pid1 "; // MySqlConnection myCon = new MySqlConnection(mycon.conn); // MySqlCommand myComm = new MySqlCommand(query, myCon); // try // { // connection.Open(); // command = new MySqlCommand(query, connection); // command.Parameters.Add("@pid1", MySqlDbType.Int32, 11); // command.Parameters.Add("@pqty1", MySqlDbType.Int32, 11); // command.Parameters["@pid1"].Value = label14.Text; // command.Parameters["@pqty1"].Value = ans; // if (command.ExecuteNonQuery() == 1) // { // // MessageBox.Show("Data Inserted"); // } // connection.Close(); // } // catch (Exception ex) // { // MessageBox.Show(ex.ToString()); // } // } // break; // } //} private void button2_Click(object sender, EventArgs e) { //UPDATE DB PRODUCTS // String PID1, PNAME1, PTYPE1, PBRAND1, PQTY1, PPRICE1; PID1 = cid.Text; PNAME1 = cname.Text; PTYPE1 = ctype.Text; PBRAND1 = cbrand.Text; PQTY1 = label19.Text; PPRICE1 = cprice.Text; double a, b; b = Convert.ToDouble(cprice.Text) * Convert.ToDouble(cqty.Text); a = Convert.ToDouble(label7.Text) - b; label7.Text = a.ToString(); //addtotal(); try { connDB connect1 = new connDB(); connect1.updateDel(PID1, PNAME1, PTYPE1, PBRAND1, PQTY1, PPRICE1); table1(); table2(); table3(); table4(); table5(); table6(); } catch (Exception ex) { MessageBox.Show(ex.Message + "3"); } // DELETE TO TRANSACTION String id; id = label6.Text; try { connDB conn = new connDB(); conn.delTrans(id); MessageBox.Show("Cart no: " + id + " has been Deleted"); // LoadTable(); } catch (Exception ex) { MessageBox.Show(ex.Message); } //delete to dataGrid listView1.Items.RemoveAt(listView1.SelectedIndices[0]); cid.Text = null; cname.Text = null; ctype.Text = null; cbrand.Text = null; cqty.Text = null; ctotal.Text = null; cprice.Text = null; cstock.Text = null; }
//EDIT ACCOUNT private void button1_Click(object sender, EventArgs e) { ++cntr; switch (cntr) { case 1: fname1.Enabled = true; lname1.Enabled = true; uname1.Enabled = true; pass1.Enabled = true; button2.Enabled = false; button3.Enabled = false; button1.Text = "Update"; break; default: if ((fname1.Text == "") || (lname1.Text == "") || (uname1.Text == "") || (pass1.Text == "")) { MessageBox.Show("Please Fill Up Informations!"); } else { String id, fname, lname, uname, pass; id = txtID.Text; fname = fname1.Text; lname = lname1.Text; uname = uname1.Text; pass = pass1.Text; try { connDB connect = new connDB(); connect.editAcc(id, fname, lname, uname, pass); MessageBox.Show("Account ID no: " + id + " has been updated"); fname1.Enabled = false; lname1.Enabled = false; uname1.Enabled = false; pass1.Enabled = false; button2.Enabled = true; button3.Enabled = true; cntr = 0; LoadTable(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } break; } }
void idtxt() { connDB gnum = new connDB(); gnum.ntid(); int recentID = Int32.Parse(loginfo.tid) + 1; idd = recentID.ToString(); // label14.Text = idd; }
void custId() { connDB gnum = new connDB(); gnum.nexcust(); int nextCust = Int32.Parse(loginfo.custId) + 1; custID.Text = nextCust.ToString(); loginfo.custId1 = custID.Text; loginfo.custId2 = loginfo.custId1; }
private void button1_Click(object sender, EventArgs e) { if (ctr == 2) { MessageBox.Show("you have one try left to login"); ctr--; } if (ctr == 0) { MessageBox.Show("You have tried to Login Many Times, What's Wrong with you?"); this.Close(); } string ad = "admin"; try { if (connDB.Clogin(textBox1.Text, textBox2.Text, ad)) { loginfo.uname = textBox1.Text; MessageBox.Show("APPROVED"); connDB connect = new connDB(); string id, name, brand, type, qty, price, approval; Random rnd = new Random(); int dice = rnd.Next(1, 7); DateTime myDateTime = DateTime.Now; String sqlFormattedDate = myDateTime.Date.ToString("yyyy-mm-dd"); DateTime dateTime = new DateTime(); dateTime = DateTime.Now; DateTime newDateTime = new DateTime(); TimeSpan NumberOfDays = new TimeSpan(dice, 0, 0, 0, 0); newDateTime = dateTime.Add(NumberOfDays); string nice = newDateTime.ToString(); login = true; connect.pendingtodelivery(loginfo.pdid1, loginfo.pdname, loginfo.pdbrand, loginfo.pdtype, loginfo.pdqty, loginfo.pdprice, loginfo.time, nice); connect.deletepending(loginfo.pdid1); this.Close(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } if (login == false) { ctr--; MessageBox.Show("Invalid Login Details"); } }
private void button2_Click(object sender, EventArgs e) { String id; id = txtID.Text; try { connDB conn = new connDB(); conn.delAcc(id); MessageBox.Show("Account ID no: " + id + " has been Deleted"); LoadTable(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
// DELETE STOCK - PULL OUT ITEMS // private void button2_Click(object sender, EventArgs e) { String id1; id1 = id.Text; try { connDB conn = new connDB(); conn.delIn(id1); MessageBox.Show("Product no: " + id.Text + " has been Deleted"); table1(); table2(); table3(); table4(); table5(); table6(); id.Text = null; name.Text = null; type.Text = null; brand.Text = null; price.Text = null; stock.Text = null; } catch (Exception ex) { MessageBox.Show(ex.Message); } }
}// #endregion #region CART MANIP //ADD TO CART // private void button1_Click(object sender, EventArgs e) { if ((qty.Text == "")) { MessageBox.Show("Please Enter Purchase Quantity"); } else { // ADD TO "CART" // Addrow(idd, id.Text, name.Text, type.Text, brand.Text, price.Text, stock.Text, qty.Text, total.Text); //listBox1.Items.Add(idd.PadRight(10) + id.Text.PadRight(10) + name.Text.PadRight(30) + price.Text.PadRight(30) + qty.Text.PadRight(30) + total.Text.PadRight(0)); String ID, CID, PID, PNAME, PTYPE, PBRAND, PQTY, TOTAL, Date, ST; ID = idd; PID = id.Text; CID = loginfo.custId2; PNAME = name.Text; PTYPE = type.Text; PBRAND = brand.Text; PQTY = qty.Text; TOTAL = total.Text; ST = label12.Text; Date = this.dateTimePicker1.Text; // LESS STOCK VAUES - PER ADD TO CART // int a, b; a = Convert.ToInt32(stock.Text); b = Convert.ToInt32(PQTY); ns = a - b; Stock1 = ns.ToString(); // label15.Text = Stock1; try { connDB connect = new connDB(); connect.transac(ID, CID, PID, PNAME, PTYPE, PBRAND, PQTY, TOTAL, this.dateTimePicker1.Text, ST); connect.hist(ID, CID, PNAME, PTYPE, PBRAND, PQTY, TOTAL, Date); idtxt(); // compt(); String PID1, PNAME1, PTYPE1, PBRAND1, PQTY1, PPRICE1; PID1 = id.Text; PNAME1 = name.Text; PTYPE1 = type.Text; PBRAND1 = brand.Text; PQTY1 = Stock1; PPRICE1 = price.Text; addtotal(); try { connDB connect1 = new connDB(); connect1.updateStock(PID1, PNAME1, PTYPE1, PBRAND1, PQTY1, PPRICE1); id.Text = null; name.Text = null; type.Text = null; brand.Text = null; qty.Text = null; total.Text = null; price.Text = null; stock.Text = null; table1(); table2(); table3(); table4(); table5(); table6(); } catch (Exception ex) { MessageBox.Show(ex.Message + "2"); } } catch (Exception ex) { MessageBox.Show(ex.Message + "error1"); } } }
//ADD ITEMS - STOCKS TO DATABASE // private void button3_Click(object sender, EventArgs e) { idtxt(); ++cntr; dataGridView1.Visible = false; dataGridView4.Visible = false; dataGridView5.Visible = false; dataGridView6.Visible = false; dataGridView7.Visible = false; dataGridView8.Visible = false; // id.Text = null; switch (cntr) { case 1: name.Text = null; type.Text = null; brand.Text = null; price.Text = null; stock.Text = null; pictureBox1.Image = null; name.Enabled = true; type.Visible = false; comboBox1.Visible = true; brand.Visible = false; brand.Enabled = false; price.Enabled = true; stock.Enabled = true; type.Visible = true; type.Enabled = true; button1.Enabled = false; button2.Enabled = false; button4.Enabled = true; pictureBox1.Visible = true; button3.Text = "SAVE"; break; default: if ((name.Text == "") || (comboBox1.Text == "") || (price.Text == "") || (stock.Text == "")) { MessageBox.Show("Please Fill Up Informations!"); } else { String pname, ptype, pbrand, pqty, pprice, pid = id.Text; pname = name.Text; ptype = comboBox1.Text; pbrand = type.Text; pqty = stock.Text; pprice = price.Text; try { MemoryStream ms = new MemoryStream(); pictureBox1.Image.Save(ms, pictureBox1.Image.RawFormat); byte[] img = ms.ToArray(); Random rnd = new Random(); int dice = rnd.Next(1, 7); DateTime myDateTime = DateTime.Now; String sqlFormattedDate = myDateTime.Date.ToString("yyyy-mm-dd"); DateTime dateTime = new DateTime(); dateTime = DateTime.Now; DateTime newDateTime = new DateTime(); TimeSpan NumberOfDays = new TimeSpan(dice, 0, 0, 0, 0); newDateTime = dateTime.Add(NumberOfDays); string nice = newDateTime.ToString(); connDB connect = new connDB(); int price1 = int.Parse(pqty) * int.Parse(pprice); connect.additemsnew(pid, pname, ptype, pbrand, pqty, pprice, img); connect.adddelivery(pid, pname, pbrand, ptype, pqty, price1.ToString(), this.dateTimePicker1.Text, nice); MessageBox.Show("Product ID no: " + id.Text + " has been added"); name.Enabled = false; type.Enabled = false; brand.Enabled = false; price.Enabled = false; stock.Enabled = false; button1.Enabled = true; button2.Enabled = true; button3.Enabled = true; button4.Enabled = true; type.Visible = true; button4.Enabled = false; pictureBox1.Visible = false; pictureBox1.Image = null; comboBox1.Visible = false; //status editor // //---// name.Text = null; type.Text = null; brand.Text = null; price.Text = null; stock.Text = null; // cntr = 0; table1(); table2(); table3(); table4(); table5(); table6(); button3.Text = "Add Items"; } catch (Exception ex) { MessageBox.Show(ex.Message); } } break; } // end of switch } //
// EDIT STOCK // private void button1_Click(object sender, EventArgs e) { ++cntr; switch (cntr) { case 1: name.Enabled = true; type.Enabled = true; comboBox1.Visible = true; brand.Enabled = true; price.Enabled = true; stock.Enabled = true; type.Visible = true; button2.Enabled = false; button3.Enabled = false; button4.Enabled = true; button1.Text = "SAVE"; break; default: DialogResult dialogResult = MessageBox.Show("Do you Approve of this order?", "Approval ", MessageBoxButtons.YesNo); /* if (int.Parse(loginfo.stock) < int.Parse(this.stock.Text)) * { * MessageBox.Show("you cannot lessen the current stocks"); * }*/ if ((name.Text == "") || (type.Text == "") || (brand.Text == "") || (price.Text == "") || (stock.Text == "")) { MessageBox.Show("Please Fill Up Informations!"); } else if (dialogResult == DialogResult.Yes) { String PID, PNAME, PTYPE, BRAND, PQTY, PPRICE; PID = id.Text; PNAME = name.Text; PTYPE = brand.Text; BRAND = type.Text; PQTY = stock.Text; PPRICE = price.Text; try { MemoryStream ms = new MemoryStream(); pictureBox1.Image.Save(ms, pictureBox1.Image.RawFormat); byte[] img = ms.ToArray(); Random rnd = new Random(); int dice = rnd.Next(1, 7); DateTime myDateTime = DateTime.Now; String sqlFormattedDate = myDateTime.Date.ToString("yyyy-mm-dd"); DateTime dateTime = new DateTime(); dateTime = DateTime.Now; DateTime newDateTime = new DateTime(); TimeSpan NumberOfDays = new TimeSpan(dice, 0, 0, 0, 0); newDateTime = dateTime.Add(NumberOfDays); string nice = newDateTime.ToString(); int price1 = int.Parse(PQTY) * int.Parse(PPRICE); connDB connect = new connDB(); connect.editIn(PID, PNAME, PTYPE, BRAND, PQTY, PPRICE, img); connect.adddelivery(PID, PNAME, BRAND, PTYPE, PQTY, price1.ToString(), this.dateTimePicker1.Text, nice); MessageBox.Show("Product ID no: " + id.Text + " has been updated"); name.Enabled = false; type.Enabled = false; brand.Enabled = false; price.Enabled = false; stock.Enabled = false; button2.Enabled = true; button3.Enabled = true; type.Visible = true; pictureBox1.Visible = false; button4.Enabled = false; comboBox1.Visible = false; cntr = 0; table1(); table2(); table3(); table4(); table5(); table6(); button1.Text = "UPDATE"; } catch (System.NullReferenceException) { MessageBox.Show("Insert an image"); } catch (Exception ex) { MessageBox.Show(ex.Message); } } if (dialogResult == DialogResult.No) { String PID, PNAME, PTYPE, BRAND, PQTY, PPRICE, APPR; PID = id.Text; PNAME = name.Text; PTYPE = brand.Text; BRAND = type.Text; PQTY = stock.Text; PPRICE = price.Text; APPR = "Pending"; loginfo.pdid = PID; int price1 = int.Parse(PQTY) * int.Parse(PPRICE); connDB connect = new connDB(); connect.pendingdelivery(int.Parse(PID), PNAME, PTYPE, BRAND, int.Parse(PQTY), price1, APPR); } break; } }