protected void Page_Load(object sender, EventArgs e)
    {
        dics.Add("TF_TABLE-root", "TF_TABLE");
        dics.Add("TF_TABLE", "TF_TABLE");
        //dics.Add("TF_TABLE", "TF_TABLE-mx");
        if (!IsPostBack)
        {
            #region////显示子节点
            if (Request["getSubNodes"] != null)
            {
                string nodetype = Request["ntype"];
                StringBuilder sb = new StringBuilder("[");
                string id = Request["id"];
                if (nodetype == "TF_TABLE-root")
                {
                    #region
                    TF_TABLE obj = new TF_TABLE();
                    TF_TABLE val = new TF_TABLE();
                    obj.M_TB_ID = 0;
                    val.OrderBy(TF_TABLE.Attribute.SORT_NO, Order.Asc);
                    List<TF_TABLE> lst = BLLTable<TF_TABLE>.Select(val, obj);
                    if (lst.Count != null)
                    {
                        for (int i = 0; i < lst.Count; i++)
                        {
                            if (sb.Length > 2)
                            {
                                sb.Append(",");
                            }
                            sb.Append("{id:'").Append(lst[i].TB_ID);
                            sb.Append("',pid:'").Append("0").Append("',no:").Append(lst[i].SORT_NO);
                            sb.Append(",sc:").Append("-1");
                            sb.Append(",name:'").Append(lst[i].CH_NAME).Append("',ntype:'TF_TABLE'}");
                        }
                    }
                    #endregion
                }
                if (nodetype == "TF_TABLE" || nodetype == "TF_TABLE-mx")
                {
                    if (nodetype == "TF_TABLE")//明细表,将不会再有子级的明细表。。。
                    {
                        #region
                        TF_TABLE objTB = new TF_TABLE();
                        TF_TABLE valTB = new TF_TABLE();
                        objTB.M_TB_ID = int.Parse(id);
                        valTB.OrderBy(TF_TABLE.Attribute.SORT_NO, Order.Asc);
                        List<TF_TABLE> lstTB = BLLTable<TF_TABLE>.Select(valTB, objTB);
                        if (lstTB.Count != null)
                        {
                            for (int i = 0; i < lstTB.Count; i++)
                            {
                                if (sb.Length > 2)
                                {
                                    sb.Append(",");
                                }
                                sb.Append("{id:'").Append(lstTB[i].TB_ID);
                                sb.Append("',pid:'").Append(id).Append("',no:").Append(lstTB[i].SORT_NO);
                                sb.Append(",sc:").Append("1");
                                sb.Append(",name:'").Append(lstTB[i].CH_NAME).Append("',ntype:'TF_TABLE-mx'}");
                            }
                        }
                        #endregion
                    }
                    #region
                    TF_TB_FIELD obj = new TF_TB_FIELD();
                    TF_TB_FIELD val = new TF_TB_FIELD();
                    obj.TB_ID = int.Parse(id);
                    val.OrderBy(TF_TB_FIELD.Attribute.SORT_NO, Order.Asc);

                    List<TF_TB_FIELD> lst = BLLTable<TF_TB_FIELD>.Select(val, obj);
                    if (lst.Count > 0)
                    {
                        for (int i = 0; i < lst.Count; i++)
                        {
                            if (sb.Length > 2)
                            {
                                sb.Append(",");
                            }
                            sb.Append("{id:'").Append(lst[i].FIELD_ID.ToString());
                            sb.Append("',pid:'").Append(lst[i].TB_ID.ToString()).Append("',no:").Append(lst[i].SORT_NO);
                            sb.Append(",sc:").Append("0");
                            sb.Append(",name:'").Append(lst[i].NOTE).Append("',ntype:'TF_F_COLUMN'}");

                        }

                    }
                    #endregion
                }

                if (nodetype == "TF_FORM-root")
                {
                    #region
                    TF_FORM obj = new TF_FORM();
                    TF_FORM val = new TF_FORM();
                    obj.M_FORM_ID = 0;
                    val.OrderBy(TF_FORM.Attribute.FORM_ID, Order.Asc);
                    List<TF_FORM> lst = BLLTable<TF_FORM>.Select(val, obj);
                    if (lst.Count != null)
                    {
                        for (int i = 0; i < lst.Count; i++)
                        {
                            if (sb.Length > 2)
                            {
                                sb.Append(",");
                            }
                            sb.Append("{id:'").Append(lst[i].FORM_ID);
                            sb.Append("',pid:'").Append(lst[i].TB_ID).Append("',no:").Append(lst[i].FORM_ID);
                            sb.Append(",sc:").Append("1");
                            sb.Append(",name:'").Append(lst[i].F_NAME).Append("',ntype:'TF_FORM'}");
                        }
                    }
                    #endregion
                }
                if (nodetype == "TF_FORM" || nodetype == "TF_FORM-mx")
                {
                    if (nodetype == "TF_FORM")
                    {
                        #region
                        TF_FORM objForm = new TF_FORM();
                        TF_FORM valForm = new TF_FORM();
                        objForm.M_FORM_ID = int.Parse(id);
                        valForm.OrderBy(TF_FORM.Attribute.FORM_ID, Order.Asc);
                        List<TF_FORM> lstForm = BLLTable<TF_FORM>.Select(valForm, objForm);
                        if (lstForm.Count != null)
                        {
                            for (int i = 0; i < lstForm.Count; i++)
                            {
                                if (sb.Length > 2)
                                {
                                    sb.Append(",");
                                }
                                sb.Append("{id:'").Append(lstForm[i].FORM_ID);
                                sb.Append("',pid:'").Append(id).Append("',no:").Append(lstForm[i].FORM_ID);
                                sb.Append(",sc:").Append("1");
                                sb.Append(",name:'").Append(lstForm[i].F_NAME).Append("',ntype:'TF_FORM-mx'}");
                            }
                        }
                        #endregion
                    }
                    #region
                    TF_F_COLUMN obj = new TF_F_COLUMN();
                    TF_F_COLUMN val = new TF_F_COLUMN();
                    //obj.IS_DEFAULT = "0";
                    obj.FORM_ID = int.Parse(id);
                    val.OrderBy(TF_F_COLUMN.Attribute.SORT_NO, Order.Asc);
                    List<TF_F_COLUMN> lst = BLLTable<TF_F_COLUMN>.Select(val, obj);
                    if (lst.Count != null)
                    {
                        for (int i = 0; i < lst.Count; i++)
                        {
                            if (sb.Length > 2)
                            {
                                sb.Append(",");
                            }
                            sb.Append("{id:'").Append(lst[i].COLUMN_ID);
                            sb.Append("',pid:'").Append(lst[i].FORM_ID).Append("',no:").Append(lst[i].SORT_NO);
                            sb.Append(",sc:").Append("0");
                            sb.Append(",name:'").Append(lst[i].SHOW_NAME).Append("',ntype:'TF_F_COLUMN'}");
                        }
                    }
                    #endregion
                }
                //sb.Append("{id:'").Append("1");
                //sb.Append("',pid:'").Append("0").Append("',no:").Append("1");
                //sb.Append(",sc:").Append("1");
                //sb.Append(",name:'").Append("aaaaa(aaa)").Append("',ntype:'TF_FORM'}");

                sb.Append("]");
                Response.Write(sb.ToString());
            }
            #endregion

            #region//删除节点
            if (Request["deleteNode"] != null)
            {
                string str = "";
                string delID=Request["id"];
                string ntype=Request["ntype"];
                if (ntype == "table" || ntype == "TF_TABLE-mx")
                {
                    #region//删除表
                    int re = 0;
                    string msg = "删除数据库表成功!";
                    TF_TABLE cccSub = new TF_TABLE();
                    cccSub.M_TB_ID = int.Parse(delID);
                    if (BLLTable<TF_TABLE>.Count(cccSub) > 0)
                    {
                        msg = "存在明细表,不能删除!";
                    }
                    else
                    {
                        TF_TB_FIELD hadcol = new TF_TB_FIELD();
                        hadcol.TB_ID = int.Parse(delID);
                        if (BLLTable<TF_TB_FIELD>.Exists(hadcol))
                        {
                            msg = "存在字段,不能删除此表";
                        }
                        else
                        {
                            TF_FORM useTB = new TF_FORM();
                            useTB.Where("TB_ID=" + delID + " or TB_IDS like '%," + delID + ",%'");
                            if (BLLTable<TF_FORM>.Exists(useTB))
                            {
                                msg = "此表已被表单使用,不能删除";
                            }
                            else
                            {
                                re = new TF_TABLEHelper(conn).DelTable(delID, ref msg);// ;
                                if (re > 0)
                                {
                                    if (BLLTable<TF_TABLE>.Delete(TF_TABLE.Attribute.TB_ID, delID) <= 0)
                                    {
                                        msg = "删除数据库表成功,但删除表结构信息失败!";
                                    }
                                }
                                else
                                {
                                    msg = "删除表结构信息失败!";
                                }
                            }
                        }
                    }
                    #endregion
                    str = "{re:" + re + ",msg:'" + msg + "'}";
                }
                else if (ntype == "field")
                {
                    #region//删除表字段
                    string msg = "删除数据库表字段成功!";
                    int re = new TF_TABLEHelper(conn).DelField(delID, ref msg);// ;
                    if (re > 0)
                    {
                        if (BLLTable<TF_TB_FIELD>.Delete(TF_TB_FIELD.Attribute.FIELD_ID, delID) <= 0)
                        {
                            msg = "删除数据库表字段成功,但删除字段结构信息失败!";
                        }
                    }
                    else {
                        msg = "删除数据库表字段失败!";
                    }
                    #endregion
                    str = "{re:" + re + ",msg:'" + msg + "'}";
                }
                else if (ntype == "TF_FORM" || ntype == "TF_FORM-mx")
                {
                    #region//删除表单
                    int re = 0;
                    string msg = "删除表单成功!";
                    TF_FORM cccSub = new TF_FORM();
                    cccSub.M_FORM_ID = int.Parse(delID);
                    if (BLLTable<TF_FORM>.Count(cccSub) > 0)
                    {
                        msg = "存在明细表单,不能删除!";
                    }
                    else
                    {
                        TF_F_COLUMN ccc = new TF_F_COLUMN();
                        ccc.FORM_ID = int.Parse(delID);
                        ccc.IS_DEFAULT = "0";

                        if (BLLTable<TF_F_COLUMN>.Count(ccc) > 0)
                        {
                            msg = "存在栏目,不能删除!";
                        }
                        else
                        {
                            re = BLLTable<TF_FORM>.Delete(TF_FORM.Attribute.FORM_ID, delID);
                            BLLTable<TF_F_COLUMN>.Delete(TF_F_COLUMN.Attribute.FORM_ID, delID);
                            if (re <= 0)
                            {
                                msg = "删除表单失败!";
                            }
                        }
                    }
                    #endregion
                    str = "{re:" + re+",msg:'" + msg + "'}";
                }
                else if (ntype == "TF_F_COLUMN")
                {
                    string msg = "删除表单栏目成功!";

                    TF_F_COLUMN oldObj = BLLTable<TF_F_COLUMN>.GetRowData(TF_F_COLUMN.Attribute.COLUMN_ID, delID);

                    int re = BLLTable<TF_F_COLUMN>.Delete(TF_F_COLUMN.Attribute.COLUMN_ID, delID);

                    if (re <= 0)
                    {
                        msg = "删除表单栏目失败";
                    }
                    else {
                        if (oldObj != null)
                        {
                            BLLTable<TF_TB_FIELD>.Update(TF_TB_FIELD.Attribute.FIELD_ID, oldObj.FIELD_ID,
                                TF_TB_FIELD.Attribute.CREATED, 0);
                        }
                    }

                    str = "{re:" + re + ",msg:'" + msg + "'}";
                }
                Response.Write(str);
            }
            #endregion
        }

        Response.End();
    }
