private void buttonMail_Click(object sender, EventArgs e) { this.Hide(); Mail mail = new Mail(); mail.Show(); }
private void btn_UserAdd_Click(object sender, EventArgs e) { using (MySqlConnection mysqlCon = new MySqlConnection(connectionString)) { mysqlCon.Open(); MySqlCommand mySqlCmd = new MySqlCommand("UserAdd", mysqlCon); mySqlCmd.CommandType = CommandType.StoredProcedure; mySqlCmd.Parameters.AddWithValue("_UserID", userId); mySqlCmd.Parameters.AddWithValue("_UserType", cb_type.Text); mySqlCmd.Parameters.AddWithValue("_UserName", txt_name.Text.Trim()); mySqlCmd.Parameters.AddWithValue("_Password", txt_pw.Text.Trim()); mySqlCmd.Parameters.AddWithValue("_UserEmail", txt_email.Text.Trim()); mySqlCmd.ExecuteNonQuery(); MessageBox.Show("User Added Successfully"); UserGridFill(); } if (txt_name.Text != "" && txt_email.Text != "") { string userMail = null; using (MySqlConnection mysqlCon = new MySqlConnection(connectionString)) { mysqlCon.Open(); String sql = "SELECT Email FROM pml_user WHERE Username='******'"; MySqlCommand mySc = new MySqlCommand(sql, mysqlCon); MySqlDataReader myDr = mySc.ExecuteReader(); while (myDr.Read()) { userMail = myDr.GetValue(0).ToString(); } } Mail.userEmail = userMail; Mail.toName = txt_email.Text; Mail.subject = "New User Credentials"; Mail.message = "Please note that now you have access to our KHS2 Constructions Desktop Application. Your loging credentiols are as of follows. " + "\n" + "User Name : " + txt_name.Text + "\n" + " Password : "******"\n" + "In case if you want to change your login credentials, you can do it via 'My Profile'." + "\n" + "\n" + "Thanks & Regards."; Mail openMail = new Mail(); openMail.Show(); } else { MessageBox.Show("Please add a new user first."); } UserClear(); }
private void btn_POAdd_Click(object sender, EventArgs e) { using (MySqlConnection mysqlCon = new MySqlConnection(connectionString)) { mysqlCon.Open(); String sql = "SELECT Email FROM pml_user WHERE Username='******'"; MySqlCommand mySc = new MySqlCommand(sql, mysqlCon); MySqlDataReader myDr = mySc.ExecuteReader(); while (myDr.Read()) { userMail = myDr.GetValue(0).ToString(); } } using (MySqlConnection mysqlCon = new MySqlConnection(connectionString)) { { mysqlCon.Open(); MySqlCommand mySqlCmd = new MySqlCommand("OrderAddOrEdit", mysqlCon); mySqlCmd.CommandType = CommandType.StoredProcedure; mySqlCmd.Parameters.AddWithValue("_OrderID", orderId); mySqlCmd.Parameters.AddWithValue("_RefNo", txt_refNo.Text.Trim()); mySqlCmd.Parameters.AddWithValue("_Material", cb_material.Text.Trim()); mySqlCmd.Parameters.AddWithValue("_Description", txt_Description.Text); mySqlCmd.Parameters.AddWithValue("_Supplier", cb_supplier.Text); mySqlCmd.Parameters.AddWithValue("_Price", txt_price.Text); mySqlCmd.Parameters.AddWithValue("_Quantity", txt_qty.Text); mySqlCmd.Parameters.AddWithValue("_Site", cmb_site.Text); mySqlCmd.Parameters.AddWithValue("_DelDate", dateTimeReqDate.Text.Trim()); mySqlCmd.ExecuteNonQuery(); MessageBox.Show("Submitted Successfully"); OrderGridFill(); Mail mail = new Mail(); Mail.toName = "*****@*****.**"; Mail.ccName = "*****@*****.**"; Mail.subject = "Request Approval for Purchase Order"; Mail.message = "Dear Sir, I would like to kindly ask for your approval to the purchase order under the reference number " + txt_refNo.Text + ". I appreciate your prompt response for my request. Thank You"; Mail.userEmail = userMail; mail.Show(); this.Hide(); OrderClear(); } } }
private void btn_statusUpdate_Click(object sender, EventArgs e) { using (MySqlConnection mysqlCon = new MySqlConnection(connectionString)) { if (cb_status.SelectedIndex != -1) { MySqlCommand cmd; cmd = new MySqlCommand("UPDATE purchase_order SET Status='" + cb_status.Text + "', CheckedBy='" + txt_updatedBy.Text + "', CheckedOn='" + dtp_updatedDate.Text.Trim() + "' WHERE OrderID=@OrderID", mysqlCon); mysqlCon.Open(); cmd.Parameters.AddWithValue("@OrderID", order_id); cmd.ExecuteNonQuery(); MessageBox.Show("Order Status Updated Successfully"); } } if (cb_status.Text == "Hold" && txt_orderRef.Text != "") { MessageBox.Show("Order Holded"); string userMail = null; using (MySqlConnection mysqlCon = new MySqlConnection(connectionString)) { mysqlCon.Open(); String sql = "SELECT Email FROM pml_user WHERE Username='******'"; MySqlCommand mySc = new MySqlCommand(sql, mysqlCon); MySqlDataReader myDr = mySc.ExecuteReader(); while (myDr.Read()) { userMail = myDr.GetValue(0).ToString(); } } Mail.userEmail = userMail; Mail.subject = "Hold Purchase Orders"; Mail.message = txt_orderRef.Text + "order is marked as hold order because the agreed price is not mentioned."; Mail openMail = new Mail(); openMail.Show(); } GridFill(); Clear(); }
private void btn_placeOrder_Click(object sender, EventArgs e) { using (MySqlConnection mysqlCon = new MySqlConnection(connectionString)) { MySqlCommand cmd; cmd = new MySqlCommand("UPDATE purchase_order SET Status='Placed' WHERE OrderID=@OrderID", mysqlCon); mysqlCon.Open(); cmd.Parameters.AddWithValue("@OrderID", order_id); cmd.ExecuteNonQuery(); MessageBox.Show("Order Status Updated Successfully"); if (txt_orderRef.Text != "") { Document pdoc = new Document(PageSize.A4, 50f, 0f, 0f, 30f); PdfWriter pWriter = PdfWriter.GetInstance(pdoc, new FileStream("C:/" + txt_orderRef.Text + ".pdf", FileMode.Create)); pdoc.Open(); System.Drawing.Image PImage = System.Drawing.Image.FromFile("C:\\ReportHeader.png"); iTextSharp.text.Image ItextImage = iTextSharp.text.Image.GetInstance(PImage, System.Drawing.Imaging.ImageFormat.Png); ItextImage.Alignment = Element.ALIGN_CENTER; pdoc.Add(ItextImage); Paragraph address = new Paragraph("KHS2 Cnstructions (Pvt) Ltd ," + "\n" + "No: 01 ," + "\n" + "Dane's Plains ," + "\n" + "Katukurunda ," + "\n" + "Kaluthara North." + "\n"); address.Alignment = Element.ALIGN_LEFT; pdoc.Add(address); Paragraph heading = new Paragraph("\n" + "\n" + "Prchase Order Requisition" + "\n" + "\n"); heading.Alignment = Element.ALIGN_CENTER; pdoc.Add(heading); Paragraph para = new Paragraph("\n" + "Purchase Order Details are as of below. Please be kind enough to let us know if there are any information that should be modified." + "\n" + "\n" + "\n"); para.Alignment = Element.ALIGN_LEFT; pdoc.Add(para); Paragraph para1 = new Paragraph("Order Reference : " + txt_orderRef.Text + "\n" + "Construction Site : " + txt_site.Text + "\n" + "Order Material : " + txt_material.Text + "\n" + "Order Description : " + txt_des.Text + "\n" + "Supplier Name : " + txt_supplier.Text + "\n" + "Agreed Price : LKR. " + txt_amount.Text + "\n" + "Delivery Date : " + dtp_po.Value + "\n" + "\n"); para1.Alignment = Element.ALIGN_BASELINE; pdoc.Add(para1); Paragraph para2 = new Paragraph("\n" + "Thanks & Regards!" + "\n"); para2.Alignment = Element.ALIGN_LEFT; pdoc.Add(para2); System.Drawing.Image PImage1 = System.Drawing.Image.FromFile("C:\\stamp.png"); iTextSharp.text.Image ItextImage1 = iTextSharp.text.Image.GetInstance(PImage1, System.Drawing.Imaging.ImageFormat.Png); ItextImage1.Alignment = Element.ALIGN_LEFT; pdoc.Add(ItextImage1); pdoc.Close(); MessageBox.Show("Order Report Created Successfully."); } GridFill(); } if (txt_orderRef.Text != "") { string userMail = null; using (MySqlConnection mysqlCon = new MySqlConnection(connectionString)) { mysqlCon.Open(); String sql = "SELECT Email FROM pml_user WHERE Username='******'"; MySqlCommand mySc = new MySqlCommand(sql, mysqlCon); MySqlDataReader myDr = mySc.ExecuteReader(); while (myDr.Read()) { userMail = myDr.GetValue(0).ToString(); } } string Tomail = null; using (MySqlConnection mysqlCon = new MySqlConnection(connectionString)) { mysqlCon.Open(); String sql = "SELECT Email FROM suppliers WHERE name='" + txt_supplier.Text + "'"; MySqlCommand mySc = new MySqlCommand(sql, mysqlCon); MySqlDataReader myDr = mySc.ExecuteReader(); while (myDr.Read()) { Tomail = myDr.GetValue(0).ToString(); } } string ccMail = null; using (MySqlConnection mysqlCon = new MySqlConnection(connectionString)) { mysqlCon.Open(); String sql = "SELECT Email FROM pml_user WHERE Username='******'"; MySqlCommand mySc = new MySqlCommand(sql, mysqlCon); MySqlDataReader myDr = mySc.ExecuteReader(); while (myDr.Read()) { ccMail = myDr.GetValue(0).ToString(); } } Mail.userEmail = userMail; Mail.toName = Tomail; Mail.ccName = ccMail; Mail.attachment = "C:\\" + txt_orderRef.Text + ".pdf"; Mail.subject = "Purchase Order Requisition"; Mail.message = "Please find the attached pdf file of order details of " + txt_material.Text + " Order No: " + txt_orderRef.Text + "\n" + "\n" + "Thanks & Regards!"; Mail openMail = new Mail(); openMail.Show(); } else { MessageBox.Show("Please select an order to be placed"); } }