Ejemplo n.º 1
0
 public ActionResult Create(DIC_TINH model)
 {
     if (ModelState.IsValid)
     {
         try
         {
             model.Cap = model.GetCapById(model.Cap);
             var result = model.Insert();
             if (result == data.enums.SqlResultType.OK)
             {
                 this.ShowNotification(data.enums.MessageObjectType.Success, "", "Tạo mới tỉnh/thành thành công.");
                 return(RedirectToAction("Index"));
             }
             else
             {
                 this.GetMessageFromSqlState(result, "Mã tỉnh");
                 return(View(model));
             }
         }
         catch (Exception ex)
         {
             this.HanderException(ex);
             return(View(model));
         }
     }
     else
     {
         return(View(model));
     }
 }
Ejemplo n.º 2
0
 public ActionResult Edit(string id = "")
 {
     using (DIC_TINH dic_tinh = new DIC_TINH())
     {
         return(View(dic_tinh.Get(id)));
     }
 }
Ejemplo n.º 3
0
 public override void SaveModel()
 {
     if (this.Validation())
     {
         DIC_TINH      tinhthanh = (DIC_TINH)this.GetModel();
         SqlResultType flag;
         if (this.actions == Common.Common.Class.Actions.AddNew)
         {
             flag = new ProvinceProvider().Insert(tinhthanh);
         }
         else
         {
             flag = new ProvinceProvider().Update(tinhthanh);
         }
         SaveCompleteEventArgs args = new SaveCompleteEventArgs();
         args.Result  = flag == SqlResultType.OK;
         args.Model   = tinhthanh;
         args.Message = "Không lưu được thông tin tỉnh thành";
         this.SaveCompleteSuccess(tinhthanh, args);
     }
     else
     {
         XtraMessageBox.Show("Thông tin chưa hợp lệ kiểm tra lại thông tin.");
     }
 }
Ejemplo n.º 4
0
        public override object GetModel()
        {
            DIC_TINH tinhthanh = new DIC_TINH();

            tinhthanh.MaTinh  = txtID.EditValue as string;
            tinhthanh.TenTinh = txtName.Text;
            tinhthanh.Status  = ckbStatus.Checked ? 1 : 0;
            return(tinhthanh);
        }
Ejemplo n.º 5
0
 // GET: tinhthanh
 public ActionResult Index(string text, string cap, bool status = true, int page = 1, int pagesize = 20)
 {
     this.SetPageInfo(page, pagesize);
     ViewBag.text   = text;
     ViewBag.cap    = cap;
     ViewBag.status = status;
     using (DIC_TINH dic_tinhthanh = new DIC_TINH())
     {
         string _cap           = dic_tinhthanh.GetCapById(cap);
         var    dic_tinhthanhs = dic_tinhthanh.GetFilter(text, _cap == "" ? null : _cap, status ? "1" : "0").ToPagedList(page, pagesize);
         return(View(dic_tinhthanhs));
     }
 }
Ejemplo n.º 6
0
        private void BindingModel()
        {
            this.dxErrorProviderModel.ClearErrors();
            this.isUpdated = false;
            this.isEdited  = false;
            DIC_TINH tinhthanh = (DIC_TINH)this.Model;

            txtID.Text        = tinhthanh.MaTinh.ToString();
            txtName.Text      = tinhthanh.TenTinh;
            ckbStatus.Checked = tinhthanh.Status == 1;
            txtID.ReadOnly    = true;
            this.isUpdated    = true;
        }
Ejemplo n.º 7
0
 public SqlResultType Delete(DIC_TINH tinhthanh)
 {
     try
     {
         this.sqlHelper.CommandType = CommandType.StoredProcedure;
         object result = this.sqlHelper.ExecuteScalar("DeleteTinhThanh", new string[] { "@MaTinh" }, new object[] { tinhthanh.MaTinh });
         int    kq     = Convert.ToInt32(result);
         return(this.GetResult(kq));
     }
     catch (Exception ex)
     {
         log.Error("Delete DANH MUC TINH THANH", ex);
         return(SqlResultType.Exception);
     }
 }
