Esempio n. 1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        title      = valObj._ZhName + "±à¼­";
        Page.Title = title;
        if (!string.IsNullOrEmpty(Request["SYN_ID"]))
        {
            keyid = Request["SYN_ID"];
        }

        if (!string.IsNullOrEmpty(Request["KeyID"]))
        {
            keyid = Request["KeyID"];
        }

        if (!string.IsNullOrEmpty(Request["edit"]))
        {
            keyid = Request["id"];
            colid = int.Parse(Request["pid"]);
        }
        else
        {
            colid = int.Parse(Request["id"]);
        }
        if (ViewState["KEYID"] != null)
        {
            keyid = ViewState["KEYID"].ToString();
        }
        if (!IsPostBack)
        {
            txtDB_SRC.Items.AddRange(FormHelper.GetListItem(SYS_DATASOURCE.Attribute.SourceName));
            txtDATA_TYPE.Items.Clear();
            //FieldDataType fty = new FieldDataType(DataBaseConnectStringHelper.GetDataBaseType(MyConfigurationSettings.GetValue(txtDB_SRC.Value)), DataBaseDataType.varchar, 20, 0, false);
            //foreach (string tp in fty.AllDataType)
            //{
            //    txtDATA_TYPE.Items.Add(new ListItem(tp, tp));
            //}
            //if (colid > 0)
            //{
            //    SYS_BILL_COL_SYN ccc = new SYS_BILL_COL_SYN();
            //    ccc.IS_AUTO = "0";
            //    ccc.ISPK = "0";
            //}
            //try
            //{
            ViewState["FORM_CTRL_ID"] = "0";
            //Response.Write(colid.ToString()); return;
            SYS_BILL_COL billCol = BLLTable <SYS_BILL_COL> .Factory(conn).GetRowData(SYS_BILL_COL.Attribute.COL_ID, colid);

            SYS_BILL billObj = BLLTable <SYS_BILL> .Factory(conn).GetRowData(SYS_BILL.Attribute.BILL_ID, billCol.BILL_ID);

            hidTABLE_NAME.Value = billObj.TABLE_NAME;
            hidConnSrc.Value    = billObj._CONN_SOURCE;
            if (keyid != "")
            {
                valObj = BLLTable <SYS_BILL_COL_SYN> .Factory(conn).GetRowData(SYS_BILL_COL_SYN.Attribute.COL_SYNID, keyid);

                if (valObj == null)
                {
                    return;
                }

                txtISPK.Value   = valObj.ISPK;
                txtCOL_ID.Value = Convert.ToString(valObj.COL_ID);              //Convert.ToInt32

                txtBILL_ID.Value = Convert.ToString(valObj.BILL_ID);            //Convert.ToInt32

                txtTABLE_NAME.Value      = Convert.ToString(valObj.TABLE_NAME); //Convert.ToString
                txtTABLE_NAME1.Value     = valObj.TABLE_NAME;
                txtCOL_NAME.Value        = Convert.ToString(valObj.COL_NAME);   //Convert.ToString
                ViewState["txtCOL_NAME"] = txtCOL_NAME.Value;

                txtCOL_NOTE.Value = Convert.ToString(valObj.COL_NOTE);    //Convert.ToString

                if (valObj.DATA_TYPE.IndexOf('(') >= 0)
                {
                    txtDATA_TYPE.Value = valObj.DATA_TYPE.Substring(0, valObj.DATA_TYPE.IndexOf('(')).ToLower();
                }
                else
                {
                    txtDATA_TYPE.Value = Convert.ToString(valObj.DATA_TYPE).ToLower(); //Convert.ToString
                }
                txtDATA_LEN.Value = Convert.ToString(valObj.DATA_LEN);                 //Convert.ToInt32

                txtDATA_ACC.Value = Convert.ToString(valObj.DATA_ACC);                 //Convert.ToInt32

                txtIS_AUTO.Value = Convert.ToString(valObj.IS_AUTO);                   //Convert.ToString
                txtDB_SRC.Value  = valObj.DB_SRC;
                //Response.Write(valObj.IS_AUTO);
                txtDVAL.Value = Convert.ToString(valObj.DVAL);    //Convert.ToString
            }
            else
            {
                txtBILL_ID.Value = billCol.BILL_ID.ToString();
                txtCOL_ID.Value  = colid.ToString();
                //txtTABLE_NAME.Value = billObj.TABLE_NAME;
            }

            //}
            //catch (Exception ex)
            //{
            //    litWarn.Text = ex.Message;
            //}
        }
    }
