public static int THEMHOCPHANHVM(DangKy dk)
        {
            int check = DangKyDB.THEMHOCPHANHVM(dk);

            if (check == 1)
            {
                return(1);
            }
            else
            {
                return(0);
            }
        }
Exemple #2
0
 private void danhSachHocPhanChon_DoubleClick(object sender, EventArgs e)
 {
     if (danhSachHocPhanChon.CurrentRow.Index != -1)
     {
         int row = danhSachHocPhanChon.CurrentRow.Index;
         MessageBox.Show("mahp " + chose_list[row].mahp);
         MessageBox.Show("namhoc " + chose_list[row].namhoc);
         MessageBox.Show("hocky " + chose_list[row].hocky);
         MessageBox.Show("hoten " + hotenLabel.Text);
         DangKy.XOAHOCPHAN(chose_list[row].mahp, chose_list[row].namhoc, Int32.Parse(chose_list[row].hocky.ToString()), hotenLabel.Text);
         danhSachHocPhanChon.Rows.RemoveAt(row);
         chose_list.RemoveAt(row);
         FillDataGridView();
     }
 }
 public static int THEMHOCPHANHVM(DangKy dk)
 {
     try
     {
         SqlCommand sqlCmd = new SqlCommand("THEMHOCPHANHVM", c.conn);
         sqlCmd.CommandType = System.Data.CommandType.StoredProcedure;
         sqlCmd.Parameters.AddWithValue("@MAHP", dk.mahp);
         sqlCmd.Parameters.AddWithValue("@NAMHOC", dk.namhoc);
         sqlCmd.Parameters.AddWithValue("@HOCKY", dk.hocky);
         sqlCmd.Parameters.AddWithValue("@MAHV", dk.mahv);
         sqlCmd.Parameters.AddWithValue("@MANV", dk.manv);
         sqlCmd.Parameters.AddWithValue("@NGAY", dk.ngay);
         sqlCmd.ExecuteNonQuery();
         return(1);
     }
     catch (Exception ex)
     {
         return(0);
     }
 }
