Ejemplo n.º 1
0
        public void EditMajorsCode()
        {
            SqlConnection cnn = new SqlConnection(con);

            frmIndex index = new frmIndex();

            try
            {
                cnn.Open(); //Mở kết nối
                SqlCommand command = new SqlCommand("UpdateMajors", cnn);
                command.Parameters.Add("@MajorsCode", SqlDbType.NVarChar, 20).Value = cbMajorsCode.Text;
                command.Parameters.Add("@MajorsName", SqlDbType.NVarChar, 20).Value = txtMajorsName.Text;
                command.Parameters.Add("@SuccessMaticNumber", SqlDbType.Int).Value  = txtSuccessMaticNumber.Text;
                command.CommandType = CommandType.StoredProcedure;
                SqlDataReader reader = command.ExecuteReader();

                while (reader.Read())
                {
                    if ((reader["Message"].ToString()) == "1")
                    {
                        MessageBox.Show("Chỉnh sửa ngành thành công");
                    }
                    else
                    {
                        MessageBox.Show(reader["Message"].ToString());
                    }
                }
                cnn.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Lỗi xảy ra: " + ex.Message);
            }
        }
Ejemplo n.º 2
0
        public void SelectMajorsCode(String code)
        {
            SqlConnection cnn = new SqlConnection(con);

            frmIndex index = new frmIndex();

            try
            {
                cnn.Open(); //Mở kết nối
                SqlCommand command = new SqlCommand("GetMajorsCode", cnn);
                command.Parameters.Add("@MajorsCode", SqlDbType.VarChar, 20).Value = code;
                command.CommandType = CommandType.StoredProcedure;
                SqlDataReader reader = command.ExecuteReader();

                while (reader.Read())
                {
                    txtMajorsName.Text         = reader["MajorsName"].ToString();
                    txtSuccessMaticNumber.Text = reader["SuccessMaticNumber"].ToString();
                }


                cnn.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Lỗi xảy ra: " + ex.Message);
            }
        }
Ejemplo n.º 3
0
        private void btnDeleteThematic_Click(object sender, EventArgs e)
        {
            SqlConnection cnn = new SqlConnection(con);

            frmIndex index = new frmIndex();

            try
            {
                cnn.Open(); //Mở kết nối
                SqlCommand command = new SqlCommand("DeleteThematic", cnn);
                command.Parameters.Add("@ThematicCode", SqlDbType.VarChar, 20).Value = cbThematicCode.Text;
                command.CommandType = CommandType.StoredProcedure;
                SqlDataReader reader = command.ExecuteReader();

                while (reader.Read())
                {
                    if ((reader["Message"].ToString()) == "1")
                    {
                        MessageBox.Show("Xóa chuyên đề thành công");
                        LoadCbMajorsCode();
                    }
                    else
                    {
                        MessageBox.Show(reader["Message"].ToString());
                    }
                }


                cnn.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Lỗi xảy ra: " + ex.Message);
            }
        }
Ejemplo n.º 4
0
        public void LoadCbMajorsCode()
        {
            SqlConnection cnn = new SqlConnection(con);

            frmIndex index = new frmIndex();

            try
            {
                cnn.Open(); //Mở kết nối
                SqlCommand command = new SqlCommand("GetListMajors", cnn);
                command.CommandType = CommandType.StoredProcedure;
                SqlDataReader reader = command.ExecuteReader();

                DataTable dt = new DataTable();
                dt.Columns.Add("MajorsCode", typeof(string));
                dt.Load(reader);
                cbMajorsCode.ValueMember   = "MajorsCode";
                cbMajorsCode.DisplayMember = "MajorsCode";
                cbMajorsCode.DataSource    = dt;
                cnn.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Lỗi xảy ra: " + ex.Message);
            }
        }
Ejemplo n.º 5
0
        public void LoadCbThematicCode(String code)
        {
            SqlConnection cnn = new SqlConnection(con);

            frmIndex index = new frmIndex();

            try
            {
                cnn.Open(); //Mở kết nối
                SqlCommand command = new SqlCommand("GetListTheMaticFix", cnn);
                command.Parameters.Add("@MajorsCode", SqlDbType.VarChar, 20).Value = code;
                command.Parameters.Add("@Enable", SqlDbType.Int).Value             = 1;
                command.CommandType = CommandType.StoredProcedure;
                SqlDataReader reader = command.ExecuteReader();

                DataTable dt = new DataTable();
                dt.Columns.Add("ThematicCode", typeof(string));
                dt.Load(reader);
                cbThematicCode.ValueMember   = "ThematicCode";
                cbThematicCode.DisplayMember = "ThematicCode";
                cbThematicCode.DataSource    = dt;
                cnn.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Lỗi xảy ra: " + ex.Message);
            }
        }