Beispiel #2
0
    protected void btnOK_Click(object sender, EventArgs e)
    {
        //try
        //{
        #region
        TF_TB_FIELD valObj = new TF_TB_FIELD();

        valObj.TB_ID = int.Parse(tbid);    // Convert.ToInt32(txtTB_ID.Value);
        if (txtFIELD_NAME.Value != "")
        {
            valObj.FIELD_NAME = Convert.ToString(txtFIELD_NAME.Value);
        }

        if (ViewState["OLDNAME"].ToString() != txtFIELD_NAME.Value)
        {
            if (BLLTable <TF_TB_FIELD> .Exists(valObj))
            {
                litWarn.Text = "此字段已经存在,请重新输入!";
                return;
            }
        }

        if (txtFIELD_ID.Value != "")
        {
            valObj.FIELD_ID = Convert.ToInt32(txtFIELD_ID.Value);
        }



        if (txtFIELD_TYPE.Value != "")
        {
            TF_FIELD_DBTYPE typeObj = BLLTable <TF_FIELD_DBTYPE> .Factory(conn).GetRowData(TF_FIELD_DBTYPE.Attribute.TYPE_CODE, txtFIELD_TYPE.Value);

            valObj.TYPE_CODE = typeObj.TYPE_CODE;
            valObj.DB_TYPE   = typeObj.DB_TYPE;
            //valObj.TYPE_ID = Convert.ToInt32(txtFIELD_TYPE.Value);
        }


        //if(txtDB_TYPE.Value !="" )
        //    valObj.DB_TYPE = Convert.ToString(txtDB_TYPE.Value);


        valObj.IS_NULL = txtIS_NULL.Checked == true ? 1 : 0;


        if (txtNOTE.Value != "")
        {
            valObj.NOTE = Convert.ToString(txtNOTE.Value);
        }


        if (txtDEFAULT_VAL.Value != "")
        {
            valObj.DEFAULT_VAL = Convert.ToString(txtDEFAULT_VAL.Value);
        }


        //if (txtTB_ID.Value != "")



        if (txtCTRL_TYPE.Value != "")
        {
            valObj.CTRL_TYPE = Convert.ToString(txtCTRL_TYPE.Value);
        }


        if (txtSORT_NO.Value != "")
        {
            valObj.SORT_NO = Convert.ToInt32(txtSORT_NO.Value);
        }

        #endregion
        int editb = -9;
        if (keyid != "")
        {
            valObj.FIELD_ID = Convert.ToInt32(keyid);

            //TF_TB_FIELD oldObj = BLLTable<TF_TB_FIELD>.Factory(conn).GetRowData(TF_TB_FIELD.Attribute.FIELD_ID, keyid);
            editb = new AgileFrame.Common.TF_TABLEHelper(conn).SaveOrUpdateField(valObj, ViewState["OLDNAME"].ToString(), ref errMsg);    //同时修改正式表和流程临时表字段
            if (editb > 0)
            {
                count = BLLTable <TF_TB_FIELD> .Factory(conn).Update(valObj, TF_TB_FIELD.Attribute.FIELD_ID);
            }
            else
            {
                litWarn.Text = "在数据库里修改字段信息失败!" + editb;
                return;
            }
        }
        else
        {
            //editb = new AgileFrame.Common.TF_TABLEHelper(conn).AddField(valObj, ref errMsg);
            editb = new AgileFrame.Common.TF_TABLEHelper(conn).InsertOrUpdateField(valObj, null, ref errMsg);
            if (editb > 0)
            {
                valObj.CREATED = ckAddToFormCol.Checked == true ? 1 : 0;
                count          = BLLTable <TF_TB_FIELD> .Factory(conn).Insert(valObj, TF_TB_FIELD.Attribute.FIELD_ID);

                keyid = valObj.FIELD_ID.ToString();
            }
            else
            {
                litWarn.Text = "在数据库里创建字段信息失败!" + editb;
                return;
            }
        }
        if (count > 0)
        {
            if (editb > 0)
            {
                if (ckAddToFormCol.Checked == true && count > 0)
                {
                    #region    //同时新建为某个表单的栏目,前提是此表倍某个表单使用中。
                    List <TF_FORM> lstForm = BLLTable <TF_FORM> .Factory(conn).Select(TF_FORM.Attribute.TB_ID, valObj.TB_ID);

                    if (lstForm != null)
                    {
                        lstForm.ForEach(f =>
                        {
                            TF_F_COLUMN valCol = new TF_F_COLUMN();
                            valCol.TB_ID       = valObj.TB_ID;
                            valCol.FORM_ID     = f.FORM_ID;

                            valCol.FIELD_ID = valObj.FIELD_ID;

                            if (!BLLTable <TF_F_COLUMN> .Exists(valCol))
                            {
                                valCol.SHOW_NAME = valObj.NOTE;
                                valCol.CTRL_TYPE = valObj.CTRL_TYPE;

                                valCol.MAX_VAL = 0;

                                valCol.IS_DEFAULT = "0";

                                valCol.MIN_VAL     = 0;
                                valCol.IS_NEED     = valObj.IS_NULL == 1 ? 0 : 1;
                                valCol.SORT_NO     = valObj.SORT_NO;
                                valCol.SHOWIN_FORM = "1";
                                BLLTable <TF_F_COLUMN> .Factory(conn).Insert(valCol, TF_F_COLUMN.Attribute.COLUMN_ID);
                            }
                        });
                    }
                    #endregion
                }
            }
            #region
            if (Request["tree"] != null)
            {
                string        gotoUrl = "../../../../ok.aspx";
                StringBuilder sb      = new StringBuilder("{");
                sb.Append("id:'");
                sb.Append(keyid).Append("',pid:'").Append(valObj.TB_ID).Append("',no:").Append(valObj.SORT_NO).Append(",sc:0,name:'");
                sb.Append(valObj.NOTE).Append("',ntype:'field'}");
                if (Request["edit"] == null)
                {
                    AgileFrame.Core.ScriptHelper.ResponseScript(Page, "parent.TV.showSubNodes(\"" + sb.ToString() + "\");location.replace('" + gotoUrl + "');", false);
                }
                else
                {
                    AgileFrame.Core.ScriptHelper.ResponseScript(Page, "parent.TV.editNodeInfo(\"" + sb.ToString() + "\");location.replace('" + gotoUrl + "');", false);
                }
            }
            else
            {
                StringBuilder        sbData = new StringBuilder("({valObj:''");
                List <AttributeItem> lstCol = valObj.af_AttributeItemList;
                for (int i = 0; i < lstCol.Count; i++)
                {
                    object val = valObj.GetValue(lstCol[i]);
                    if (val != null)
                    {
                        sbData.Append(",").Append(lstCol[i].FieldName).Append(":'").Append(val.ToString()).Append("'");
                    }
                }
                sbData.Append("})");

                Button btn = (Button)sender;
                if (btn.ID == "btnOK")
                {
                    if (ViewState["hadSave"] == null)
                    {
                        ScriptManager.RegisterStartupScript(Page, this.GetType(), "goto", "if (window.opener){window.opener.returnValue = '" + sbData.ToString() + "';}else{window.returnValue = '" + sbData.ToString() + "';}window.close();", true);
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(Page, this.GetType(), "goto", "if (window.opener){window.opener.returnValue = 're';}else{window.returnValue = 're';}window.close();", true);
                    }
                }
                else
                {
                    txtFIELD_NAME.Value  = "";
                    txtFIELD_TYPE.Value  = "";
                    txtIS_NULL.Value     = "";
                    txtNOTE.Value        = "";
                    txtDEFAULT_VAL.Value = "";
                }
            }
            #endregion
        }
        else
        {
            litWarn.Text = "修改记录没有成功!";
        }
        //}
        //catch (Exception ex)
        //{
        //    litWarn.Text = ex.Message;
        //}
    }
