private void btnSave_Click(object sender, EventArgs e)
        {
            DataSet ds = new DataSet();

            try
            {
                HouseholderDTO obj = new HouseholderDTO();
                obj.ID      = -1;
                obj.Name    = txtName.Text;
                obj.Address = txtAddress.Text;
                obj.Phone   = txtPhone.Text;

                ds = HouseholderDAO.Householder_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();
            }
        }
Exemple #2
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            DataSet ds = new DataSet();

            try
            {
                HouseholderDTO obj = new HouseholderDTO();
                obj.ID      = -1;
                obj.Name    = txtName.Text;
                obj.Address = txtAddress.Text;
                obj.Phone   = txtPhone.Text;

                ds = HouseholderDAO.Householder_Search(obj);
                if (ds != null && ds.Tables.Count > 0)
                {
                    dgvHouseholder.DataSource = ds.Tables[0].Copy();
                }
                else
                {
                    clsMessages.ShowWarning("Không tìm thấy");
                }
            }
            catch (Exception ex)
            {
                clsMessages.ShowErrorException(ex);
            }
            finally
            {
                ds.Dispose();
            }
        }
        public static DataSet Householder_InsUpd(HouseholderDTO _Householder)
        {
            DataSet ds = new DataSet();

            try
            {
                ds = clsDatabaseExecute.ExecuteDatasetSP("Householder_InsUpd", _Householder.ID, _Householder.Name, _Householder.Address, _Householder.Phone);
            }
            catch (Exception ex)
            {
                clsMessages.ShowErrorException(ex);
            }
            return(ds);
        }
Exemple #4
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            DataSet ds = new DataSet();

            try
            {
                HouseholderDTO obj = new HouseholderDTO();
                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.Name    = txtName.Text;
                obj.Address = txtAddress.Text;
                obj.Phone   = txtPhone.Text;

                ds = HouseholderDAO.Householder_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();
            }
        }