Ejemplo n.º 1
0
        private StudentSearchCriteria makeSearchCriteria()
        {
            StudentSearchCriteria sc = new StudentSearchCriteria();


            if (Student.parseStudentID(RollTextBox.Text.Trim(), sc) == false)
            {
                MessageBox.Show("Invalid Student ID");
                return null;
            }
            //sc.RollLike = this.rollTextBox.Text.Trim();
            sc.Name = this.NameTextBox.Text.Trim();

            if (sc.Batch != null)
            {
                if (this.BatchTextBox.Text.Trim() != "" && !this.BatchTextBox.Text.Trim().Equals(sc.Batch))
                {
                    MessageBox.Show("Student ID and Batch do not match.");
                    return null;
                }
            }
            else
                sc.Batch = this.BatchTextBox.Text.Trim();
            //////////////////////////////////////////////

            return sc;
        }
Ejemplo n.º 2
0
 private void GenerateButton_Click(object sender, EventArgs e)
 {
     if (batchTextBox.Text.Length != 2)
     {
         MessageBox.Show("Invalid Batch.");
         return;
     }
     else if (startRollTextBox.Text.Length != 2)
     {
         MessageBox.Show("Invalid Start Roll.");
         return;
     }
     else if (endRollTextBox.Text.Length != 2)
     {
         MessageBox.Show("Invalid End Roll.");
         return;
     }
     int startRoll = int.Parse(startRollTextBox.Text);
     int endRoll = int.Parse(endRollTextBox.Text);
     if ( endRoll<startRoll )
     {
         MessageBox.Show("End Roll Must be Greater than Start Roll");
         return;
     }
     int numOfStudents = endRoll - startRoll + 1;
     studentList = new List<Student>(numOfStudents);
     for (int i = 0; i < numOfStudents; i++)
     {
         studentList.Add(new Student());
         studentList[i].Batch = batchTextBox.Text;
         studentList[i].Roll = startRoll++.ToString("D2");
     }
     StudentSearchCriteria sc = new StudentSearchCriteria();
     sc.Batch = batchTextBox.Text;
     List<Student> existingStudentList = new List<Student>();
     existingStudentList = Student.GetStudentList(sc);
     for (int i = 0; i < numOfStudents; i++)
     {
         for (int j = 0; j < existingStudentList.Count; j++)
         {
             if (studentList[i].Roll == existingStudentList[j].Roll)
             {
                 studentList[i].StudentId = existingStudentList[j].StudentId;
                 studentList[i].Name = existingStudentList[j].Name;
                 break;
             }
         }
     }
     for (int i = 0; i < numOfStudents; i++)
     { 
         
     }
     this.DialogResult = DialogResult.OK;
     this.Close();
 }
Ejemplo n.º 3
0
 public static Boolean parseStudentID(String StdID, StudentSearchCriteria sc)
 {
     Boolean retValue = false;
     if (StdID.Length == 6)
     {
         sc.Batch = StdID.Substring(0, 2);
         sc.RollExact = StdID.Substring(4, 2);
         retValue = true;
     }
     else if (StdID.Length == 2)
     {
         sc.RollExact = StdID;
         sc.Batch = "";
         retValue = true;
     }
     else if (StdID.Length == 0)
         retValue = true;
     return retValue;
 }
Ejemplo n.º 4
0
        public static List<Student> GetStudentList(StudentSearchCriteria sc)
        {
            //MySqlConnection connection = new MySqlConnection(global::CCMS.Properties.Settings.Default.ccmsConnectionString);
            OleDbConnection connection = new OleDbConnection(global::ResultManagement.Properties.Settings.Default.ConnectionString);
            
            string cmdStr = @"SELECT     student.id, student.Roll, student.batch, student.St_name
                   FROM  student WHERE  1 ";
            
            #region search criteria
            if (sc.StudentId != null)
            {
                cmdStr += " AND student.id = " + sc.StudentId.ToString();
            }

            if (sc.RollLike != null)
            {
                cmdStr += " AND student.roll LIKE '%" + sc.RollLike + "%'";
            }

            if (sc.RollExact != null)
            {
                cmdStr += " AND student.roll = '" + sc.RollExact + "'";
            }

            if (sc.Name != null)
            {
                cmdStr += " AND student.St_name LIKE '%" + sc.Name + "%'";
            }

            if (sc.Batch != null)
            {
                cmdStr += " AND student.batch = '" + sc.Batch + "'";
            }

            cmdStr += " ORDER BY batch,roll";
            #endregion


            //MySqlCommand cmd = new MySqlCommand(cmdStr, connection);
            OleDbCommand cmd = new OleDbCommand(cmdStr, connection);

            List<Student> sList = new List<Student>();

            try
            {
                connection.Open();
                //MySqlDataReader reader = cmd.ExecuteReader();
                OleDbDataReader reader = cmd.ExecuteReader();

                while (reader.Read())
                {
                    Student s = new Student();


                    #region student
                    object val;

                    s.studentId = (int)reader.GetValue(reader.GetOrdinal("id"));

                    val = reader.GetValue(reader.GetOrdinal("Roll"));
                    if (val != DBNull.Value)
                    {
                        s.roll = (string)val;
                    }

                    val = reader.GetValue(reader.GetOrdinal("St_name"));
                    if (val != DBNull.Value)
                    {
                        s.name = (string)val;
                    }

                    
                    val = reader.GetValue(reader.GetOrdinal("batch"));
                    if (val != DBNull.Value)
                    {
                        s.batch = (string)val;
                    }

                    #endregion

                    sList.Add(s);
                }
            }
            finally
            {
                connection.Close();
            }
        
            return sList;
        }