private void btnSearch_Click(object sender, EventArgs e) { DataSet ds = new DataSet(); try { HouseTypeDTO obj = new HouseTypeDTO(); obj.ID = -1; obj.Description = txtDescription.Text; obj.Name = txtName.Text; ds = HouseTypeDAO.HouseType_Search(obj); if (ds != null && ds.Tables.Count > 0) { dgvHouseType.DataSource = ds.Tables[0].Copy(); } else { clsMessages.ShowWarning("Không tìm thấy"); } } catch (Exception ex) { clsMessages.ShowErrorException(ex); } finally { ds.Dispose(); } }
private void btnSave_Click(object sender, EventArgs e) { DataSet ds = new DataSet(); try { HouseTypeDTO obj = new HouseTypeDTO(); obj.ID = -1; obj.Description = txtDescription.Text; obj.Name = txtName.Text; ds = HouseTypeDAO.HouseType_InsUpd(obj); if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0 && Convert.ToInt32(ds.Tables[0].Rows[0]["Result"]) == 1) { clsMessages.ShowInformation("Thêm thành công!"); frmParent.LoadDataToForm(); this.Close(); } else { clsMessages.ShowWarning("Thêm thất bại!"); } } catch (Exception ex) { clsMessages.ShowErrorException(ex); } finally { ds.Dispose(); } }
public List <HouseTypeDTO> House() { using (IDbSvc dbSvc = new DbSvc(_configSvc)) { try { dbSvc.OpenConnection(); MySqlCommand command = new MySqlCommand(); command.CommandText = "select HouseTypeId,HouseTypeDescription from housetype where Active=1"; command.Connection = dbSvc.GetConnection() as MySqlConnection; _dtData = new DataTable(); MySqlDataAdapter msDa = new MySqlDataAdapter(command); msDa.Fill(_dtData); List <HouseTypeDTO> lstHouse = new List <HouseTypeDTO>(); if (_dtData != null && _dtData.Rows.Count > 0) { HouseTypeDTO houseDTO = null; foreach (DataRow dr in _dtData.Rows) { houseDTO = new HouseTypeDTO(); houseDTO.HouseTypeId = (int)dr["HouseTypeId"]; houseDTO.HouseTypeDescription = dr["HouseTypeDescription"].ToString(); lstHouse.Add(houseDTO); } } return(lstHouse); } catch (Exception exp) { throw exp; } } }
public static DataSet HouseType_InsUpd(HouseTypeDTO _HouseType) { DataSet ds = new DataSet(); try { ds = clsDatabaseExecute.ExecuteDatasetSP("HouseType_InsUpd", _HouseType.ID, _HouseType.Name, _HouseType.Description); } catch (Exception ex) { clsMessages.ShowErrorException(ex); } return(ds); }
private void btnSave_Click(object sender, EventArgs e) { DataSet ds = new DataSet(); try { HouseTypeDTO obj = new HouseTypeDTO(); if (string.IsNullOrWhiteSpace(txtID.Text)) { clsMessages.ShowInformation("Vui lòng chọn dòng dữ liệu muốn sửa!"); return; } obj.ID = Convert.ToInt64(txtID.Text); obj.Description = txtDescription.Text; obj.Name = txtName.Text; ds = HouseTypeDAO.HouseType_InsUpd(obj); if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0 && Convert.ToInt32(ds.Tables[0].Rows[0]["Result"]) == 1) { clsMessages.ShowInformation("Cập nhật thành công!"); LoadDataToForm(); } else { clsMessages.ShowWarning("Cập nhật thất bại!"); } } catch (Exception ex) { clsMessages.ShowErrorException(ex); } finally { ds.Dispose(); } }