Exemple #4
0
        private void danhSachHocPhan_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex >= 0)
            {
                if (Int32.Parse(this.danhSachHocPhan.Rows[e.RowIndex].Cells[2].Value.ToString()) < 30)
                {
                    if (Int32.Parse(this.danhSachHocPhan.Rows[e.RowIndex].Cells[8].Value.ToString()) == 0)
                    {
                        string date = DateTime.Now.ToString("yyyy-MM-dd");
                        DangKy dkdb = new DangKy();
                        dkdb.KHOITAO(this.danhSachHocPhan.Rows[e.RowIndex].Cells[9].Value.ToString(),
                                     this.danhSachHocPhan.Rows[e.RowIndex].Cells[4].Value.ToString(),
                                     Int32.Parse(this.danhSachHocPhan.Rows[e.RowIndex].Cells[5].Value.ToString()),
                                     hotenLabel.Text,
                                     LOGIN.username,
                                     date);
                        int check = DangKy.THEMHOCPHAN(dkdb);
                        if (check == 1)
                        {
                            int rowId = danhSachHocPhanChon.Rows.Add();

                            this.danhSachHocPhanChon.Rows[rowId].Cells[0].Value = this.danhSachHocPhan.Rows[e.RowIndex].Cells[0].Value.ToString();
                            this.danhSachHocPhanChon.Rows[rowId].Cells[1].Value = this.danhSachHocPhan.Rows[e.RowIndex].Cells[1].Value.ToString();
                            this.danhSachHocPhanChon.Rows[rowId].Cells[2].Value = (Int32.Parse(this.danhSachHocPhan.Rows[e.RowIndex].Cells[2].Value.ToString()) + 1).ToString();
                            this.danhSachHocPhanChon.Rows[rowId].Cells[3].Value = this.danhSachHocPhan.Rows[e.RowIndex].Cells[3].Value.ToString();
                            this.danhSachHocPhanChon.Rows[rowId].Cells[4].Value = this.danhSachHocPhan.Rows[e.RowIndex].Cells[4].Value.ToString();
                            this.danhSachHocPhanChon.Rows[rowId].Cells[5].Value = this.danhSachHocPhan.Rows[e.RowIndex].Cells[5].Value.ToString();
                            this.danhSachHocPhanChon.Rows[rowId].Cells[6].Value = this.danhSachHocPhan.Rows[e.RowIndex].Cells[6].Value.ToString();
                            this.danhSachHocPhanChon.Rows[rowId].Cells[7].Value = this.danhSachHocPhan.Rows[e.RowIndex].Cells[7].Value.ToString();
                            this.danhSachHocPhanChon.Rows[rowId].Cells[8].Value = this.danhSachHocPhan.Rows[e.RowIndex].Cells[8].Value.ToString();

                            HocPhanMo subject = new HocPhanMo();

                            subject.KHOITAO(this.danhSachHocPhan.Rows[e.RowIndex].Cells[0].Value.ToString(),
                                            this.danhSachHocPhan.Rows[e.RowIndex].Cells[1].Value.ToString(),
                                            Int32.Parse(this.danhSachHocPhan.Rows[e.RowIndex].Cells[2].Value.ToString()),
                                            (float)Convert.ToDouble(this.danhSachHocPhan.Rows[e.RowIndex].Cells[3].Value.ToString()),
                                            this.danhSachHocPhan.Rows[e.RowIndex].Cells[4].Value.ToString(),
                                            Int32.Parse(this.danhSachHocPhan.Rows[e.RowIndex].Cells[5].Value.ToString()),
                                            Int32.Parse(this.danhSachHocPhan.Rows[e.RowIndex].Cells[6].Value.ToString()),
                                            this.danhSachHocPhan.Rows[e.RowIndex].Cells[7].Value.ToString(),
                                            this.danhSachHocPhan.Rows[e.RowIndex].Cells[8].Value.ToString(),
                                            this.danhSachHocPhan.Rows[e.RowIndex].Cells[9].Value.ToString(),
                                            this.danhSachHocPhan.Rows[e.RowIndex].Cells[10].Value.ToString(),
                                            this.danhSachHocPhan.Rows[e.RowIndex].Cells[11].Value.ToString());

                            chose_list.Add(subject);
                            FillDataGridView();
                        }

                        else
                        {
                            MessageBox.Show("Học phần đã được chọn.");
                        }
                    }
                    else
                    {
                        if (DangKy.KIEMTRAHOCPHANCOBAN(this.danhSachHocPhan.Rows[e.RowIndex].Cells[10].Value.ToString(), hotenLabel.Text) == 1)
                        {
                            string date = DateTime.Now.ToString("yyyy-MM-dd");
                            DangKy dkdb = new DangKy();
                            dkdb.KHOITAO(this.danhSachHocPhan.Rows[e.RowIndex].Cells[9].Value.ToString(),
                                         this.danhSachHocPhan.Rows[e.RowIndex].Cells[4].Value.ToString(),
                                         Int32.Parse(this.danhSachHocPhan.Rows[e.RowIndex].Cells[5].Value.ToString()),
                                         hotenLabel.Text,
                                         LOGIN.username,
                                         date);
                            int check = DangKy.THEMHOCPHAN(dkdb);
                            if (check == 1)
                            {
                                int rowId = danhSachHocPhanChon.Rows.Add();

                                this.danhSachHocPhanChon.Rows[rowId].Cells[0].Value = this.danhSachHocPhan.Rows[e.RowIndex].Cells[0].Value.ToString();
                                this.danhSachHocPhanChon.Rows[rowId].Cells[1].Value = this.danhSachHocPhan.Rows[e.RowIndex].Cells[1].Value.ToString();
                                this.danhSachHocPhanChon.Rows[rowId].Cells[2].Value = (Int32.Parse(this.danhSachHocPhan.Rows[e.RowIndex].Cells[2].Value.ToString()) + 1).ToString();
                                this.danhSachHocPhanChon.Rows[rowId].Cells[3].Value = this.danhSachHocPhan.Rows[e.RowIndex].Cells[3].Value.ToString();
                                this.danhSachHocPhanChon.Rows[rowId].Cells[4].Value = this.danhSachHocPhan.Rows[e.RowIndex].Cells[4].Value.ToString();
                                this.danhSachHocPhanChon.Rows[rowId].Cells[5].Value = this.danhSachHocPhan.Rows[e.RowIndex].Cells[5].Value.ToString();
                                this.danhSachHocPhanChon.Rows[rowId].Cells[6].Value = this.danhSachHocPhan.Rows[e.RowIndex].Cells[6].Value.ToString();
                                this.danhSachHocPhanChon.Rows[rowId].Cells[7].Value = this.danhSachHocPhan.Rows[e.RowIndex].Cells[7].Value.ToString();
                                this.danhSachHocPhanChon.Rows[rowId].Cells[8].Value = this.danhSachHocPhan.Rows[e.RowIndex].Cells[8].Value.ToString();

                                HocPhanMo subject = new HocPhanMo();

                                subject.KHOITAO(this.danhSachHocPhan.Rows[e.RowIndex].Cells[0].Value.ToString(),
                                                this.danhSachHocPhan.Rows[e.RowIndex].Cells[1].Value.ToString(),
                                                Int32.Parse(this.danhSachHocPhan.Rows[e.RowIndex].Cells[2].Value.ToString()),
                                                (float)Convert.ToDouble(this.danhSachHocPhan.Rows[e.RowIndex].Cells[3].Value.ToString()),
                                                this.danhSachHocPhan.Rows[e.RowIndex].Cells[4].Value.ToString(),
                                                Int32.Parse(this.danhSachHocPhan.Rows[e.RowIndex].Cells[5].Value.ToString()),
                                                Int32.Parse(this.danhSachHocPhan.Rows[e.RowIndex].Cells[6].Value.ToString()),
                                                this.danhSachHocPhan.Rows[e.RowIndex].Cells[7].Value.ToString(),
                                                this.danhSachHocPhan.Rows[e.RowIndex].Cells[8].Value.ToString(),
                                                this.danhSachHocPhan.Rows[e.RowIndex].Cells[9].Value.ToString(),
                                                this.danhSachHocPhan.Rows[e.RowIndex].Cells[10].Value.ToString(),
                                                this.danhSachHocPhan.Rows[e.RowIndex].Cells[11].Value.ToString());

                                chose_list.Add(subject);
                                FillDataGridView();
                            }
                            else
                            {
                                MessageBox.Show("Học phần đã được chọn.");
                            }
                        }
                        else
                        {
                            string date = DateTime.Now.ToString("yyyy-MM-dd");
                            DangKy dkdb = new DangKy();
                            dkdb.KHOITAO(this.danhSachHocPhan.Rows[e.RowIndex].Cells[9].Value.ToString(),
                                         this.danhSachHocPhan.Rows[e.RowIndex].Cells[4].Value.ToString(),
                                         Int32.Parse(this.danhSachHocPhan.Rows[e.RowIndex].Cells[5].Value.ToString()),
                                         hotenLabel.Text,
                                         LOGIN.username,
                                         date);
                            int check = DangKy.THEMHOCPHANHVM(dkdb);

                            if (check == 1)
                            {
                                int rowId = danhSachHocPhanChon.Rows.Add();

                                this.danhSachHocPhanChon.Rows[rowId].Cells[0].Value = this.danhSachHocPhan.Rows[e.RowIndex].Cells[0].Value.ToString();
                                this.danhSachHocPhanChon.Rows[rowId].Cells[1].Value = this.danhSachHocPhan.Rows[e.RowIndex].Cells[1].Value.ToString();
                                this.danhSachHocPhanChon.Rows[rowId].Cells[2].Value = (Int32.Parse(this.danhSachHocPhan.Rows[e.RowIndex].Cells[2].Value.ToString()) + 1).ToString();
                                this.danhSachHocPhanChon.Rows[rowId].Cells[3].Value = this.danhSachHocPhan.Rows[e.RowIndex].Cells[3].Value.ToString();
                                this.danhSachHocPhanChon.Rows[rowId].Cells[4].Value = this.danhSachHocPhan.Rows[e.RowIndex].Cells[4].Value.ToString();
                                this.danhSachHocPhanChon.Rows[rowId].Cells[5].Value = this.danhSachHocPhan.Rows[e.RowIndex].Cells[5].Value.ToString();
                                this.danhSachHocPhanChon.Rows[rowId].Cells[6].Value = this.danhSachHocPhan.Rows[e.RowIndex].Cells[6].Value.ToString();
                                this.danhSachHocPhanChon.Rows[rowId].Cells[7].Value = this.danhSachHocPhan.Rows[e.RowIndex].Cells[7].Value.ToString();
                                this.danhSachHocPhanChon.Rows[rowId].Cells[8].Value = this.danhSachHocPhan.Rows[e.RowIndex].Cells[8].Value.ToString();

                                HocPhanMo subject = new HocPhanMo();

                                subject.KHOITAO(this.danhSachHocPhan.Rows[e.RowIndex].Cells[0].Value.ToString(),
                                                this.danhSachHocPhan.Rows[e.RowIndex].Cells[1].Value.ToString(),
                                                Int32.Parse(this.danhSachHocPhan.Rows[e.RowIndex].Cells[2].Value.ToString()),
                                                (float)Convert.ToDouble(this.danhSachHocPhan.Rows[e.RowIndex].Cells[3].Value.ToString()),
                                                this.danhSachHocPhan.Rows[e.RowIndex].Cells[4].Value.ToString(),
                                                Int32.Parse(this.danhSachHocPhan.Rows[e.RowIndex].Cells[5].Value.ToString()),
                                                Int32.Parse(this.danhSachHocPhan.Rows[e.RowIndex].Cells[6].Value.ToString()),
                                                this.danhSachHocPhan.Rows[e.RowIndex].Cells[7].Value.ToString(),
                                                this.danhSachHocPhan.Rows[e.RowIndex].Cells[8].Value.ToString(),
                                                this.danhSachHocPhan.Rows[e.RowIndex].Cells[9].Value.ToString(),
                                                this.danhSachHocPhan.Rows[e.RowIndex].Cells[10].Value.ToString(),
                                                this.danhSachHocPhan.Rows[e.RowIndex].Cells[11].Value.ToString());

                                chose_list.Add(subject);
                                FillDataGridView();
                            }
                            else
                            {
                                MessageBox.Show("Học phần đã được chọn.");
                            }
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Sỉ số tối đa là 30 học viên.");
                }
            }
        }