Beispiel #3
0
    protected void btnOK_Click(object sender, EventArgs e)
    {
        try
        {
            TF_TABLE valObj = new TF_TABLE();

            if (string.IsNullOrEmpty(keyid))
            {
                if (txtTB_NAME.Value != "")
                    valObj.TB_NAME = txtTB_NAME_PRE.Value + txtTB_NAME.Value;

                if (ViewState["OLDNAME"].ToString() != valObj.TB_NAME)
                {
                    if (BLLTable<TF_TABLE>.Exists(valObj))
                    {
                        litWarn.Text = "�ñ��Ѿ����ڣ����������룡";
                        return;
                    }
                }
                if (txtTB_ID.Value != "")
                    valObj.TB_ID = Convert.ToInt32(txtTB_ID.Value);

                //if (txtM_TB_ID.Value != "")
                valObj.M_TB_ID = pid;

                if (txtTB_TYPE.Value != "")
                    valObj.TB_TYPE = Convert.ToInt32(txtTB_TYPE.Value);

            }
            else {
                valObj.TB_NAME = txtTB_NAME_PRE.Value + txtTB_NAME.Value;
            }

            if(txtSORT_NO.Value !="" )
                valObj.SORT_NO = Convert.ToInt32(txtSORT_NO.Value);

            //ADD START ��������ȱ�� jin-shenjian 2013/10/12
            if (txtCH_NAME.Value != "")
                valObj.CH_NAME = Convert.ToString(txtCH_NAME.Value);
            //ADD END ��������ȱ�� jin-shenjian 2013/10/12

            if(txtNOTE.Value !="" )
                valObj.NOTE = Convert.ToString(txtNOTE.Value);

            if (keyid != "")
            {
                valObj.TB_ID = Convert.ToInt32(keyid);
                count = BLLTable<TF_TABLE>.Factory(conn).Update(valObj, TF_TABLE.Attribute.TB_ID);
                if (count > 0)
                {
                    TF_TABLEHelper.Factory(conn).EditTable(ViewState["OLDNAME"].ToString(), valObj, ref errMsg);
                }
            }
            else
            {
                int ret1 = AgileFrame.Common.TF_TABLEHelper.Factory(conn).AddTableWithDefaultCols(valObj, txtTB_NAME_Save.Value, GetConnByDevKey(txtDB_NAME_Save.Value), ref errMsg);
                if (ret1 == 0)
                {
                    litWarn.Text = errMsg;
                    Response.End(); return;
                }
                valObj.SOURCE_TABLE = txtTB_NAME_Save.Value;
                valObj.SOURCE_DB = txtDB_NAME_Save.Value;
                count = BLLTable<TF_TABLE>.Factory(conn).Insert(valObj, TF_TABLE.Attribute.TB_ID);
                keyid = valObj.TB_ID.ToString();

                TF_TB_FIELD valField = new TF_TB_FIELD();
                DataBaseTable tbsource = null;
                string strRetMessage = "";
                if (!string.IsNullOrEmpty(valObj.TB_NAME) && DataBase.Factory(conn).TryGetValue(valObj.TB_NAME, out tbsource))
                {
                    int count1 = new TF_TABLEHelper(conn).SaveToTF_TB_FIELD(valObj.TB_NAME, valObj.TB_ID,ref  strRetMessage);
                    if (count1 < 1)
                    {

                    }
                }

            }
            if (count > 0)
            {
                string gotoUrl = WebHelper.GetAppPath() + @"ok.aspx";
                if (Request["tree"] != null)
                {
                    StringBuilder sb = new StringBuilder("{");
                    sb.Append("id:'");
                    sb.Append(keyid).Append("',pid:'").Append("0").Append("',no:").Append(valObj.SORT_NO).Append(",sc:1,name:'");
                    if (valObj.M_TB_ID > 0)
                    {
                        sb.Append(valObj.CH_NAME).Append("',ntype:'TF_TABLE-mx'}");
                    }
                    else
                    {
                        sb.Append(valObj.CH_NAME).Append("',ntype:'TF_TABLE'}");
                    }
                    if (Request["edit"] == null)
                    {
                        AgileFrame.Core.ScriptHelper.ResponseScript(Page, "parent.TV.showSubNodes(\"" + sb.ToString() + "\");location.replace('" + gotoUrl + "');", false);
                    }
                    else
                    {
                        AgileFrame.Core.ScriptHelper.ResponseScript(Page, "parent.TV.editNodeInfo(\"" + sb.ToString() + "\");location.replace('" + gotoUrl + "');", false);
                    }
                }
                else
                {
                    StringBuilder sbData = new StringBuilder("({valObj:''");
                    List<AttributeItem> lstCol = valObj.af_AttributeItemList;
                    for (int i = 0; i < lstCol.Count; i++)
                    {
                        object val = valObj.GetValue(lstCol[i]);
                        if (val != null)
                        {
                            sbData.Append(",").Append(lstCol[i].FieldName).Append(":'").Append(val.ToString()).Append("'");
                        }
                    }
                    sbData.Append("})");

                    Button btn = (Button)sender;
                    if (btn.ID.IndexOf("btnOK") != -1)
                    {
                        if (ViewState["hadSave"] == null)
                        {
                            ScriptManager.RegisterStartupScript(Page, this.GetType(), "goto", "if (window.opener){window.opener.returnValue = '" + sbData.ToString() + "';}else{window.returnValue = '" + sbData.ToString() + "';}window.close();", true);
                        }
                        else
                        {
                            ScriptManager.RegisterStartupScript(Page, this.GetType(), "goto", "if (window.opener){window.opener.returnValue = 're';}else{window.returnValue = 're';}window.close();", true);
                        }
                    }
                    else
                    {
                        txtTB_NAME.Value = "";
                        txtCH_NAME.Value = "";
                        txtNOTE.Value = "";
                    }
                }
            }
        }
        catch (Exception ex)
        {
            litWarn.Text = ex.Message;
        }
    }