Ejemplo n.º 6
0
        private void Create()
        {
            SqlConnection cnn = new SqlConnection(con);

            frmIndex index = new frmIndex();

            try
            {
                cnn.Open(); //Mở kết nối
                SqlCommand command = new SqlCommand("CreatePC", cnn);
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.Add("@TeacherCode", SqlDbType.VarChar, 20).Value  = cbTeacherCode.Text;
                command.Parameters.Add("@ThematicCode", SqlDbType.VarChar, 20).Value = cbThematicCode.Text;

                SqlDataReader reader = command.ExecuteReader();
                while (reader.Read())
                {
                    if ((reader["Message"].ToString()) == "1")
                    {
                        MessageBox.Show("Phân công thành công");
                    }
                    else
                    {
                        MessageBox.Show(reader["Message"].ToString());
                    }
                }
                cnn.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Lỗi xảy ra: " + ex.Message);
            }
        }
Ejemplo n.º 7
0
        public void SelectAcctCode(String code)
        {
            SqlConnection cnn = new SqlConnection(con);

            frmIndex index = new frmIndex();

            try
            {
                cnn.Open(); //Mở kết nối
                SqlCommand command = new SqlCommand("GetAccountCode", cnn);
                command.Parameters.Add("@AccountCode", SqlDbType.VarChar, 20).Value = code;
                command.CommandType = CommandType.StoredProcedure;
                SqlDataReader reader = command.ExecuteReader();

                while (reader.Read())
                {
                    txtAccountName.Text = reader["FullName"].ToString();
                    txtPW.Text          = reader["PassWord"].ToString();
                    txtPWCF.Text        = reader["PassWord"].ToString();
                    if ((reader["Enable"].ToString()) == "1")
                    {
                        rdOpen.Checked = true;
                    }
                    else
                    {
                        rdClose.Checked = true;
                    }
                    if ((reader["Type"].ToString()) == "1")
                    {
                        rbGV.Checked = true;
                    }
                    else if ((reader["Type"].ToString()) == "2")
                    {
                        rbSV.Checked = true;
                    }
                    if ((reader["Sex"].ToString()) == "1")
                    {
                        rbNam.Checked = true;
                    }
                    else
                    {
                        rbNu.Checked = true;
                    }
                    dtpBirthDate.Text = Convert.ToDateTime(reader["Birthday"]).ToString();
                    txtAddr.Text      = reader["Address"].ToString();
                    cbMajorsCode.Text = reader["MajorsCode"].ToString();
                }


                cnn.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Lỗi xảy ra: " + ex.Message);
            }
        }
Ejemplo n.º 8
0
        private void Create()
        {
            SqlConnection cnn = new SqlConnection(con);

            frmIndex index = new frmIndex();

            try
            {
                cnn.Open(); //Mở kết nối
                SqlCommand command = new SqlCommand("CreateClass", cnn);
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.Add("@TeacherCode", SqlDbType.VarChar, 20).Value  = cbTeacherCode.Text;
                command.Parameters.Add("@StartDate", SqlDbType.DateTime).Value       = dtpStartDate.Text;
                command.Parameters.Add("@EndDate", SqlDbType.DateTime).Value         = dtpStartDate.Text;
                command.Parameters.Add("@MaxGroup", SqlDbType.Int).Value             = txtGroupLimit.Text;
                command.Parameters.Add("@ThematicCode", SqlDbType.VarChar, 20).Value = cbThematicCode.Text;
                command.Parameters.Add("@TimeRes", SqlDbType.DateTime).Value         = dpTimeRes.Text;
                command.Parameters.Add("@TimeGroup", SqlDbType.DateTime).Value       = dpTimeGroup.Text;
                if (rdOpen.Checked)
                {
                    command.Parameters.Add("@Enable", SqlDbType.Int).Value = 1;
                }
                else
                {
                    command.Parameters.Add("@Enable", SqlDbType.Int).Value = 0;
                }
                if (rdHK1.Checked)
                {
                    command.Parameters.Add("@HK", SqlDbType.Int).Value = 1;
                }
                else
                {
                    command.Parameters.Add("@HK", SqlDbType.Int).Value = 2;
                }
                command.Parameters.Add("@NameClass", SqlDbType.VarChar, 100).Value = txtClassName.Text;

                SqlDataReader reader = command.ExecuteReader();
                while (reader.Read())
                {
                    if ((reader["Message"].ToString()) == "1")
                    {
                        MessageBox.Show("Mở lớp thành công");
                    }
                    else
                    {
                        MessageBox.Show(reader["Message"].ToString());
                    }
                }
                cnn.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Lỗi xảy ra: " + ex.Message);
            }
        }
