コード例 #1
0
        public int Update(Object.StudentInfo student)
        {
            using (SqlConnection con = new SqlConnection(SharedMethods.getConnectionString()))
            {
                SqlCommand cmd = new SqlCommand("spUpdateStudentInfo_tblStudentInfo", con);
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.AddWithValue("@Id", student.Id);
                cmd.Parameters.AddWithValue("@FirstName", student.FirstName);
                cmd.Parameters.AddWithValue("@MiddleName", student.MiddleName);
                cmd.Parameters.AddWithValue("@FamilyName", student.FamilyName);

                cmd.Parameters.AddWithValue("@EGN", student.EGN);
                cmd.Parameters.AddWithValue("@PhoneNumber", student.PhoneNumber);
                cmd.Parameters.AddWithValue("@Adress", student.Adress);
                cmd.Parameters.AddWithValue("@Photo", student.Photo);

                cmd.Parameters.AddWithValue("@DoctorId", student.DoctorId);

                cmd.Parameters.AddWithValue("@ParentFullname", student.ParentFullName);
                cmd.Parameters.AddWithValue("@ParentPhoneNumber", student.ParentPhoneNumber);
                cmd.Parameters.AddWithValue("@ParentAdress", student.ParentAdress);

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

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

                return((int)Result.Value);
            }
        }
コード例 #2
0
        public void Create(string firstName, string middleName, string familyName,
                           string EGN, string phoneNumber, string adress,
                           System.Web.UI.WebControls.FileUpload fileUploadPhoto,
                           int DoctorId, string ParentFullName, string ParentPhoneNumber,
                           string ParentAdress, out string Message, out System.Drawing.Color Color)
        {
            Object.StudentInfo student = new Object.StudentInfo();
            student.FirstName  = firstName;
            student.MiddleName = middleName;
            student.FamilyName = familyName;

            student.EGN         = EGN;
            student.PhoneNumber = phoneNumber;
            student.Adress      = adress;
            student.Photo       = SharedMethods.getImage(fileUploadPhoto);

            student.DoctorId = DoctorId;

            student.ParentFullName    = ParentFullName;
            student.ParentPhoneNumber = phoneNumber;
            student.ParentAdress      = ParentAdress;

            //If image has not been chosen, mark photo as null instead of 0 or ""
            if (student.Photo.Length == 0)
            {
                student.Photo = null;
            }

            int resultNumber = crud.Create(student);

            message.Create(resultNumber, out Message, out Color);
        }
コード例 #3
0
        public void Update(int Id, string firstName, string middleName, string familyName,
                           string EGN, string phoneNumber, string adress, string Photo,
                           int DoctorId, string ParentFullName, string ParentPhoneNumber,
                           string ParentAdress, out string Message, out System.Drawing.Color Color)
        {
            Object.StudentInfo student = new Object.StudentInfo();

            student.Id = Id;

            student.FirstName  = firstName;
            student.MiddleName = middleName;
            student.FamilyName = familyName;

            student.EGN         = EGN;
            student.PhoneNumber = phoneNumber;
            student.Adress      = adress;

            if (Photo != null)
            {
                student.Photo = BusinessLayer.SharedMethods.getImageBase64(Photo);
            }

            student.DoctorId = DoctorId;

            student.ParentFullName    = ParentFullName;
            student.ParentPhoneNumber = phoneNumber;
            student.ParentAdress      = ParentAdress;

            int resultNum = crud.Update(student);

            message.Update(resultNum, out Message, out Color);
        }
コード例 #4
0
        public void Delete(int Id, out string Message, out System.Drawing.Color Color)
        {
            Object.StudentInfo student = new Object.StudentInfo();
            student.Id = Id;

            int resultNum = crud.Delete(student);

            message.Delete(resultNum, out Message, out Color);
        }
コード例 #5
0
        public int Delete(Object.StudentInfo student)
        {
            using (SqlConnection con = new SqlConnection(SharedMethods.getConnectionString()))
            {
                SqlCommand cmd = new SqlCommand("Delete From tblStudentInfo Where Id = @Id", con);
                cmd.Parameters.AddWithValue("@Id", student.Id);

                con.Open();
                return((int)cmd.ExecuteNonQuery());
            }
        }