Ejemplo n.º 1
0
        public bool AddStudent(StudentModel sModel)
        {
            //TODO if user exist not insert
            StudentLogic   studentLogicBL     = new StudentLogic();
            StudentsDetail studentsDetailList = new StudentsDetail();

            studentsDetailList.UserName = sModel.UserName;
            //Encrypt Password
            var keyNew          = EncryptUtility.GeneratePassword(10);
            var encryptPassword = EncryptUtility.EncodePassword(sModel.Password, keyNew);

            studentsDetailList.Password                 = encryptPassword;
            studentsDetailList.student_first_name       = sModel.FirstName;
            studentsDetailList.student_last_name        = sModel.LastName;
            studentsDetailList.student_middle_name      = sModel.MiddleName;
            studentsDetailList.student_address1         = sModel.Address_Line1;
            studentsDetailList.student_city             = sModel.City;
            studentsDetailList.student_country          = sModel.Country;
            studentsDetailList.student_email            = sModel.Email;
            studentsDetailList.student_graduation_year  = sModel.GraduationYear;
            studentsDetailList.student_id               = sModel.StudentId;
            studentsDetailList.is_international_student = sModel.isInternationStudent;
            studentsDetailList.date_created             = DateTime.Now;
            return(studentLogicBL.AddStudent(studentsDetailList));
            //return false;
        }
        public ActionResult DeleteConfirmed(int id)
        {
            StudentsDetail studentsDetail = db.StudentsDetails.Find(id);

            db.StudentsDetails.Remove(studentsDetail);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "StudentsId,StudentsName,EmailId,Contact,YearOfPassing,Gender,StudentsCategory,StudentsBatchId,LastModifiedDate,LastModifiedBy,CreatedDate,CreatedBy")] StudentsDetail studentsDetail)
 {
     if (ModelState.IsValid)
     {
         db.Entry(studentsDetail).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.StudentsBatchId = new SelectList(db.BatchDetails, "StudentsBatchId", "StudentsBatchName", studentsDetail.StudentsBatchId);
     ViewBag.StudentsBatchId = new SelectList(db.BatchDetails, "StudentsBatchId", "StudentsBatchName", studentsDetail.StudentsBatchId);
     return(View(studentsDetail));
 }
        // GET: StudentsDetails/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            StudentsDetail studentsDetail = db.StudentsDetails.Find(id);

            if (studentsDetail == null)
            {
                return(HttpNotFound());
            }
            return(View(studentsDetail));
        }
        // GET: StudentsDetails/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            StudentsDetail studentsDetail = db.StudentsDetails.Find(id);

            if (studentsDetail == null)
            {
                return(HttpNotFound());
            }
            ViewBag.StudentsBatchId = new SelectList(db.BatchDetails, "StudentsBatchId", "StudentsBatchName", studentsDetail.StudentsBatchId);
            ViewBag.StudentsBatchId = new SelectList(db.BatchDetails, "StudentsBatchId", "StudentsBatchName", studentsDetail.StudentsBatchId);
            return(View(studentsDetail));
        }
Ejemplo n.º 6
0
        private void ViewStudents_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            try
            {
                id     = int.Parse(GetSelectedCellValue());
                result = db.StudentsDetails.SingleOrDefault(x => x.ID == id);

                txtID.Text         = result.tbStudent.ID.ToString();
                txtName.Text       = result.tbStudent.studentName;
                txtCourse.Text     = result.tbCours.courseName;
                txtDate.Text       = result.Date.ToString();
                txtPrice.Text      = result.tbCours.Price.ToString();
                txtInstructor.Text = result.tbCours.Instructor;

                img.Source = (result.tbStudent.Image == null || result.tbStudent.Image == "") ? new BitmapImage(new Uri("C:\\Users\\iradi\\source\\repos\\Center Application\\Center Application\\Images\\imgStudents.png")) : new BitmapImage(new Uri(result.tbStudent.Image));
            }
            catch { }
        }