Ejemplo n.º 9
0
        private void Create()
        {
            SqlConnection cnn = new SqlConnection(con);

            frmIndex index = new frmIndex();

            try
            {
                cnn.Open(); //Mở kết nối
                SqlCommand command = new SqlCommand("CreateThematic", cnn);
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.Add("@ThematicCode", SqlDbType.VarChar, 20).Value = txtThematicCode.Text;
                command.Parameters.Add("@ThematicName", SqlDbType.VarChar, 20).Value = txtThematicName.Text;
                command.Parameters.Add("@MajorsCode", SqlDbType.VarChar, 20).Value   = cbMajorsCode.Text;
                if (rdOpen.Checked)
                {
                    command.Parameters.Add("@Enable", SqlDbType.Int).Value = 1;
                }
                else
                {
                    command.Parameters.Add("@Enable", SqlDbType.Int).Value = 0;
                }
                if (rdYes.Checked)
                {
                    command.Parameters.Add("@IsCompel", SqlDbType.Int).Value = 1;
                }
                else
                {
                    command.Parameters.Add("@IsCompel", SqlDbType.Int).Value = 0;
                }
                command.Parameters.Add("@ThematicLimit", SqlDbType.Int).Value = txtThematicLimit.Text;
                command.Parameters.Add("@RuleDate", SqlDbType.DateTime).Value = dtpRuleDate.Text;

                SqlDataReader reader = command.ExecuteReader();
                while (reader.Read())
                {
                    if ((reader["Message"].ToString()) == "1")
                    {
                        MessageBox.Show("Tạo chuyên đề thành công");
                    }
                    else
                    {
                        MessageBox.Show(reader["Message"].ToString());
                    }
                }
                cnn.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Lỗi xảy ra: " + ex.Message);
            }
        }
Ejemplo n.º 10
0
        public void LoadCbThematicCode(String code)
        {
            SqlConnection cnn = new SqlConnection(con);

            frmIndex index = new frmIndex();

            try
            {
                cnn.Open(); //Mở kết nối
                SqlCommand command = new SqlCommand("GetClassThematicCodeFix", cnn);
                command.Parameters.Add("@ThematicCode", SqlDbType.VarChar, 20).Value = code;
                command.CommandType = CommandType.StoredProcedure;
                SqlDataReader reader = command.ExecuteReader();

                while (reader.Read())
                {
                    cbTeacherCode.Text = reader["TeacherCode"].ToString();
                    txtGroupLimit.Text = reader["MaxGroup"].ToString();
                    if ((reader["Enable"].ToString()) == "1")
                    {
                        rdOpen.Checked = true;
                    }
                    else
                    {
                        rdClose.Checked = true;
                    }
                    if ((reader["HK"].ToString()) == "1")
                    {
                        rdHK1.Checked = true;
                    }
                    else
                    {
                        rdHK2.Checked = true;
                    }
                    dtpStartDate.Text = Convert.ToDateTime(reader["StartDate"]).ToString();
                    dtpEndDate.Text   = Convert.ToDateTime(reader["EndDate"]).ToString();
                    dpTimeRes.Text    = Convert.ToDateTime(reader["TimeRes"]).ToString();
                    dpTimeGroup.Text  = Convert.ToDateTime(reader["TimeGroup"]).ToString();
                }


                cnn.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Lỗi xảy ra: " + ex.Message);
            }
        }
