Exemplo n.º 1
0
 protected List <DIC_XAPHUONG> DataReaderToList(SqlDataReader dataReader)
 {
     try
     {
         List <DIC_XAPHUONG> dsChuyenKhoa = new List <DIC_XAPHUONG>();
         while (dataReader.Read())
         {
             DIC_XAPHUONG xaphuong = new DIC_XAPHUONG();
             xaphuong.MaXa     = dataReader["MaXa"].ToString();
             xaphuong.MaHuyen  = dataReader["MaHuyen"].ToString();
             xaphuong.TenXa    = dataReader["TenXa"].ToString();
             xaphuong.TenHuyen = dataReader["TenHuyen"].ToString();
             xaphuong.MaTinh   = dataReader["MaTinh"].ToString();
             xaphuong.TenTinh  = dataReader["TenTinh"].ToString();
             xaphuong.Status   = DataConverter.StringToInt(dataReader["Status"].ToString());
             dsChuyenKhoa.Add(xaphuong);
         }
         return(dsChuyenKhoa);
     }
     catch (Exception ex)
     {
         log.Error("Generate DANH MUC XA/PHUONG", ex);
         return(null);
     }
 }
Exemplo n.º 2
0
 public override void SaveModel()
 {
     if (this.Validation())
     {
         DIC_XAPHUONG  xa = (DIC_XAPHUONG)this.GetModel();
         SqlResultType flag;
         if (this.actions == Common.Common.Class.Actions.AddNew)
         {
             flag = new RuralCommuneProvider().Insert(xa);
         }
         else
         {
             flag = new RuralCommuneProvider().Update(xa);
         }
         SaveCompleteEventArgs args = new SaveCompleteEventArgs();
         args.Result  = flag == SqlResultType.OK;
         args.Model   = xa;
         args.Message = "Không lưu được thông tin xã phường";
         this.SaveCompleteSuccess(xa, args);
     }
     else
     {
         XtraMessageBox.Show("Thông tin chưa hợp lệ kiểm tra lại thông tin.");
     }
 }
Exemplo n.º 3
0
        public override object GetModel()
        {
            DIC_XAPHUONG xa = new DIC_XAPHUONG();

            xa.MaXa    = txtID.EditValue as string;
            xa.TenXa   = txtName.Text;
            xa.MaHuyen = cmbDistrict.EditValue as string;
            xa.MaTinh  = cmbProvince.EditValue as string;
            xa.Status  = ckbStatus.Checked ? 1 : 0;
            return(xa);
        }
Exemplo n.º 4
0
 public SqlResultType Delete(DIC_XAPHUONG xa)
 {
     try
     {
         this.sqlHelper.CommandType = CommandType.StoredProcedure;
         object result = this.sqlHelper.ExecuteScalar("DeleteXaPhuong", new string[] { "@MaXa" }, new object[] { xa.MaXa });
         int    kq     = Convert.ToInt32(result);
         return(this.GetResult(kq));
     }
     catch (Exception ex)
     {
         log.Error("Delete DANH MUC XA/PHUONG", ex);
         return(SqlResultType.Exception);
     }
 }
Exemplo n.º 5
0
        private void BindingModel()
        {
            this.dxErrorProviderModel.ClearErrors();
            this.isUpdated = false;
            this.isEdited  = false;
            DIC_XAPHUONG xa = (DIC_XAPHUONG)this.Model;

            txtID.Text            = xa.MaXa.ToString();
            txtName.Text          = xa.TenXa;
            cmbDistrict.EditValue = xa.MaHuyen;
            cmbProvince.EditValue = xa.MaTinh;
            ckbStatus.Checked     = xa.Status == 1;
            txtID.ReadOnly        = true;
            this.isUpdated        = true;
        }
Exemplo n.º 6
0
 public SqlResultType Insert(DIC_XAPHUONG xa)
 {
     try
     {
         this.sqlHelper.CommandType = CommandType.StoredProcedure;
         object result = this.sqlHelper.ExecuteScalar("InsertXaPhuong",
                                                      new string[] { "@MaXa", "@MaHuyen", "@TenXa", "@Status" },
                                                      new object[] { xa.MaXa, xa.MaHuyen, xa.TenXa, xa.Status }
                                                      );
         int kq = Convert.ToInt32(result);
         return(this.GetResult(kq));
     }
     catch (Exception ex)
     {
         log.Error("Insert DANH MUC XA/PHUONG", ex);
         return(SqlResultType.Exception);
     }
 }
Exemplo n.º 7
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_XAPHUONG  xa         = (DIC_XAPHUONG)this.Model;
             SqlResultType resultType = new RuralCommuneProvider().Delete(xa);
             if (resultType == SqlResultType.OK)
             {
                 this.ClearModel();
                 this.DisabledLayout(true);
             }
             return(resultType == SqlResultType.OK);
         }
     }
     return(false);
 }