Beispiel #1
0
 private void cmbBatchSearch_SelectedIndexChanged(object sender, EventArgs e)
 {
     try
     {
         CmbClassSearch.Items.Clear();
         CmbClassSearch.Text    = "";
         CmbClassSearch.Enabled = true;
         CmbClassSearch.Focus();
         con = new SqlConnection(cs.DBcon);
         con.Open();
         string ct1 = "SELECT distinct Rtrim(MarksEntry.StudentClass) FROM MarksEntry INNER JOIN MarksEntry_Join ON MarksEntry.M_ID = MarksEntry_Join.MarksID where MarksEntry.StudentSchool=@d1 and MarksEntry.Session=@d2";
         cmd            = new SqlCommand(ct1);
         cmd.Connection = con;
         cmd.Parameters.AddWithValue("@d1", cmbSchoolSearch.Text);
         cmd.Parameters.AddWithValue("@d2", cmbBatchSearch.Text);
         rdr = cmd.ExecuteReader();
         while (rdr.Read())
         {
             CmbClassSearch.Items.Add(rdr[0]);
         }
         con.Close();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
 private void cmbBatchSearch_SelectedIndexChanged(object sender, EventArgs e)
 {
     try
     {
         CmbClassSearch.Items.Clear();
         CmbClassSearch.Text    = "";
         CmbClassSearch.Enabled = true;
         CmbClassSearch.Focus();
         con = new SqlConnection(cs.DBcon);
         con.Open();
         string ct1 = "SELECT distinct Rtrim(Class.ClassName) FROM Student INNER JOIN School ON Student.School_ID = School.SchoolID INNER JOIN Sessions ON Student.Session_ID = Sessions.SessionID INNER JOIN ClassSection ON Student.ClassSection_ID = ClassSection.ClassSectionID INNER JOIN Class ON ClassSection.Class_ID = Class.ClassID where School.SchoolName=@d1 and Sessions.Session=@d2";
         cmd            = new SqlCommand(ct1);
         cmd.Connection = con;
         cmd.Parameters.AddWithValue("@d1", cmbSchoolSearch.Text);
         cmd.Parameters.AddWithValue("@d2", cmbBatchSearch.Text);
         rdr = cmd.ExecuteReader();
         while (rdr.Read())
         {
             CmbClassSearch.Items.Add(rdr[0]);
         }
         con.Close();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Beispiel #3
0
 private void Button1_Click(object sender, EventArgs e)
 {
     try
     {
         if (cmbSchoolSearch.Text == "")
         {
             MessageBox.Show("Please select school", "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             cmbSchoolSearch.Focus();
             return;
         }
         if (cmbBatchSearch.Text == "")
         {
             MessageBox.Show("Please Enter Batch", "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             cmbBatchSearch.Focus();
             return;
         }
         if (CmbClassSearch.Text == "")
         {
             MessageBox.Show("Please Enter Class", "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             CmbClassSearch.Focus();
             return;
         }
         Cursor         = Cursors.WaitCursor;
         Timer1.Enabled = true;
         con            = new SqlConnection(cs.DBcon);
         con.Open();
         cmd    = new SqlCommand("SELECT * FROM Student INNER JOIN MarksEntry ON Student.AdmissionNo = MarksEntry.AdmissionNo INNER JOIN MarksEntry_Join ON MarksEntry.M_ID = MarksEntry_Join.MarksID INNER JOIN Subject ON MarksEntry_Join.Subject_ID = Subject.SubjectID Where StudentSchool=@d1 and MarksEntry.Session=@d2 and StudentClass=@d3", con);
         adp    = new SqlDataAdapter(cmd);
         dtable = new DataTable();
         adp.Fill(dtable);
         ds = new DataSet();
         con.Close();
         ds.Tables.Add(dtable);
         frm.ShowDialog();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
        private void btnUpdate_record_Click(object sender, EventArgs e)
        {
            try
            {
                if (cmbSchoolSearch.Text == "")
                {
                    MessageBox.Show("Please select school name", "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    cmbSchoolSearch.Focus();
                    return;
                }
                if (cmbBatchSearch.Text == "")
                {
                    MessageBox.Show("Please select session", "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    cmbBatchSearch.Focus();
                    return;
                }
                if (CmbClassSearch.Text == "")
                {
                    MessageBox.Show("Please select class", "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    CmbClassSearch.Focus();
                    return;
                }
                if (cmbSubjectName.Text == "")
                {
                    MessageBox.Show("Please select subject name", "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    cmbSubjectName.Focus();
                    return;
                }
                if (cmbStaffName.Text == "")
                {
                    MessageBox.Show("Please select staff name", "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    cmbStaffName.Focus();
                    return;
                }
                if (txtStaffID.Text == "")
                {
                    MessageBox.Show("Please retrieve staff id", "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    txtStaffID.Focus();
                    return;
                }

                if (listView1.Items.Count == 0)
                {
                    MessageBox.Show("Sorry nothing to save.. Please retrieve data in listview", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                con = new SqlConnection(cs.DBcon);
                con.Open();
                string cd = "Update Set AttendanceMaster SetStaffID=@d2,AttendanceDate=@d3,SubjectID=@d4 where AttendanceID=@d1";
                cmd = new SqlCommand(cd);
                cmd.Parameters.AddWithValue("@d1", txtAttendanceID.Text);
                cmd.Connection = con;
                con.Open();
                cmd.ExecuteNonQuery();
                con.Close();
                con = new SqlConnection(cs.DBcon);
                con.Open();
                string cq1 = "delete from Attendance where Attendance_ID='" + txtAttendanceID.Text + "'";
                cmd            = new SqlCommand(cq1);
                cmd.Connection = con;
                cmd.ExecuteNonQuery();
                con.Close();

                MessageBox.Show("Successfully Updated", "Record", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (cmbSchoolSearch.Text == "")
                {
                    MessageBox.Show("Please select school name", "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    cmbSchoolSearch.Focus();
                    return;
                }
                if (cmbBatchSearch.Text == "")
                {
                    MessageBox.Show("Please select session", "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    cmbBatchSearch.Focus();
                    return;
                }
                if (CmbClassSearch.Text == "")
                {
                    MessageBox.Show("Please select class", "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    CmbClassSearch.Focus();
                    return;
                }
                if (cmbSubjectName.Text == "")
                {
                    MessageBox.Show("Please select subject name", "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    cmbSubjectName.Focus();
                    return;
                }
                if (cmbStaffName.Text == "")
                {
                    MessageBox.Show("Please select staff name", "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    cmbStaffName.Focus();
                    return;
                }
                if (txtStaffID.Text == "")
                {
                    MessageBox.Show("Please retrieve staff id", "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    txtStaffID.Focus();
                    return;
                }

                if (listView1.Items.Count == 0)
                {
                    MessageBox.Show("Sorry nothing to save.. Please retrieve data in listview", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                con = new SqlConnection(cs.DBcon);
                con.Open();
                string cd = "Insert Into AttendanceMaster(AttendanceID,StaffID,AttendanceDate,SubjectID) Values(@d1,@d2,@d3,@d4)";
                cmd            = new SqlCommand(cd);
                cmd.Connection = con;
                cmd.Parameters.AddWithValue("@d1", txtAttendanceID.Text);
                cmd.Parameters.AddWithValue("@d2", txtEmployeeID.Text);
                cmd.Parameters.AddWithValue("@d3", dtpDate.Value.Date);
                cmd.Parameters.AddWithValue("@d4", txtSubjectID.Text);
                cmd.ExecuteNonQuery();
                con.Close();

                MessageBox.Show("Successfully saved", "Record", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }