コード例 #1
0
    protected void btnOK_Click(object sender, EventArgs e)
    {
        //try
        //{
        SYS_BILL valObj = new SYS_BILL();

        if (txtBILL_ID.Value != "")
        {
            valObj.BILL_ID = Convert.ToInt32(txtBILL_ID.Value);
        }
        if (txtBILL_NAME.Value != "")
        {
            valObj.BILL_NAME = txtBILL_NAME.Value;
        }
        if (txtBILL_TYPE.Value != "")
        {
            valObj.BILL_TYPE = Convert.ToString(txtBILL_TYPE.Value);
        }
        if (txtBILL_SQL.Value != "")
        {
            valObj.BILL_SQL = Convert.ToString(txtBILL_SQL.Value);
        }

        valObj.EDITIME = DateTime.Now;

        if (txtADDER.Value != "")
        {
            valObj.ADDER = Convert.ToString(txtADDER.Value);
        }


        if (txtTABLE_NAME.Value != "")
        {
            valObj.TABLE_NAME = txtTABLE_NAME_PRE.Value.Trim() + txtTABLE_NAME.Value.Trim();
        }

        if (!DataBase.Factory(conn).DataTables.Contains(ViewState["TABLE_NAME"].ToString()))
        {
            litWarn.Text     = "表" + ViewState["TABLE_NAME"] + "不存在,请刷新列表!";
            btnOK.Enabled    = false;
            btnSave.Enabled  = false;
            _btnOK.Enabled   = false;
            _btnSave.Enabled = false;
            return;

            return;
        }

        valObj.CONN_SOURCE = Request["selDEVTB"];
        valObj.P_BILL_ID   = Convert.ToInt32(pid);



        valObj.IS_TABLE_EXISTS = txtTAVLE_EXISTS.Checked == true ? "1" : "0";

        if (valObj.IS_TABLE_EXISTS == "0")
        {
            if (DataBase.Factory(conn).DataTables.Contains(valObj.TABLE_NAME))
            {
                valObj.IS_TABLE_EXISTS = "1";
            }
        }
        try
        {
            if (keyid != "")
            {
                //valObj.BILL_ID = Convert.ToInt32(keyid);
                valObj.EDITIME = DateTime.Now;
                SYS_BILL_EXD billExd = new SYS_BILL_EXD(valObj);
                count = billExd.DB_UpdateName(ViewState["TABLE_NAME"].ToString());
            }
            else
            {
                valObj.STATUS = "0";
                SYS_BILL_EXD billExd = new SYS_BILL_EXD(valObj);
                string       msg     = "";
                count = billExd.DB_CreateTable(ckDTL.Checked == true, ref msg) == true ? 1 : 0;

                keyid = count.ToString();
            }
        }
        catch (Exception ee)
        {
            Response.Write("操作失败,请重新选择节点!");
            Response.End();
        }
        string txt = valObj.TABLE_NAME.ToLower().IndexOf("u_") == 0 ? "[系统表]" : "[客户表]";

        if (count > 0)
        {
            ViewState["TABLE_NAME"] = valObj.TABLE_NAME;
            litWarn.Text            = "保存" + txt + "成功!";
            if (Request["tree"] != null)
            {
                string dev = ".";
                if (Request["tbs"] != null)
                {
                    dev = InMTable(Request["tbs"], valObj.TABLE_NAME);
                    if (dev == ".")
                    {
                        return;
                    }
                }
                StringBuilder sb  = new StringBuilder("{");
                string[]      arr = dev.Split('.');
                sb.Append("id:'").Append(valObj.TABLE_NAME);
                sb.Append("',pid:'").Append("0").Append("',no:").Append("1");
                sb.Append(",sc:").Append("1,dev:'" + arr[0] + "',tb:'" + arr[1] + "'");
                sb.Append(",name:'").Append(valObj.TABLE_NAME).Append("',note:'[" + valObj._ZhName + "]'").Append(",ntype:'" + (valObj.P_BILL_ID > 0 ? "bill-mx" : "bill") + "'}");

                if (Request["edit"] == null)
                {
                    AgileFrame.Core.ScriptHelper.ResponseScript(Page, "parent.TV.showSubNodes(\"" + sb.ToString() + "\");", false);
                }
                else
                {
                    AgileFrame.Core.ScriptHelper.ResponseScript(Page, "parent.TV.editNodeInfo(\"" + sb.ToString() + "\");", 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("}");
                if (ViewState["sbData"] == null)
                {
                    ViewState["sbData"] = sbData.ToString();
                }
                else
                {
                    ViewState["sbData"] += "," + sbData.ToString();
                }
                Button btn = (Button)sender;
                if (btn.ID.IndexOf("btnOK") != -1)
                {
                    if (ViewState["sbData"] == null)
                    {
                        string dataStr = "[" + ViewState["sbData"].ToString() + "]";
                        ScriptManager.RegisterStartupScript(Page, this.GetType(), "goto", "if (window.opener){window.opener.returnValue = '" + dataStr + "';}else{window.returnValue = '" + dataStr + "';}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
                {
                    txtBILL_NAME.Value  = "";
                    txtBILL_TYPE.Value  = "";
                    txtADDER.Value      = "";
                    txtTABLE_NAME.Value = "";
                }
            }
        }
        else
        {
            litWarn.Text = "保存" + txt + "失败!";
        }
        //}
        //catch (Exception ex)
        //{
        //    litWarn.Text = ex.Message;
        //}
    }
コード例 #2
0
    protected void btnOK_Click(object sender, EventArgs e)
    {
        //try
        //{
        SYS_BILL valObj = new SYS_BILL();
        if (txtBILL_ID.Value != "")
            valObj.BILL_ID = Convert.ToInt32(txtBILL_ID.Value);
        if (txtBILL_NAME.Value != "")
            valObj.BILL_NAME = txtBILL_NAME.Value;
        if (txtBILL_TYPE.Value != "")
            valObj.BILL_TYPE = Convert.ToString(txtBILL_TYPE.Value);
        if (txtBILL_SQL.Value != "")
            valObj.BILL_SQL = Convert.ToString(txtBILL_SQL.Value);

        valObj.EDITIME = DateTime.Now;

        if (txtADDER.Value != "")
            valObj.ADDER = Convert.ToString(txtADDER.Value);

        if (txtTABLE_NAME.Value != "")
            valObj.TABLE_NAME = txtTABLE_NAME_PRE.Value.Trim() + txtTABLE_NAME.Value.Trim();

        if (!DataBase.Factory(conn).DataTables.Contains(ViewState["TABLE_NAME"].ToString()))
        {
            litWarn.Text = "��" + ViewState["TABLE_NAME"] + "�����ڣ���ˢ���б��";
            btnOK.Enabled = false;
            btnSave.Enabled = false;
            _btnOK.Enabled = false;
            _btnSave.Enabled = false;
            return;
            return;
        }

        valObj.CONN_SOURCE = Request["selDEVTB"];
        valObj.P_BILL_ID = Convert.ToInt32(pid);

        valObj.IS_TABLE_EXISTS = txtTAVLE_EXISTS.Checked == true ? "1" : "0";

        if (valObj.IS_TABLE_EXISTS == "0")
        {
            if (DataBase.Factory(conn).DataTables.Contains(valObj.TABLE_NAME))
            {
                valObj.IS_TABLE_EXISTS = "1";
            }
        }
        try
        {
            if (keyid != "")
            {
                //valObj.BILL_ID = Convert.ToInt32(keyid);
                valObj.EDITIME = DateTime.Now;
                SYS_BILL_EXD billExd = new SYS_BILL_EXD(valObj);
                count = billExd.DB_UpdateName(ViewState["TABLE_NAME"].ToString());
            }
            else
            {
                valObj.STATUS = "0";
                SYS_BILL_EXD billExd = new SYS_BILL_EXD(valObj);
                string msg = "";
                count = billExd.DB_CreateTable(ckDTL.Checked == true, ref msg) == true ? 1 : 0;

                keyid = count.ToString();
            }
        }
        catch (Exception ee)
        {
            Response.Write("����ʧ�ܣ�������ѡ��ڵ㣡");
            Response.End();
        }
        string txt = valObj.TABLE_NAME.ToLower().IndexOf("u_") == 0 ? "[ϵͳ��]" : "[�ͻ���]";
        if (count > 0)
        {
            ViewState["TABLE_NAME"] = valObj.TABLE_NAME;
            litWarn.Text = "����" + txt + "�ɹ���";
            if (Request["tree"] != null)
            {
                string dev = ".";
                if (Request["tbs"] != null)
                {
                    dev = InMTable(Request["tbs"], valObj.TABLE_NAME);
                    if (dev == ".")
                    {
                        return;

                    }
                }
                StringBuilder sb = new StringBuilder("{");
                string[] arr = dev.Split('.');
                sb.Append("id:'").Append(valObj.TABLE_NAME);
                sb.Append("',pid:'").Append("0").Append("',no:").Append("1");
                sb.Append(",sc:").Append("1,dev:'" + arr[0] + "',tb:'" + arr[1] + "'");
                sb.Append(",name:'").Append(valObj.TABLE_NAME).Append("',note:'[" + valObj._ZhName + "]'").Append(",ntype:'" + (valObj.P_BILL_ID > 0 ? "bill-mx" : "bill") + "'}");

                if (Request["edit"] == null)
                {
                    AgileFrame.Core.ScriptHelper.ResponseScript(Page, "parent.TV.showSubNodes(\"" + sb.ToString() + "\");", false);
                }
                else
                {
                    AgileFrame.Core.ScriptHelper.ResponseScript(Page, "parent.TV.editNodeInfo(\"" + sb.ToString() + "\");", 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("}");
                if (ViewState["sbData"] == null)
                {
                    ViewState["sbData"] = sbData.ToString();
                }
                else
                {
                    ViewState["sbData"] += "," + sbData.ToString();
                }
                Button btn = (Button)sender;
                if (btn.ID.IndexOf("btnOK") != -1)
                {
                    if (ViewState["sbData"] == null)
                    {
                        string dataStr = "[" + ViewState["sbData"].ToString() + "]";
                        ScriptManager.RegisterStartupScript(Page, this.GetType(), "goto", "if (window.opener){window.opener.returnValue = '" + dataStr + "';}else{window.returnValue = '" + dataStr + "';}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
                {
                    txtBILL_NAME.Value = "";
                    txtBILL_TYPE.Value = "";
                    txtADDER.Value = "";
                    txtTABLE_NAME.Value = "";
                }
            }
        }
        else
        {
            litWarn.Text = "����" + txt + "ʧ�ܣ�";
        }
        //}
        //catch (Exception ex)
        //{
        //    litWarn.Text = ex.Message;
        //}
    }
コード例 #3
0
ファイル: BILLEdit.aspx.cs プロジェクト: Fred-Lee/AppInOneBPM
    protected void btnOK_Click(object sender, EventArgs e)
    {
        //try
        //{
        SYS_BILL valObj = new SYS_BILL();
        if (txtBILL_ID.Value != "")
            valObj.BILL_ID = Convert.ToInt32(txtBILL_ID.Value);
        if (txtBILL_NAME.Value != "")
            valObj.BILL_NAME = txtBILL_NAME.Value;
        //if(txtBILL_TYPE.Value !="" )
        //    valObj.BILL_TYPE = Convert.ToString(txtBILL_TYPE.Value);
        if (txtBILL_SQL.Value != "")
            valObj.BILL_SQL = Convert.ToString(txtBILL_SQL.Value);

        valObj.EDITIME = DateTime.Now;

        if (txtADDER.Value != "")
            valObj.ADDER = Convert.ToString(txtADDER.Value);

        if (txtTABLE_NAME.Value != "")
            valObj.TABLE_NAME = txtTABLE_NAME.Value;

        valObj.CONN_SOURCE = Request["selDEVTB"];
        if (!string.IsNullOrEmpty(valObj.CONN_SOURCE) && valObj.CONN_SOURCE.Length > 0)
        {
            if (valObj.CONN_SOURCE.Substring(0, 1) == ",")
            {
                valObj.CONN_SOURCE.Substring(1);
            }
        }
        valObj.P_BILL_ID = Convert.ToInt32(pid);

        valObj.IS_TABLE_EXISTS = "1";

        if (keyid != "")
        {
            valObj.EDITIME = DateTime.Now;
            SYS_BILL_EXD billExd = new SYS_BILL_EXD(valObj);
            count = BLLTable<SYS_BILL>.Factory(conn).Update(valObj, SYS_BILL.Attribute.BILL_ID);// billExd.AD_Update(ViewState["TABLE_NAME"].ToString());
        }
        else
        {
            valObj.STATUS = "1";
            //SYS_BILL_EXD billExd = new SYS_BILL_EXD(valObj);
            //count = billExd.AD_Add();
            count = BLLTable<SYS_BILL>.Factory(conn).Insert(valObj, SYS_BILL.Attribute.BILL_ID);
            keyid = valObj.BILL_ID.ToString();// count.ToString();
            if (count > 0)
            {
                //DataBaseTable tbllext = DataBase.Factory(conn).DataTables[valObj.TABLE_NAME];// new DataBaseTable(_Base.TABLE_NAME, "", dbROG);
                //DataBaseFieldCollection fields = tbllext.DataFields;
                //if (fields != null)
                //{
                //    string keys = "";
                //    for (int i = 0; i < fields.Count; i++)
                //    {

                //        DataBaseField f = fields[i];
                //        if (f.IsKey == true)
                //        {
                //            keys += keys == "" ? f.FieldName : "," + f.FieldName;
                //        }
                //        SYS_BILL_COL col = DataBaseHelper.FieldToCol(f, valObj.BILL_ID);
                //        BLLTable<SYS_BILL_COL>.Factory(conn).Insert(col, SYS_BILL_COL.Attribute.COL_ID);
                //    }
                //    //��¼���������
                //    BLLTable<SYS_BILL>.Factory(conn).Update(SYS_BILL.Attribute.BILL_ID, valObj.BILL_ID, SYS_BILL.Attribute.KEYS, keys);
                //}
            }

        }
        int saveSuccessCount = 0;
        if (count > 0)
        {
            #region//����豸��ҵ����
            //�½�����������Ѿ����� �򲻽�����
            //�༭ʱ�ȼ�¼��ԭ�����õľ�����ֵ䣬����ֵ����еĵ������������û������ɾ���ֵ�����Ǹ�������
            Dictionary<string, string> dicDelOldDEVS = new Dictionary<string, string>();
            if (ViewState["CONN_SOURCE"] != null)
            {
                string[] arr = StringHelper.GetStringArray(ViewState["CONN_SOURCE"].ToString(), ',');
                if (arr != null)
                {
                    for (int i = 0; i < arr.Length; i++)
                    {
                        string[] aaa = arr[i].Split('.');
                        if (aaa.Length > 2)
                        {
                            dicDelOldDEVS.Add(arr[i], aaa[2]);
                        }
                    }
                }
            }
            if (!string.IsNullOrEmpty(valObj.CONN_SOURCE))
            {
                string[] arr = StringHelper.GetStringArray(valObj.CONN_SOURCE, ',');
                string newSrc = "";
                if (arr != null)
                {
                    //DataBase.Factory(conn).Load(true);
                    for (int i = 0; i < arr.Length; i++)
                    {
                        string[] aaa = arr[i].Split('.');
                        newSrc += "," + arr[i];
                        if (aaa[0] == "AIO")
                        {
                            continue;
                        }
                        if (aaa.Length > 2)
                        {
                            //ԭ���Ѿ�����������Ϣ
                            if (dicDelOldDEVS.ContainsKey(arr[i]))
                            {
                                dicDelOldDEVS.Remove(arr[i]);
                            }
                            continue;
                        }
                        string tbname = "ERP_"+aaa[0]+"_" + aaa[1];

                        DataBaseTable addTB = GetAddTable(aaa[0], aaa[1], ref tbname);
                        if (addTB != null)
                        {
                            string msg = "";
                            if (DataBase.Factory(conn).AddTable(addTB, ref msg))
                            {
                                newSrc += "." + tbname;
                                saveSuccessCount++;
                            }
                        }
                        else
                            newSrc += "." + tbname;
                    }
                }
                if (newSrc != "") {
                    newSrc = newSrc.Substring(1);
                }
                BLLTable<SYS_BILL>.Factory(conn).Update(SYS_BILL.Attribute.BILL_ID, keyid, SYS_BILL.Attribute.CONN_SOURCE, newSrc);
            }
            int delSuccessCount = 0;
            if (dicDelOldDEVS.Count > 0)
            {
                string msg = "";
                foreach (KeyValuePair<string, string> ppp in dicDelOldDEVS)
                {
                    delSuccessCount += DataBase.Factory(conn).DeleteTable(ppp.Value, true, ref msg) ? 1 : 0;
                }
            }

            #endregion

            litWarn.Text = "���������ɹ���:" + saveSuccessCount + (dicDelOldDEVS.Count > 0 ? (",ɾ�������ɹ���" + delSuccessCount) : "");
            if (Request["tree"] != null)
            {
                //Response.Write(keyid);
                StringBuilder sb = new StringBuilder("{");
                sb.Append("id:'");
                sb.Append(keyid).Append("',pid:'").Append("0").Append("',no:").Append(valObj.BILL_ID).Append(",sc:1,name:'");
                if (valObj.P_BILL_ID > 0)
                {
                    sb.Append(valObj.BILL_NAME).Append("',ntype:'bill-mx'}");
                }
                else
                {
                    sb.Append(valObj.BILL_NAME).Append("',ntype:'bill'}");
                }
                if (Request["edit"] == null)
                {
                    AgileFrame.Core.ScriptHelper.ResponseScript(Page, "parent.TV.showSubNodes(\"" + sb.ToString() + "\");", false);
                }
                else
                {
                    AgileFrame.Core.ScriptHelper.ResponseScript(Page, "parent.TV.editNodeInfo(\"" + sb.ToString() + "\");", 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("}");
                if (ViewState["sbData"] == null)
                {
                    ViewState["sbData"] = sbData.ToString();
                }
                else
                {
                    ViewState["sbData"] += "," + sbData.ToString();
                }
                Button btn = (Button)sender;
                if (btn.ID.IndexOf("btnOK") != -1)
                {
                    if (ViewState["sbData"] == null)
                    {
                        string dataStr = "[" + ViewState["sbData"].ToString() + "]";
                        ScriptManager.RegisterStartupScript(Page, this.GetType(), "goto", "if (window.opener){window.opener.returnValue = '" + dataStr + "';}else{window.returnValue = '" + dataStr + "';}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
                {
                    txtBILL_NAME.Value = "";
                    //txtBILL_TYPE.Value = "";
                    txtADDER.Value = "";
                    txtTABLE_NAME.Value = "";
                }
            }
        }
        else
        {
            litWarn.Text = "����ʧ�ܣ�";
        }
        //}
        //catch (Exception ex)
        //{
        //    litWarn.Text = ex.Message;
        //}
    }
コード例 #4
0
ファイル: BILLEdit.aspx.cs プロジェクト: sx81128/AppInOneBPM
    protected void btnOK_Click(object sender, EventArgs e)
    {
        //try
        //{
        SYS_BILL valObj = new SYS_BILL();

        if (txtBILL_ID.Value != "")
        {
            valObj.BILL_ID = Convert.ToInt32(txtBILL_ID.Value);
        }
        if (txtBILL_NAME.Value != "")
        {
            valObj.BILL_NAME = txtBILL_NAME.Value;
        }
        //if(txtBILL_TYPE.Value !="" )
        //    valObj.BILL_TYPE = Convert.ToString(txtBILL_TYPE.Value);
        if (txtBILL_SQL.Value != "")
        {
            valObj.BILL_SQL = Convert.ToString(txtBILL_SQL.Value);
        }

        valObj.EDITIME = DateTime.Now;


        if (txtADDER.Value != "")
        {
            valObj.ADDER = Convert.ToString(txtADDER.Value);
        }


        if (txtTABLE_NAME.Value != "")
        {
            valObj.TABLE_NAME = txtTABLE_NAME.Value;
        }

        valObj.CONN_SOURCE = Request["selDEVTB"];
        if (!string.IsNullOrEmpty(valObj.CONN_SOURCE) && valObj.CONN_SOURCE.Length > 0)
        {
            if (valObj.CONN_SOURCE.Substring(0, 1) == ",")
            {
                valObj.CONN_SOURCE.Substring(1);
            }
        }
        valObj.P_BILL_ID = Convert.ToInt32(pid);


        valObj.IS_TABLE_EXISTS = "1";


        if (keyid != "")
        {
            valObj.EDITIME = DateTime.Now;
            SYS_BILL_EXD billExd = new SYS_BILL_EXD(valObj);
            count = BLLTable <SYS_BILL> .Factory(conn).Update(valObj, SYS_BILL.Attribute.BILL_ID);// billExd.AD_Update(ViewState["TABLE_NAME"].ToString());
        }
        else
        {
            valObj.STATUS = "1";
            //SYS_BILL_EXD billExd = new SYS_BILL_EXD(valObj);
            //count = billExd.AD_Add();
            count = BLLTable <SYS_BILL> .Factory(conn).Insert(valObj, SYS_BILL.Attribute.BILL_ID);

            keyid = valObj.BILL_ID.ToString();// count.ToString();
            if (count > 0)
            {
                //DataBaseTable tbllext = DataBase.Factory(conn).DataTables[valObj.TABLE_NAME];// new DataBaseTable(_Base.TABLE_NAME, "", dbROG);
                //DataBaseFieldCollection fields = tbllext.DataFields;
                //if (fields != null)
                //{
                //    string keys = "";
                //    for (int i = 0; i < fields.Count; i++)
                //    {

                //        DataBaseField f = fields[i];
                //        if (f.IsKey == true)
                //        {
                //            keys += keys == "" ? f.FieldName : "," + f.FieldName;
                //        }
                //        SYS_BILL_COL col = DataBaseHelper.FieldToCol(f, valObj.BILL_ID);
                //        BLLTable<SYS_BILL_COL>.Factory(conn).Insert(col, SYS_BILL_COL.Attribute.COL_ID);
                //    }
                //    //记录主键到表单
                //    BLLTable<SYS_BILL>.Factory(conn).Update(SYS_BILL.Attribute.BILL_ID, valObj.BILL_ID, SYS_BILL.Attribute.KEYS, keys);
                //}
            }
        }
        int saveSuccessCount = 0;

        if (count > 0)
        {
            #region//相关设备表业务处理
            //新建镜像表,如果已经存在 则不建立。
            //编辑时先记录下原来配置的镜像表字典,如果字典里有的但是新配置里的没有吗,则删除字典里的那个镜像表。
            Dictionary <string, string> dicDelOldDEVS = new Dictionary <string, string>();
            if (ViewState["CONN_SOURCE"] != null)
            {
                string[] arr = StringHelper.GetStringArray(ViewState["CONN_SOURCE"].ToString(), ',');
                if (arr != null)
                {
                    for (int i = 0; i < arr.Length; i++)
                    {
                        string[] aaa = arr[i].Split('.');
                        if (aaa.Length > 2)
                        {
                            dicDelOldDEVS.Add(arr[i], aaa[2]);
                        }
                    }
                }
            }
            if (!string.IsNullOrEmpty(valObj.CONN_SOURCE))
            {
                string[] arr    = StringHelper.GetStringArray(valObj.CONN_SOURCE, ',');
                string   newSrc = "";
                if (arr != null)
                {
                    //DataBase.Factory(conn).Load(true);
                    for (int i = 0; i < arr.Length; i++)
                    {
                        string[] aaa = arr[i].Split('.');
                        newSrc += "," + arr[i];
                        if (aaa[0] == "AIO")
                        {
                            continue;
                        }
                        if (aaa.Length > 2)
                        {
                            //原来已经存的物理表信息
                            if (dicDelOldDEVS.ContainsKey(arr[i]))
                            {
                                dicDelOldDEVS.Remove(arr[i]);
                            }
                            continue;
                        }
                        string tbname = "ERP_" + aaa[0] + "_" + aaa[1];

                        DataBaseTable addTB = GetAddTable(aaa[0], aaa[1], ref tbname);
                        if (addTB != null)
                        {
                            string msg = "";
                            if (DataBase.Factory(conn).AddTable(addTB, ref msg))
                            {
                                newSrc += "." + tbname;
                                saveSuccessCount++;
                            }
                        }
                        else
                        {
                            newSrc += "." + tbname;
                        }
                    }
                }
                if (newSrc != "")
                {
                    newSrc = newSrc.Substring(1);
                }
                BLLTable <SYS_BILL> .Factory(conn).Update(SYS_BILL.Attribute.BILL_ID, keyid, SYS_BILL.Attribute.CONN_SOURCE, newSrc);
            }
            int delSuccessCount = 0;
            if (dicDelOldDEVS.Count > 0)
            {
                string msg = "";
                foreach (KeyValuePair <string, string> ppp in dicDelOldDEVS)
                {
                    delSuccessCount += DataBase.Factory(conn).DeleteTable(ppp.Value, true, ref msg) ? 1 : 0;
                }
            }

            #endregion


            litWarn.Text = "保存物理表成功数:" + saveSuccessCount + (dicDelOldDEVS.Count > 0 ? (",删除物理表成功数" + delSuccessCount) : "");
            if (Request["tree"] != null)
            {
                //Response.Write(keyid);
                StringBuilder sb = new StringBuilder("{");
                sb.Append("id:'");
                sb.Append(keyid).Append("',pid:'").Append("0").Append("',no:").Append(valObj.BILL_ID).Append(",sc:1,name:'");
                if (valObj.P_BILL_ID > 0)
                {
                    sb.Append(valObj.BILL_NAME).Append("',ntype:'bill-mx'}");
                }
                else
                {
                    sb.Append(valObj.BILL_NAME).Append("',ntype:'bill'}");
                }
                if (Request["edit"] == null)
                {
                    AgileFrame.Core.ScriptHelper.ResponseScript(Page, "parent.TV.showSubNodes(\"" + sb.ToString() + "\");", false);
                }
                else
                {
                    AgileFrame.Core.ScriptHelper.ResponseScript(Page, "parent.TV.editNodeInfo(\"" + sb.ToString() + "\");", 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("}");
                if (ViewState["sbData"] == null)
                {
                    ViewState["sbData"] = sbData.ToString();
                }
                else
                {
                    ViewState["sbData"] += "," + sbData.ToString();
                }
                Button btn = (Button)sender;
                if (btn.ID.IndexOf("btnOK") != -1)
                {
                    if (ViewState["sbData"] == null)
                    {
                        string dataStr = "[" + ViewState["sbData"].ToString() + "]";
                        ScriptManager.RegisterStartupScript(Page, this.GetType(), "goto", "if (window.opener){window.opener.returnValue = '" + dataStr + "';}else{window.returnValue = '" + dataStr + "';}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
                {
                    txtBILL_NAME.Value = "";
                    //txtBILL_TYPE.Value = "";
                    txtADDER.Value      = "";
                    txtTABLE_NAME.Value = "";
                }
            }
        }
        else
        {
            litWarn.Text = "保存失败!";
        }
        //}
        //catch (Exception ex)
        //{
        //    litWarn.Text = ex.Message;
        //}
    }