Exemplo n.º 1
0
        public IHttpActionResult AdminLogin(LogInModel Model)
        {
            LogInResult resModel = new LogInResult();
            String      newID    = Shuffle(Model.ID);

            resModel.ID     = newID;
            resModel.Result = false;

            SQL_function sql_function  = new SQL_function();
            String       strQuery_auth = @"SELECT COUNT(*) FROM [DuLieuTotNghiep].[dbo].[Account]
  WHERE [UserName] = @UserName and [Password] =@Password ";
            SqlCommand   cmd_auth      = new SqlCommand(strQuery_auth);

            cmd_auth.Parameters.Add("@UserName", SqlDbType.NVarChar).Value = Model.UserName;
            cmd_auth.Parameters.Add("@Password", SqlDbType.NVarChar).Value = Model.Password;
            String[,] array_auth = sql_function.xml_deserialize(sql_function.GetData(cmd_auth, "sqlconnString"));

            if (array_auth[0, 0] == "1")
            {
                String     strQuery = @"UPDATE [dbo].[Session] SET ID =@newID ,[UserName] = @UserName WHERE ID = @ID";
                SqlCommand cmd      = new SqlCommand(strQuery);
                cmd.Parameters.Add("@newID", SqlDbType.NVarChar).Value    = newID;
                cmd.Parameters.Add("@UserName", SqlDbType.NVarChar).Value = "admin";
                cmd.Parameters.Add("@ID", SqlDbType.NVarChar).Value       = Model.ID;
                String insertRes = sql_function.InsertUpdateData(cmd, "sqlconnString");
                if (insertRes == "1")
                {
                    resModel.Result = true;
                }
            }

            return(Json(resModel));
        }
Exemplo n.º 2
0
        public String[] SoHieu()
        {
            SQL_function sql_function = new SQL_function();
            String       strQuery     = @"SELECT DISTINCT [SoHieu] FROM [DuLieuTotNghiep].[dbo].[DataTotNghiep]";
            SqlCommand   cmd          = new SqlCommand(strQuery);

            String[,] array = sql_function.xml_deserialize(sql_function.GetData(cmd, "sqlconnString"));
            string[] res = new string[array.GetLength(0)];
            for (int i = 0; i < array.GetLength(0); i++)
            {
                res[i] = array[i, 0];
            }

            return(res);
        }
Exemplo n.º 3
0
        public String[] DanToc()
        {
            SQL_function sql_function = new SQL_function();
            String       strQuery     = @"SELECT[DanTocID],[TenDanToc],[Moet_DanTocID]
        FROM[DuLieuTotNghiep].[dbo].[T_DM_DanToc]";
            SqlCommand   cmd          = new SqlCommand(strQuery);

            String[,] array = sql_function.xml_deserialize(sql_function.GetData(cmd, "sqlconnString"));
            string[] res = new string[array.GetLength(0)];
            for (int i = 0; i < array.GetLength(0); i++)
            {
                res[i] = array[i, 0];
            }

            return(res);
        }