Esempio n. 2
0
    protected void btnOK_Click(object sender, EventArgs e)
    {
        //try
        //{
        SYS_BILL_COL_SYN valObj = new SYS_BILL_COL_SYN();

        if (txtBILL_ID.Value != "")
        {
            valObj.BILL_ID = Convert.ToInt32(txtBILL_ID.Value);
        }

        //if (keyid == "")
        //{
        //    if (BLLTable<SYS_BILL_COL_SYN>.Exists(valObj))
        //    {
        //        litWarn.Text = "ÒѾ­´æÔÚ´Ë×ֶΣ¡";
        //        return;
        //    }
        //}

        #region
        if (txtTABLE_NAME.Value != "")
        {
            valObj.TABLE_NAME = Convert.ToString(txtTABLE_NAME.Value);
        }
        else
        {
            if (txtTABLE_NAME1.Value != "")
            {
                valObj.TABLE_NAME = Convert.ToString(txtTABLE_NAME1.Value);
            }
        }

        DataBaseField field = null;
        if (txtCOL_NAME.Value != "")
        {
            valObj.COL_NAME = Convert.ToString(txtCOL_NAME.Value);
            try
            {
                field = DataBase.Factory(MyConfigurationSettings.GetValue(txtDB_SRC.Value)).DataTables[valObj.TABLE_NAME].DataFields[valObj.COL_NAME];
            }
            catch { field = null; }
        }
        if (field == null)
        {
            litWarn.Text = "±£´æʧ°Ü£¡Ã»ÓÐÕÒµ½¸Ã×ֶΣ¡";
            return;
        }

        if (txtCOL_ID.Value != "")
        {
            valObj.COL_ID = Convert.ToInt32(txtCOL_ID.Value);
        }

        valObj.ISPK = field.IsKeyID ? "1" : "0";

        valObj.COL_NOTE = field.Desc.ZhName;

        valObj.DATA_TYPE = field.DataType.TypeNameString;

        valObj.DATA_LEN = field.DataType.DataLen;

        valObj.DATA_ACC = field.DataType.Scale;

        valObj.IS_AUTO = field.IsAutoIncrease ? "1" : "0";

        valObj.DVAL = field.DefaultValue;

        valObj.DB_SRC = txtDB_SRC.Value;

        valObj.PK_VALCODE = txtPK_VALCODE.Value;
        #endregion

        if (keyid != "")
        {
            valObj.COL_SYNID = Convert.ToInt32(keyid);

            count = BLLTable <SYS_BILL_COL_SYN> .Factory(conn).Update(valObj, SYS_BILL_COL_SYN.Attribute.COL_SYNID);
        }
        else
        {
            valObj.SetInitialized(SYS_BILL_COL_SYN.Attribute.COL_SYNID, false);
            count = BLLTable <SYS_BILL_COL_SYN> .InsertReturnID(valObj);

            keyid = count.ToString();
            ViewState["KEYID"] = keyid;
            if (count > 0 && valObj.ISPK == "1")
            {
                SYS_BILL_COL_EXD billExd = new SYS_BILL_COL_EXD(valObj.ToBILL_COL());
                billExd.Add();
            }
        }
        if (count > 0)
        {
            if (Request["tree"] != null)
            {
                StringBuilder sb = new StringBuilder("{");
                sb.Append("id:'");
                sb.Append(keyid).Append("',pid:'").Append(valObj.COL_ID).Append("',no:1,sc:0,name:'");

                sb.Append(valObj.COL_NAME + "[" + valObj.COL_NOTE + "]").Append("',ntype:'syncol'}");

                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);
                }
                litWarn.Text = "±£´æ³É¹¦";
            }
            else
            {
                #region
                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", "_FormView();if (window.opener){window.opener.returnValue = '" + dataStr + "';}else{window.returnValue = '" + dataStr + "';}window.close();", true);
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(Page, this.GetType(), "goto", "_FormView();if (window.opener){window.opener.returnValue = 're';}else{window.returnValue = 're';}window.close();", true);
                    }
                }
                else
                {
                    AgileFrame.Core.ScriptHelper.ResponseScript(Page, "_FormView();", false);
                    txtTABLE_NAME.Value = "";
                    txtCOL_NAME.Value   = "";
                    hidTABLE_NAME.Value = "";
                }
                #endregion
            }
        }
        else
        {
            litWarn.Text = "ÐÞ¸Äʧ°Ü£¡";
        }
        //}
        //catch (Exception ex)
        //{
        //    litWarn.Text = ex.Message;
        //}
    }
