07-05-2011, 02:49 PM
Settings
Title.cs (School Title)
Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.OleDb;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace SchoolManagementSystem
{
public partial class Title : Form
{
OleDbConnection con = new OleDbConnection(ConnectionStringForSMS.MyConnectionString());
public Title()
{
InitializeComponent();
}
private void btnsubmit_Click(object sender, EventArgs e)
{
try
{
if (txttitle.Text.Trim() == "" || txtaddress.Text.Trim() == "")
{
MessageBox.Show("Please Enter Title And Address", "School Management System");
txttitle.Focus();
}
else
{
OleDbDataAdapter datitle = new OleDbDataAdapter("Select Address from Schooltitle", con);
DataSet dstitle = new DataSet();
datitle.Fill(dstitle);
if (dstitle.Tables[0].Rows.Count > 0)
{
DialogResult result;
result = MessageBox.Show("Do you want to change the title", "School Mangement System", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
if (result == System.Windows.Forms.DialogResult.Yes)
{
con.Open();
string title = dstitle.Tables[0].Rows[0][0].ToString();
OleDbCommand cmdtitle = new OleDbCommand("Update Schooltitle set SchoolTitle='" + txttitle.Text + "',Address='" + txtaddress.Text + "'where Address='" + title + "' ", con);
cmdtitle.ExecuteNonQuery();
con.Close();
con.Open();
OleDbCommand cmd = new OleDbCommand("Update Class set SchoolTitle='" + txttitle.Text + "',Address='" + txtaddress.Text + "' where Address='" + title + "' ", con);
cmd.ExecuteNonQuery();
con.Close();
con.Open();
OleDbCommand cmd1 = new OleDbCommand("Update AddTeacher set SchoolTitle='" + txttitle.Text + "',SchoolAddress='" + txtaddress.Text + "' where SchoolAddress='" + title + "' ", con);
cmd1.ExecuteNonQuery();
con.Close();
MessageBox.Show("Title Changed Successfully", "School Management System", MessageBoxButtons.OK, MessageBoxIcon.Information);
txttitle.Text = "";
txtaddress.Text = "";
}
else if (result == System.Windows.Forms.DialogResult.No)
{
txttitle.Focus();
}
}
}
}
catch (Exception ex)
{
MessageBox.Show("Try Again", "School Management System", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void btncancel_Click(object sender, EventArgs e)
{
txttitle.Text = "";
txtaddress.Text = "";
txttitle.Focus();
}
private void Title_Load(object sender, EventArgs e)
{
OleDbDataAdapter da23 = new OleDbDataAdapter("select schooltitle,Address from schooltitle", con);
DataSet ds23 = new DataSet();
da23.Fill(ds23);
string schooltitle = ds23.Tables[0].Rows[0].ItemArray[0].ToString();
string address = ds23.Tables[0].Rows[0].ItemArray[1].ToString();
this.Text = schooltitle + "-SetTitle";
label4.Text = "";
label4.Text = schooltitle;
}
private void txttitle_Leave(object sender, EventArgs e)
{
txttitle.Text = ConnectionStringForSMS.Capitalize(txttitle.Text);
}
private void txtaddress_Leave(object sender, EventArgs e)
{
txtaddress.Text = ConnectionStringForSMS.Capitalize(txtaddress.Text);
}
private void button1_Click(object sender, EventArgs e)
{
this.Close();
}
private void pictureBox1_Click(object sender, EventArgs e)
{
this.Close();
SettringsForm s = new SettringsForm();
s.Show();
}
private void pictureBox2_Click(object sender, EventArgs e)
{
this.Close();
SMSMainForm a = new SMSMainForm();
a.Show();
}
}
}