コード例 #1
0
        public string CheckUnique(string email)
        {
            Query = "SELECT * FROM Teacher WHERE TeacherEmail=@TeacherEmail";

            Command = new SqlCommand(Query, Connection);

            Command.Parameters.Clear();


            Command.Parameters.Add("TeacherEmail", SqlDbType.VarChar);
            Command.Parameters["TeacherEmail"].Value = email;

            Connection.Open();

            Reader = Command.ExecuteReader();

            TeacherGom teacher = new TeacherGom();

            while (Reader.Read())
            {
                teacher.Email = Reader["TeacherEmail"].ToString();
            }

            Reader.Close();
            Connection.Close();


            return(teacher.Email);
        }
コード例 #2
0
        public string Save(TeacherGom aTeacherGom)
        {
            string msg         = "Data Insertion Failed";
            int    rowAffected = save.Show(aTeacherGom);

            if (rowAffected > 0)
            {
                msg = "Data Insertation Successed";
            }

            return(msg);
        }
コード例 #3
0
        public int Show(TeacherGom aTeacherGom)
        {
            Connection = new SqlConnection(connectionString);
            Query      = "INSERT INTO Teacher(TeacherName,TeacherAddress,TeacherEmail,TeacherContactNo,DesignationId,DepartmentId,CreditTaken,RemainingCredit) VALUES(@TeacherName,@TeacherAddress,@TeacherEmail,@TeacherContactNo,@DesignationId,@DepartmentId,@CreditTaken,@CreditTaken)";
            Command    = new SqlCommand(Query, Connection);

            Command.Parameters.Clear();


            Command.Parameters.Add("TeacherName", SqlDbType.VarChar);
            Command.Parameters["TeacherName"].Value = aTeacherGom.Name;

            Command.Parameters.Add("TeacherAddress", SqlDbType.VarChar);
            Command.Parameters["TeacherAddress"].Value = aTeacherGom.Address;


            Command.Parameters.Add("TeacherEmail", SqlDbType.VarChar);
            Command.Parameters["TeacherEmail"].Value = aTeacherGom.Email;


            Command.Parameters.Add("TeacherContactNo", SqlDbType.VarChar);
            Command.Parameters["TeacherContactNo"].Value = aTeacherGom.ContactNo;

            Command.Parameters.Add("DesignationId", SqlDbType.Int);
            Command.Parameters["DesignationId"].Value = aTeacherGom.DesignationId;

            Command.Parameters.Add("DepartmentId", SqlDbType.Int);
            Command.Parameters["DepartmentId"].Value = aTeacherGom.DepartmentId;


            Command.Parameters.Add("CreditTaken", SqlDbType.Decimal);
            Command.Parameters["CreditTaken"].Value = aTeacherGom.CreditTaken;


            Connection.Open();
            int rowAffected = 0;

            try
            {
                rowAffected = Command.ExecuteNonQuery();
            }
            catch
            {
                rowAffected = -999;
            }

            Connection.Close();

            return(rowAffected);
        }
コード例 #4
0
        public ActionResult SaveTeacher(TeacherGom aTeacherGom)
        {
            ShowDept();
            ShowDesignation();
            string msg = null;
            TeacherUniqueEmailManager unique = new TeacherUniqueEmailManager();

            msg         = unique.CheckUnique(aTeacherGom.Email);
            ViewBag.msg = msg;

            if (msg == null)
            {
                SaveTeacherManagerGOM save = new SaveTeacherManagerGOM();
                msg         = save.Save(aTeacherGom);
                ViewBag.msg = msg;
            }


            return(View());
        }