static void Main(string[] args)
        {
            DatabaseManager.Initialize();

            TcpAccountInfo accInfo = new TcpAccountInfo("root", "123qweasd", "김정현", "Super");

            if (DatabaseManager.TryToRegister(accInfo, false))
            {
                Console.WriteLine("root 계정을 추가하였습니다.");
            }
            else
            {
                Console.WriteLine("root 계정이 이미 있으므로 추가하지 않았습니다.");
            }

            TcpLoginInfo loginInfo1 = new TcpLoginInfo("wrong", "123qweasd");
            TcpLoginInfo loginInfo2 = new TcpLoginInfo("root", "wrong");
            TcpLoginInfo loginInfo3 = new TcpLoginInfo("root", "123qweasd");

            Console.WriteLine(DatabaseManager.MatchLoginInfo(loginInfo1).ToString());
            Console.WriteLine(DatabaseManager.MatchLoginInfo(loginInfo2).ToString());
            Console.WriteLine(DatabaseManager.MatchLoginInfo(loginInfo3).ToString());

            TcpDataInsert         insert = new TcpDataInsert();
            List <DatabaseValues> values = new List <DatabaseValues>();

            values.Add(new DatabaseValues("#2000-8-14#", "99".ToSQLString(), "99".ToSQLString(), "99".ToSQLString(), "김정현".ToSQLString(), "1", "1", "1", "1", "1", "1", "1", "1", "1"));
            values.Add(new DatabaseValues("#2000-8-14#", "99".ToSQLString(), "99".ToSQLString(), "100".ToSQLString(), "김정현".ToSQLString(), "1", "1", "1", "1", "1", "1", "1", "1", "1"));
            values.Add(new DatabaseValues("#2000-8-14#", "99".ToSQLString(), "99".ToSQLString(), "101".ToSQLString(), "김정현".ToSQLString(), "1", "1", "1", "1", "1", "1", "1", "1", "1"));

            insert.ColumnsText = "";
            insert.TableName   = "출석부";
            insert.Values      = values;

            Console.WriteLine($"출석부에 {DatabaseManager.DBInsert(insert)}개 줄이 추가됨.");

            TcpDataUpdate update = new TcpDataUpdate();

            update.TableName = "출석부";
            update.Setter.Add("[0교시]", "2");
            update.Setter.Add("[1교시]", "2");
            update.Setter.Add("[2교시]", "2");
            update.Setter.Add("[3교시]", "2");
            update.Where = "[일자]=#2000-8-14# AND 학년=\"99\" AND 반=\"99\" AND 번호=\"99\"";


            Console.WriteLine($"출석부에서 {DatabaseManager.DBUpdate(update)}개 줄이 업데이트됨.");

            TcpDataDelete delete = new TcpDataDelete();

            delete.TableName = "[출석부]";
            delete.Where     = "[일자]=#2000-8-14# AND 학년=\"99\" AND 반=\"99\" AND 번호=\"99\"";

            Console.WriteLine($"출석부에서 {DatabaseManager.DBDelete(delete)}개 줄이 삭제됨.");

            DatabaseManager.Close();
        }
Beispiel #2
0
        public static bool TryToRegister(TcpAccountInfo accountInfo, bool accepted)
        {
            DataSet data = DBSelect("[교사 ID]", "[교사 목록]", $"[교사 ID]={accountInfo.ID.ToSQLString()}", null);

            if (data.Tables[0].Rows.Count != 0)
            {
                return(false);
            }

            DBInsert("[교사 목록]", accountInfo.ID.ToSQLString(), PasswordHashManager.HashPassword(accountInfo.Password).ToSQLString(),
                     accountInfo.Name.ToSQLString(), accountInfo.Type.ToSQLString(), accepted ? "True" : "False");

            return(true);
        }
Beispiel #3
0
        private void Submit_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrWhiteSpace(PasswordText2.Password) || PasswordText1.Password != PasswordText2.Password)
            {
                MessageBox.Show(this, "비밀번호 항목과 비밀번호 확인 항목이 일치하지 않거나, 사용할 수 없는 비밀번호를 사용했습니다.", "가입 실패", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            if (string.IsNullOrWhiteSpace(IDText.Text) || string.IsNullOrWhiteSpace(PasswordText2.Password) ||
                string.IsNullOrWhiteSpace(NameText.Text))
            {
                MessageBox.Show(this, "각 항목을 제대로 입력해주십시오.\n모든 항목은 비어있거나 공백만으로 구성되어선 안됩니다.", "가입 실패", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            try
            {
                string type;

                if (SuperRadio.IsChecked == true)
                {
                    type = "Super";
                }
                else if (HeadRadio.IsChecked == true)
                {
                    type = $"Head {HeadGrade.Text}";
                }
                else if (HomeRadio.IsChecked == true)
                {
                    type = $"{HomeGrade.Text} {HomeClass.Text}";
                }
                else
                {
                    MessageBox.Show(this, "회원 구분을 체크해주십시오.", "가입 실패", MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }

                mClient.ReceivedRegisterResult += MClient_ReceivedRegisterResult;
                AccountInfo = new TcpAccountInfo(IDText.Text, PasswordText2.Password, NameText.Text, type);
                mClient.Register(AccountInfo);

                this.IsEnabled = false;
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, $"가입을 시도하던 중 예기치 못한 오류가 발생하였습니다.\n{ex.Message}", "가입 실패", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
        }