Ejemplo n.º 8
0
 public ActionResult Delete(string id)
 {
     using (DIC_TINH dic_tinh = new DIC_TINH())
     {
         dic_tinh.MaTinh = id;
         var result = dic_tinh.Delete();
         if (result == data.enums.SqlResultType.OK)
         {
             this.ShowNotification(data.enums.MessageObjectType.Success, "Xóa tỉnh thành", "Đã xóa thành công ");
             return(RedirectToAction("Index"));
         }
         else
         {
             this.ShowNotification(result, "Xóa tỉnh thành", "Không xóa được bản ghi này.");
             return(RedirectToAction("Index"));
         }
     }
 }
Ejemplo n.º 9
0
 public SqlResultType Update(DIC_TINH chuyenKhoa)
 {
     try
     {
         this.sqlHelper.CommandType = CommandType.StoredProcedure;
         object result = this.sqlHelper.ExecuteScalar("UpdateTinhThanh",
                                                      new string[] { "@MaTinh", "@TenTinh", "@Status" },
                                                      new object[] { chuyenKhoa.MaTinh, chuyenKhoa.TenTinh, chuyenKhoa.Status }
                                                      );
         int kq = Convert.ToInt32(result);
         return(this.GetResult(kq));
     }
     catch (Exception ex)
     {
         log.Error("Update DANH MUC TINH THANH", ex);
         return(SqlResultType.Exception);
     }
 }
Ejemplo n.º 10
0
 public override bool DeleteModel()
 {
     if (this.Model != null)
     {
         if (XtraMessageBox.Show("Bạn có muốn xóa bản ghi này không?", "Xóa bản ghi", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.OK)
         {
             DIC_TINH      tinhthanh  = (DIC_TINH)this.Model;
             SqlResultType resultType = new ProvinceProvider().Delete(tinhthanh);
             if (resultType == SqlResultType.OK)
             {
                 this.ClearModel();
                 this.DisabledLayout(true);
             }
             return(resultType == SqlResultType.OK);
         }
     }
     return(false);
 }
Ejemplo n.º 11
0
 public ActionResult Edit(string id, DIC_TINH model)
 {
     if (ModelState.IsValid)
     {
         try
         {
             model.Cap = model.GetCapById(model.Cap);
             var entityUpdate = model.Get(DataConverter.StringToInt(id));
             if (entityUpdate != null)
             {
                 entityUpdate.MaTinh  = model.MaTinh;
                 entityUpdate.TenTinh = model.TenTinh;
                 entityUpdate.Cap     = model.Cap;
                 entityUpdate.Status  = model.Status;
                 var result = entityUpdate.Update();
                 if (result == data.enums.SqlResultType.OK)
                 {
                     this.ShowNotification(data.enums.MessageObjectType.Success, "", "Chỉnh sửa thành công.");
                     return(RedirectToAction("Index"));
                 }
                 else
                 {
                     this.GetMessageFromSqlState(result, "Mã tỉnh");
                     return(View(model));
                 }
             }
             else
             {
                 this.GetMessageFromSqlState(data.enums.SqlResultType.NotExisted, "Mã tỉnh");
                 return(View(model));
             }
         }
         catch (Exception ex)
         {
             this.HanderException(ex);
             return(View(model));
         }
     }
     else
     {
         return(View(model));
     }
 }
Ejemplo n.º 12
0
 protected List <DIC_TINH> DataReaderToList(SqlDataReader dataReader)
 {
     try
     {
         List <DIC_TINH> dsChuyenKhoa = new List <DIC_TINH>();
         while (dataReader.Read())
         {
             DIC_TINH tinhthanh = new DIC_TINH();
             tinhthanh.MaTinh  = dataReader["MaTinh"].ToString();
             tinhthanh.TenTinh = dataReader["TenTinh"].ToString();
             tinhthanh.Status  = DataConverter.StringToInt(dataReader["Status"].ToString());
             dsChuyenKhoa.Add(tinhthanh);
         }
         return(dsChuyenKhoa);
     }
     catch (Exception ex)
     {
         log.Error("Generate DANH MUC TINH THANH", ex);
         return(null);
     }
 }