示例#1
0
 public static int dangkiNhom(CHITIETNHOMDTO ctDTO)
 {
     try
     {
         Connect_Helper cnn = new Connect_Helper();
         cnn.OpenSection();
         string         ProcName = "";
         SqlParameter[] prs      =
         {
             new SqlParameter("@MaNhom", SqlDbType.Int),
             new SqlParameter("@MaDoAn", SqlDbType.Int),
             new SqlParameter("@MaSV",   SqlDbType.VarChar)
         };
         prs[0].Value = ctDTO.MaNhom;
         prs[1].Value = ctDTO.MaDA;
         prs[2].Value = ctDTO.MSSV;
         SqlCommand sqlcmd = new SqlCommand(ProcName, cnn.connect);
         sqlcmd.CommandType = CommandType.StoredProcedure;
         sqlcmd.Parameters.AddRange(prs);
         int KQ = sqlcmd.ExecuteNonQuery();
         cnn.CloseSection();
         if (KQ > 0)
         {
             return(1);
         }
         else
         {
             return(0);
         }
     }
     catch
     {
         return(-1);
     }
 }
示例#2
0
 public static int TaoNhomMoi(string tennhom, int madoan, string truongnhom)
 {
     try
     {
         Connect_Helper cnn = new Connect_Helper();
         cnn.OpenSection();
         string         ProcName = "CREATE_GROUP";
         SqlParameter[] prs      =
         {
             new SqlParameter("@MaDA",       SqlDbType.Int),
             new SqlParameter("@TenNhom",    SqlDbType.NVarChar),
             new SqlParameter("@TruongNhom", SqlDbType.Char)
         };
         prs[0].Value = madoan;
         prs[1].Value = tennhom;
         prs[2].Value = truongnhom;
         SqlCommand sqlcmd = new SqlCommand(ProcName, cnn.connect);
         sqlcmd.CommandType = CommandType.StoredProcedure;
         sqlcmd.Parameters.AddRange(prs);
         int KQ = sqlcmd.ExecuteNonQuery();
         cnn.CloseSection();
         if (KQ > 0)
         {
             return(1);
         }
         else
         {
             return(0);
         }
     }
     catch
     {
         return(-1);
     }
 }
示例#3
0
        //int maNhom, string MSSV, int MaDA

        public static int huyNhom(int maNhom, string mssv)
        {
            try
            {
                Connect_Helper cnn = new Connect_Helper();
                cnn.OpenSection();
                string         ProcName = "";
                SqlParameter[] prs      = { new SqlParameter("@MaNhom", SqlDbType.Int), new SqlParameter("@MaSV", SqlDbType.VarChar) };
                prs[0].Value = maNhom;
                prs[1].Value = mssv;
                SqlCommand sqlcmd = new SqlCommand(ProcName, cnn.connect);
                sqlcmd.CommandType = CommandType.StoredProcedure;
                int KQ = sqlcmd.ExecuteNonQuery();
                cnn.CloseSection();
                if (KQ > 0)
                {
                    return(1);
                }
                else
                {
                    return(0);
                }
            }
            catch
            {
                return(-1);
            }
        }
示例#4
0
        public static int maxMemberNhom(int manhom, int madoan)
        {
            try
            {
                Connect_Helper cnn = new Connect_Helper();
                cnn.OpenSection();
                string ProcName = "CHECK_EXCEED_NUMBER_MEMBER_Of_GROUP";
                //SqlCommand sqlcmd = new SqlCommand(ProcName, cnn.connect);
                SqlCommand sqlcmd = new SqlCommand(ProcName);
                sqlcmd.CommandType = CommandType.StoredProcedure;
                sqlcmd.Connection  = cnn.connect;
                //SqlParameter[] prs =
                //{
                //    new SqlParameter("@MaDoAn", SqlDbType.Int),
                //    new SqlParameter("@KQ", SqlDbType.Int)
                //};
                //prs[0].Value = madoan;
                //prs[1].Direction = ParameterDirection.Output;
                //sqlcmd.Parameters.AddRange(prs);
                sqlcmd.Parameters.Add("@MaDoAn", SqlDbType.Int).Value = madoan;
                sqlcmd.Parameters.Add("@MaNhom", SqlDbType.Int).Value = manhom;
                sqlcmd.Parameters.Add("@KQ", SqlDbType.Int).Direction = ParameterDirection.Output;
                int n = sqlcmd.ExecuteNonQuery();
                if (n > 0)
                {
                    //int KQ = Convert.ToInt32(prs[1].Value.ToString());
                    int KQ = Convert.ToInt32(sqlcmd.Parameters["@KQ"].Value);
                    cnn.CloseSection();
                    if (KQ == 2)
                    {
                        return(1);
                    }
                    else
                    {
                        return(0);
                    }
                }
                else
                {
                    return(-1);
                }
            }

            catch
            {
                return(-2);
            }
        }
