Ejemplo n.º 1
0
        public void Create(int grade, char letter, int specializationId
            , string teacherEGN, out string Message, out System.Drawing.Color Color)
        {
            Object.Class Class = new Object.Class();
            Class.Grade = grade;
            Class.Letter = letter;
            Class.SpecializationId = specializationId;

            DataTable table = new DataTable();

            table.Columns.Add("Grade");
            table.Columns.Add("Letter");
            table.Columns.Add("SpecializationId");
            table.Columns.Add("ClassTeacherEGN");

            if (teacherEGN.Length == 10)
            {
                Class.ClassTeacherEGN = teacherEGN;

                int resultNum = crud.Create(Class);
                message.Create(resultNum, out Message, out Color);
            }
            else if (grade < 1 || grade > 12)
            {
                message.Create(-5, out Message, out Color);
            }
            else
            {
                message.Create(-3, out Message, out Color);
            }
        }
Ejemplo n.º 2
0
        public void Delete(int Id, out string Message, out System.Drawing.Color Color)
        {
            Object.Class Class = new Object.Class();
            Class.Id = Id;

            int ResultNumber = crud.Delete(Class);

            message.Delete(ResultNumber, out Message, out Color);
        }
Ejemplo n.º 3
0
        public int Delete(Object.Class Class)
        {
            using (SqlConnection con = new SqlConnection(SharedMethods.getConnectionString()))
            {
                SqlCommand cmd = new SqlCommand("Delete From tblClass Where Id = @Id",con);
                cmd.CommandType = CommandType.Text;

                cmd.Parameters.AddWithValue("@Id", Class.Id);

                con.Open();
                return (int)cmd.ExecuteNonQuery();
            }
        }
Ejemplo n.º 4
0
        public int Create(Object.Class Class)
        {
            using (SqlConnection con = new SqlConnection(SharedMethods.getConnectionString()))
            {
                SqlCommand cmd = new SqlCommand("spAddClass_tblClass", con);
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.AddWithValue("@ClassGrade", Class.Grade);
                cmd.Parameters.AddWithValue("@ClassLetter", Class.Letter);
                cmd.Parameters.AddWithValue("@SpecializationId", Class.SpecializationId);
                cmd.Parameters.AddWithValue("@ClassTeacherEGN", Class.ClassTeacherEGN);

                SqlParameter Result = new SqlParameter("@ResultNumber", DbType.Int32);
                Result.Direction = ParameterDirection.Output;
                cmd.Parameters.Add(Result);

                con.Open();
                cmd.ExecuteScalar();
                con.Close();

                return (int)Result.Value;
            }
        }
Ejemplo n.º 5
0
        public void Update(int Id, int Grade, char Letter, int SpecializationId, string ClassTeacherEGN,
            out string Message, out System.Drawing.Color Color)
        {
            if (Grade < 1 || Grade > 12)
            {
                message.Update(-3, out Message, out Color);
            }
            else if (Letter < 'А' || Letter > 'Я'){
                message.Update(-4, out Message, out Color);
            }
            else
            {
                Object.Class Class = new Object.Class();
                Class.Id = Id;
                Class.Grade = Grade;
                Class.Letter = Letter;
                Class.SpecializationId = SpecializationId;
                Class.ClassTeacherEGN = ClassTeacherEGN;

                int resultNumber = crud.Update(Class);
                message.Update(resultNumber, out Message, out Color);
            }
        }