Beispiel #1
0
 private void gridkhoa_SelectedItemChanged(object sender, DevExpress.Xpf.Grid.SelectedItemChangedEventArgs e)
 {
     try
     {
         KhoaModel select = gridkhoa.SelectedItem as KhoaModel;
         Khoa      khoa   = khoaControll.GetById(select.MaKhoa);
         _txtmakhoa.Text  = khoa.MaKhoa;
         _txttenkhoa.Text = khoa.TenKhoa;
     }
     catch { }
 }
        public ActionResult Create(KhoaModel khoa)
        {
            try
            {
                khoaCollection.InsertOne(khoa);

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
        public ActionResult Delete(string id, KhoaModel khoa)
        {
            try
            {
                khoaCollection.DeleteOne(Builders <KhoaModel> .Filter.Eq("_id", ObjectId.Parse(id)));

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
        public ResponseResult SuaKhoa(KhoaModel model)
        {
            ResponseResult res = null;

            try
            {
                res = KhoaDA.SuaKhoa(model);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(res);
        }
        public KhoaModel ChiTietKhoa(int KhoaID)
        {
            KhoaModel model = null;

            try
            {
                model = KhoaDA.ChiTietKhoa(KhoaID);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(model);
        }
        public ResponseResult ThemKhoa(KhoaModel model)
        {
            ResponseResult res = null;

            try
            {
                model.NguoiTao = AccountUtils.CurrentUsername();
                res            = KhoaDA.ThemKhoa(model);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(res);
        }
Beispiel #7
0
        public KhoaModel ChiTietKhoa(int KhoaID)
        {
            KhoaModel model = null;

            try
            {
                List <SqlParameter> listParameter = new List <SqlParameter>();
                listParameter.Add(new SqlParameter("@KhoaID", KhoaID));
                model = DBUtils.ExecuteSP <KhoaModel>("SP_Khoa_ChiTiet", listParameter);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(model);
        }
        public ActionResult Edit(string id, KhoaModel khoa)
        {
            try
            {
                var filter = Builders <KhoaModel> .Filter.Eq("_id", ObjectId.Parse(id));

                var update = Builders <KhoaModel> .Update
                             .Set("TenKhoa", khoa.TenKhoa)
                             .Set("NamThanhLap", khoa.NamThanhLap)
                             .Set("DiaChi", khoa.DiaChi);

                var result = khoaCollection.UpdateOne(filter, update);
                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
        public bool Update(KhoaModel model)
        {
            string msgError = "";

            try
            {
                var result = _dbHelper.ExecuteScalarSProcedureWithTransaction(out msgError, "sp_Khoa_update",
                                                                              "@makhoa", model.makhoa,
                                                                              "@tenkhoa", model.tenkhoa);
                if ((result != null && !string.IsNullOrEmpty(result.ToString())) || !string.IsNullOrEmpty(msgError))
                {
                    throw new Exception(Convert.ToString(result) + msgError);
                }
                return(true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #10
0
        public ResponseResult ThemKhoa(KhoaModel model)
        {
            ResponseResult res = null;

            try
            {
                List <SqlParameter> listParameter = new List <SqlParameter>();
                listParameter.Add(new SqlParameter("@TenKhoa", model.TenKhoa));
                listParameter.Add(new SqlParameter("@NamBatDau", model.NamBatDau));
                listParameter.Add(new SqlParameter("@NamKetThuc", model.NamKetThuc));
                listParameter.Add(new SqlParameter("@SLSV", model.SLSV));
                listParameter.Add(new SqlParameter("@CTDTID", model.CTDTID));
                listParameter.Add(new SqlParameter("@NguoiTao", model.NguoiTao));
                res = DBUtils.ExecuteSP <ResponseResult>("SP_Khoa_Them", listParameter);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(res);
        }
Beispiel #11
0
 public ActionResult SuaKhoa(KhoaModel model)
 {
     try
     {
         var result = KhoaService.SuaKhoa(model);
         if (result != null && result.ResponseCode == 1)
         {
             return(Json(JsonResponseViewModel.CreateSuccess("Cập nhật khoá thành công.")));
         }
         else if (result != null && result.ResponseCode == -1)
         {
             return(Json(JsonResponseViewModel.CreateFail(result.ResponseMessage)));
         }
         else
         {
             return(Json(JsonResponseViewModel.CreateFail("Cập nhật khoá thất bại.")));
         }
     }
     catch (Exception ex)
     {
         return(Json(JsonResponseViewModel.CreateFail(ex)));
     }
 }
Beispiel #12
0
 public List <KhoaModel> GetListTableModelBySearch(string search)
 {
     return(KhoaModel.ToListByListKhoa(_khoaControls.GetBySearch(search)));
 }
Beispiel #13
0
 public KhoaModel CreateItem([FromBody] KhoaModel model)
 {
     model.ID_Khoa = Guid.NewGuid().ToString();
     _KhoaBLL.Create(model);
     return(model);
 }
Beispiel #14
0
 public bool Update(KhoaModel model)
 {
     return(_res.Update(model));
 }
Beispiel #15
0
 public bool Create(KhoaModel model)
 {
     return(_res.Create(model));
 }
Beispiel #16
0
 public KhoaModel UpdateUser([FromBody] KhoaModel model)
 {
     _KhoaBLL.Update(model);
     return(model);
 }
Beispiel #17
0
 public KhoaModel UpdateKhoa([FromBody] KhoaModel model)
 {
     _KhoaBusiness.Update(model);
     return(model);
 }