Beispiel #1
0
        /// <summary>
        /// Get object by key
        /// </summary>
        /// <modified>
        /// Author          Date            Comment
        /// HungNM          20/06/2014      Add
        /// </modified>
        public VO.CITY GetById(short id)
        {
            DataTable dt = new DAO.CITY().GetById(id);

            if (dt != null && dt.Rows.Count > 0)
            {
                DataRow dr = dt.Rows[0];
                VO.CITY obj = new VO.CITY();

                obj.ID = (short)dr["ID"];
                obj.CITY_NAME = (string)dr["CITY_NAME"];

                return obj;
            }
            else
                return null;
        }
Beispiel #2
0
 /// <summary>
 /// Event button update click
 /// </summary>
 /// <modified>
 /// Author          Date            Comment
 /// HungNM          14/06/2014      Add
 /// </modified>
 protected void btnUpdate_Click(object sender, EventArgs e)
 {
     // Convert id
     short intId;
     if (!short.TryParse(Request["id"], out intId))
     {
         RunJavascript("alert('Id không hợp lệ!');window.location='/Admin/City/Default.aspx';");
         return;
     }
     BUS.CITY objBUS = new BUS.CITY();
     // Get object update
     _city = objBUS.GetById(intId);
     if (_city == null)
     {
         ShowMessage("Không tìm thấy thành phố này để cập nhật thông tin!");
         return;
     }
     // Validate
     _validate = new Common.Validate();
     GetInput();
     if (_validate.IsError)
     {
         ShowMessage(_validate.Message);
         return;
     }
     // Check exist
     if (objBUS.CheckExist(_city.ID, _city.CITY_NAME.ToLower()) > 0)
     {
         ShowMessage("Tên thành phố đã tồn tại!");
         return;
     }
     // Update
     if (objBUS.Update(_city) > 0)
         RunJavascript("alert('Cập nhật thành công!');window.location='/Admin/City/Default.aspx';");
     else
         ShowMessage("Cập nhật thất bại!");
 }
Beispiel #3
0
 /// <summary>
 /// Event button insert click
 /// </summary>
 /// <modified>
 /// Author          Date            Comment
 /// HungNM          14/06/2014      Add
 /// </modified>
 protected void btnInsert_Click(object sender, EventArgs e)
 {
     _city = new VO.CITY();
     // Validate
     _validate = new Common.Validate();
     GetInput();
     if (_validate.IsError)
     {
         ShowMessage(_validate.Message);
         return;
     }
     // Check exist
     BUS.CITY objBUS = new BUS.CITY();
     if (objBUS.CheckExist(_city.ID, _city.CITY_NAME.ToLower()) > 0)
     {
         ShowMessage("Tên thành phố đã tồn tại!");
         return;
     }
     // Insert
     if (objBUS.Insert(_city) > 0)
         RunJavascript("alert('Thêm mới thành công');window.location='/Admin/City/Default.aspx'");
     else
         RunJavascript("alert('Thêm mới thất bại');window.location='/Admin/City/Default.aspx'");
 }
Beispiel #4
0
        /// <summary>
        /// Bind city
        /// </summary>
        /// <modified>
        /// Author          Date            Comment
        /// HungNM          14/06/2014      Add
        /// </modified>
        private void BindCity(short id)
        {
            _city = new BUS.CITY().GetById(id);
            if (_city == null)
            {
                _validate.IsError = true;
                _validate.Message = "Không tồn tại thành phố này";
                return;
            }

            txtCityName.Text = _city.CITY_NAME;
        }