Ejemplo n.º 11
0
        public void SelectThematicCode(String code)
        {
            SqlConnection cnn = new SqlConnection(con);

            frmIndex index = new frmIndex();

            try
            {
                cnn.Open(); //Mở kết nối
                SqlCommand command = new SqlCommand("GetThematicCode", cnn);
                command.Parameters.Add("@ThematicCode", SqlDbType.VarChar, 20).Value = code;
                command.CommandType = CommandType.StoredProcedure;
                SqlDataReader reader = command.ExecuteReader();

                while (reader.Read())
                {
                    txtThematicName.Text  = reader["ThematicName"].ToString();
                    txtThematicLimit.Text = reader["ThematicLimit"].ToString();
                    if ((reader["Enable"].ToString()) == "1")
                    {
                        rdOpen.Checked = true;
                    }
                    else
                    {
                        rdClose.Checked = true;
                    }
                    if ((reader["IsCompel"].ToString()) == "1")
                    {
                        rdYes.Checked = true;
                    }
                    else
                    {
                        rdNo.Checked = true;
                    }
                    dtpRuleDate.Text = Convert.ToDateTime(reader["RuleDate"]).ToString();
                }


                cnn.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Lỗi xảy ra: " + ex.Message);
            }
        }
Ejemplo n.º 12
0
        private void Login()
        {
            String        con = @"Data Source=DESKTOP-OR1OHFA\SQLEXPRESS;Initial Catalog=CourseRegistration;Integrated Security=True";
            SqlConnection cnn = new SqlConnection(con);

            frmIndex index = new frmIndex();

            try
            {
                cnn.Open(); //Mở kết nối
                SqlCommand command = new SqlCommand("GetAccountLogin", cnn);
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.Add("@AccountCode", SqlDbType.VarChar, 20).Value = txtAccountCode.Text;
                command.Parameters.Add("@PassWord", SqlDbType.VarChar, 20).Value    = txtPassWord.Text;

                SqlDataReader reader = command.ExecuteReader();
                while (reader.Read())
                {
                    if ((reader["Message"].ToString()) == "1")
                    {
                        index.Show();
                        this.Hide();
                    }
                    else
                    {
                        MessageBox.Show(reader["Message"].ToString());
                    }
                }
                if (reader.NextResult())
                {
                    while (reader.Read())
                    {
                        index.AccountCode = reader["AccountCode"].ToString();
                        index.AccountType = reader["Type"].ToString();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Lỗi xảy ra: " + ex.Message);
            }
        }
Ejemplo n.º 13
0
        public void EditAccountCode()
        {
            SqlConnection cnn = new SqlConnection(con);

            frmIndex index = new frmIndex();

            try
            {
                cnn.Open(); //Mở kết nối
                SqlCommand command = new SqlCommand("UpdateAccount", cnn);
                command.Parameters.Add("@AccountCode", SqlDbType.NVarChar, 20).Value = cbAccountCode.Text;
                command.Parameters.Add("@PassWord", SqlDbType.NVarChar, 20).Value    = txtPW.Text;
                command.Parameters.Add("@PWConfirm", SqlDbType.NVarChar, 20).Value   = txtPWCF.Text;
                command.Parameters.Add("@FullName", SqlDbType.NVarChar, 20).Value    = txtAccountName.Text;
                if (rdOpen.Checked)
                {
                    command.Parameters.Add("@Enable", SqlDbType.Int).Value = 1;
                }
                else
                {
                    command.Parameters.Add("@Enable", SqlDbType.Int).Value = 0;
                }
                if (rbNam.Checked)
                {
                    command.Parameters.Add("@Sex", SqlDbType.Int).Value = 1;
                }
                else
                {
                    command.Parameters.Add("@Sex", SqlDbType.Int).Value = 0;
                }
                if (rbGV.Checked)
                {
                    command.Parameters.Add("@Type", SqlDbType.Int).Value = 1;
                }
                else if (rbSV.Checked)
                {
                    command.Parameters.Add("@Type", SqlDbType.Int).Value = 2;
                }
                command.Parameters.Add("@BirthDay", SqlDbType.Date).Value           = dtpBirthDate.Text;
                command.Parameters.Add("@Address", SqlDbType.NVarChar, 300).Value   = txtAddr.Text;
                command.Parameters.Add("@MajorsCode", SqlDbType.NVarChar, 20).Value = cbMajorsCode.Text;
                command.CommandType = CommandType.StoredProcedure;
                SqlDataReader reader = command.ExecuteReader();

                while (reader.Read())
                {
                    if ((reader["Message"].ToString()) == "1")
                    {
                        MessageBox.Show("Chỉnh sửa tài khoản thành công");
                    }
                    else
                    {
                        MessageBox.Show(reader["Message"].ToString());
                    }
                }
                cnn.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Lỗi xảy ra: " + ex.Message);
            }
        }