private void btnSave_Click_1(object sender, EventArgs e) { if (cboClientID.Text == "") { MessageBox.Show("Ensure all fields are filled!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Error); cboClientID.Focus(); } else if (cboVehicleID.Text == "") { MessageBox.Show("Ensure all fields are filled!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Error); cboVehicleID.Focus(); } else if (dtReturn.Text == "") { MessageBox.Show("Ensure all fields are filled!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Error); dtReturn.Focus(); } else if (txtExtracost.Text == "") { MessageBox.Show("Ensure all fields are filled!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Error); txtExtracost.Focus(); } /** else * { * if (FindRecord(txtClientID.Text) == true) * { * MessageBox.Show(txtClientID.Text + " already exists!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); * txtVehicleID.Focus(); * }**/ string query; query = "INSERT INTO Check_in VALUES('" + cboClientID.Text + "','" + cboVehicleID.Text + "','" + dtReturn.Text + "','" + txtExtracost.Text + "')"; conn cn = new conn(); if (cn.OpenConnection() == true) { if (MessageBox.Show("Are you sure you want to save record?", "KUNIS Messaging System", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { MySqlCommand cmd = new MySqlCommand(query, cn.connect); cmd.ExecuteNonQuery(); cleanData(); MessageBox.Show("Records Saved!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Records not Saved!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); cboClientID.Focus(); } } cn.CloseConnection(); }
private void button1_Click_1(object sender, EventArgs e) { if (txtEmployeeID.Text == "") { MessageBox.Show("Ensure all fields are filled!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Error); txtEmployeeID.Focus(); } else if (txtEmployeeName.Text == "") { MessageBox.Show("Ensure all fields are filled!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Error); txtEmployeeName.Focus(); } else if (txtMobileNo.Text == "") { MessageBox.Show("Ensure all fields are filled!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Error); txtMobileNo.Focus(); } else { if (FindRecord(txtEmployeeID.Text) == true) { MessageBox.Show(txtEmployeeID.Text + " already exists!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtEmployeeID.Focus(); } string query; query = "INSERT INTO Employee VALUES('" + txtEmployeeID.Text + "','" + txtEmployeeName.Text + "','" + txtMobileNo.Text + "')"; conn cn = new conn(); if (cn.OpenConnection() == true) { if (MessageBox.Show("Are you sure you want to save record?", "KUNIS Messaging System", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { MySqlCommand cmd = new MySqlCommand(query, cn.connect); cmd.ExecuteNonQuery(); cleanData(); MessageBox.Show("Records Saved!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Records not Saved!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtEmployeeID.Focus(); } } cn.CloseConnection(); } }
private void btnDelete_Click_1(object sender, EventArgs e) { if (txtVehicleID.Text == "") { MessageBox.Show("Ensure all fields are filled!", "Vehicle Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Error); txtVehicleID.Focus(); } else if (txtMake.Text == "") { MessageBox.Show("Ensure all fields are filled!", "Vehicle Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Error); txtMake.Focus(); } else if (txtModel.Text == "") { MessageBox.Show("Ensure all fields are filled!", "Vehicle Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Error); txtModel.Focus(); } else if (txtSearch.Text == "") { MessageBox.Show("Ensure all fields are filled!", "Vehicle Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Error); txtSearch.Focus(); } else { query = "DELETE FROM Vehicle WHERE Vehicle_ID='" + txtSearch.Text + "'"; conn cn = new conn(); if (cn.OpenConnection() == true) { if (MessageBox.Show("Are you sure you want to delete record?", "Vehicle Messaging System", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { MySqlCommand cmd = new MySqlCommand(query, cn.connect); cmd.ExecuteNonQuery(); cleanData(); MessageBox.Show("Record deleted!", "Vehicle Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Record failed to delete!", "Vehicle Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtVehicleID.Focus(); } } cn.CloseConnection(); } }
private void btnSave_Click(object sender, EventArgs e) { if (txtClientID.Text == "") { MessageBox.Show("Ensure all fields are filled!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Error); txtClientID.Focus(); } else if (txtClientName.Text == "") { MessageBox.Show("Ensure all fields are filled!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Error); txtClientName.Focus(); } else if (txtMobileNo.Text == "") { MessageBox.Show("Ensure all fields are filled!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Error); txtMobileNo.Focus(); } /** else if (!IsValidEmail(txtEmail.Text.Replace(" ", "").ToString())) * { * MessageBox.Show("Invalid Email", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); * txtEmail.Focus(); * }*/ else if (txtCountry.Text == "") { MessageBox.Show("Ensure all fields are filled!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Error); txtCountry.Focus(); } /** else if (txtOwnerID.Text == "") * { * MessageBox.Show("Ensure all fields are filled!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Error); * txtOwnerID.Focus(); * } * else if (!long.TryParse(phn, out phone)) * { * MessageBox.Show("Invalid Phone Number!", "Looptech International Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); * txtPhoneNo.Focus(); * } * else if (!txtPhoneNo.Text.Contains("+")) * { * MessageBox.Show("Invalid Phone Number!", "Looptech International Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); * txtPhoneNo.Focus(); * }*/ else { if (FindRecord(txtClientID.Text) == true) { MessageBox.Show(txtClientID.Text + " already exists!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtClientID.Focus(); } else { int sts; //string gnder; if (chckStatus.CheckState == CheckState.Checked) { sts = 1; } else { sts = 0; } /** if (rbtnFemale.Checked == true) * { * gnder = "Female"; * } * else * { * gnder = "Male"; * }*/ string query; // pic = txtPic.Text.Replace("\\", "__"); query = "INSERT INTO Client VALUES('" + txtClientID.Text + "','" + txtClientName.Text + "','" + txtMobileNo.Text + "','" + txtCountry.Text + "','" + sts + "')"; conn cn = new conn(); if (cn.OpenConnection() == true) { if (MessageBox.Show("Are you sure you want to save record?", "KUNIS Messaging System", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { MySqlCommand cmd = new MySqlCommand(query, cn.connect); cmd.ExecuteNonQuery(); cleanData(); MessageBox.Show("Records Saved!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Records not Saved!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtClientID.Focus(); } } cn.CloseConnection(); } } }
private void btnLogin_Click(object sender, EventArgs e) { if (txtLoginName.Text.Replace(" ", "") == "") { MessageBox.Show("Ensure all fields are filled!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtLoginName.Focus(); } else if (txtPassword.Text == "") { MessageBox.Show("Ensure all fields are filled!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtPassword.Focus(); } else { conn connect = new conn(); string query = "SELECT * FROM Users WHERE User_Name='" + txtLoginName.Text.ToString() + "' AND Password='******' AND Status=1"; //open connection if (connect.OpenConnection() == true) { //create command and assign the query and connection from the constructor MySqlCommand cmd = new MySqlCommand(query, connect.connect); MySqlDataReader dataReader = cmd.ExecuteReader(); //Read the data and store them in the list if (dataReader.Read()) { //list[0].Add(dataReader["id"] + ""); //list[1].Add(dataReader["name"] + ""); if (dataReader["User_Name"].ToString() == txtLoginName.Text && dataReader["Password"].ToString() == txtPassword.Text) { Sessions.username = dataReader["User_Name"].ToString(); Sessions.prev = dataReader["Priveledges"].ToString(); Sessions.userID = dataReader["User_ID"].ToString(); Sessions.loginTime = DateTime.Now.ToString(); MDI mdi = new MDI(); mdi.Visible = true; this.Dispose(); } else { MessageBox.Show("Username/Password Mismatch!\nPlease Try again!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtLoginName.Text = ""; txtPassword.Text = ""; txtLoginName.Focus(); } } else { MessageBox.Show("Username/Password Mismatch!\nPlease Try again!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtLoginName.Text = ""; txtPassword.Text = ""; txtLoginName.Focus(); } //close Data Reader dataReader.Close(); //close connection connect.CloseConnection(); } } }
private void btnEdit_Click_1(object sender, EventArgs e) { if (txtVehicleID.Text == "") { MessageBox.Show("Ensure all fields are filled!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Error); txtVehicleID.Focus(); } else if (txtMake.Text == "") { MessageBox.Show("Ensure all fields are filled!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Error); txtMake.Focus(); } else if (txtModel.Text == "") { MessageBox.Show("Ensure all fields are filled!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Error); txtModel.Focus(); } else if (dtpicDoR.Text == "") { MessageBox.Show("Ensure all fields are filled!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Error); dtpicDoR.Focus(); } else if (txtRate.Text == "") { MessageBox.Show("Ensure all fields are filled!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Error); txtRate.Focus(); } else if (cboOwnerID.Text == "") { MessageBox.Show("Ensure all fields are filled!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Error); cboOwnerID.Focus(); } else { int sts; // string gnder; if (chckStatus.CheckState == CheckState.Checked) { sts = 1; } else { sts = 0; } string pic; pic = txtPic.Text.Replace("\\", "__"); query = "UPDATE Vehicle SET Vehicle_ID='" + txtVehicleID.Text + "',Make='" + txtMake.Text + "',Model='" + txtModel.Text + "',Reg_Date='" + dtpicDoR.Value.ToString("yyyy-MM-dd") + "',Rate='" + txtRate.Text + "',Owner_ID='" + cboOwnerID.Text + "',Status='" + sts + "',Photo='" + pic + "' WHERE Vehicle_ID='" + txtVehicleID.Text + "'"; conn cn = new conn(); if (cn.OpenConnection() == true) { if (MessageBox.Show("Are you sure you want to save changes?", "KUNIS Messaging System", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { MySqlCommand cmd = new MySqlCommand(query, cn.connect); cmd.ExecuteNonQuery(); cleanData(); MessageBox.Show("Records Saved!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Records not Saved!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtVehicleID.Focus(); } } cn.CloseConnection(); } }
private void btnSave_Click(object sender, EventArgs e) { if (txtVehicleID.Text == "") { MessageBox.Show("Ensure all fields are filled!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Error); txtVehicleID.Focus(); } else if (txtMake.Text == "") { MessageBox.Show("Ensure all fields are filled!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Error); txtMake.Focus(); } else if (txtModel.Text == "") { MessageBox.Show("Ensure all fields are filled!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Error); txtModel.Focus(); } else if (txtRate.Text == "") { MessageBox.Show("Ensure all fields are filled!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Error); txtRate.Focus(); } else if (cboOwnerID.Text == "") { MessageBox.Show("Ensure all fields are filled!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Error); cboOwnerID.Focus(); } else { if (FindRecord(txtVehicleID.Text) == true) { MessageBox.Show(txtVehicleID.Text + " already exists!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtVehicleID.Focus(); } else { int sts; //string gnder; if (chckStatus.CheckState == CheckState.Checked) { sts = 1; } else { sts = 0; } string pic; pic = txtPic.Text.Replace("\\", "__"); query = "INSERT INTO Vehicle VALUES('" + txtVehicleID.Text + "','" + txtMake.Text + "','" + txtModel.Text + "','" + dtpicDoR.Value.ToString("yyyy-MM-dd") + "','" + txtRate.Text + "','" + cboOwnerID.Text + "', '" + sts + "','" + pic + "')"; conn cn = new conn(); if (cn.OpenConnection() == true) { if (MessageBox.Show("Are you sure you want to save record?", "KUNIS Messaging System", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { MySqlCommand cmd = new MySqlCommand(query, cn.connect); cmd.ExecuteNonQuery(); cleanData(); MessageBox.Show("Records Saved!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Records not Saved!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtVehicleID.Focus(); } } cn.CloseConnection(); } } }
private void btnSave_Click_1(object sender, EventArgs e) { if (cboClientID.Text == "") { MessageBox.Show("Ensure all fields are filled!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Error); cboClientID.Focus(); } else if (cboVehicleID.Text == "") { MessageBox.Show("Ensure all fields are filled!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Error); cboVehicleID.Focus(); } else if (dtHire.Text == "") { MessageBox.Show("Ensure all fields are filled!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Error); dtHire.Focus(); } /** else if (!IsValidEmail(txtEmail.Text.Replace(" ", "").ToString())) * { * MessageBox.Show("Invalid Email", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); * txtEmail.Focus(); * }*/ else if (txtDuration.Text == "") { MessageBox.Show("Ensure all fields are filled!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Error); txtDuration.Focus(); } else if (txtDuration.Text == "") { MessageBox.Show("Ensure all fields are filled!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Error); txtDuration.Focus(); } else if (txtAmountPaid.Text == "") { MessageBox.Show("Ensure all fields are filled!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Error); txtAmountPaid.Focus(); } else { if (FindRecord(cboClientID.Text) == true) { MessageBox.Show(cboClientID.Text + " already exists!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); cboClientID.Focus(); } else { int sts; if (chckStatus.CheckState == CheckState.Checked) { sts = 1; } else { sts = 0; } string query; query = "INSERT INTO Check_out VALUES('" + cboClientID.Text + "','" + cboVehicleID.Text + "','" + dtHire.Value.ToString("yyyy-MM-dd") + "','" + txtDuration.Text + "','" + txtDescription.Text + "','" + sts + "','" + txtAmountPaid.Text + "')"; conn cn = new conn(); if (cn.OpenConnection() == true) { if (MessageBox.Show("Are you sure you want to save record?", "KUNIS Messaging System", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { MySqlCommand cmd = new MySqlCommand(query, cn.connect); cmd.ExecuteNonQuery(); cleanData(); MessageBox.Show("Records Saved!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Records not Saved!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); cboClientID.Focus(); } } cn.CloseConnection(); } } }
private void btnSave_Click(object sender, EventArgs e) { if (txtUserID.Text == "") { MessageBox.Show("Ensure all fields are filled!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Error); txtUserID.Focus(); } else if (txtUserName.Text == "") { MessageBox.Show("Ensure all fields are filled!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Error); txtUserName.Focus(); } else if (txtPassword.Text == "") { MessageBox.Show("Ensure all fields are filled!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Error); txtPassword.Focus(); } else if (cboPriveledges.Text == "") { MessageBox.Show("Ensure all fields are filled!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Error); cboPriveledges.Focus(); } else { if (FindRecord(txtUserID.Text) == true) { MessageBox.Show(txtUserID.Text + " already exists!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtUserID.Focus(); } else { int sts; if (chckStatus.CheckState == CheckState.Checked) { sts = 1; } else { sts = 0; } string query; query = "INSERT INTO Users VALUES('" + txtUserID.Text + "','" + txtUserName.Text + "','" + txtPassword.Text + "','" + cboPriveledges.Text + "','" + sts + "')"; conn cn = new conn(); if (cn.OpenConnection() == true) { if (MessageBox.Show("Are you sure you want to save record?", "KUNIS Messaging System", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { MySqlCommand cmd = new MySqlCommand(query, cn.connect); cmd.ExecuteNonQuery(); cleanData(); MessageBox.Show("Records Saved!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Records not Saved!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtUserID.Focus(); } } cn.CloseConnection(); } } }
private void btnEdit_Click(object sender, EventArgs e) { if (txtUserID.Text == "") { MessageBox.Show("Ensure all fields are filled!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Error); txtUserID.Focus(); } else if (txtUserName.Text == "") { MessageBox.Show("Ensure all fields are filled!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Error); txtUserName.Focus(); } else if (txtPassword.Text == "") { MessageBox.Show("Ensure all fields are filled!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Error); txtPassword.Focus(); } else if (cboPriveledges.Text == "") { MessageBox.Show("Ensure all fields are filled!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Error); cboPriveledges.Focus(); } else { int sts; // string gnder; if (chckStatus.CheckState == CheckState.Checked) { sts = 1; } else { sts = 0; } string query; //pic = txtPic.Text.Replace("\\", "__"); query = "UPDATE Users SET User_ID='" + txtUserID.Text + "',User_Name='" + txtUserName.Text + "',Password='******',Priveledges='" + cboPriveledges.Text + "',Status='" + sts + "' WHERE User_ID='" + txtUserID.Text + "'"; conn cn = new conn(); if (cn.OpenConnection() == true) { if (MessageBox.Show("Are you sure you want to save changes?", "KUNIS Messaging System", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { MySqlCommand cmd = new MySqlCommand(query, cn.connect); cmd.ExecuteNonQuery(); cleanData(); MessageBox.Show("Records Saved!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Records not Saved!", "KUNIS Messaging System", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtUserID.Focus(); } } cn.CloseConnection(); } }