Beispiel #4
0
    protected void btnOK_Click(object sender, EventArgs e)
    {
        //try
        //{
            #region
            TF_TB_FIELD valObj = new TF_TB_FIELD();

            valObj.TB_ID = int.Parse(tbid);// Convert.ToInt32(txtTB_ID.Value);
            if (txtFIELD_NAME.Value != "")
                valObj.FIELD_NAME = Convert.ToString(txtFIELD_NAME.Value);

            if (ViewState["OLDNAME"].ToString() != txtFIELD_NAME.Value)
            {
                if (BLLTable<TF_TB_FIELD>.Exists(valObj)) {
                    litWarn.Text = "���ֶ��Ѿ����ڣ����������룡";
                    return;
                }
            }

            if (txtFIELD_ID.Value != "")
                valObj.FIELD_ID = Convert.ToInt32(txtFIELD_ID.Value);

            if (txtFIELD_TYPE.Value != "")
            {
                TF_FIELD_DBTYPE typeObj = BLLTable<TF_FIELD_DBTYPE>.Factory(conn).GetRowData(TF_FIELD_DBTYPE.Attribute.TYPE_CODE, txtFIELD_TYPE.Value);
                valObj.TYPE_CODE = typeObj.TYPE_CODE;
                valObj.DB_TYPE = typeObj.DB_TYPE;
                //valObj.TYPE_ID = Convert.ToInt32(txtFIELD_TYPE.Value);
            }

            //if(txtDB_TYPE.Value !="" )
            //    valObj.DB_TYPE = Convert.ToString(txtDB_TYPE.Value);

            valObj.IS_NULL = txtIS_NULL.Checked == true ? 1 : 0;

            if(txtNOTE.Value !="" )
                valObj.NOTE = Convert.ToString(txtNOTE.Value);

            if(txtDEFAULT_VAL.Value !="" )
                valObj.DEFAULT_VAL = Convert.ToString(txtDEFAULT_VAL.Value);

            //if (txtTB_ID.Value != "")

            if(txtCTRL_TYPE.Value !="" )
                valObj.CTRL_TYPE = Convert.ToString(txtCTRL_TYPE.Value);

            if(txtSORT_NO.Value !="" )
                valObj.SORT_NO = Convert.ToInt32(txtSORT_NO.Value);

            #endregion
            int editb = -9;
            if (keyid != "")
            {
                valObj.FIELD_ID = Convert.ToInt32(keyid);

                //TF_TB_FIELD oldObj = BLLTable<TF_TB_FIELD>.Factory(conn).GetRowData(TF_TB_FIELD.Attribute.FIELD_ID, keyid);
                editb = new AgileFrame.Common.TF_TABLEHelper(conn).SaveOrUpdateField(valObj, ViewState["OLDNAME"].ToString(), ref errMsg);//ͬʱ�޸���ʽ���������ʱ���ֶ�
                if (editb > 0)
                {
                    count = BLLTable<TF_TB_FIELD>.Factory(conn).Update(valObj, TF_TB_FIELD.Attribute.FIELD_ID);
                }
                else
                {
                    litWarn.Text = "�����ݿ����޸��ֶ���Ϣʧ�ܣ�" + editb;
                    return;
                }
            }
            else
            {
                //editb = new AgileFrame.Common.TF_TABLEHelper(conn).AddField(valObj, ref errMsg);
                editb = new AgileFrame.Common.TF_TABLEHelper(conn).InsertOrUpdateField(valObj, null, ref errMsg);
                if (editb > 0)
                {
                    valObj.CREATED = ckAddToFormCol.Checked == true ? 1 : 0;
                    count = BLLTable<TF_TB_FIELD>.Factory(conn).Insert(valObj, TF_TB_FIELD.Attribute.FIELD_ID);
                    keyid = valObj.FIELD_ID.ToString();
                }
                else
                {
                    litWarn.Text = "�����ݿ��ﴴ���ֶ���Ϣʧ�ܣ�" + editb;
                    return;
                }
            }
            if (count > 0)
            {
                if (editb > 0)
                {
                    if (ckAddToFormCol.Checked == true && count > 0)
                    {
                        #region//ͬʱ�½�Ϊij���������Ŀ��ǰ���Ǵ˱��ij�����ʹ���С�
                        List<TF_FORM> lstForm = BLLTable<TF_FORM>.Factory(conn).Select(TF_FORM.Attribute.TB_ID, valObj.TB_ID);
                        if (lstForm != null)
                        {
                            lstForm.ForEach(f =>
                            {
                                TF_F_COLUMN valCol = new TF_F_COLUMN();
                                valCol.TB_ID = valObj.TB_ID;
                                valCol.FORM_ID = f.FORM_ID;

                                valCol.FIELD_ID = valObj.FIELD_ID;

                                if (!BLLTable<TF_F_COLUMN>.Exists(valCol))
                                {
                                    valCol.SHOW_NAME = valObj.NOTE;
                                    valCol.CTRL_TYPE = valObj.CTRL_TYPE;

                                    valCol.MAX_VAL = 0;

                                    valCol.IS_DEFAULT = "0";

                                    valCol.MIN_VAL = 0;
                                    valCol.IS_NEED = valObj.IS_NULL == 1 ? 0 : 1;
                                    valCol.SORT_NO = valObj.SORT_NO;
                                    valCol.SHOWIN_FORM = "1";
                                    BLLTable<TF_F_COLUMN>.Factory(conn).Insert(valCol, TF_F_COLUMN.Attribute.COLUMN_ID);
                                }

                            });
                        }
                        #endregion
                    }
                }
                #region
                if (Request["tree"] != null)
                {
                    string gotoUrl = "../../../../ok.aspx";
                    StringBuilder sb = new StringBuilder("{");
                    sb.Append("id:'");
                    sb.Append(keyid).Append("',pid:'").Append(valObj.TB_ID).Append("',no:").Append(valObj.SORT_NO).Append(",sc:0,name:'");
                    sb.Append(valObj.NOTE).Append("',ntype:'field'}");
                    if (Request["edit"] == null)
                    {

                        AgileFrame.Core.ScriptHelper.ResponseScript(Page, "parent.TV.showSubNodes(\"" + sb.ToString() + "\");location.replace('" + gotoUrl + "');", false);
                    }
                    else
                    {
                        AgileFrame.Core.ScriptHelper.ResponseScript(Page, "parent.TV.editNodeInfo(\"" + sb.ToString() + "\");location.replace('" + gotoUrl + "');", false);
                    }
                }
                else
                {
                    StringBuilder sbData = new StringBuilder("({valObj:''");
                    List<AttributeItem> lstCol = valObj.af_AttributeItemList;
                    for (int i = 0; i < lstCol.Count; i++)
                    {
                        object val = valObj.GetValue(lstCol[i]);
                        if (val != null)
                        {
                            sbData.Append(",").Append(lstCol[i].FieldName).Append(":'").Append(val.ToString()).Append("'");
                        }
                    }
                    sbData.Append("})");

                    Button btn = (Button)sender;
                    if (btn.ID == "btnOK")
                    {
                        if (ViewState["hadSave"] == null)
                        {
                            ScriptManager.RegisterStartupScript(Page, this.GetType(), "goto", "if (window.opener){window.opener.returnValue = '" + sbData.ToString() + "';}else{window.returnValue = '" + sbData.ToString() + "';}window.close();", true);
                        }
                        else
                        {
                            ScriptManager.RegisterStartupScript(Page, this.GetType(), "goto", "if (window.opener){window.opener.returnValue = 're';}else{window.returnValue = 're';}window.close();", true);
                        }
                    }
                    else
                    {
                        txtFIELD_NAME.Value = "";
                        txtFIELD_TYPE.Value = "";
                        txtIS_NULL.Value = "";
                        txtNOTE.Value = "";
                        txtDEFAULT_VAL.Value = "";

                    }
                }
                #endregion
            }
            else {
                litWarn.Text ="�޸ļ�¼û�гɹ���";
            }
        //}
        //catch (Exception ex)
        //{
        //    litWarn.Text = ex.Message;
        //}
    }