예제 #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            DataSet ds = new DataSet();

            try
            {
                BranchOfficeDTO obj = new BranchOfficeDTO();
                obj.ID         = -1;
                obj.Name       = txtName.Text;
                obj.Phone      = txtPhone.Text;
                obj.Fax        = txtFax.Text;
                obj.IDLocation = Convert.ToInt64((cboLocation.SelectedItem as clsComboItem).Value);

                ds = BranchOfficeDAO.BranchOffice_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();
            }
        }
예제 #2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            DataSet ds = new DataSet();

            try
            {
                BranchOfficeDTO obj = new BranchOfficeDTO();
                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.Phone      = txtPhone.Text;
                obj.Fax        = txtFax.Text;
                obj.IDLocation = Convert.ToInt64((cboLocation.SelectedItem as clsComboItem).Value);

                ds = BranchOfficeDAO.BranchOffice_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();
            }
        }