private void button2_Click(object sender, EventArgs e) { databaseAccess d1 = new databaseAccess(); con.Open(); cmd = con.CreateCommand(); cmd.CommandType = CommandType.Text; string query = "select SupplierId,sum(TotalPrice) from harasara.ordereditems where Date='" + dateTimePicker1.Text + "' group by SupplierId"; cmd.CommandText = query; MySqlDataAdapter da = new MySqlDataAdapter(cmd); DataTable dt = new DataTable(); da.Fill(dt); con.Close(); foreach (DataRow dr in dt.Rows) { string id = dr[0].ToString(); double ppp = Convert.ToDouble(dr[1]); string query1 = "insert into harasara.purchaseorders (SupplierId,Price,Date) values ('" + id + "','" + ppp + "','" + dateTimePicker1.Text + "')"; d1.InsertData(query1); }
private void Add_Click(object sender, EventArgs e) { if (String.IsNullOrWhiteSpace(quantity.Text)) { error.ForeColor = Color.Red; error.Text = "Please,Input Qunantity"; } else if (String.IsNullOrWhiteSpace(comboBox1.Text)) { error.ForeColor = Color.Red; error.Text = "Select Supplier"; } else { databaseAccess d1 = new databaseAccess(); int qu = Convert.ToInt32(quantity.Text); int Index = dataGridView1.SelectedRows[0].Index; int itemID = Convert.ToInt32(dataGridView1.Rows[Index].Cells[0].Value); string desc = dataGridView1.Rows[Index].Cells[1].Value.ToString(); double price = Convert.ToDouble(dataGridView1.Rows[Index].Cells[3].Value); double tPrice = qu * price; string query = "insert into harasara.ordereditems (ItemNo,ItemDescription,Price,Quantity,TotalPrice,SupplierId,Date)values ('" + itemID + "','" + desc + "','" + price + "','" + qu + "','" + tPrice + "','" + comboBox1.Text + "','" + dateTimePicker1.Text + "')"; d1.InsertData(query); d1.deleteSelectedRow(dataGridView1); string query1 = "select * from harasara.ordereditems where Date='" + dateTimePicker1.Text + "'"; d1.displayData(query1, dataGridView2); } }
private void update_Click(object sender, EventArgs e) { string query = "UPDATE supplier SET supplierName='" + textBox1.Text + "', contactNumber='" + textBox2.Text + "', Address='" + richTextBox2.Text + "',Bank='" + comboBox2.Text + "',AccountNumber='" + textBox7.Text + "' where SupID='" + textBox6.Text + "'"; databaseAccess d1 = new databaseAccess(); d1.InsertData(query); }
private void update_Click(object sender, EventArgs e) { databaseAccess d1 = new databaseAccess(); string query = "update harasara.supplier set (supplierName='" + textBox1.Text + "',contactNumber='" + textBox2.Text + "',Address='" + richTextBox2.Text + "',Bank='" + comboBox2.Text + "',AccountNumber='" + textBox7.Text + "')"; d1.InsertData(query); }
private void button1_Click(object sender, EventArgs e) { string query = "insert into harasara.itemsandsupplier (SupID,ItemNo,ItemDescription) values ('" + textBox6.Text + "','" + Convert.ToInt32(comboBox1.Text) + "','" + label10.Text + "')"; string query1 = "select * from harasara.itemsandsupplier"; databaseAccess d1 = new databaseAccess(); d1.InsertData(query); d1.displayData(query1, dataGridView1); }
private void button2_Click(object sender, EventArgs e) { databaseAccess d1 = new databaseAccess(); string total = "select sum(TotalPrice) from ordereditems where orderID='" + Convert.ToInt32(label8.Text) + "'"; double finalPrice = d1.getValue(total); string query = "insert into purchaseorders values ('" + Convert.ToInt32(label8.Text) + "','" + label9.Text + "','" + finalPrice + "','" + dateTimePicker1.Text + "')"; d1.InsertData(query); CustomMsgBox.Show("Your order is succefully processed", "OK"); }
private void button1_Click(object sender, EventArgs e) { double tprice = (Convert.ToDouble(label14.Text)) * (Convert.ToInt32(textBox2.Text)); string query = "insert into ordereditems values ('" + Convert.ToInt32(label8.Text) + "','" + Convert.ToInt32(label10.Text) + "','" + comboBox1.Text + "','" + Convert.ToDouble(label14.Text) + "','" + Convert.ToInt32(textBox2.Text) + "','" + tprice + "','" + label9.Text + "','" + dateTimePicker1.Text + "')"; databaseAccess d1 = new databaseAccess(); d1.InsertData(query); string query2 = "select * from ordereditems where orderId='" + label8.Text + "' "; d1.displayData(query2, dataGridView1); }
private void PayB_Click(object sender, EventArgs e) { if (label7.Text == "SupplierID") { databaseAccess d2 = new databaseAccess(); string pID = "PU" + invoiceBill.Text + label2.Text; if (pType == "Cash") { string query = "insert into purchasepayments values('" + pID + "','" + label8.Text + "','" + DateTime.Now.Date.ToString("yyyy-MM-dd") + ",,'" + pType + "','" + label2.Text + "','" + label1.Text + "','" + emailBill.Text + "')"; d2.InsertData(query); } else if (pType == "Credit") { string query = "insert into purchasepayments values('" + pID + "','" + label8.Text + "','" + DateTime.Now.Date.ToString("yyyy-MM-dd") + ",,'" + pType + "','" + label2.Text + "','" + label1.Text + "','" + emailBill.Text + "')"; d2.InsertData(query); } } else { databaseAccess d1 = new databaseAccess(); string pID = "SL" + invoiceBill.Text + label2.Text; if (pType == "Cash") { string query = "insert into harasara.payments(PaymentID,customerID,date,type,CardNumber,orderID,Price) values('" + pID + "','" + label8.Text + "','" + DateTime.Now.Date.ToString("yyyy-MM-dd") + "','" + pType + "','" + textBox1.Text + "','" + label2.Text + "','" + Convert.ToDouble(label1.Text) + "') "; d1.InsertData(query); } else if (pType == "Credit") { string query = "insert into harasara.payments(PaymentID,customerID,date,type,CardNumber,orderID,Price) values('" + pID + "','" + label8.Text + "','" + DateTime.Now.Date.ToString("yyyy-MM-dd") + "','" + pType + "','" + textBox1.Text + "','" + label2.Text + "','" + Convert.ToDouble(label1.Text) + "') "; d1.InsertData(query); } string dlQuery = "Delete from harasara.slorders where orderID='" + label2.Text + "'"; d1.deleterow(dlQuery); CustomMsgBox.Show("Payment was successfull", "OK"); } }
private void button4_Click(object sender, EventArgs e) { databaseAccess d1 = new databaseAccess(); string query1 = "select count(*) from harasara.supplier where SupID='" + textBox6.Text + "'"; if (0 == d1.getValue(query1)) { string query = "insert into harasara.supplier (SupID,supplierName,contactNumber,Address,Bank,AccountNumber) values ('" + textBox6.Text + "','" + textBox1.Text + "','" + textBox2.Text + "','" + richTextBox2.Text + "','" + comboBox2.Text + "','" + textBox7.Text + "')"; d1.InsertData(query); CustomMsgBox.Show("Added New Supplier ", "OK"); } }
//Insert customer provided order details in to the database public void getOrderdetails() { double sum = 0; int orderID = Convert.ToInt32(label20.Text); for (int i = 0; i < dataGridView2.Rows.Count; ++i) { sum += Convert.ToDouble(dataGridView2.Rows[i].Cells[4].Value); } string query = "insert into harasara.slorders values ('" + orderID + "','" + textBox5.Text + "','" + label22.Text + "','" + sum + "','" + dateTimePicker1.Text + "')"; databaseAccess d1 = new databaseAccess(); d1.InsertData(query); label24.Text = sum.ToString(); }