Esempio n. 3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        #region////��ʾ�ӽڵ�
        if (Request["getSubNodes"] != null)
        {
            string nodetype = Request["ntype"];
            StringBuilder sb = new StringBuilder("[");
            string id = Request["id"];
            if (nodetype == "bill-root")
            {
                #region
                SYS_BILL obj = new SYS_BILL();
                SYS_BILL val = new SYS_BILL();
                obj.P_BILL_ID = 0;
                //obj.STATUS = "1";
                bool fromtb = Request["TB"] != null;
                if (Request["TB"] == null)
                {
                    obj.Where("STATUS<>'0'");
                }

                val.af_PageBy(SYS_BILL.Attribute.BILL_ID, Order.Asc);
                List<SYS_BILL> lst = BLLTable<SYS_BILL>.Factory(conn).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].BILL_ID);
                        sb.Append("',pid:'").Append("0").Append("',no:").Append(lst[i].BILL_ID);
                        sb.Append(",sc:").Append("1");
                        sb.Append(",name:'").Append(lst[i].BILL_NAME + (lst[i].STATUS=="11"?"(��ɾ)":"")).Append("',note:''").Append(",ntype:'bill'}");
                    }
                }
                #endregion
            }
            if (nodetype == "bill" || nodetype == "bill-mx")
            {
                if (nodetype == "bill")
                {
                    #region ������ϸ���
                    SYS_BILL objTB = new SYS_BILL();
                    SYS_BILL valTB = new SYS_BILL();
                    objTB.P_BILL_ID = int.Parse(id);
                    valTB.OrderBy(SYS_BILL.Attribute.BILL_ID, Order.Asc);
                    List<SYS_BILL> lstTB = BLLTable<SYS_BILL>.Factory(conn).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].BILL_ID);
                            sb.Append("',pid:'").Append(id).Append("',no:").Append(lstTB[i].BILL_ID);
                            sb.Append(",sc:").Append("1");
                            sb.Append(",name:'").Append(lstTB[i].BILL_NAME).Append("',note:''").Append(",ntype:'bill-mx'}");
                        }
                    }
                    #endregion
                }
                #region ������
                SYS_BILL_COL obj = new SYS_BILL_COL();
                SYS_BILL_COL val = new SYS_BILL_COL();
                obj.BILL_ID = int.Parse(id);
                //obj.Where("COL_NAME not in('MX_ID','BILL_ID')");
                val.af_PageBy(SYS_BILL_COL.Attribute.SORT_NO, Order.Asc);

                List<SYS_BILL_COL> lst = BLLTable<SYS_BILL_COL>.Factory(conn).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].COL_ID.ToString());
                        sb.Append("',pid:'").Append(lst[i].BILL_ID.ToString()).Append("',no:").Append(lst[i].SORT_NO);
                        sb.Append(",sc:").Append("1");
                        sb.Append(",name:'").Append(lst[i].COL_NAME).Append("',note:'[" + lst[i].COL_NOTE + "]'").Append(",ntype:'col'}");

                    }

                }
                #endregion
            }//ѡ���˱����
            if (nodetype == "col")
            {

                SYS_BILL_COL_SYN obj = new SYS_BILL_COL_SYN();
                SYS_BILL_COL_SYN val = new SYS_BILL_COL_SYN();
                obj.COL_ID = int.Parse(id);
                //obj.Where("COL_NAME not in('MX_ID','BILL_ID')");
                //val.af_PageBy(SYS_BILL_COL_SYN.Attribute.SORT_NO, Order.Asc);

                List<SYS_BILL_COL_SYN> lst = BLLTable<SYS_BILL_COL_SYN>.Factory(conn).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].COL_SYNID.ToString());
                        sb.Append("',pid:'").Append(lst[i].COL_ID.ToString()).Append("',no:").Append("0");
                        sb.Append(",sc:").Append("0");
                        sb.Append(",name:'").Append("[" + lst[i].DB_SRC + "].[" + lst[i].TABLE_NAME + "].[" + lst[i].COL_NAME + "]").Append("',note:'[" + lst[i].COL_NOTE + "]'").Append(",ntype:'syncol'}");

                    }

                }
            }
            //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:'table'}");

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

        #region//ɾ���ڵ�
        if (Request["deleteNode"] != null)
        {
            string str = "";
            string delID = Request["id"];
            string ntype = Request["ntype"];
            if (ntype == "bill" || ntype == "bill-mx")
            {
                #region//ɾ����
                SYS_BILL_EXD eee = new SYS_BILL_EXD(int.Parse(delID));
                string msg = "";
                int re = eee.Delete(out msg);

                #endregion
                str = "{re:" + re + ",msg:'" + msg + "'}";
            }
            else if (ntype == "col")
            {
                #region//ɾ�����ֶ�

                string msg = "ɾ�����ݿ���ֶγɹ���";

                SYS_BILL_EXD bllexd = new SYS_BILL_EXD(int.Parse(Request["pid"]));
                int re = bllexd.DeleteCol(int.Parse(delID));// TF_TABLEHelper.DelField(delID);// ;
                if (re > 0)
                {
                    msg = "ɾ�����ݿ���ֶγɹ���";
                }
                else
                {
                    msg = "ɾ�����ݿ���ֶ�ʧ�ܣ�";
                }
                #endregion
                str = "{re:" + re + ",msg:'" + msg + "'}";
            }
            else if (ntype == "syncol")
            {
                #region//ɾ�����ֶ�

                string msg = "ɾ��ͬ���ֶγɹ���";
                int re = BLLTable<SYS_BILL_COL_SYN>.Factory(conn).Delete(SYS_BILL_COL_SYN.Attribute.COL_SYNID, delID);
                if (re > 0)
                {
                    msg = "ɾ��ͬ���ֶγɹ���";
                }
                else
                {
                    msg = "ɾ��ͬ���ֶ�ʧ�ܣ�";
                }
                #endregion
                str = "{re:" + re + ",msg:'" + msg + "'}";
            }
            Response.Write(str);
        }
        #endregion

        #region//�����ֶ�
        if (Request["intbCols"] != null)
        {

            string pid = Request["pid"];
            string id = Request["id"];
            string billid = Request["billid"];
            DataBaseTable tbllext = DataBase.Factory(conn).DataTables[pid];// new DataBaseTable(_Base.TABLE_NAME, "", dbROG);
            DataBaseFieldCollection fields = tbllext.DataFields;
            string keys = "";

            DataBaseField fs = fields[id];
            if (fs.IsKeyID == true)
            {
                keys += keys == "" ? fs.FieldName : "," + fs.FieldName;
            }
            SYS_BILL_COL col = AgileFrame.AppInOne.SYS.SysDataBaseHelper.FieldToCol(fs, int.Parse(billid));
            SYS_BILL_COL ccc = new SYS_BILL_COL();
            ccc.BILL_ID = int.Parse(billid);
            ccc.COL_NAME = fs.FieldName.ToUpper();
            int re = 1;
            SYS_BILL_COL oldCol = BLLTable<SYS_BILL_COL>.Factory(conn).GetRowData(new SYS_BILL_COL(), ccc);
            int colid = 0;
            if (oldCol == null)
            {
                re = BLLTable<SYS_BILL_COL>.Factory(conn).Insert(col, SYS_BILL_COL.Attribute.COL_ID);
                colid = col.COL_ID;
            }
            else {
                colid = oldCol.COL_ID;
            }
            if (re > 0)
            {
                SYS_BILL_COL_SYN valObj = new SYS_BILL_COL_SYN();
                valObj.BILL_ID = Convert.ToInt32(Request["billid"]);

                valObj.COL_NAME = fs.FieldName.ToUpper();

                valObj.TABLE_NAME = Request["tb"];
                valObj.COL_ID = colid;
                valObj.ISPK = fs.IsKeyID == true ? "1" : "0";
                valObj.COL_NOTE = fs.Desc.ZhName;
                valObj.DATA_TYPE = fs.DataType.TypeNameString;
                valObj.DATA_LEN = fs.DataType.DataLen;
                valObj.DATA_ACC = fs.DataType.Scale;
                valObj.IS_AUTO = fs.IsAutoIncrease == true ? "1" : "0";
                valObj.DVAL = fs.DefaultValue;
                valObj.DB_SRC = Request["dev"];
                valObj.PK_VALCODE = "";

                BLLTable<SYS_BILL_COL_SYN>.InsertReturnID(valObj);
            }
            //��¼���������
            if (keys != "")
            {
                BLLTable<SYS_BILL>.Factory(conn).Update(SYS_BILL.Attribute.BILL_ID, billid, SYS_BILL.Attribute.KEYS, keys);
            }
            Response.Write("ok");
        }

        #endregion

        #region
        if (Request["addSynCols"] != null)
        {
            string[]aaa=StringHelper.GetStringArray(Request["ids"],',');
            for (int i = 0; i < aaa.Length; i++) {
                string[] bbb = aaa[i].Split('.');
                if (bbb[2] != "col") {
                    continue;
                }
                DataBaseTable tbllext = DataBase.Factory(conn).DataTables[bbb[0]];
                DataBaseField fs = tbllext.DataFields[bbb[1]];

                    SYS_BILL_COL_SYN valObj = new SYS_BILL_COL_SYN();
                    valObj.BILL_ID = Convert.ToInt32(Request["billid"]);
                    valObj.COL_ID = Convert.ToInt32(Request["colid"]);
                    valObj.COL_NAME = fs.FieldName;
                    if (!BLLTable<SYS_BILL_COL_SYN>.Exists(valObj))
                    {
                        valObj.TABLE_NAME = tbllext.TableName;
                        valObj.ISPK = fs.IsKeyID == true ? "1" : "0";
                        valObj.COL_NOTE = fs.Desc.ZhName;
                        valObj.DATA_TYPE = fs.DataType.TypeNameString.Replace("_","") ;
                        valObj.DATA_LEN = fs.DataType.DataLen;
                        valObj.DATA_ACC = fs.DataType.Scale;
                        valObj.IS_AUTO = fs.IsAutoIncrease == true ? "1" : "0";
                        valObj.DVAL = fs.DefaultValue;
                        valObj.DB_SRC = bbb[0];
                        valObj.PK_VALCODE = "";

                        BLLTable<SYS_BILL_COL_SYN>.InsertReturnID(valObj);
                    }

            }
            Response.Write("ok");
        }
        #endregion

        #region//����ɾ�����
        if (Request["clearBill"] != null)
        {
            #region//ɾ����
            string str = "";
            string delID = Request["id"];
            SYS_BILL_EXD eee = new SYS_BILL_EXD(int.Parse(delID));
            string msg="";
            int re = eee.Delete(out msg);

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

        //���б�����ɾ����ť��ͨ��AJAXִ������ĺ�̨���룬ɾ��һ����¼
        if (Request["DelBILL_ID"] != null)
        {
            int re = BLLTable<SYS_BILL>.Factory(conn).Delete(SYS_BILL.Attribute.BILL_ID, Request["DelBILL_ID"]);
            if (re > 0)
            {
                Response.Write("1");//����������� ����0 ��ʾ�����ɹ���Ҳ����ֱ����� �ַ������ͻ��˽��������ַ�����Ϣ��Ϊ��ʾ
            }
            else
            {
                Response.Write("ɾ��ʧ�ܣ�");
            }
        }

        //���б�������ɾ����ť��ͨ��AJAXִ������ĺ�̨���룬ɾ��������¼
        if (Request["DelKeyIDS"] != null)
        {
            SYS_BILL cond = new SYS_BILL();
            cond.In(SYS_BILL.Attribute.BILL_ID, Request["DelKeyIDS"]);
            int re = BLLTable<SYS_BILL>.Factory(conn).Delete(cond);
            if (re > 0)
            {
                Response.Write("1");//����������� ����0 ��ʾ�����ɹ���Ҳ����ֱ����� �ַ������ͻ��˽��������ַ�����Ϣ��Ϊ��ʾ
            }
            else
            {
                Response.Write("ɾ��ʧ�ܣ�");
            }
        }

        //���û���ϸ��Ϣ�鿴�༭ҳ�棬�㱣��ʱ��ͨ��AJAXִ������ĺ�̨���룬ʵ�ֲ����ֶεĸ���
        if (Request["saveInfo"] != null)
        {
            SYS_BILL val = new SYS_BILL();
            val.BILL_ID = int.Parse(Request["FieldKeyID"]);
            List<AttributeItem> lstCol = val.af_AttributeItemList;
            for (int i = 0; i < lstCol.Count; i++)
            {
                if (!string.IsNullOrEmpty(Request["txt" + lstCol[i].FieldName]))
                {
                    val.SetValue(lstCol[i].FieldName, Request["txt" + lstCol[i].FieldName]);
                }
            }

            BLLTable<SYS_BILL>.Factory(conn).Update(val, SYS_BILL.Attribute.BILL_ID);
            Response.Write("�޸��û���Ϣ�ɹ�");

        }
        Response.End();
    }
