Example #1
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            if (MessageService.AskQuestion("${res:FanHai.Hemera.Addins.Msg.SaveRemind}", "${res:Global.SystemInfo}"))
            {
                DataSet   dataSet   = new DataSet();
                DataTable dataTable = CreateDataTable();
                string    groupName = string.Empty;
                bool      bNew      = false;
                groupName = this.txtName.Text.Trim();
                if (this.txtName.Text == string.Empty)
                {
                    MessageService.ShowMessage("${res:FanHai.Hemera.Addins.RBAC.AddResourceGroup.Msg.NameOrCodeIsNull}", "${res:Global.SystemInfo}");
                    return;
                }
                if (!System.Text.RegularExpressions.Regex.IsMatch(this.txtCode.Text, @"^\d{2}$"))
                {
                    MessageService.ShowMessage("${res:FanHai.Hemera.Addins.RBAC.AddResourceGroup.CodeError}", "${res:Global.SystemInfo}");
                    return;
                }
                resourceGroupEntity.GroupName         = groupName;
                resourceGroupEntity.Descriptions      = this.txtDescription.Text;
                resourceGroupEntity.Remark            = this.txtRemark.Text;
                resourceGroupEntity.ResourceGroupCode = this.txtCode.Text;
                resourceGroupEntity.Creator           = PropertyService.Get(PROPERTY_FIELDS.USER_NAME);
                resourceGroupEntity.CreateTimeZone    = PropertyService.Get(PROPERTY_FIELDS.TIMEZONE);
                resourceGroupEntity.Editor            = PropertyService.Get(PROPERTY_FIELDS.USER_NAME);
                resourceGroupEntity.EditTimeZone      = PropertyService.Get(PROPERTY_FIELDS.TIMEZONE);
                if (resourceGroupEntity.GroupKey == "")
                {
                    resourceGroupEntity.GroupKey = CommonUtils.GenerateNewKey(0);
                    bNew = true;
                }
                Dictionary <string, string> rowData = new Dictionary <string, string>()
                {
                    { RBAC_RESOURCE_GROUP_FIELDS.FIELD_RESOURCE_GROUP_KEY, resourceGroupEntity.GroupKey },
                    { RBAC_RESOURCE_GROUP_FIELDS.FIELD_GROUP_NAME, resourceGroupEntity.GroupName },
                    { RBAC_RESOURCE_GROUP_FIELDS.FIELD_DESCRIPTIONS, resourceGroupEntity.Descriptions },
                    { RBAC_RESOURCE_GROUP_FIELDS.FIELD_REMARK, resourceGroupEntity.Remark },
                    { RBAC_RESOURCE_GROUP_FIELDS.FIELD_CREATOR, resourceGroupEntity.Creator },
                    { RBAC_RESOURCE_GROUP_FIELDS.FIELD_CREATE_TIMEZONE, resourceGroupEntity.CreateTimeZone },
                    { RBAC_RESOURCE_GROUP_FIELDS.FIELD_RESOURCE_GROUP_CODE, resourceGroupEntity.ResourceGroupCode }
                };

                FanHai.Hemera.Utils.Common.Utils.AddRowDataToDataTable(ref dataTable, rowData);
                dataSet.Tables.Add(dataTable);
                resourceGroupEntity.AddResourceGroup(bNew, dataSet);
                if (resourceGroupEntity.ErrorMsg == "")
                {
                    DialogResult = DialogResult.OK;
                    this.Close();
                    resourceGroupEntity.ResetDirtyList();
                }
                else
                {
                    DialogResult = DialogResult.Retry;
                    MessageService.ShowError("${res:FanHai.Hemera.Addins.Msg.SaveFailed}" + resourceGroupEntity.ErrorMsg);
                }
            }
        }