Beispiel #1
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            var dr = MessageBox.Show(ConstantInfo.CONFIRM_ADD_NEW, "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (dr != DialogResult.Yes)
            {
                return;
            }

            if (_mode == 0)
            {
                //validate
                if (validate())
                {
                    tblCompany company = new tblCompany();
                    company.CompanyCode = txtCompanyCode.Text.Trim();
                    company.CompanyName = txtCompanyName.Text.Trim();
                    company.Description = txtDescription.Text.Trim();
                    company.CreatedBy   = _userInfo.UserID;
                    company.ModifiedBy  = _userInfo.UserID;
                    if (CompanyFactory.Insert(company) > 0)
                    {
                        try
                        {
                            _frmListCompany.init();
                        }
                        catch (Exception ex)
                        {
                            //do nothing
                        }
                        MessageBox.Show("Thêm mới doanh nghiệp thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        reset();
                        txtCompanyCode.Focus();
                    }
                    else
                    {
                        MessageBox.Show("Thêm mới doanh nghiệp không thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }