public void refreshHRLeaveTable() { if (tabCheckLeaveRequests.Text == "Check Leave Requests") { MySqlConnection connDatabase = ConnectionOld.getConnection(); MySqlCommand q4 = new MySqlCommand("select EmpId,RequestedDate,StartDate,EndDate,NoOfDays,Type,Reason,Status from leave_view where Status = @status;", connDatabase); q4.Parameters.AddWithValue("@status", "Pending"); try { MySqlDataAdapter sda = new MySqlDataAdapter(); sda.SelectCommand = q4; DataTable dataset = new DataTable(); sda.Fill(dataset); BindingSource bSource = new BindingSource(); bSource.DataSource = dataset; dataGridView3.DataSource = bSource; //sda.Update(dataset); } catch (MySqlException ex) { PanException.Show(this.MdiParent, ex); } } }
public void refreshOtTable() { //MessageBox.Show("Hello"); MySqlConnection connDatabase = ConnectionOld.getConnection(); MySqlCommand q4 = new MySqlCommand(@"select e.EmpId,FirstName,LastName,o.OTHours from employee e LEFT OUTER JOIN ( select EmpId,OTHours from ot where Month = '" + mon + "' ) o ON o.EmpId =e.EmpId;", connDatabase); //q4.Parameters.AddWithValue("@mon", mon); try { // MySqlDataAdapter sda = new MySqlDataAdapter(); sda.SelectCommand = q4; //DataTable dataset = new DataTable(); datasetOT.Clear(); sda.Fill(datasetOT); //BindingSource bSource = new BindingSource(); bindingSource1.DataSource = datasetOT; dataGridView4.DataSource = bindingSource1; //sda.Update(dataset); } catch (MySqlException ex) { PanException.Show(this.MdiParent, ex); } }
public void refreshEmpLeaveTable() { if (tabSendLeaveRequests.Text == "Send Leave Requests") { MySqlConnection connDatabase = ConnectionOld.getConnection(); MySqlCommand q4 = new MySqlCommand("select RequestedDate,StartDate,EndDate,NoOfDays,Type,Reason,Status from leave_view where EmpId = @empid ;", connDatabase); q4.Parameters.AddWithValue("@empId", Connection.getUserIdFromConnectionString()); try { MySqlDataAdapter sda = new MySqlDataAdapter(); sda.SelectCommand = q4; DataTable dataset = new DataTable(); sda.Fill(dataset); BindingSource bSource = new BindingSource(); bSource.DataSource = dataset; dataGridView1.DataSource = bSource; //sda.Update(dataset); } catch (MySqlException ex) { PanException.Show(this.MdiParent, ex); } } }
public void getNoOfLeaveDays() { try { String a = "select COALESCE(sum(NoOfDays),0) from itp.leave_view where EmpId = '" + Connection.getUserIdFromConnectionString() + "' and Status = 'Accepted' and Type = 'Annual' ;"; String c = "select COALESCE(sum(NoOfDays),0) from itp.leave_view where EmpId = '" + Connection.getUserIdFromConnectionString() + "' and Status = 'Accepted' and Type = 'Casual';"; MySqlConnection MyConn = ConnectionOld.getConnection(); MySqlCommand SelectCommandAnnual = new MySqlCommand(a, MyConn); MySqlCommand SelectCommandCasual = new MySqlCommand(c, MyConn); MySqlDataReader MyReader; MyConn.Open(); MyReader = SelectCommandAnnual.ExecuteReader(); if (MyReader.Read()) { labRemAnnual.Text = (14 - MyReader.GetInt32(0)).ToString(); } MyConn.Close(); MyReader = null; MyConn.Open(); MyReader = SelectCommandCasual.ExecuteReader(); if (MyReader.Read()) { int x; x = MyReader.GetInt32(0); labRemCasual.Text = (7 - x).ToString(); } } catch (MySqlException ex) { PanException.Show(this.MdiParent, ex); } }
private void button1_Click(object sender, EventArgs e) { if (MessageBox.Show("Do you really want to delete this entry from the table?", "Confirmation", MessageBoxButtons.YesNo) == DialogResult.Yes) { try { DBConnect connection = new DBConnect(); connection.OpenConnection(); MySqlConnection returnConn = new MySqlConnection(); returnConn = connection.GetConnection(); string query = "DELETE FROM itp.buyer WHERE storeName = '" + listBox1.Text + "'"; MySqlCommand cmd = new MySqlCommand(query, returnConn); cmd.ExecuteNonQuery(); connection.CloseConnection(); PanMessage.Show(this.MdiParent, "Success", "Entry deleted successfully"); this.listBox1.Items.Clear(); fillList(); } catch (MySqlException ex) { PanException.Show(this.MdiParent, ex); } } }
private void textBox4_TextChanged(object sender, EventArgs e) { string qty = (textBox4.Text); if (String.IsNullOrEmpty(qty)) { label13.Text = "0"; } else { int qtyInt = 0; bool yes = int.TryParse(qty, out qtyInt); if (yes) { double unitCost = Double.Parse(textBox3.Text); this.tempTotal = unitCost * (Int32.Parse(qty)); label13.Text = tempTotal.ToString(); } else { PanException.Show(this.MdiParent, "Invalid input", "Enter valid quantity amount"); } } }
private void CalSalary_Click_1(object sender, EventArgs e) { try { if (con.State != ConnectionState.Open) { con.Open(); } MySqlCommand command = new MySqlCommand("calcSalary", con); command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("_month", salMonth); command.ExecuteScalar(); //MessageBox.Show("Salary is calculated for "+salMonth); PanMessage.Show(this.MdiParent, "Salary", "Salary is calculated for " + salMonth); } catch (MySqlException ex) { PanException.Show(this.MdiParent, ex); } finally { con.Close(); } }
private void Rem_Click_1(object sender, EventArgs e) { if (dataGridView2.SelectedRows.Count > 0) { DataGridViewRow row = this.dataGridView2.SelectedRows[0]; emp = row.Cells["EmpId"].Value.ToString(); } String q2 = "delete from itp.employee where EmpId ='" + emp + "' "; MySqlConnection connDatabase = ConnectionOld.getConnection(); MySqlCommand cmdDatabase = new MySqlCommand(q2, connDatabase); MySqlDataReader myReader; try { connDatabase.Open(); myReader = cmdDatabase.ExecuteReader(); //MessageBox.Show("Record is deleted successfully"); PanMessage.Show(this.MdiParent, "Record Deleted", "Record is deleted successfully"); displayDataGridViewSearch(); } catch (MySqlException ex) { PanException.Show(this.MdiParent, ex); } }
public void defaultOtTable() { MySqlConnection connDatabase = ConnectionOld.getConnection(); MySqlCommand q4 = new MySqlCommand("select e.EmpId,FirstName,LastName,o.OTHours from employee e LEFT OUTER JOIN ot o ON e.EmpId = o.EmpId where o.Month = @mon;", connDatabase); q4.Parameters.AddWithValue("@mon", "January"); try { //MySqlDataAdapter sda = new MySqlDataAdapter(); sda.SelectCommand = q4; //DataTable dataset = new DataTable(); datasetOT.Clear(); sda.Fill(datasetOT); //BindingSource bSource = new BindingSource(); bindingSource1.DataSource = datasetOT; dataGridView4.DataSource = bindingSource1; //sda.Update(dataset); } catch (MySqlException ex) { PanException.Show(this.MdiParent, ex); } }
private void button4_Click(object sender, EventArgs e) { int Annual = Int32.Parse(labRemAnnual.Text); int Casual = Int32.Parse(labRemCasual.Text); DateTime endDate = dateTimePicker2.Value; DateTime startDate = dateTimePicker3.Value; TimeSpan tspan = endDate - startDate; int differenceInDays = tspan.Days; if ((this.Type_combo.Text == "Annual") && (differenceInDays > Annual)) { PanException.Show(this.MdiParent, "Annual leave", "You are exceeding the number of remaining annual days"); return; } if ((this.Type_combo.Text == "Casual") && (differenceInDays > Casual)) { PanException.Show(this.MdiParent, "Casual leave", "You are exceeding the number of remaining casual days"); return; } DateTime start = Convert.ToDateTime(dateTimePicker3.Text); DateTime end = Convert.ToDateTime(dateTimePicker2.Text); String query = "insert into `leave`(Type,Reason,StartDate,EndDate,RequestedDate,Status,EmpId) values('" + this.Type_combo.Text + "','" + this.Reason.Text + "', @date1 , @date2 , CURDATE(),'Pending', '" + Connection.getUserIdFromConnectionString() + "')"; MySqlConnection connDatabase = ConnectionOld.getConnection(); MySqlCommand cmdDatabase = new MySqlCommand(query, connDatabase); MySqlParameter param = new MySqlParameter("@date1", MySqlDbType.Date); param.Value = dateTimePicker3.Value; MySqlParameter param2 = new MySqlParameter("@date2", MySqlDbType.Date); param2.Value = dateTimePicker2.Value; cmdDatabase.Parameters.Add(param); cmdDatabase.Parameters.Add(param2); try { connDatabase.Open(); cmdDatabase.ExecuteNonQuery(); //MessageBox.Show("Records are saved successfully\n"); PanMessage.Show(this.MdiParent, "Success", "Your leave request has been sent"); refreshEmpLeaveTable(); } catch (MySqlException ex) { PanException.Show(this.MdiParent, ex); } }
public bool isEmpty() { if (First_txt.Text == " ") { //MessageBox.Show("FirstName can't be null"); PanException.Show(this.MdiParent, "Validation Error", "FirstName can't be null"); return(false); } else if (Last_txt.Text == " ") { // MessageBox.Show("LastName can't be null"); PanException.Show(this.MdiParent, "Validation Error", "LastName can't be null"); return(false); } else if (nat == null) { //MessageBox.Show("Nationality can't be null"); PanException.Show(this.MdiParent, "Validation Error", "Nationality can't be null"); return(false); } else if (NIC_txt.Text == " ") { //MessageBox.Show("NIC can't be null"); PanException.Show(this.MdiParent, "Validation Error", "NIC can't be null"); return(false); } else if (Add_txt.Text == " ") { //MessageBox.Show("Address can't be null"); PanException.Show(this.MdiParent, "Validation Error", "Address can't be null"); return(false); } else if (Mob_txt.Text == "(__) __-_______") { //MessageBox.Show("MobileNo can't be null"); PanException.Show(this.MdiParent, "Validation Error", "MobileNo can't be null"); return(false); } else if (Email_txt.Text == " ") { //MessageBox.Show("Email can't be null"); PanException.Show(this.MdiParent, "Validation Error", "Email can't be null"); return(false); } else if (Posi_combo.Text == " ") { //MessageBox.Show("Position can't be null"); PanException.Show(this.MdiParent, "Validation Error", "Position can't be null"); return(false); } else { return(true); } }
public void Insert() { isEmpty(); if (!checkMail(this.Email_txt.Text)) { //MessageBox.Show("Not a valid Email address "); PanException.Show(this.MdiParent, "Validation Error", "Not a valid Email address"); return; } else if (labNationality.Text == "NIC" && (!checkNIC(this.NIC_txt.Text))) { //MessageBox.Show("Not a valid NIC Number "); PanException.Show(this.MdiParent, "Validation Error", "Not a valid NIC Number"); return; } else if (Double.Parse(textBox5.Text) < 10000) { //MessageBox.Show("Basic Salary should be above 10000"); PanException.Show(this.MdiParent, "Validation Error", "Basic Salary should be above 10000"); return; } /*if (!checkMobile()) * { * MessageBox.Show("Mobile Number should have 10 digits"); * return; * }*/ String us = assignUserName(); int val = getNewId(); Double sal = Double.Parse(this.textBox5.Text); String query = "insert into itp.employee(EmpId,FirstName,LastName,Nationality,Email,MobileNo,NIC,Position,DepId,Gender,DOB,Address,UserName,Password,BasicSalary) values('" + this.Emp_txt.Text + "','" + this.First_txt.Text + "','" + this.Last_txt.Text + "','" + nat + "','" + this.Email_txt.Text + "','" + this.Mob_txt.Text + "','" + this.NIC_txt.Text + "','" + this.Posi_combo.Text + "','" + dep + "','" + gender + "','" + this.dateTimePicker1.Text + "','" + this.Add_txt.Text + "','" + us + "','" + pw + "','" + sal + "'); "; MySqlConnection connDatabase = ConnectionOld.getConnection(); MySqlCommand cmdDatabase = new MySqlCommand(query, connDatabase); MySqlCommand createUser = new MySqlCommand("CREATE_USER", connDatabase); createUser.CommandType = CommandType.StoredProcedure; createUser.Parameters.AddWithValue("user_id_", this.Emp_txt.Text); createUser.Parameters.AddWithValue("password_", pw); createUser.Parameters.AddWithValue("name_", this.First_txt.Text + " " + this.Last_txt.Text); try { connDatabase.Open(); cmdDatabase.ExecuteNonQuery(); createUser.ExecuteNonQuery(); //MessageBox.Show("Records are saved successfully\n" + this.First_txt.Text + this.Last_txt.Text + " 's Username is " + us); PanMessage.Show(this.MdiParent, "Success", "Records are saved successfully\n" + this.First_txt.Text + this.Last_txt.Text + " 's Username is " + us); } catch (MySqlException ex) { PanException.Show(this.MdiParent, ex); } }
private void toolStripMenuItemNew_Click(object sender, EventArgs e) { try { rawsettingstabBindingSource.AddNew(); } catch (Exception ex) { PanException.Show(this.MdiParent, ex); } }
private void updateBtn_Click(object sender, EventArgs e) { if (validate.isEmpty(store.Text) && validate.isContact(officeNo.Text) && validate.isNumber(creditLimit.Text) && validate.isEmpty(address.Text) && validate.isChar(city.Text) && validate.isChar(district.Text) && validate.isChar(contact.Text) && validate.isChar(contactJob.Text) && validate.isContact(contactNum.Text)) { this.x = true; if (!String.IsNullOrEmpty(fax.Text)) { this.x = validate.isContact(fax.Text); } if (!String.IsNullOrEmpty(email.Text)) { this.x = validate.isEmail(email.Text); } } if (this.x == true) { try { DBConnect connection = new DBConnect(); connection.OpenConnection(); MySqlConnection returnConn = new MySqlConnection(); returnConn = connection.GetConnection(); string query = "UPDATE itp.buyer SET storeName='" + store.Text + "', contactName='" + contact.Text + "', contactJob='" + contactJob.Text + "', officeNo='" + officeNo.Text + "', personalNo='" + contactNum.Text + "', fax='" + fax.Text + "', email='" + email.Text + "', address='" + address.Text + "', city ='" + city.Text + "', district ='" + district.Text + "', creditLimit='" + creditLimit.Text + "' WHERE storeName ='" + listBox1.SelectedItem.ToString() + "'";; MySqlCommand cmd = new MySqlCommand(query, returnConn); cmd.Connection = returnConn; cmd.ExecuteNonQuery(); connection.CloseConnection(); this.listBox1.Items.Clear(); fillList(); PanMessage.Show(this.MdiParent, "Success", "Buyer information updated"); } catch (MySqlException ex) { PanException.Show(this.MdiParent, ex); //throw; } } else { PanException.Show(this.MdiParent, "Invalid entries", "Check entered fields"); } }
private void New() { try { DataRowView row = rawpurchaseorderBindingSource.AddNew() as DataRowView; row.Row.SetField("order_id", getNextId()); row.Row.SetField("creator", Connection.getUserIdFromConnectionString()); txtCreator.Text = Connection.getUserIdFromConnectionString(); txtOrderId.Text = getNextId(); } catch (Exception ex) { PanException.Show(this.MdiParent, ex); } }
private void listBox1_SelectedIndexChanged(object sender, EventArgs e) { try { DBConnect connection = new DBConnect(); connection.OpenConnection(); MySqlConnection returnConn = new MySqlConnection(); returnConn = connection.GetConnection(); string query = "SELECT * FROM itp.buyer WHERE storeName = '" + listBox1.Text + "'"; MySqlCommand cmd = new MySqlCommand(query, returnConn); try { using (MySqlDataReader read = cmd.ExecuteReader()) { int checkFax = read.GetOrdinal("fax"); //checks whether it contains null values int checkMail = read.GetOrdinal("email"); while (read.Read()) { store.Text = read.GetString("storeName").ToString(); officeNo.Text = read.GetString("officeNo").ToString(); creditLimit.Text = read.GetString("creditLimit").ToString(); //check sales info fax.Text = read.IsDBNull(checkFax) ? string.Empty : read.GetString("fax").ToString(); email.Text = read.IsDBNull(checkMail) ? string.Empty : read.GetString("email").ToString(); address.Text = read.GetString("address").ToString(); city.Text = read.GetString("city").ToString(); district.Text = read.GetString("district").ToString(); contact.Text = read.GetString("contactName").ToString(); contactJob.Text = read.GetString("contactJob").ToString(); contactNum.Text = read.GetString("personalNo").ToString(); } } } catch (MySqlException ex) { PanException.Show(this.MdiParent, ex); } } catch (MySqlException ex) { PanException.Show(this.MdiParent, ex); } }
public void setDetails() { String q2 = "update itp.employee set FirstName ='" + this.First_txt.Text + "', LastName ='" + this.Last_txt.Text + "',Gender ='" + gender + "', Address ='" + this.Add_txt.Text + "', MobileNo ='" + this.Mob_txt.Text + "', Email ='" + this.Email_txt.Text + "' where EmpId = '" + Connection.getUserIdFromConnectionString() + "' "; MySqlConnection connDatabase = ConnectionOld.getConnection(); MySqlCommand cmdDatabase = new MySqlCommand(q2, connDatabase); MySqlDataReader myReader; try { connDatabase.Open(); myReader = cmdDatabase.ExecuteReader(); //MessageBox.Show("Records are edited successfully"); PanMessage.Show(this.MdiParent, "Success", "Records are edited successfully"); } catch (MySqlException ex) { PanException.Show(this.MdiParent, ex); } }
private void button5_Click(object sender, EventArgs e) { String q2 = "update itp.leave set Status ='Denied' where EmpId = '" + emp + "' "; MySqlConnection connDatabase = ConnectionOld.getConnection(); MySqlCommand cmdDatabase = new MySqlCommand(q2, connDatabase); MySqlDataReader myReader; try { connDatabase.Open(); myReader = cmdDatabase.ExecuteReader(); //MessageBox.Show("You have rejected the request"); PanMessage.Show(this.MdiParent, "Leave Request", "Leave request rejected"); refreshHRLeaveTable(); } catch (MySqlException ex) { PanException.Show(this.MdiParent, ex); } }
//add to cart method private void button1_Click(object sender, EventArgs e) { if (textBox4.Text == "0" || String.IsNullOrEmpty(textBox4.Text)) { PanException.Show(this.MdiParent, "Error", "Select quantity"); } else { DataGridViewRow row = (DataGridViewRow)metroGrid1.Rows[0].Clone(); row.Cells[0].Value = this.tempPID; row.Cells[1].Value = this.tempItem; row.Cells[2].Value = this.tempUnitPrice; row.Cells[3].Value = textBox4.Text; row.Cells[4].Value = this.tempTotal; metroGrid1.Rows.Add(row); this.count = this.count + this.tempTotal; textBox5.Text = this.count.ToString(); //MessageBox.Show("Successfully added"); } }
/*public bool checkMail() * { * string pattern = null; * pattern = "^([0-9a-zA-Z]([-\\.\\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\\w]*[0-9a-zA-Z]\\.)+[a-zA-Z]{2,9})$"; * * if (!Regex.IsMatch(Email_txt.Text, pattern)) * { * * return false; * } * return true; * }*/ //bool checkMail(string email) //{ // try // { // var addr = new System.Net.Mail.MailAddress(email); // return addr.Address == email; // } // catch // { // return false; // } //} public static bool checkMail(String s) { try { int num = s.IndexOf('@'); int num2 = s.IndexOf('.'); if (!string.IsNullOrEmpty(s) && (s[0] != ' ' || s[0] != '\t' || s[0] != '.')) { if (s.EndsWith(".com") || s.EndsWith(".lk")) { if (num < num2 && (num + 1) != num2) { return(true); } else { PanException.Show(null, "invalid email id", "error"); return(false); } } else { PanException.Show(null, "enter a valid email id", "error"); return(false); } } else { PanException.Show(null, "enter a valid email id", "error"); return(false); } } catch { return(false); } }
private void fillList() { try { DBConnect connection = new DBConnect(); connection.OpenConnection(); MySqlConnection returnConn = new MySqlConnection(); returnConn = connection.GetConnection(); string query = "SELECT * FROM itp.buyer ORDER BY storeName"; MySqlCommand cmd = new MySqlCommand(query, returnConn); cmd.CommandType = CommandType.Text; //default MySqlDataReader sqlread; try { //returnConn.Open(); sqlread = cmd.ExecuteReader(); while (sqlread.Read()) { string store = sqlread.GetString("storeName"); listBox1.Items.Add(store); } } catch (MySqlException ex) { PanException.Show(this.MdiParent, ex); } } catch (MySqlException ex) { PanException.Show(this.MdiParent, ex); } }
public void refreshSalaryTable() { MySqlConnection connDatabase = ConnectionOld.getConnection(); MySqlCommand q4 = new MySqlCommand("select Month,NetSalary from salary where EmpId = @empid ;", connDatabase); q4.Parameters.AddWithValue("@empId", Connection.getUserIdFromConnectionString()); try { MySqlDataAdapter sal = new MySqlDataAdapter(); sal.SelectCommand = q4; DataTable dt = new DataTable(); sal.Fill(dt); BindingSource bSal = new BindingSource(); bSal.DataSource = dt; metroGrid1.DataSource = bSal; //sda.Update(dataset); } catch (MySqlException ex) { PanException.Show(this.MdiParent, ex); } }
public void displayDataGridViewSearch() { q5 = "select EmpId,FirstName,LastName,Position,DepId,Address,MobileNo,Email from itp.employee ;"; MySqlConnection connDatabase = ConnectionOld.getConnection(); MySqlCommand q4 = new MySqlCommand(q5, connDatabase); try { MySqlDataAdapter sda = new MySqlDataAdapter(); sda.SelectCommand = q4; dataset = new DataTable(); sda.Fill(dataset); BindingSource bSource = new BindingSource(); bSource.DataSource = dataset; dataGridView2.DataSource = bSource; //sda.Update(dataset); } catch (MySqlException ex) { PanException.Show(this.MdiParent, ex); } }
private void metroGrid1_DataError(object sender, DataGridViewDataErrorEventArgs e) { PanException.metroGrid1_DataError(this.MdiParent, sender, e); }
private void button1_Click(object sender, EventArgs e) { string amount; string desc; string cheque; string bank; string invoice = comboBox1.Text; string payee = textBox1.Text; try { DBConnect connection = new DBConnect(); connection.OpenConnection(); MySqlConnection returnConn = new MySqlConnection(); returnConn = connection.GetConnection(); string query = "INSERT INTO itp.payment (invoiceNo, paid, description) VALUES (@1, @2, @3)"; MySqlCommand cmd = new MySqlCommand(query, returnConn); //cmd.CommandType = CommandType.Text; //default cmd.Parameters.AddWithValue("@1", invoice); if (radioButton1.Checked) { amount = textBox6.Text; int n; if (!string.IsNullOrEmpty(amount) || !string.IsNullOrWhiteSpace(amount) || int.TryParse(amount, out n)) { desc = "Payee " + payee + " has used Cash Payment method"; cmd.Parameters.AddWithValue("@2", amount); cmd.Parameters.AddWithValue("@3", desc); } else { PanException.Show(this.MdiParent, "Invalid Input", "Invalid value for amount"); } } else if (radioButton2.Checked) { amount = textBox5.Text; cheque = textBox3.Text; bank = textBox4.Text; int n; if (!string.IsNullOrEmpty(amount) || !string.IsNullOrWhiteSpace(amount) || int.TryParse(amount, out n) || int.TryParse(cheque, out n)) { desc = "Payee " + payee + " has used Cheque Payment method - Cheque No: " + cheque + " / Bank: " + bank; cmd.Parameters.AddWithValue("@2", amount); cmd.Parameters.AddWithValue("@3", desc); } else { PanException.Show(this.MdiParent, "Error", "Invalid Inputs"); } } else { PanException.Show(this.MdiParent, "Error", "Select a payment method"); } //connection.OpenConnection(); cmd.ExecuteNonQuery(); connection.CloseConnection(); PanMessage.Show(this.MdiParent, "Success"); } catch (MySqlException ex) { PanException.Show(this.MdiParent, ex); } }
private void Employee_Load(object sender, EventArgs e) { Emp_txt.ReadOnly = true; dateTimePicker3.MinDate = DateTime.Now.AddDays(1); dateTimePicker2.MinDate = dateTimePicker3.MinDate.AddDays(1); dateTimePicker2.MaxDate = DateTime.Now.AddMonths(2); refreshSalaryTable(); combo_Month.SelectedIndex = 0; radioButton1.Enabled = true; radioButton2.Enabled = true; AddOT.TabPages.Remove(tabCheckLeaveRequests); AddOT.TabPages.Remove(tabAddOT); //AddOT.TabPages.Remove(tabCalSalary); MySqlConnection con = ConnectionOld.getConnection(); MySqlCommand sc = new MySqlCommand("select role from user_role_tab where user = @user", con); sc.Parameters.AddWithValue("@user", Connection.getUserIdFromConnectionString()); try { con.Open(); MySqlDataReader read = sc.ExecuteReader(); while (read.Read()) { string role = read.GetString("role"); switch (role) { case "HR Manager": AddNewEmp.Show(); Save.Show(); AddOT.TabPages.Remove(tabSendLeaveRequests); //AddOT.TabPages.Remove(tabViewSalary); //this.tabViewSalary.Text = "Calculate Salary"; AddOT.TabPages.Add(tabCheckLeaveRequests); AddOT.TabPages.Add(tabAddOT); //AddOT.TabPages.Add(tabCalSalary); Rem.Show(); //Emp_txt.ReadOnly = false; First_txt.ReadOnly = false; Last_txt.ReadOnly = false; //radioButton1.Enabled = true; //radioButton2.Enabled = true; dateTimePicker1.Enabled = true; Nat_txt.ReadOnly = false; NIC_txt.ReadOnly = false; Add_txt.ReadOnly = false; Mob_txt.ReadOnly = false; Email_txt.ReadOnly = false; Posi_combo.Enabled = true; textBox5.ReadOnly = false; combo_Nat.Enabled = true; break; } } } catch (MySqlException ex) { PanException.Show(this.MdiParent, ex); } finally { con.Close(); } /* first2 = Login.un.Substring(0, 2); * if (tabControl1.SelectedIndex == 0 && first2 != "HR") * { * AddNewEmp.Hide(); * Rem.Hide(); * Emp_txt.ReadOnly = true; * First_txt.ReadOnly = true; * Last_txt.ReadOnly = true; * radioButton1.Enabled = false; * radioButton2.Enabled = false; * dateTimePicker1.Enabled = false; * Nat_txt.ReadOnly = true; * NIC_txt.ReadOnly = true; * Add_txt.ReadOnly = false; * Mob_txt.ReadOnly = false; * Email_txt.ReadOnly = false; * Posi_combo.Enabled = false; * } * * if (tabControl1.SelectedIndex == 1 && first2 != "HR") * { * Calculate.Hide(); * button2.Hide(); * } * * if (first2 != "HR") * { * tabControl1.TabPages.Remove(tabPage5); * tabControl1.TabPages.Remove(tabPage2); * } * else * { * tabControl1.TabPages.Remove(tabPage3); * this.tabPage2.Text = "Calculate Salary"; * } * * if (tabPage4.Text == "Search Employees" && first2 == "HR") * { * Rem.Show(); * }*/ }
//confirm order method private void button3_Click(object sender, EventArgs e) { string query, query2; string mailOrder = null; try { DBConnect conn = new DBConnect(); conn.OpenConnection(); MySqlConnection returnConn = new MySqlConnection(); returnConn = conn.GetConnection(); if (!string.IsNullOrEmpty(textBox1.Text) || !string.IsNullOrEmpty(this.tempBuyerId) || metroGrid1.Rows.Count != 0 || !string.IsNullOrEmpty(this.tempDate) || !string.IsNullOrEmpty(this.tempAgent)) { for (int i = 0; i < metroGrid1.Rows.Count - 1; i++) { query = "INSERT INTO itp.orders (invoiceNo, buyerId, productId, quantity, unitPrice, total, shippingDate, empId) VALUES (" + "'" + textBox1.Text + "'," + "'" + this.tempBuyerId + "'," + metroGrid1.Rows[i].Cells[0].Value + "," + metroGrid1.Rows[i].Cells[3].Value + "," + metroGrid1.Rows[i].Cells[2].Value + "," + metroGrid1.Rows[i].Cells[4].Value + "," + "'" + this.tempDate + "'," + "'" + this.tempAgent + "');"; #region !!!!!!!! query2 = "INSERT INTO itp.payment (invoiceNo, paid, description) VALUES ('" + textBox1.Text + "', 0, 'Order received - Payment yet be received')"; MySqlCommand cmd = new MySqlCommand(query, returnConn); cmd.ExecuteNonQuery(); MySqlCommand cmd2 = new MySqlCommand(query2, returnConn); cmd2.ExecuteNonQuery(); #endregion mailOrder += "" + metroGrid1.Rows[i].Cells[0].Value + " (" + metroGrid1.Rows[i].Cells[3].Value + ") =" + metroGrid1.Rows[i].Cells[4].Value + " \n"; } PanMessage.Show(this.MdiParent, "Order has been placed"); conn.CloseConnection(); if (!String.IsNullOrEmpty(this.tempMail)) { try { mailOrder += "------------------------------------------ \n" + "Grand total = " + this.count + "\n" + "Delivery Date = " + this.tempDate; emailThis mail = new emailThis(); mail.sendMail(this.tempMail, mailOrder); } catch (Exception ex) { PanException.Show(this.MdiParent, "Error", "Mail has not been sent"); } } //invoiceViewer a = new invoiceViewer(); //a.method1(textBox1.Text); //a.method2(textBox2.Text); } else { PanException.Show(this, "Invalid inputs", "Please recheck your entry"); } } catch (MySqlException ex) { PanException.Show(this.MdiParent, "Error", "Invoice duplicating is not allowed\n" + ex); } }