Esempio n. 4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        #region////显示子节点
        if (Request["getSubNodes"] != null)
        {
            string        nodetype = Request["ntype"];
            StringBuilder sb       = new StringBuilder("[");
            string        id       = Request["id"];
            if (nodetype == "bill-root")
            {
                #region
                SYS_BILL obj = new SYS_BILL();
                SYS_BILL val = new SYS_BILL();
                obj.P_BILL_ID = 0;
                //obj.STATUS = "1";
                bool fromtb = Request["TB"] != null;
                if (Request["TB"] == null)
                {
                    obj.Where("STATUS<>'0'");
                }

                val.af_PageBy(SYS_BILL.Attribute.BILL_ID, Order.Asc);
                List <SYS_BILL> lst = BLLTable <SYS_BILL> .Factory(conn).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].BILL_ID);
                        sb.Append("',pid:'").Append("0").Append("',no:").Append(lst[i].BILL_ID);
                        sb.Append(",sc:").Append("1");
                        sb.Append(",name:'").Append(lst[i].BILL_NAME + (lst[i].STATUS == "11"?"(已删)":"")).Append("',note:''").Append(",ntype:'bill'}");
                    }
                }
                #endregion
            }
            if (nodetype == "bill" || nodetype == "bill-mx")
            {
                if (nodetype == "bill")
                {
                    #region 载入明细表单
                    SYS_BILL objTB = new SYS_BILL();
                    SYS_BILL valTB = new SYS_BILL();
                    objTB.P_BILL_ID = int.Parse(id);
                    valTB.OrderBy(SYS_BILL.Attribute.BILL_ID, Order.Asc);
                    List <SYS_BILL> lstTB = BLLTable <SYS_BILL> .Factory(conn).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].BILL_ID);
                            sb.Append("',pid:'").Append(id).Append("',no:").Append(lstTB[i].BILL_ID);
                            sb.Append(",sc:").Append("1");
                            sb.Append(",name:'").Append(lstTB[i].BILL_NAME).Append("',note:''").Append(",ntype:'bill-mx'}");
                        }
                    }
                    #endregion
                }
                #region 载入列
                SYS_BILL_COL obj = new SYS_BILL_COL();
                SYS_BILL_COL val = new SYS_BILL_COL();
                obj.BILL_ID = int.Parse(id);
                //obj.Where("COL_NAME not in('MX_ID','BILL_ID')");
                val.af_PageBy(SYS_BILL_COL.Attribute.SORT_NO, Order.Asc);

                List <SYS_BILL_COL> lst = BLLTable <SYS_BILL_COL> .Factory(conn).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].COL_ID.ToString());
                        sb.Append("',pid:'").Append(lst[i].BILL_ID.ToString()).Append("',no:").Append(lst[i].SORT_NO);
                        sb.Append(",sc:").Append("1");
                        sb.Append(",name:'").Append(lst[i].COL_NAME).Append("',note:'[" + lst[i].COL_NOTE + "]'").Append(",ntype:'col'}");
                    }
                }
                #endregion
            }//选中了表单列
            if (nodetype == "col")
            {
                SYS_BILL_COL_SYN obj = new SYS_BILL_COL_SYN();
                SYS_BILL_COL_SYN val = new SYS_BILL_COL_SYN();
                obj.COL_ID = int.Parse(id);
                //obj.Where("COL_NAME not in('MX_ID','BILL_ID')");
                //val.af_PageBy(SYS_BILL_COL_SYN.Attribute.SORT_NO, Order.Asc);

                List <SYS_BILL_COL_SYN> lst = BLLTable <SYS_BILL_COL_SYN> .Factory(conn).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].COL_SYNID.ToString());
                        sb.Append("',pid:'").Append(lst[i].COL_ID.ToString()).Append("',no:").Append("0");
                        sb.Append(",sc:").Append("0");
                        sb.Append(",name:'").Append("[" + lst[i].DB_SRC + "].[" + lst[i].TABLE_NAME + "].[" + lst[i].COL_NAME + "]").Append("',note:'[" + lst[i].COL_NOTE + "]'").Append(",ntype:'syncol'}");
                    }
                }
            }
            //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:'table'}");

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

        #region//删除节点
        if (Request["deleteNode"] != null)
        {
            string str   = "";
            string delID = Request["id"];
            string ntype = Request["ntype"];
            if (ntype == "bill" || ntype == "bill-mx")
            {
                #region//删除表
                SYS_BILL_EXD eee = new SYS_BILL_EXD(int.Parse(delID));
                string       msg = "";
                int          re  = eee.Delete(out msg);

                #endregion
                str = "{re:" + re + ",msg:'" + msg + "'}";
            }
            else if (ntype == "col")
            {
                #region//删除表字段

                string msg = "删除数据库表字段成功!";

                SYS_BILL_EXD bllexd = new SYS_BILL_EXD(int.Parse(Request["pid"]));
                int          re     = bllexd.DeleteCol(int.Parse(delID));// TF_TABLEHelper.DelField(delID);// ;
                if (re > 0)
                {
                    msg = "删除数据库表字段成功!";
                }
                else
                {
                    msg = "删除数据库表字段失败!";
                }
                #endregion
                str = "{re:" + re + ",msg:'" + msg + "'}";
            }
            else if (ntype == "syncol")
            {
                #region//删除表字段

                string msg = "删除同步字段成功!";
                int    re  = BLLTable <SYS_BILL_COL_SYN> .Factory(conn).Delete(SYS_BILL_COL_SYN.Attribute.COL_SYNID, delID);

                if (re > 0)
                {
                    msg = "删除同步字段成功!";
                }
                else
                {
                    msg = "删除同步字段失败!";
                }
                #endregion
                str = "{re:" + re + ",msg:'" + msg + "'}";
            }
            Response.Write(str);
        }
        #endregion

        #region//导入字段
        if (Request["intbCols"] != null)
        {
            string                  pid     = Request["pid"];
            string                  id      = Request["id"];
            string                  billid  = Request["billid"];
            DataBaseTable           tbllext = DataBase.Factory(conn).DataTables[pid];// new DataBaseTable(_Base.TABLE_NAME, "", dbROG);
            DataBaseFieldCollection fields  = tbllext.DataFields;
            string                  keys    = "";

            DataBaseField fs = fields[id];
            if (fs.IsKeyID == true)
            {
                keys += keys == "" ? fs.FieldName : "," + fs.FieldName;
            }
            SYS_BILL_COL col = AgileFrame.AppInOne.SYS.SysDataBaseHelper.FieldToCol(fs, int.Parse(billid));
            SYS_BILL_COL ccc = new SYS_BILL_COL();
            ccc.BILL_ID  = int.Parse(billid);
            ccc.COL_NAME = fs.FieldName.ToUpper();
            int          re     = 1;
            SYS_BILL_COL oldCol = BLLTable <SYS_BILL_COL> .Factory(conn).GetRowData(new SYS_BILL_COL(), ccc);

            int colid = 0;
            if (oldCol == null)
            {
                re = BLLTable <SYS_BILL_COL> .Factory(conn).Insert(col, SYS_BILL_COL.Attribute.COL_ID);

                colid = col.COL_ID;
            }
            else
            {
                colid = oldCol.COL_ID;
            }
            if (re > 0)
            {
                SYS_BILL_COL_SYN valObj = new SYS_BILL_COL_SYN();
                valObj.BILL_ID = Convert.ToInt32(Request["billid"]);

                valObj.COL_NAME = fs.FieldName.ToUpper();

                valObj.TABLE_NAME = Request["tb"];
                valObj.COL_ID     = colid;
                valObj.ISPK       = fs.IsKeyID == true ? "1" : "0";
                valObj.COL_NOTE   = fs.Desc.ZhName;
                valObj.DATA_TYPE  = fs.DataType.TypeNameString;
                valObj.DATA_LEN   = fs.DataType.DataLen;
                valObj.DATA_ACC   = fs.DataType.Scale;
                valObj.IS_AUTO    = fs.IsAutoIncrease == true ? "1" : "0";
                valObj.DVAL       = fs.DefaultValue;
                valObj.DB_SRC     = Request["dev"];
                valObj.PK_VALCODE = "";

                BLLTable <SYS_BILL_COL_SYN> .InsertReturnID(valObj);
            }
            //记录主键到表单
            if (keys != "")
            {
                BLLTable <SYS_BILL> .Factory(conn).Update(SYS_BILL.Attribute.BILL_ID, billid, SYS_BILL.Attribute.KEYS, keys);
            }
            Response.Write("ok");
        }


        #endregion

        #region
        if (Request["addSynCols"] != null)
        {
            string[] aaa = StringHelper.GetStringArray(Request["ids"], ',');
            for (int i = 0; i < aaa.Length; i++)
            {
                string[] bbb = aaa[i].Split('.');
                if (bbb[2] != "col")
                {
                    continue;
                }
                DataBaseTable tbllext = DataBase.Factory(conn).DataTables[bbb[0]];
                DataBaseField fs      = tbllext.DataFields[bbb[1]];

                SYS_BILL_COL_SYN valObj = new SYS_BILL_COL_SYN();
                valObj.BILL_ID  = Convert.ToInt32(Request["billid"]);
                valObj.COL_ID   = Convert.ToInt32(Request["colid"]);
                valObj.COL_NAME = fs.FieldName;
                if (!BLLTable <SYS_BILL_COL_SYN> .Exists(valObj))
                {
                    valObj.TABLE_NAME = tbllext.TableName;
                    valObj.ISPK       = fs.IsKeyID == true ? "1" : "0";
                    valObj.COL_NOTE   = fs.Desc.ZhName;
                    valObj.DATA_TYPE  = fs.DataType.TypeNameString.Replace("_", "");
                    valObj.DATA_LEN   = fs.DataType.DataLen;
                    valObj.DATA_ACC   = fs.DataType.Scale;
                    valObj.IS_AUTO    = fs.IsAutoIncrease == true ? "1" : "0";
                    valObj.DVAL       = fs.DefaultValue;
                    valObj.DB_SRC     = bbb[0];
                    valObj.PK_VALCODE = "";

                    BLLTable <SYS_BILL_COL_SYN> .InsertReturnID(valObj);
                }
            }
            Response.Write("ok");
        }
        #endregion


        #region//彻底删除表单
        if (Request["clearBill"] != null)
        {
            #region//删除表
            string       str   = "";
            string       delID = Request["id"];
            SYS_BILL_EXD eee   = new SYS_BILL_EXD(int.Parse(delID));
            string       msg   = "";
            int          re    = eee.Delete(out msg);

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

        //在列表里点击删除按钮,通过AJAX执行这里的后台代码,删除一条记录
        if (Request["DelBILL_ID"] != null)
        {
            int re = BLLTable <SYS_BILL> .Factory(conn).Delete(SYS_BILL.Attribute.BILL_ID, Request["DelBILL_ID"]);

            if (re > 0)
            {
                Response.Write("1");//可以输出数字 大于0 表示操作成功,也可以直接输出 字符串,客户端将弹出此字符串信息作为提示
            }
            else
            {
                Response.Write("删除失败!");
            }
        }

        //在列表顶部点击删除按钮,通过AJAX执行这里的后台代码,删除多条记录
        if (Request["DelKeyIDS"] != null)
        {
            SYS_BILL cond = new SYS_BILL();
            cond.In(SYS_BILL.Attribute.BILL_ID, Request["DelKeyIDS"]);
            int re = BLLTable <SYS_BILL> .Factory(conn).Delete(cond);

            if (re > 0)
            {
                Response.Write("1");//可以输出数字 大于0 表示操作成功,也可以直接输出 字符串,客户端将弹出此字符串信息作为提示
            }
            else
            {
                Response.Write("删除失败!");
            }
        }

        //在用户详细信息查看编辑页面,点保存时,通过AJAX执行这里的后台代码,实现部门字段的更新
        if (Request["saveInfo"] != null)
        {
            SYS_BILL val = new SYS_BILL();
            val.BILL_ID = int.Parse(Request["FieldKeyID"]);
            List <AttributeItem> lstCol = val.af_AttributeItemList;
            for (int i = 0; i < lstCol.Count; i++)
            {
                if (!string.IsNullOrEmpty(Request["txt" + lstCol[i].FieldName]))
                {
                    val.SetValue(lstCol[i].FieldName, Request["txt" + lstCol[i].FieldName]);
                }
            }

            BLLTable <SYS_BILL> .Factory(conn).Update(val, SYS_BILL.Attribute.BILL_ID);

            Response.Write("修改用户信息成功");
        }
        Response.End();
    }