Ejemplo n.º 7
0
        //Get student detail by id
        public IEnumerable <StudentsDetail> GetStudentById(int id)
        {
            List <StudentsDetail> studentsDetailList = new List <StudentsDetail>();
            string conStr = ConfigurationManager.ConnectionStrings["studentConn"].ToString();

            using (var connection = new SqlConnection(conStr))
            {
                using (SqlCommand command = connection.CreateCommand())
                {
                    command.CommandType = CommandType.StoredProcedure;
                    command.CommandText = "sp_getStudentById";
                    command.Parameters.Add(new SqlParameter {
                        ParameterName = "@id", Value = id
                    }).SqlDbType = SqlDbType.Int;
                    connection.Open();
                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            StudentsDetail studentDetail = new StudentsDetail();
                            studentDetail.Id                       = (reader["Id"] != DBNull.Value) ? Convert.ToInt32(reader["Id"]) : Null.NullInt;
                            studentDetail.UserName                 = (reader["UserName"] != DBNull.Value) ? Convert.ToString(reader["UserName"]) : String.Empty;
                            studentDetail.Password                 = (reader["Password"] != DBNull.Value) ? Convert.ToString(reader["Password"]) : String.Empty;
                            studentDetail.student_first_name       = (reader["student_first_name"] != DBNull.Value) ? Convert.ToString(reader["student_first_name"]) : String.Empty;
                            studentDetail.student_middle_name      = (reader["student_middle_name"] != DBNull.Value) ? Convert.ToString(reader["student_middle_name"]) : String.Empty;
                            studentDetail.student_last_name        = (reader["student_last_name"] != DBNull.Value) ? Convert.ToString(reader["student_last_name"]) : String.Empty;
                            studentDetail.student_address1         = (reader["student_address1"] != DBNull.Value) ? Convert.ToString(reader["student_address1"]) : String.Empty;
                            studentDetail.student_city             = (reader["student_city"] != DBNull.Value) ? Convert.ToString(reader["student_city"]) : String.Empty;
                            studentDetail.student_country          = (reader["student_country"] != DBNull.Value) ? Convert.ToString(reader["student_country"]) : String.Empty;
                            studentDetail.student_email            = (reader["student_email"] != DBNull.Value) ? Convert.ToString(reader["student_email"]) : String.Empty;
                            studentDetail.student_graduation_year  = (reader["student_graduation_year"] != DBNull.Value) ? Convert.ToInt32(reader["student_graduation_year"]) : Null.NullInt;
                            studentDetail.student_id               = (reader["student_id"] != DBNull.Value) ? Convert.ToString(reader["student_id"]) : String.Empty;
                            studentDetail.is_international_student = (reader["is_international_student"] != DBNull.Value) ? Convert.ToBoolean(reader["is_international_student"]) : false;
                            studentDetail.date_created             = (reader["date_created"] != DBNull.Value) ? Convert.ToDateTime(reader["date_created"]) : Null.NullDateTime;
                            studentsDetailList.Add(studentDetail);
                        }
                        reader.Close();
                    }
                }
                connection.Close();
            }
            return(studentsDetailList);
        }
Ejemplo n.º 8
0
        //Add New Student
        public bool AddStudent(StudentsDetail studentsDetail)
        {
            int    rowsAffected = 0;
            bool   returnValue  = false;
            string constring    = ConfigurationManager.ConnectionStrings["studentConn"].ToString();

            using (var connection = new SqlConnection(constring))
            {
                using (SqlCommand command = connection.CreateCommand())
                {
                    command.CommandType = CommandType.StoredProcedure;
                    command.CommandText = "sp_insertStudentData";



                    command.Parameters.Add(new SqlParameter {
                        ParameterName = "@UserName", Value = studentsDetail.UserName
                    }).SqlDbType = SqlDbType.VarChar;
                    command.Parameters.Add(new SqlParameter {
                        ParameterName = "@Password", Value = studentsDetail.Password
                    }).SqlDbType = SqlDbType.VarChar;
                    command.Parameters.Add(new SqlParameter {
                        ParameterName = "@student_first_name", Value = studentsDetail.student_first_name
                    }).SqlDbType = SqlDbType.VarChar;
                    var param = new SqlParameter {
                        ParameterName = "@student_middle_name", Value = studentsDetail.student_middle_name ?? string.Empty
                    };
                    command.Parameters.Add(param);
                    command.Parameters.Add(new SqlParameter {
                        ParameterName = "@student_last_name", Value = studentsDetail.student_last_name
                    }).SqlDbType = SqlDbType.VarChar;
                    command.Parameters.Add(new SqlParameter {
                        ParameterName = "@student_address1", Value = studentsDetail.student_address1
                    }).SqlDbType = SqlDbType.VarChar;
                    command.Parameters.Add(new SqlParameter {
                        ParameterName = "@student_city", Value = studentsDetail.student_city
                    }).SqlDbType = SqlDbType.VarChar;
                    command.Parameters.Add(new SqlParameter {
                        ParameterName = "@student_country", Value = studentsDetail.student_country
                    }).SqlDbType = SqlDbType.VarChar;
                    command.Parameters.Add(new SqlParameter {
                        ParameterName = "@student_email", Value = studentsDetail.student_email
                    }).SqlDbType = SqlDbType.VarChar;
                    command.Parameters.Add(new SqlParameter {
                        ParameterName = "@student_graduation_year", Value = studentsDetail.student_graduation_year
                    }).SqlDbType = SqlDbType.Int;
                    //command.Parameters.Add(new SqlParameter { ParameterName = "@student_id", Value = studentsDetail.student_id }).SqlDbType = SqlDbType.VarChar;
                    command.Parameters.Add(new SqlParameter {
                        ParameterName = "@is_international_student", Value = studentsDetail.is_international_student
                    }).SqlDbType = SqlDbType.Bit;
                    command.Parameters.Add(new SqlParameter {
                        ParameterName = "@date_created", Value = studentsDetail.date_created
                    });

                    connection.Open();
                    rowsAffected += command.ExecuteNonQuery();
                }
            }
            if (rowsAffected > 0)
            {
                returnValue = true;
            }
            return(returnValue);
        }
Ejemplo n.º 9
0
        public bool AddStudent(StudentsDetail studentsDetail)
        {
            bool returnVal = studentAccountsDA.AddStudent(studentsDetail);

            return(returnVal);
        }