Exemple #1
0
        private void btnSave_BtnClick(object sender, EventArgs e)
        {
            try
            {
                if (!validator1.Validate())
                {
                    return;
                }
                entityFiller.FillEntity(m_menus);
                m_menus.ParentId = Convert.ToInt32(combMenus.SelectedValue);
                if (m_menus.ParentId != 0)
                {
                    m_menus.ParentName = combMenus.Text;
                }

                MenuApi       menuApi       = new MenuApi();
                ResponseModel responseModel = new ResponseModel();
                if (!IsModify)
                {
                    responseModel = menuApi.AddMenu(m_menus);
                }
                else
                {
                    responseModel = menuApi.ModifyMenu(m_menus);
                }
                if (responseModel.Code == 1)
                {
                    FrmTips.ShowTipsSuccess(AppHelper.MainForm, "保存成功!", ContentAlignment.MiddleCenter, 1000);
                    m_menus           = JsonConvert.DeserializeObject <Menus>(responseModel.Data.ToString());
                    bIsUpdate         = true;
                    this.DialogResult = DialogResult.OK;
                    this.Close();
                }
                else
                {
                    FrmTips.ShowTipsError(AppHelper.MainForm, "保存失败!" + responseModel.Message, ContentAlignment.MiddleCenter, 1000);
                }
            }
            catch (Exception ex)
            {
                FrmTips.ShowTipsError(AppHelper.MainForm, "保存失败!" + ex.Message, ContentAlignment.MiddleCenter, 1000);
            }
        }