Exemplo n.º 1
0
        protected void btnModel_Click(object sender, EventArgs e)
        {
            KingTop.Model.Content.ModelManage       mModel;
            KingTop.BLL.Content.ModelManage         model;
            List <KingTop.Model.Content.LinkList>[] mTxtLinkList;     // [0] 需删除的链接 [1] 需添加的链执着
            List <KingTop.Model.Content.LinkList>[] mButtonLinkList;  // [0] 需删除的按钮链接 [1] 需添加的按钮链接
            List <KingTop.Model.Content.SysField>[] mSysField;        // [0]  需删除的字段,[1] 需添加的字段
            string ddlSQL;                                            // DDL SQL语句
            string dmlSQL;                                            // DML SQL语句

            string[] temp;                                            // 临时数组用于接收方法返回的DDL和DML语句
            bool     isAdd;                                           // 当前操作
            bool     isPublicOperSynchronization;                     // 当前模型中的操作是否和操作表同步
            string   chkSysFieldValue;                                // 系统自定义字段值
            string   chkCommonFieldValue;                             // 公用字段值
            string   chkListLinkValue;                                // 选取的链接
            string   chkListButtonValue;                              // 选取的按钮
            string   returnMsg;
            string   tranType;                                        // 操作类型
            string   commonFieldPrompt;                               // 公用字段操作提示
            bool     isValidate;                                      // 权限验证

            mModel = new KingTop.Model.Content.ModelManage();
            model  = new KingTop.BLL.Content.ModelManage(mModel);

            model.RptButtonValue  = ControlUtils.GetCheckBoxListSelectValue(chklOperationColumn);
            chkListButtonValue    = ControlUtils.GetCheckBoxListSelectValue(chkListButton);
            chkListLinkValue      = ControlUtils.GetCheckBoxListSelectValue(chkListLink);
            model.ListButtonValue = chkListButtonValue;
            chkSysFieldValue      = model.GetCheckBoxListField(chklField, true);
            chkCommonFieldValue   = model.GetCheckBoxListField(chklField, false);
            ddlSQL   = null;
            dmlSQL   = null;
            isAdd    = true;
            tranType = "NEW";

            if (this.Action == "edit")
            {
                isValidate = IsHaveRightByOperCode("Edit");  // 修改权限认证

                if (!isValidate)
                {
                    jsMessage = "errmsg=\"对不起,您没有修改模型的操作权限,请与管理员联系!\";id=\"" + ID + "\"";
                }
                else
                {
                    tranType           = "EDIT";
                    isAdd              = false;
                    mModel.ID          = this.ID;
                    mModel.ModuleID    = ddlModuleID.SelectedValue;
                    mModel.TableName   = hdnPreFix.Value + Utils.HtmlEncode(txtTableName.Text.Trim());
                    mModel.IsEnable    = Utils.ParseBool(radlIsEnable.SelectedValue);
                    mModel.IsOrderEdit = Utils.ParseBool(radlIsOrderEdit.SelectedValue);
                    mModel.Title       = Utils.HtmlEncode(txtTitle.Text.Trim());
                    mModel.SysField    = chkSysFieldValue;
                    mModel.CustomCol   = hdnCustomCol.Value;
                    mModel.Memo        = Utils.HtmlEncode(txtMemo.Text.Trim());
                    mModel.ListLink    = model.GetLinkList(hdnListLink, chkListLink);
                    mModel.ListButton  = model.GetLinkList(hdnListButton, chkListButton);
                }
            }
            else
            {
                string[] tableID;

                isValidate = IsHaveRightByOperCode("New");  // 新增权限认证

                if (!isValidate)
                {
                    jsMessage = "type=2;errmsg=\"对不起,您没有添加模型的操作权限,请与管理员联系!\";id=\"" + ID + "\"";
                    return;
                }
                else
                {
                    if (IsSub == "1")
                    {
                        mModel.BackDeliverUrlParam      = "NodeCode,ParentID,OriginalUrl";
                        mModel.FieldFromUrlParamValue   = "ParentID";
                        mModel.NotSearchField           = "NodeCode";
                        mModel.DeliverAndSearchUrlParam = "ParentID";
                    }
                    else
                    {
                        mModel.BackDeliverUrlParam = "NodeCode";
                    }

                    tableID            = GetTableID("0", "K_ModelManage");
                    mModel.ID          = tableID[0];
                    mModel.TableName   = ddlPreFix.SelectedValue + Utils.HtmlEncode(txtTableName.Text.Trim());
                    mModel.ModuleID    = ddlModuleID.SelectedValue;
                    mModel.MenuNo      = NodeID;
                    mModel.SiteID      = 1;
                    mModel.IsHtml      = true;
                    mModel.IsDel       = false;
                    mModel.IsEnable    = Utils.ParseBool(radlIsEnable.SelectedValue);
                    mModel.IsOrderEdit = Utils.ParseBool(radlIsOrderEdit.SelectedValue);
                    mModel.Title       = Utils.HtmlEncode(txtTitle.Text.Trim());
                    mModel.SysField    = chkSysFieldValue;
                    mModel.CustomCol   = hdnCustomCol.Value;
                    mModel.Orders      = Utils.ParseInt(tableID[1], 50);
                    mModel.Memo        = Utils.HtmlEncode(txtMemo.Text.Trim());
                    mModel.ListLink    = model.GetLinkList(hdnListLink, chkListLink);
                    mModel.ListButton  = model.GetLinkList(hdnListButton, chkListButton);
                    ddlSQL             = model.CreateTable(mModel.TableName, Common.Utils.ParseBool(IsSub));
                    dmlSQL             = model.InsertInitField(mModel.ID, Common.Utils.ParseBool(IsSub));
                }
            }

            if (isValidate)
            {
                mModel.IsSub = chkIsSub.Checked;

                if (mModel.IsSub)
                {
                    mModel.SubModelGroupID = Request.Form["ddlSubModelGroup"];
                }
                else
                {
                    mModel.SubModelGroupID = string.Empty;
                }

                mModel.CommonField          = chkCommonFieldValue;
                mModel.OperationColumn      = model.RptButtonValue;
                mModel.IsListContentClip    = Utils.ParseBool(radlIsListContentClip.SelectedValue);
                mModel.OperationColumnWidth = txtOperationColumnWidth.Text.Trim();
                mModel.ConfigMan            = txtConfigMan.Text.Trim();
                mTxtLinkList    = model.GetLinkList(hdnOriginalListLink.Value, chkListLinkValue, false, isAdd);
                mButtonLinkList = model.GetLinkList(hdnOriginalListButton.Value, chkListButtonValue, true, isAdd);
                mSysField       = model.GetSysField(hdnOriginalSysField.Value, chkSysFieldValue);

                // 获取链接的DDL与DML语句
                temp   = model.GetLinkListSQL(mTxtLinkList, mButtonLinkList);
                ddlSQL = ddlSQL + temp[0];
                dmlSQL = dmlSQL + temp[1];
                // 获取系统(自定义)字段的DDL与DML语句
                temp   = model.GetSysFieldSQL(mSysField);
                ddlSQL = ddlSQL + temp[0];
                dmlSQL = dmlSQL + temp[1];

                //e3bbb9df-afff-409d-bf13-64f92382e5ae通用标题字段ID
                if (Action.ToLower() == "add" && ddlSQL.ToLower().IndexOf(" title ") == -1 && chkCommonFieldValue.IndexOf("e3bbb9df-afff-409d-bf13-64f92382e5ae") == -1)
                {
                    jsMessage = "errmsg=\"对不起,添加失败,标题字段必须选择。\";type=2;id=\"" + this.ID + "\";";
                    return;
                }
                //return;

                // 同步当前模型的操作
                isPublicOperSynchronization = model.PublicOperSynchronization();

                if (isPublicOperSynchronization)
                {
                    returnMsg         = model.Save(tranType, mModel, ddlSQL, dmlSQL);
                    commonFieldPrompt = string.Empty;

                    if (this.Action.ToLower() != "edit")
                    {
                        commonFieldPrompt = model.SaveCommonField(hdnOriginalCommonField.Value, chkCommonFieldValue, isAdd);
                    }

                    if (returnMsg == "1")
                    {
                        if (this.Action == "edit")
                        {
                            jsMessage = "type=1;title=\"" + mModel.Title + " \";id=\"" + this.ID + "\"";
                            WriteLog("更新模型 " + mModel.Title + "(ID:" + mModel.ID + ") 成功!", null, 2);
                        }
                        else
                        {
                            jsMessage = "type=0;title=\"" + mModel.Title + " \";id=\"" + this.ID + "\"";
                            WriteLog("新增模型 " + mModel.Title + "(ID:" + mModel.ID + ") 成功!", null, 2);
                        }

                        if (commonFieldPrompt != "[]")
                        {
                            jsMessageParam = commonFieldPrompt;
                        }
                    }
                    else
                    {
                        jsMessage = "errmsg=\"对不起,操作失败。\";type=2;id=\"" + this.ID + "\";";
                        WriteLog("新增模型 " + mModel.Title + "(ID:" + mModel.ID + ") 失败!", returnMsg, 3);
                    }
                }
                else  // 模型操作同步失败
                {
                    jsMessage = "errmsg=\"对不起,模型操作同步失败,请重试。\";type=2;id=\"" + this.ID + "\";";

                    if (this.Action == "edit")
                    {
                        WriteLog("修改模型 " + mModel.Title + "(ID:" + mModel.ID + ") 时同步至模块、操作时失败!", "", 3);
                    }
                    else
                    {
                        WriteLog("新增模型 " + mModel.Title + "(ID:" + mModel.ID + ") 时同步至模块、操作时失败!", "", 3);
                    }
                }
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// 增、改K_ModelManage表
 /// </summary>
 /// <param name="tranType">操作类型,NEW=增,EDIT=改</param>
 /// <param name="ModModel"></param>
 /// <returns>返回大于0的数字操作正常,返回非数字表示操作错误,返回的是系统错误说明</returns>
 public string Save(string trantype, KingTop.Model.Content.ModelManage modModel, string ddlSQL, string dmlSQL)
 {
     return(dal.Save(trantype, modModel, ddlSQL, dmlSQL, this.operationTitle, this.operationName, this.operationCount));
 }