示例#5
0
        public static string Laytruongnhom(int madoan, int manhom)
        {
            try
            {
                Connect_Helper cnn = new Connect_Helper();
                cnn.OpenSection();
                string     ProcName = "RETRIEVE_LEADER_GROUP";
                SqlCommand sqlcmd   = new SqlCommand(ProcName);
                sqlcmd.CommandType = CommandType.StoredProcedure;
                sqlcmd.Connection  = cnn.connect;
                //SqlParameter[] prs =
                //{
                //    new SqlParameter("@MaDoAn", SqlDbType.Int),
                //    new SqlParameter("@KQ", SqlDbType.Int)
                //};
                //prs[0].Value = madoan;
                //prs[1].Direction = ParameterDirection.Output;
                //sqlcmd.Parameters.AddRange(prs);
                sqlcmd.Parameters.Add("@MaDA", SqlDbType.Int).Value         = madoan;
                sqlcmd.Parameters.Add("@MaNhom", SqlDbType.Int).Value       = madoan;
                sqlcmd.Parameters.Add("@stringKQ", SqlDbType.Int).Direction = ParameterDirection.Output;
                int n = sqlcmd.ExecuteNonQuery();
                if (n > 0)
                {
                    //int KQ = Convert.ToInt32(prs[1].Value.ToString());
                    string KQ = Convert.ToString(sqlcmd.Parameters["@stringKQ"].Value);
                    cnn.CloseSection();
                    if (KQ != "")
                    {
                        return(KQ);
                    }
                    else
                    {
                        return("");
                    }
                }
                else
                {
                    return("");
                }
            }

            catch
            {
                return("");
            }
        }
示例#6
0
        public static int LaTruongNhom(int MaDA, string MSSV)
        {
            try
            {
                Connect_Helper cnn = new Connect_Helper();
                cnn.OpenSection();
                string     ProcName = "";
                SqlCommand sqlcmd   = new SqlCommand(ProcName, cnn.connect);
                sqlcmd.CommandType = CommandType.StoredProcedure;
                SqlParameter[] prs =
                {
                    new SqlParameter("@MSSV", SqlDbType.Char),
                    new SqlParameter("@MaDA", SqlDbType.Int),
                    new SqlParameter("@KQ",   SqlDbType.Int)
                };
                prs[0].Value     = MaDA;
                prs[1].Value     = MSSV;
                prs[2].Direction = ParameterDirection.Output;
                int n = sqlcmd.ExecuteNonQuery();
                if (n > 0)
                {
                    int KQ = Convert.ToInt32(prs[2].Value.ToString());
                    cnn.CloseSection();
                    if (KQ == 2)
                    {
                        return(1);
                    }
                    else
                    {
                        return(0);
                    }
                }
                else
                {
                    return(-1);
                }
            }

            catch
            {
                return(-2);
            }
        }
示例#7
0
        public static DataTable GET_ALL_SUBJECT()
        {
            Connect_Helper cnn = new Connect_Helper();

            try
            {
                cnn.OpenSection();
                DataTable  dt  = new DataTable();
                SqlCommand cmd = new SqlCommand("SELECT_ALL_SUBJECT", cnn.connect);
                cmd.CommandType = CommandType.StoredProcedure;
                SqlDataAdapter da = new SqlDataAdapter(cmd);
                da.Fill(dt);
                cnn.CloseSection();
                return(dt);
            }
            catch
            {
                return(null);
            }
        }
示例#8
0
        public static string DangNhap(string magv, string password)
        {
            //    Connect_Helper cnn = new Connect_Helper();
            //    cnn.OpenSection();
            //    string ProcName = "TEACHER_LOGIN";
            //    SqlCommand sqlcmd = new SqlCommand(ProcName);
            //    sqlcmd.CommandType = CommandType.StoredProcedure;
            //    sqlcmd.Connection = cnn.connect;
            //    //SqlParameter[] prs =
            //    //{
            //    //    new SqlParameter("@id", SqlDbType.Char),
            //    //    new SqlParameter("@pwd", SqlDbType.NVarChar),
            //    //    new SqlParameter("@stringKQ", SqlDbType.NVarChar)
            //    //};
            //    //prs[0].Value = magv;
            //    //prs[1].Value = password;
            //    //prs[2].Direction = ParameterDirection.Output;
            //    //sqlcmd.Parameters.AddRange(prs);
            //    sqlcmd.Parameters.Add("@id", SqlDbType.Char).Value=magv;
            //    sqlcmd.Parameters.Add("@pwd", SqlDbType.NVarChar).Value=password;
            //    sqlcmd.Parameters.Add("@stringKQ", SqlDbType.NVarChar).Direction = ParameterDirection.Output;
            //   int n = sqlcmd.ExecuteNonQuery();
            //    string KQ;
            //    if (n > 0)
            //    {
            //        KQ = (string)sqlcmd.Parameters["stringKQ"].Value;
            //        cnn.CloseSection();
            //    }
            //    else KQ = "";
            //    return KQ;

            //}

            //catch
            //{
            //    return "";
            //}
            try
            {
                Connect_Helper connectDB = new Connect_Helper();
                connectDB.OpenSection();
                string     procedureName = "TEACHER_LOGIN";
                SqlCommand cmd           = new SqlCommand(procedureName);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Connection  = connectDB.connect;

                cmd.Parameters.Add("@id", SqlDbType.Char).Value               = magv;
                cmd.Parameters.Add("@pwd", SqlDbType.NVarChar).Value          = password;
                cmd.Parameters.Add("@stringKQ", SqlDbType.NVarChar).Direction = ParameterDirection.Output;
                int    KQ  = cmd.ExecuteNonQuery();
                string str = "";
                if (KQ > 0)
                {
                    str = (string)cmd.Parameters["stringKQ"].Value;
                }
                connectDB.CloseSection();
                return(str);
            }
            catch
            {
                return("");
            }
        }