public ActionResult Edit(TrinhDo trinhDo)
        {
            try
            {
                // TODO: Add update logic here
                if (ModelState.IsValid)
                {
                    var _trinhDoDao = new TrinhDoDao();

                    var res = _trinhDoDao.Update(trinhDo);
                    if (res)
                    {
                        return(RedirectToAction("Index", "TrinhDo"));
                    }
                    else
                    {
                        ModelState.AddModelError("", "Cập nhật lỗi");
                    }
                }

                return(View(trinhDo));
            }
            catch
            {
                return(RedirectToAction("Index", "TrinhDo"));
            }
        }
 private void btnSuaTrinhDo_Click(object sender, EventArgs e)
 {
     try
     {
         updateTrinhDo.TrinhDo1 = txtTrinhDo.Text.Trim();
         if (trinhDoServices.UpdateTrinhDo(updateTrinhDo))
         {
             MessageBox.Show("Đã Sửa Trình Độ Thành Công!", "Thông Báo", MessageBoxButtons.OK);
             InitGridView();
             dataGridTrinhDo.Refresh();
             updateTrinhDo          = null;
             txtTrinhDo.Text        = "";
             btnSuaTrinhDo.Enabled  = false;
             btnThemTrinhDo.Enabled = true;
         }
         else
         {
             MessageBox.Show("Lỗi! Vui Lòng Kiểm Tra Lại Thông Tin Đầu Vào!", "Error!",
                             MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     catch (InvalidOperationException ex)
     {
         if (UserProfile.permission == 1)
         {
             MessageBox.Show(ex.ToString(), "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
         else
         {
             MessageBox.Show("Đã Có Lỗi! Vui Lòng Kiểm Tra Thông Tin Đầu Vào!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
        // Insert Trình độ.
        private TrinhDo Insert_TrinhDo()
        {
            string maDV      = txt_TD_MaDV.Text;
            string trinhDoPT = txt_TD_PT.Text;
            string chuyenMon = txt_TD_Chuyenmon.Text;
            string hocVi     = cb_TD_HV.SelectedItem.ToString();
            string hocHam    = cb_TD_HH.SelectedItem.ToString();

            string lyLuanCT = txt_TD_Lyluan.Text;
            string ngoaiNgu = rtxt_TD_NN.Text;

            DateTime dt_HV = ConvertStringToDate(txt_TD_CTHV.Text);
            DateTime dt_HH;

            if (maDV == "")
            {
                MessageBox.Show("Vui lòng nhập Mã ĐV!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(null);
            }
            else
            {
                if (txt_TD_CTHH.Text != "")
                {
                    dt_HH    = ConvertStringToDate(txt_TD_CTHH.Text);
                    _trinhDo = new TrinhDo(maDV, trinhDoPT, chuyenMon, hocVi, dt_HV, hocHam, dt_HH, lyLuanCT, ngoaiNgu, 0);
                }
                else
                {
                    _trinhDo = new TrinhDo(maDV, trinhDoPT, chuyenMon, hocVi, dt_HV, lyLuanCT, ngoaiNgu, 1);
                }

                return(_trinhDo);
            }
        }
        private void Add_DoanVien_Click(object sender, RoutedEventArgs e)
        {
            Add = true;

            Add_DoanVien.IsEnabled = false;
            Mod_DoanVien.IsEnabled = false;

            SQLiteConnection sqlite_conn = new SQLiteConnection("Data source = QuanLyDoanVien.db");
            SQLiteCommand    sqlite_com  = new SQLiteCommand();

            sqlite_conn.Open();
            sqlite_com = sqlite_conn.CreateCommand();

            sqlite_com.CommandText = "SELECT Max(ID) FROM DoanVien";
            MaDoanVien.Text        = (Convert.ToInt32(sqlite_com.ExecuteScalar()) + 1).ToString();



            HoVaTen.IsEnabled                   = NgaySinh.IsEnabled = QueQuan.IsEnabled =
                GioiTinh.IsEnabled              = ChiDoan.IsEnabled = ChucVu.IsEnabled = ToDanPho.IsEnabled =
                    PhuongXa.IsEnabled          = QuanHuyen.IsEnabled = TinhThanh.IsEnabled = NgayVaoDang.IsEnabled =
                        NgayVaoDoan.IsEnabled   = TinhTrang.IsEnabled = CMND.IsEnabled = Email.IsEnabled =
                            DienThoai.IsEnabled = DanToc.IsEnabled = TonGiao.IsEnabled = HoanCanh.IsEnabled = TrinhDo.IsEnabled
                                                                                                                  = true;

            HoVaTen.Clear();
            NgaySinh.Clear(); QueQuan.Clear();
            GioiTinh.Clear(); ChiDoan.Clear(); ChucVu.Clear(); ToDanPho.Clear();
            PhuongXa.Clear(); QuanHuyen.Clear(); TinhThanh.Clear(); NgayVaoDang.Clear();
            NgayVaoDoan.Clear(); TinhTrang.Clear(); CMND.Clear(); Email.Clear();
            DienThoai.Clear(); DanToc.Clear(); TonGiao.Clear(); HoanCanh.Clear(); TrinhDo.Clear();
        }
 private void dataGridTrinhDo_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     updateTrinhDo          = trinhDoServices.GetTrinhDoById(Convert.ToInt32(dataGridTrinhDo.CurrentRow.Cells[0].Value.ToString()));
     txtTrinhDo.Text        = updateTrinhDo.TrinhDo1;
     btnSuaTrinhDo.Enabled  = true;
     btnThemTrinhDo.Enabled = false;
 }
        // Update Trình độ.
        private void Update_TrinhDo(TrinhDo trinhDo)
        {
            txt_TD_MaDV.Text      = trinhDo.MaDV;
            txt_TD_PT.Text        = trinhDo.TrinhDoPT;
            txt_TD_Chuyenmon.Text = trinhDo.ChuyenMon;
            cb_TD_HV.SelectedText = trinhDo.HocVi;
            cb_TD_HH.SelectedText = trinhDo.HocHam;

            txt_TD_Lyluan.Text = trinhDo.LyLuanCT;
            rtxt_TD_NN.Text    = trinhDo.NgoaiNgu;
            txt_TD_CTHV.Text   = trinhDo.DTHocVi.ToShortDateString();
            txt_TD_CTHH.Text   = trinhDo.DTHocham.ToShortDateString();

            //if (maDV == "")
            //{
            //    MessageBox.Show("Vui lòng nhập Mã ĐV!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
            //    return null;
            //}
            //else
            //{
            //    if (txt_TD_CTHH.Text != "")
            //    {
            //        dt_HH = ConvertStringToDate(txt_TD_CTHH.Text);
            //        _trinhDo = new TrinhDo(maDV, trinhDoPT, chuyenMon, hocVi, dt_HV, hocHam, dt_HH, lyLuanCT, ngoaiNgu, 0);
            //    }
            //    else
            //        _trinhDo = new TrinhDo(maDV, trinhDoPT, chuyenMon, hocVi, dt_HV, lyLuanCT, ngoaiNgu, 1);

            //    return _trinhDo;
            //}
        }
        public void SetThongTinLop(string maLop)
        {
            lbMaLop.Text = "Mã lớp : " + maLop;
            LOP lp = Lop.GetLopByMaLop(maLop);

            if (lp != null)
            {
                MaTD = lp.TRINHDO;
                KHOA    khRow = Khoa.GetKhoaByMaKhoa(lp.MAKH);
                TRINHDO tdRow = TrinhDo.GetTDByMaTD(lp.TRINHDO);
                if (khRow != null)
                {
                    MaKhoa      = khRow.MAKH;
                    lbKhoa.Text = "Khoa : " + khRow.TENKH;
                }
                if (tdRow != null)
                {
                    lbTrinhDo.Text = "Trình độ : " + tdRow.TENTD;
                }
                lbTenLop.Text = "Tên lớp : " + lp.TENLOP;
                mONHOCTableAdapter.Connection.ConnectionString = Program.connstr;
                dtsTTN.EnforceConstraints = false;
                mONHOCTableAdapter.Fill(dtsTTN.MONHOC);

                mONHOCBindingSource.Filter = "MAKH ='" + lp.MAKH + "'";
                cbbMonHoc.DataSource       = mONHOCBindingSource;
                cbbMonHoc.DisplayMember    = "TENMH";
                cbbMonHoc.ValueMember      = "MAMH";
            }
            lbSLSV.Text = "Số lượng sinh viên : " + Lop.CountSV(maLop).ToString().Trim();
        }
Example #8
0
        public ActionResult DeleteConfirmed(string id)
        {
            TrinhDo trinhDo = db.Trinhdos.Find(id);

            db.Trinhdos.Remove(trinhDo);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public ActionResult EditLevel(TrinhDo trinhDo)
        {
            var _daoTrinhDo = new TrinhDoDao();

            var res = _daoTrinhDo.Update(trinhDo);

            return(View());
        }
Example #10
0
 public int Insert(TrinhDo obj)
 {
     SqlParameter[] para =
     {
         new SqlParameter("IDTrinhDo",  obj.IDTrinhDo),
         new SqlParameter("TenTrinhDo", obj.TenTrinhDo),
     };
     return(db.ExecuteSQL("TrinhDo_Insert", para));
 }
Example #11
0
 public int Update(TrinhDo obj)
 {
     SqlParameter[] para =
     {
         new SqlParameter("IDTrinhDo",  obj.IDTrinhDo),
         new SqlParameter("TenTrinhDo", obj.TenTrinhDo)
     };
     return(db.ExecuteSQL("TrinhDo_Update", para));
 }
Example #12
0
 public ActionResult Edit([Bind(Include = "Ma_trinhdo,Ten_trinhdo")] TrinhDo trinhDo)
 {
     if (ModelState.IsValid)
     {
         db.Entry(trinhDo).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(trinhDo));
 }
Example #13
0
        public ActionResult Create([Bind(Include = "Ma_trinhdo,Ten_trinhdo")] TrinhDo trinhDo)
        {
            if (ModelState.IsValid)
            {
                db.Trinhdos.Add(trinhDo);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(trinhDo));
        }
 public static void Them(TrinhDo td)
 {
     try
     {
         db.TrinhDos.InsertOnSubmit(td);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Example #15
0
        public DataTable findTrinhDo(TrinhDo trinhDo)
        {
            string        sql  = "SELECT * FROM trinhdo WHERE 1=1 and manv LIKE '%" + trinhDo.MaNV + "%' AND  nganh LIKE '%" + trinhDo.Nganh + "%' AND trinhdo LIKE '%" + trinhDo.TrinhDoDaoTao + "%' AND truong like '%" + trinhDo.Truong + "%'";
            SqlConnection conn = getConnection();

            conn.Open();
            SqlDataAdapter da = new SqlDataAdapter(sql, conn);
            DataTable      dt = new DataTable();

            da.Fill(dt);
            return(dt);
        }
Example #16
0
        private void InitTrinhDo()
        {
            TrinhDo firstItem = new TrinhDo {
                idTrinhDo = 0, TrinhDo1 = "Tất Cả", ThongTinTrinhDoes = null
            };
            List <TrinhDo> listTrinhDo = new List <TrinhDo>();

            listTrinhDo.Add(firstItem);
            listTrinhDo.AddRange(trinhDoServices.GetAllTrinhDo());
            comboTrinhDo.DataSource    = listTrinhDo;
            comboTrinhDo.DisplayMember = "TrinhDo1";
            comboTrinhDo.ValueMember   = "idTrinhDo";
        }
Example #17
0
        public void deleteTrinhDo(TrinhDo trinhDo)
        {
            String        sql  = "delete trinhdo where manv=@manv and nganh=@nganh";
            SqlConnection conn = getConnection();

            conn.Open();
            SqlCommand cmd = new SqlCommand(sql, conn);

            cmd.Parameters.AddWithValue("manv", trinhDo.MaNV);
            cmd.Parameters.AddWithValue("nganh", trinhDo.Nganh);

            cmd.ExecuteNonQuery();
        }
Example #18
0
        // GET: TrinhDos/Delete/5
        public ActionResult Delete(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TrinhDo trinhDo = db.Trinhdos.Find(id);

            if (trinhDo == null)
            {
                return(HttpNotFound());
            }
            return(View(trinhDo));
        }
Example #19
0
        public void updateTrinhDo(TrinhDo trinhDo)
        {
            String        sql  = "update trinhdo set trinhdo=@trinhdo, truong=@truong where manv=@manv and nganh=@nganh";
            SqlConnection conn = getConnection();

            conn.Open();
            SqlCommand cmd = new SqlCommand(sql, conn);

            cmd.Parameters.AddWithValue("manv", trinhDo.MaNV);
            cmd.Parameters.AddWithValue("nganh", trinhDo.Nganh);
            cmd.Parameters.AddWithValue("trinhdo", trinhDo.TrinhDoDaoTao);
            cmd.Parameters.AddWithValue("truong", trinhDo.Truong);

            cmd.ExecuteNonQuery();
        }
Example #20
0
        public void insertTrinhDo(TrinhDo trinhDo)
        {
            String        sql  = "insert into trinhdo values(@manv, @nganh, @trinhdo, @truong)";
            SqlConnection conn = getConnection();

            conn.Open();
            SqlCommand cmd = new SqlCommand(sql, conn);

            cmd.Parameters.AddWithValue("manv", trinhDo.MaNV);
            cmd.Parameters.AddWithValue("nganh", trinhDo.Nganh);
            cmd.Parameters.AddWithValue("trinhdo", trinhDo.TrinhDoDaoTao);
            cmd.Parameters.AddWithValue("truong", trinhDo.Truong);

            cmd.ExecuteNonQuery();
        }
 public bool SuaTrinhDo(TrinhDo trinhDo)
 {
     try
     {
         var trinhDo1 = db.TrinhDoes.Find(trinhDo.ID_TrinhDo);
         trinhDo1.TenTrinhDo  = trinhDo.TenTrinhDo;
         trinhDo1.TinViecLams = trinhDo.TinViecLams;
         trinhDo1.CV_UngVien  = trinhDo.CV_UngVien;
         db.SaveChanges();
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
 private void btnLuu_Click(object sender, EventArgs e)
 {
     try
     {
         TrinhDo td = new TrinhDo();
         if (!string.IsNullOrEmpty(txtMaTrinhDo.Text))
         {
             td.MaTrinhDo = txtMaTrinhDo.Text.Trim();
         }
         else
         {
             MsgboxUtil.Exclamation("Mã trình độ không được để trống");
             txtMaTrinhDo.Focus();
             return;
         }
         if (!string.IsNullOrEmpty(txtTenTrinhDo.Text))
         {
             td.TenTrinhDo = txtTenTrinhDo.Text.Trim();
         }
         else
         {
             MsgboxUtil.Exclamation("Tên trình độ không được để trống");
             txtTenTrinhDo.Focus();
             return;
         }
         if (numLuong.Value > 0)
         {
             td.HeSoLuong = (int)numLuong.Value;
         }
         else
         {
             MsgboxUtil.Exclamation("Tên trình độ không được để trống");
             txtTenTrinhDo.Focus();
             return;
         }
         TrinhDoBUS.Them(td);
         StaticClass.LuuThayDoi();
         log.GhiFile("Thêm mới trình độ: " + td.MaTrinhDo);
         MsgboxUtil.Success("Thành công");
         btnHuy_Click(null, null);
     }
     catch (Exception ex)
     {
         ExceptionUtil.ThrowMsgBox(ex.Message);
     }
 }
Example #23
0
        private void guna2ButtonTimKiem_Click(object sender, EventArgs e)
        {
            try
            {
                TrinhDo trinhDo = new TrinhDo();
                trinhDo.MaNV          = guna2ComboBoxMaNV.Text;
                trinhDo.Nganh         = guna2TextBoxNganh.Text;
                trinhDo.TrinhDoDaoTao = guna2TextBoxTrinhDo.Text;
                trinhDo.Truong        = guna2TextBoxTruong.Text;

                guna2DataGridViewTrinhDo.DataSource = trinhDo_BUL.findTrinhDo(trinhDo);
            }
            catch (System.Data.SqlClient.SqlException sqlException)
            {
                MessageBox.Show("Lỗi khi thực thi lệnh tìm kiếm!");
            }
        }
        public ActionResult Create(TrinhDo trinhDo)
        {
            // TODO: Add insert logic here
            var trinhDoDao = new TrinhDoDao();

            int maTrinhDo = trinhDoDao.Insert(trinhDo);

            if (maTrinhDo > 0)
            {
                return(RedirectToAction("Index", "TrinhDo"));
            }
            else
            {
                ModelState.AddModelError("", "Thêm thất bại");
            }

            return(View(trinhDo));
        }
        public void SetData()
        {
            if (LISTMACH.Count == 0)
            {
                return;
            }
            lblTenMonHoc.Text = "XE TRƯỚC BỘ ĐỀ MÔN : " + TTENMH;
            KHOA kh = Khoa.GetKhoaByMaKhoa(MAKHOA);

            lblTenKhoa.Text    = "KHOA : " + kh.TENKH;
            lblTrinhDo.Text    = TrinhDo.GetTDByMaTD(MATRINHDO).TENTD;
            lblThongTinBD.Text = "Thời gian : " + THOIGIANTHI.ToString() + " phút";

            RichTextBox    rtbCau = new RichTextBox();
            CAUHOI         ch     = null;
            List <LUACHON> lc     = null;

            for (int i = 0; i < LISTMACH.Count; i++)
            {
                ch = CauHoi.GetCauHoiByMaCH(LISTMACH[i]);
                if (rtbCau.Text.Trim() == string.Empty)
                {
                    rtbCau.Text = "Câu " + (i + 1).ToString() + " : ";
                    rtbCau.AppendText(Environment.NewLine + "    " + ch.NOIDUNG);
                }
                else
                {
                    rtbCau.AppendText(Environment.NewLine + "Câu " + (i + 1).ToString() + " : " + ch.NOIDUNG);
                }
                lc = CauHoi.GetLuaChonByMaCH(LISTMACH[i]);
                for (int j = 0; j < lc.Count; j++)
                {
                    rtbCau.AppendText(Environment.NewLine + "     Câu " + KeyConst.LUACHON[j] + " : " + lc[j].NOIDUNG);
                }
            }
            rtbCau.Dock = DockStyle.Fill;
            FontStyle newFontStyle = (FontStyle)(FontStyle.Bold);

            rtbCau.Font           = new Font("Times New Rowman", 25, newFontStyle);
            pnBaiThi.AutoScroll   = true;
            rtbCau.SelectionStart = 0;
            pnBaiThi.Controls.Add(rtbCau);
        }
Example #26
0
        public bool Update(TrinhDo entity)
        {
            try
            {
                var _lopHoc = _context.TrinhDoes.Find(entity.MaTrinhDo);

                _lopHoc.TenTrinhDo = entity.TenTrinhDo;
                _lopHoc.GhiChu     = entity.GhiChu;
                _lopHoc.TinhTrang  = entity.TinhTrang;

                _context.SaveChanges();

                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
Example #27
0
        private void guna2ButtonThem_Click(object sender, EventArgs e)
        {
            try
            {
                TrinhDo trinhDo = new TrinhDo();
                trinhDo.MaNV          = guna2ComboBoxMaNV.Text;
                trinhDo.Nganh         = guna2TextBoxNganh.Text;
                trinhDo.TrinhDoDaoTao = guna2TextBoxTrinhDo.Text;
                trinhDo.Truong        = guna2TextBoxTruong.Text;

                trinhDo_BUL.insertTrinhDo(trinhDo);

                LamSach();
                HienThi();
                MessageBox.Show("Thêm mới thành công!");
            }catch (System.Data.SqlClient.SqlException sqlException)
            {
                MessageBox.Show("Lỗi khi thực thi lệnh thêm mới!");
            }
        }
        public ActionResult ThemMoiTrinhDo(TrinhDo trinhDo)
        {
            var trinhDoDao = new GiaoVienDao();

            //trinhDo.MaTrinhDo = maTrinhDo + 1;

            int _maTrinhDo = trinhDoDao.InsertTrinhDo(trinhDo);

            if (_maTrinhDo > 0)
            {
                SetAlert("Thêm thành công", 1);
                return(RedirectToAction("Index", "GiaoVien"));
            }
            else
            {
                SetAlert("Thêm thất bại", 3);
                //ModelState.AddModelError("", "Thêm thất bại");
            }

            return(View(trinhDo));
        }
Example #29
0
        public void KTTringDo()
        {
            Console.WriteLine("Tring Do: Cu Nhan(1), Thac Si(2), Tien Si(3)");
            int cke = int.Parse(Console.ReadLine());

            if (cke == 1)
            {
                trinhDo = TrinhDo.CuNhan;
            }
            else if (cke == 2)
            {
                trinhDo = TrinhDo.ThacSi;
            }
            else if (cke == 3)
            {
                trinhDo = TrinhDo.TienSi;
            }
            else
            {
                Console.WriteLine("khong ton tai !!!");
            }
        }
        // TRÌNH ĐỘ
        public bool Update_TrinhDo(TrinhDo trinhDo)
        {
            SqlCommand cmd = new SqlCommand();

            cmd.CommandType = CommandType.StoredProcedure;


            cmd.Parameters.Add("@MADV", SqlDbType.NVarChar).Value      = trinhDo.MaDV;
            cmd.Parameters.Add("@TRINHDOPT", SqlDbType.NVarChar).Value = trinhDo.TrinhDoPT;
            cmd.Parameters.Add("@CHUYENMON", SqlDbType.NVarChar).Value = trinhDo.ChuyenMon;
            cmd.Parameters.Add("@HOCVI", SqlDbType.NVarChar).Value     = trinhDo.HocVi;
            cmd.Parameters.Add("@DATE_HV", SqlDbType.Date).Value       = trinhDo.DTHocVi;
            cmd.Parameters.Add("@LYLUANCT", SqlDbType.NVarChar).Value  = trinhDo.LyLuanCT;
            cmd.Parameters.Add("@NGOAINGU", SqlDbType.NVarChar).Value  = trinhDo.NgoaiNgu;

            if (trinhDo.ViTri == 0)
            {
                cmd.CommandText = "SP_Update_TRINHDO_0";
                cmd.Parameters.Add("@HOCHAM", SqlDbType.NVarChar).Value = trinhDo.HocHam;
                cmd.Parameters.Add("@DATE_HH", SqlDbType.Date).Value    = trinhDo.DTHocham;
            }
            else
            {
                cmd.CommandText = "SP_Update_TRINHDO_1";
            }

            cmd.Connection = _conn;

            try
            {
                _conn.Open();
                cmd.ExecuteNonQuery();

                return(true);
            }
            catch { return(false); }
            finally { _conn.Close(); }
        }