Example #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (!CheckValid())
                {
                    return;
                }

                APILicense objApiCode = new APILicense();
                objApiCode.Id           = _id;
                objApiCode.APICode      = txtAPICode.Text.Trim();
                objApiCode.APIKey       = BuildLicenseUtil.BuildEncrypt(txtAPICode.Text.Trim());
                objApiCode.FK_CompanyID = cboCompany.EditValue.To <int>();
                if (_id == -1)//Add Api Code cho công ty!
                {
                    objApiCode.Insert();
                }
                else
                {
                    objApiCode.Update();
                }

                new MessageBoxBA().Show("Cập nhật thông tin API License thành công!", "Thông báo", MessageBoxButtonsBA.OK, MessageBoxIconBA.Information);
                ResetForm();
                RefreshGridControl();
            }
            catch (Exception ex)
            {
                LogError.WriteLogError("btnSave_Click: ", ex);
            }
        }
Example #2
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                if (_id == -1)
                {
                    new MessageBoxBA().Show("Bạn vui lòng chọn dữ liệu trên lưới!", "Thông báo", MessageBoxButtonsBA.OK, MessageBoxIconBA.Error);
                    return;
                }

                var result = new MessageBoxBA().Show("Bạn có muốn xóa API Company này không?", "Thông báo", MessageBoxButtonsBA.YesNo, MessageBoxIconBA.Error);
                if (result == MessageBoxResult.Yes)
                {
                    APILicense objApiLicense = new APILicense();
                    objApiLicense.Id = _id;
                    objApiLicense.Delete();
                    new MessageBoxBA().Show("Xóa thông tin API Company thành công!", "Thông báo", MessageBoxButtonsBA.OK, MessageBoxIconBA.Error);
                    ResetForm();
                    RefreshGridControl();
                }
            }
            catch (Exception ex)
            {
                LogError.WriteLogError("btnDelete_Click: ", ex);
            }
        }
 private void LoadCurrentAPIKey()
 {
     try
     {
         if (inputLookUp_Company.EditValue != null)
         {
             int companyID = 0;
             int.TryParse(inputLookUp_Company.EditValue.ToString(), out companyID);
             APILicense objAPILicense = APILicense.Inst.GetItemFromCompanyId(companyID);
             if (objAPILicense != null)
             {
                 txtAPICode.Text = objAPILicense.APICode;
             }
             else
             {
                 txtAPICode.Text = string.Empty;
             }
         }
     }
     catch (Exception ex)
     {
         LogError.WriteLogError("BuildLicense_Form.LoadCurrentAPIKey", ex);
     }
 }