Esempio n. 5
0
    protected void btnOK_Click(object sender, EventArgs e)
    {
        //try
        //{
            SYS_BILL_COL_SYN valObj = new SYS_BILL_COL_SYN();
            if (txtBILL_ID.Value != "")
                valObj.BILL_ID = Convert.ToInt32(txtBILL_ID.Value);

            //if (keyid == "")
            //{
            //    if (BLLTable<SYS_BILL_COL_SYN>.Exists(valObj))
            //    {
            //        litWarn.Text = "�Ѿ����ڴ��ֶΣ�";
            //        return;
            //    }
            //}

            #region
            if (txtTABLE_NAME.Value != "")
            {
                valObj.TABLE_NAME = Convert.ToString(txtTABLE_NAME.Value);
            }
            else {
                if (txtTABLE_NAME1.Value != "")
                {
                    valObj.TABLE_NAME = Convert.ToString(txtTABLE_NAME1.Value);
                }
            }

            DataBaseField field = null;
            if (txtCOL_NAME.Value != "")
            {
                valObj.COL_NAME = Convert.ToString(txtCOL_NAME.Value);
                try
                {
                    field = DataBase.Factory(MyConfigurationSettings.GetValue(txtDB_SRC.Value)).DataTables[valObj.TABLE_NAME].DataFields[valObj.COL_NAME];
                }
                catch { field = null; }
            }
            if (field == null)
            {
                litWarn.Text = "����ʧ�ܣ�û���ҵ����ֶΣ�";
                return;
            }

            if (txtCOL_ID.Value !="" )
                valObj.COL_ID = Convert.ToInt32(txtCOL_ID.Value);

            valObj.ISPK = field.IsKeyID ? "1" : "0";

            valObj.COL_NOTE = field.Desc.ZhName;

            valObj.DATA_TYPE = field.DataType.TypeNameString;

            valObj.DATA_LEN = field.DataType.DataLen;

            valObj.DATA_ACC = field.DataType.Scale;

            valObj.IS_AUTO = field.IsAutoIncrease ? "1" : "0";

            valObj.DVAL = field.DefaultValue;

            valObj.DB_SRC = txtDB_SRC.Value;

            valObj.PK_VALCODE = txtPK_VALCODE.Value;
            #endregion

            if (keyid != "")
            {
                valObj.COL_SYNID = Convert.ToInt32(keyid);

                count = BLLTable<SYS_BILL_COL_SYN>.Factory(conn).Update(valObj, SYS_BILL_COL_SYN.Attribute.COL_SYNID);
            }
            else
            {
                valObj.SetInitialized(SYS_BILL_COL_SYN.Attribute.COL_SYNID, false);
                count = BLLTable<SYS_BILL_COL_SYN>.InsertReturnID(valObj);
                keyid = count.ToString();
                ViewState["KEYID"] = keyid;
                if (count > 0 && valObj.ISPK == "1")
                {
                    SYS_BILL_COL_EXD billExd = new SYS_BILL_COL_EXD(valObj.ToBILL_COL());
                    billExd.Add();
                }
            }
            if (count > 0)
            {
                if (Request["tree"] != null)
                {
                    StringBuilder sb = new StringBuilder("{");
                    sb.Append("id:'");
                    sb.Append(keyid).Append("',pid:'").Append(valObj.COL_ID).Append("',no:1,sc:0,name:'");

                    sb.Append(valObj.COL_NAME + "[" + valObj.COL_NOTE + "]").Append("',ntype:'syncol'}");

                    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);

                    }
                    litWarn.Text = "����ɹ�";
                }
                else
                {
                    #region
                    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", "_FormView();if (window.opener){window.opener.returnValue = '" + dataStr + "';}else{window.returnValue = '" + dataStr + "';}window.close();", true);
                        }
                        else
                        {
                            ScriptManager.RegisterStartupScript(Page, this.GetType(), "goto", "_FormView();if (window.opener){window.opener.returnValue = 're';}else{window.returnValue = 're';}window.close();", true);
                        }
                    }
                    else
                    {
                        AgileFrame.Core.ScriptHelper.ResponseScript(Page, "_FormView();", false);
                        txtTABLE_NAME.Value = "";
                        txtCOL_NAME.Value = "";
                        hidTABLE_NAME.Value = "";

                    }
                    #endregion

                }

            }
            else {
                litWarn.Text = "�޸�ʧ�ܣ�";
            }
        //}
        //catch (Exception ex)
        //{
        //    litWarn.Text = ex.Message;
        //}
    }
