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)); } }
public ActionResult Edit(string id = "") { using (DIC_TINH dic_tinh = new DIC_TINH()) { return(View(dic_tinh.Get(id))); } }
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."); } }
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); }
// 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)); } }
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; }
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); } }
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")); } } }
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); } }
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); }
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)); } }
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); } }