Esempio n. 6
0
    protected void Page_Load(object sender, EventArgs e)
    {
        title = valObj._ZhName + "�༭";
        Page.Title = title;
        if (!string.IsNullOrEmpty(Request["SYN_ID"]))
        {
            keyid = Request["SYN_ID"];
        }

        if (!string.IsNullOrEmpty(Request["KeyID"]))
        {
            keyid = Request["KeyID"];
        }

        if (!string.IsNullOrEmpty(Request["edit"]))
        {
            keyid = Request["id"];
            colid = int.Parse(Request["pid"]);
        }
        else {
            colid = int.Parse(Request["id"]);
        }
        if (ViewState["KEYID"] != null)
        {
            keyid = ViewState["KEYID"].ToString();
        }
        if (!IsPostBack)
        {
            txtDB_SRC.Items.AddRange(FormHelper.GetListItem(SYS_DATASOURCE.Attribute.SourceName));
            txtDATA_TYPE.Items.Clear();
            //FieldDataType fty = new FieldDataType(DataBaseConnectStringHelper.GetDataBaseType(MyConfigurationSettings.GetValue(txtDB_SRC.Value)), DataBaseDataType.varchar, 20, 0, false);
            //foreach (string tp in fty.AllDataType)
            //{
            //    txtDATA_TYPE.Items.Add(new ListItem(tp, tp));
            //}
            //if (colid > 0)
            //{
            //    SYS_BILL_COL_SYN ccc = new SYS_BILL_COL_SYN();
            //    ccc.IS_AUTO = "0";
            //    ccc.ISPK = "0";
            //}
            //try
            //{
                ViewState["FORM_CTRL_ID"] = "0";
                //Response.Write(colid.ToString()); return;
                SYS_BILL_COL billCol = BLLTable<SYS_BILL_COL>.Factory(conn).GetRowData(SYS_BILL_COL.Attribute.COL_ID, colid);
                SYS_BILL billObj = BLLTable<SYS_BILL>.Factory(conn).GetRowData(SYS_BILL.Attribute.BILL_ID, billCol.BILL_ID);
                hidTABLE_NAME.Value = billObj.TABLE_NAME;
                hidConnSrc.Value = billObj._CONN_SOURCE;
                if (keyid != "")
                {
                    valObj = BLLTable<SYS_BILL_COL_SYN>.Factory(conn).GetRowData(SYS_BILL_COL_SYN.Attribute.COL_SYNID, keyid);
                    if (valObj == null) return;

                    txtISPK.Value = valObj.ISPK;
                    txtCOL_ID.Value = Convert.ToString(valObj.COL_ID);//Convert.ToInt32

                    txtBILL_ID.Value = Convert.ToString(valObj.BILL_ID);//Convert.ToInt32

                    txtTABLE_NAME.Value = Convert.ToString(valObj.TABLE_NAME);//Convert.ToString
                    txtTABLE_NAME1.Value = valObj.TABLE_NAME;
                    txtCOL_NAME.Value = Convert.ToString(valObj.COL_NAME);//Convert.ToString
                    ViewState["txtCOL_NAME"] = txtCOL_NAME.Value;

                    txtCOL_NOTE.Value = Convert.ToString(valObj.COL_NOTE);//Convert.ToString

                    if (valObj.DATA_TYPE.IndexOf('(') >= 0)
                        txtDATA_TYPE.Value = valObj.DATA_TYPE.Substring(0, valObj.DATA_TYPE.IndexOf('(')).ToLower();
                    else
                        txtDATA_TYPE.Value = Convert.ToString(valObj.DATA_TYPE).ToLower();//Convert.ToString

                    txtDATA_LEN.Value = Convert.ToString(valObj.DATA_LEN);//Convert.ToInt32

                    txtDATA_ACC.Value = Convert.ToString(valObj.DATA_ACC);//Convert.ToInt32

                    txtIS_AUTO.Value = Convert.ToString(valObj.IS_AUTO);//Convert.ToString
                    txtDB_SRC.Value = valObj.DB_SRC;
                    //Response.Write(valObj.IS_AUTO);
                    txtDVAL.Value = Convert.ToString(valObj.DVAL);//Convert.ToString

                }
                else
                {
                    txtBILL_ID.Value = billCol.BILL_ID.ToString();
                    txtCOL_ID.Value = colid.ToString();
                    //txtTABLE_NAME.Value = billObj.TABLE_NAME;
                }

            //}
            //catch (Exception ex)
            //{
            //    litWarn.Text = ex.Message;
            //}
        }
    }