Пример #1
0
        //����SQL����еij��������ʽ������,�������һ��SQL��䣬���м���ô洢���̣��ڴ洢����������SQL��䡣
        private int DealCEF(int m_TypeNo, int m_SetTableNo, int m_TableNo, bool isStat, int isLikeZB0110)
        {
            //����
            string m_strCON = "";
            //���ʽ
            string m_strEXP = "";
            //����
            string m_strFUN = "";
            //������
            string m_strTBL = "";
            //�ֶ���
            string m_strFLD = "";
            //�����ֶ���
            string m_strASS = "";
            char[] a;
            //�������ڷָ��
            a = "(".ToCharArray();
            string[] strTempwl;

            //����������һ���ַ���������'AA','BB'
            for (int i = 0; i <= mConst.Count - 1; i++)
            {
                if (m_strCON == "")
                {
                    m_strCON = m_strCON + "'" + mConst[i].ToString() + "'";
                }
                else
                {
                    m_strCON = m_strCON + ",'" + mConst[i].ToString() + "'";
                }
            }
            //����������һ���ַ���������'AA','BB'
            for (int i = 0; i <= mFunction.Count - 1; i++)
            {
                if (m_strFUN == "")
                {
                    strTempwl = mFunction[i].ToString().Split(a);
                    m_strFUN = m_strFUN + "'" + strTempwl[0].ToString() + "'";
                }
                else
                {
                    strTempwl = mFunction[i].ToString().Split(a);
                    m_strFUN = m_strFUN + ",'" + strTempwl[0].ToString() + "'";
                }
            }
            //�����ʽ����һ���ַ���������'AA','BB'
            for (int i = 0; i <= mExpress.Count - 1; i++)
            {
                if (m_strEXP == "")
                {
                    m_strEXP = m_strEXP + "'" + mExpress[i].ToString() + "'";
                }
                else
                {
                    m_strEXP = m_strEXP + ",'" + mExpress[i].ToString() + "'";
                }
            }
            //����������һ���ַ���������AA,BB
            for (int i = 0; i <= mTable.Count - 1; i++)
            {
                if (m_strTBL == "")
                {
                    m_strTBL = mTable[i].ToString();
                }
                else
                {
                    m_strTBL = m_strTBL + "," + mTable[i].ToString();
                }
            }
            //���ֶ�������һ���ַ���������AA,BB
            for (int i = 0; i <= mField.Count - 1; i++)
            {
                if (m_strFLD == "")
                {
                    m_strFLD = mField[i].ToString();
                }
                else
                {
                    m_strFLD = m_strFLD + "," + mField[i].ToString();
                }
            }
            //�������ֶ�����һ���ַ���������AA,BB
            for (int i = 0; i <= mAssicate.Count - 1; i++)
            {
                if (m_strASS == "")
                {
                    m_strASS = mAssicate[i].ToString();
                }
                else
                {
                    m_strASS = m_strASS + "," + mAssicate[i].ToString();
                }
            }
            //���д洢���̴�����Ҫ���ñ��ʽ�ַ����������ַ����������ַ���������ǰ��SQL���������ֶ���������Ϊ������SQL���
            //���ô洢��������SQL���洢���̷�Ϊ�����֣�һ�Ǵ���statSQL��䣬������������,ͬʱ�����ﴫ��ȫ������
            //dealData createSQL = new dealData();
            dealData RptLoad = new dealData();
            string strBaseexpr = "";
            string strBaseitem = "";
            //�õ�ȫ������,ȫ������ͨ�����뵽�洢�����У����д���
            SqlDataReader objRCReader;
            objRCReader = RptLoad.getWhole_condition(m_TypeNo, m_SetTableNo, m_TableNo);
            while (objRCReader.Read())
            {
                m_strMainObject = objRCReader["mainobject"].ToString();
                strBaseexpr = objRCReader["Baseexpr"].ToString();
                strBaseitem = objRCReader["Baseitem"].ToString();
            }
            objRCReader.Close();
            //���ɿ�ִ�е�SQL���
            m_TBL = m_strTBL;
            m_FLD = m_strFLD;
            m_ASS = m_strASS;
            reQuery re = new reQuery();
            if (isStat)
            {
                int icount1 = 0, icount2 = 0;
                if (strBaseitem != "")
                {
                    icount1 = strBaseitem.Split('~').Length;
                }
                if (m_Item != null && this.m_Item != "")
                {
                    icount2 = m_Item.Split('~').Length;
                }
                if (icount1 == 0)
                {
                    if (icount2 == 0)
                    {
                        strBaseitem = "";
                        strBaseexpr = "";
                    }
                    else
                    {
                        strBaseitem = m_Item;
                        strBaseexpr = m_Expr;
                    }
                }
                else
                {
                    if (icount2 == 0)
                    {
                        strBaseitem = strBaseitem;
                        strBaseexpr = strBaseexpr;
                    }
                    else
                    {
                        strBaseexpr = re.gs_Comexpress(icount1, icount2, strBaseexpr, m_Expr);
                        strBaseitem = strBaseitem + "  ~" + m_Item;
                    }
                }

                QueryDeal dealCondition = new QueryDeal(m_strMainObject, strBaseexpr, strBaseitem, "");
                //string strCondition=dealCondition.QueryResult();
                string strCondition = dealCondition.QueryResult(m_TypeNo, m_SetTableNo, m_TableNo, DMServer.Common.ConfigMy.strUserID);

                //hjh 2005.10.14 �����ⲿ��������,����ͳ�Ʒ�Χ����
                if (strCondition != "")
                {
                    strCondition += " and " + this.gsstrwhere;
                }
                else
                {
                    strCondition = "select za0100 from " + m_strMainObject + " where " + gsstrwhere;
                }
                RptLoad.StatTBL(m_strMainObject, m_B0110, m_TypeNo, m_SetTableNo, m_TableNo, m_strTBL, m_strFLD, m_strCON, m_strEXP, m_strFUN, "", "", strCondition, m_strASS, m_Userid, isLikeZB0110);
            }
            return 0;
        }
Пример #2
0
        //����SQL����еij��������ʽ������,�������һ��SQL��䣬���м���ô洢���̣��ڴ洢����������SQL��䡣
        public int DealCEF(int serialNo, int sequenceNo)
        {
            //����
            string m_strCON = "";
            //���ʽ
            string m_strEXP = "";
            //����
            string m_strFUN = "";
            //������
            string m_strTBL = "";
            //�ֶ���
            string m_strFLD = "";
            char[] a;
            //�������ڷָ��
            a = "(".ToCharArray();
            string[] strTempwl;

            //����������һ���ַ���������'AA','BB'
            for (int i = 0; i <= mConst.Count - 1; i++)
            {
                if (m_strCON == "")
                {
                    m_strCON = m_strCON + "'" + mConst[i].ToString() + "'";
                }
                else
                {
                    m_strCON = m_strCON + ",'" + mConst[i].ToString() + "'";
                }
            }
            //����������һ���ַ���������'AA','BB'
            for (int i = 0; i <= mFunction.Count - 1; i++)
            {
                if (m_strFUN == "")
                {
                    strTempwl = mFunction[i].ToString().Split(a);
                    m_strFUN = m_strFUN + "'" + strTempwl[0].ToString() + "'";
                }
                else
                {
                    strTempwl = mFunction[i].ToString().Split(a);
                    m_strFUN = m_strFUN + ",'" + strTempwl[0].ToString() + "'";
                }
            }

            //�����ʽ����һ���ַ���������'AA','BB'
            for (int i = 0; i <= mExpress.Count - 1; i++)
            {
                if (m_strEXP == "")
                {
                    m_strEXP = m_strEXP + "'" + mExpress[i].ToString() + "'";
                }
                else
                {
                    m_strEXP = m_strEXP + ",'" + mExpress[i].ToString() + "'";
                }
            }
            //����������һ���ַ���������AA,BB
            for (int i = 0; i <= mTable.Count - 1; i++)
            {
                if (m_strTBL == "")
                {
                    m_strTBL = mTable[i].ToString();
                }
                else
                {
                    m_strTBL = m_strTBL + "," + mTable[i].ToString();
                }
            }
            //���ֶ�������һ���ַ���������AA,BB
            for (int i = 0; i <= mField.Count - 1; i++)
            {
                if (m_strFLD == "")
                {
                    m_strFLD = mField[i].ToString();
                }
                else
                {
                    m_strFLD = m_strFLD + "," + mField[i].ToString();
                }
            }
            //���д洢���̴�����Ҫ���ñ��ʽ�ַ����������ַ����������ַ���������ǰ��SQL���������ֶ���������Ϊ������SQL���
            //���ô洢��������SQL
            dealData createSQL = new dealData();
            if (m_serialNo == -1 && m_sequenceNo == -1)
            {
                strGetSql = createSQL.runQuery(m_strMainObject, m_strTBL, m_strFLD, m_strCON, m_strEXP, m_strFUN, strSQl, outstrSQL);
            }
            else
            {
                createSQL.UpdateCondition(m_serialNo, m_sequenceNo, m_strTBL, m_strFLD, m_strCON, m_strEXP, m_strFUN, strSQl);
            }
            return 0;
        }
Пример #3
0
        /// <summary>
        /// i_TypeNo ���� i_SetTableNo �ױ�� i_TableNo ����� 
        /// strUnit ��λ 
        /// strSequence ����������е�λ�� 
        /// strUnitCount ������嵥Ԫ��λ��
        /// </summary>
        /// <param name="i_TypeNo"></param>
        /// <param name="i_SetTableNo"></param>
        /// <param name="i_TableNo"></param>
        /// <param name="strUnit"></param>
        /// <param name="strSequence"></param>
        /// <param name="strUnitCount"></param>
        public SortedList gsoutinterface(int i_TypeNo, int i_SetTableNo, int i_TableNo, string strUnit)
        {
            //���ɱ���
            //��λ
            m_B0110 = strUnit;
            //������
            string strtmp = " select MainObject from r200 where typeno = " + i_TypeNo + " and settableno = " + i_SetTableNo + " and tableno = " + i_TableNo;
            DataAccess.Data.GetSql getsql = new DataAccess.Data.GetSql();
            DataTable dt = getsql.gsQuerySql(strtmp, "R200");
            if (dt == null || dt.Rows.Count == 0)
            {
                m_strMainObject = "AA01";
            }
            else
            {
                m_strMainObject = dt.Rows[0]["MainObject"].ToString();
            }
            if (m_strMainObject == "")
            {
                m_strMainObject = "AA01";
            }
            //�ж��������Ƿ��е�λ
            string strSQLtmp = "SELECT * FROM gs_property WHERE infoid= '" + m_strMainObject + "' AND infofield = 'ab0110' ";
            dt = getsql.gsQuerySql(strSQLtmp, "gs_property");
            if (dt == null || dt.Rows.Count == 0)
            {
                m_B0110 = "-1";
            }
            //���ɱ���
            StatResult(i_TypeNo, i_SetTableNo, i_TableNo, true);
            //ȡ�����е����е�ͳ�ƽ��
            dealData RptR_C = new dealData();
            SqlDataReader objRCReader;
            objRCReader = RptR_C.getRC_R(i_TypeNo, i_SetTableNo, i_TableNo);
            int row = 7;
            int col = 3;
            int col1 = 0;
            int rowLen = 5;
            int collen = 15;
            SortedList sortmp = new SortedList();
            //ȡ����λ��
            while (objRCReader.Read())
            {
                if (objRCReader["serialtype"].ToString() == "1")
                {
                    row = (int)objRCReader["startrow"];
                    rowLen = (int)objRCReader["icount"];
                }
                else
                {
                    col1 = (int)objRCReader["startcol"];
                    collen = (int)objRCReader["icount"];
                }
            }
            if (collen == 0)
            {
                collen = 1;
            }
            if (rowLen == 0)
            {
                rowLen = 1;
            }
            objRCReader = null;
            //���ϼ����ͱ����
            row = row + 2;
            col1 = col1 + 2;
            dealData addData = new dealData();
            SqlDataReader objAssReader;
            //���������
            objAssReader = addData.getRApp(i_TypeNo, i_SetTableNo, i_TableNo, m_B0110, "T" + i_TypeNo.ToString() + "_" + i_SetTableNo.ToString() + "_" + i_TableNo.ToString(), "1");
            if (objAssReader != null)
            {
                while (objAssReader.Read())
                {
                    col = col1;
                    for (int i = col; i <= collen + col - 1; i++)
                    {
                        sortmp.Add(row + "_" + i, objAssReader["C" + (i - col + 1).ToString()]);
                    }
                    row = row + 1;
                }
            }
            objAssReader = null;
            //��Ԫ����
            dealData RptUnit = new dealData();
            SqlDataReader objUnitReader;

            objUnitReader = RptUnit.getUnitResult(i_TypeNo, i_SetTableNo, i_TableNo, m_B0110, "1");

            while (objUnitReader.Read())
            {
                sortmp.Add(objUnitReader["row"].ToString() + "_" + objUnitReader["col"].ToString(), objUnitReader["svalue"]);
            }
            return sortmp;
        }
Пример #4
0
        public void gsoutinterface(int i_TypeNo, int i_SetTableNo, int i_TableNo, out string strSequence, out string strUnitCount)
        {
            //ȡ�����е����е�ͳ�ƽ��
            dealData RptR_C = new dealData();
            SqlDataReader objRCReader;
            objRCReader = RptR_C.getRC_R(i_TypeNo, i_SetTableNo, i_TableNo);
            int row = 7;
            //int col = 3;
            int col1 = 0;
            int rowLen = 5;
            int collen = 15;
            strSequence = "";
            strUnitCount = "";
            //ȡ����λ��
            while (objRCReader.Read())
            {
                if (objRCReader["serialtype"].ToString() == "1")
                {
                    row = (int)objRCReader["startrow"];
                    rowLen = (int)objRCReader["icount"];
                }
                else
                {
                    col1 = (int)objRCReader["startcol"];
                    collen = (int)objRCReader["icount"];
                }
            }
            if (collen == 0)
            {
                collen = 1;
            }
            if (rowLen == 0)
            {
                rowLen = 1;
            }
            objRCReader = null;
            //���ϼ����ͱ����
            row = row + 2;
            col1 = col1 + 2;
            for (int i = row; i < row + rowLen; i++)
            {
                for (int j = col1; j < col1 + collen; j++)
                {
                    strSequence += i + "," + j + ";";
                }
            }
            if (strSequence.Length > 1)
            {
                strSequence = strSequence.Substring(0, strSequence.Length - 1);
            }

            //��Ԫ����
            DataAccess.Data.GetSql RptUnit = new DataAccess.Data.GetSql();
            string strSql = " select * from r201 where serialno > 2 and typeno =" + i_TypeNo + " and settableno = " + i_SetTableNo + " and tableno = " + i_TableNo;
            DataTable dt = RptUnit.gsQuerySql(strSql, "R201");
            if (dt != null && dt.Rows.Count != 0)
            {
                for (int k = 0; k < dt.Rows.Count; k++)
                {
                    if (dt.Rows[k]["startrow"].ToString() == "0" || dt.Rows[k]["startcol"].ToString() == "0")
                    {
                        continue;
                    }
                    else
                    {
                        strUnitCount += dt.Rows[k]["startrow"].ToString() + "," + dt.Rows[k]["startcol"].ToString() + ";";
                    }
                }
            }
            //����
            strSql = " select * from eg01 where typeno =" + i_TypeNo + " and settbl = " + i_SetTableNo + " and tablno = " + i_TableNo;
            dt = RptUnit.gsQuerySql(strSql, "eg01");
            if (dt != null && dt.Rows.Count != 0)
            {
                for (int l = 0; l < dt.Rows.Count; l++)
                {
                    if (dt.Rows[l]["startr"].ToString() == "0" || dt.Rows[l]["startc"].ToString() == "0")
                    {
                        continue;
                    }
                    else
                    {
                        strUnitCount += dt.Rows[l]["startr"].ToString() + "," + dt.Rows[l]["startc"].ToString() + ";";
                    }
                }
            }
            if (strUnitCount.Length > 1)
            {
                strUnitCount = strUnitCount.Substring(0, strUnitCount.Length - 1);
            }
        }
Пример #5
0
        //--------------------
        //����ı���ֶΡ����ʽ�������������ȵĴ���
        public void GetPara(string BaseItem)
        {
            string[] myValue;
            //��������
            string[] mySplit;
            //string[] myAssicate;
            //������ָ��
            char[] a;
            //�������ڷָ��
            char[] b;
            char[] c;
            char[] d;
            d = "[".ToCharArray();
            c = ",".ToCharArray();
            a = "~".ToCharArray();
            b = ":".ToCharArray();

            //-----------------------------
            string[] myAssicate;
            SqlDataReader objAssReader;
            dealData getTF = new dealData();
            objAssReader = getTF.getAssicate(m_strMainObject);
            //if (!In(m_strMainObject + ".ZA0100", mAssicate))
            //{
            //    mAssicate.Add(m_strMainObject + ".ZA0100");
            //}
            while (objAssReader.Read())
            {
                myAssicate = objAssReader[ILC.PROPERTYSET].ToString().Split(c);
                for (int i = 0; i <= myAssicate.Length - 1; i++)
                {
                    if (!In(m_strMainObject + "." + myAssicate[i].ToString().Trim(), mAssicate) && myAssicate[i].ToString().Trim() != "")
                    {
                        mAssicate.Add(m_strMainObject + "." + myAssicate[i].ToString().Trim());
                    }
                }
            }
            //------------------------------------

            //--------------------------

            myValue = BaseItem.Split(a);
            if (BaseItem != "")
            {
                //һ��ѭ���ֽⳣ�������ʽ----------------------------------------------
                for (int i = myValue.Length - 1; i >= 0; i--)
                {
                    //mysplit[4]:�洢����������Ϊ����ı��ʽ;
                    //mysplit[5]:�洢������ʽָ��;
                    //mysplit[7]:�洢������ʽ��ֵ�����г���,��������֮��ı��ʽ���޷���ֵ�ĺ���
                    //��ʶ������$,����#,���ʽ^
                    mySplit = myValue[i].ToString().Split(b);
                    //����split[4]
                    if (mySplit[4].ToString().Trim() != "" && mySplit[4].ToString().Trim() != ".")
                    {
                        switch (mySplit[4].ToString().Trim().Substring(0, 1).ToString())
                        {
                            case "#"://����
                                if (!In(mySplit[4].ToString().Trim().Substring(1).ToString(), mFunction))
                                {
                                    mFunction.Add(mySplit[4].ToString().Trim().Substring(1).ToString());
                                }
                                break;
                            case "^"://���ʽ
                                if (!In(mySplit[4].ToString().Trim().Substring(1).ToString(), mExpress))
                                {
                                    mExpress.Add(mySplit[4].ToString().Trim().Substring(1).ToString());
                                }
                                break;
                            default:
                                break;
                        }
                    }
                    //����split[7]
                    if (mySplit[7].ToString().Trim() != "" && mySplit[7].ToString().Trim() != ".")
                    {
                        switch (mySplit[7].ToString().Trim().Substring(0, 1).ToString())
                        {
                            case "#"://����
                                if (!In(mySplit[7].ToString().Trim().Substring(1).ToString(), mFunction))
                                {
                                    //if(mySplit[7].ToString().Trim().Substring(1).ToString()!="��ֵ")
                                    mFunction.Add(mySplit[7].ToString().Trim().Substring(1).ToString());
                                }
                                break;
                            case "^"://���ʽ
                                if (!In(mySplit[7].ToString().Trim().Substring(1).ToString(), mExpress))
                                {
                                    mExpress.Add(mySplit[7].ToString().Trim().Substring(1).ToString());
                                }
                                break;
                            case "$"://����
                                if (!In(mySplit[7].ToString().Trim().Substring(1).ToString(), mConst) && mySplit[7].ToString().Trim().Substring(1).ToString() != "")
                                {
                                    mConst.Add(mySplit[7].ToString().Trim().Substring(1).ToString());
                                }
                                break;
                            default:
                                break;
                        }
                    }
                    //����split[5]
                    string temp;
                    if (mySplit[5].ToString().Trim() != ".")
                    {
                        temp = mySplit[5].ToString().Trim().Substring(0, 4).ToString();
                        if (temp != "")
                        {
                            if (mySplit[5].ToString().Trim().Substring(0, 4).ToString() != m_strMainObject)
                            {
                                if (!In(mySplit[5].ToString().Trim().Substring(0, 4).ToString(), mTable) && mySplit[5].ToString().Trim().Substring(0, 4).ToString() != "")
                                {
                                    mTable.Add(mySplit[5].ToString().Trim().Substring(0, 4).ToString());
                                }
                            }
                            if (!In(mySplit[5].ToString().Trim().Substring(0).ToString(), mField) && !In(mySplit[5].ToString().Trim().Substring(0).ToString(), mAssicate) && m_strMainObject + ".ZA0100" != mySplit[5].ToString().Trim().Substring(0).ToString() && mySplit[5].ToString().Trim().Substring(0).ToString() != "")
                            {
                                mField.Add(mySplit[5].ToString().Trim().Substring(0).ToString());
                            }
                        }
                    }
                }
            }

            //�ֽ���ʽ�ͳ���---------------------------------------------
        }
Пример #6
0
        //--------------------------------------------------------------------------
        //����ı���ֶΡ����ʽ�������������ȵĴ���
        public void GetPara(int m_TypeNo, int m_SetTableNo, int m_TableNo)
        {
            string[] myValue;
            //��������
            string[] mySplit;
            string[] myAssicate;
            //������ָ��
            char[] a;
            //�������ڷָ��
            char[] b;
            char[] c;
            char[] d;
            d = "[".ToCharArray();
            c = ",".ToCharArray();
            a = "~".ToCharArray();
            b = ":".ToCharArray();
            //strSQl = "";
            SqlDataReader objAssReader;
            SqlDataReader objdataReader;
            dealData getTF = new dealData();

            //��ȡ�ֶα��ʽ����Ϣ
            //objdataReader = getTF.getTableField(m_TypeNo, m_SetTableNo, m_TableNo);
            //�����Ǵ�������ֶ�
            //����������������������������������
            objAssReader = getTF.getAssicate(m_strMainObject);
            //if (!In(m_strMainObject + ".ZA0100", mAssicate))
            //{
            //    mAssicate.Add(m_strMainObject + ".ZA0100");
            //}
            while (objAssReader.Read())
            {
                myAssicate = objAssReader[ILC.PROPERTYSET].ToString().Split(c);
                for (int i = 0; i <= myAssicate.Length - 1; i++)
                {
                    if (!In(m_strMainObject + "." + myAssicate[i].ToString().Trim(), mAssicate) && myAssicate[i].ToString().Trim() != "")
                    {
                        mAssicate.Add(m_strMainObject + "." + myAssicate[i].ToString().Trim());
                    }
                }
            }
            objAssReader.Close();
            //------------------------------------
            //��ȡ�ֶα��ʽ����Ϣ
            objdataReader = getTF.getTableField(m_TypeNo, m_SetTableNo, m_TableNo);
            while (objdataReader.Read())
            {
                //��������д����ֶ����е��ֶ�
                myAssicate = objdataReader[ILC.DEALFIELDNAME].ToString().Split(d);
                for (int i = 1; i <= myAssicate.Length - 1; i++)
                {
                    if (myAssicate[i].ToString().Trim() != "" && !In(myAssicate[i].ToString().Substring(0, 11).Trim(), mField))
                    {
                        mField.Add(myAssicate[i].ToString().Substring(0, 11).Trim());
                    }
                    if (myAssicate[i].ToString().Trim() != "" && !In(myAssicate[i].ToString().Substring(0, 4).Trim(), mTable) && myAssicate[i].ToString().Substring(0, 4).Trim() != m_strMainObject)
                    {
                        mTable.Add(myAssicate[i].ToString().Substring(0, 4).Trim());
                    }
                }

                //mTable
                //---------------------------------------------------------------
                myValue = objdataReader[ILC.BASEITEM].ToString().Split(a);
                if (objdataReader[ILC.BASEITEM].ToString() != "")
                {
                    //һ��ѭ���ֽⳣ�������ʽ----------------------------------------------
                    for (int i = myValue.Length - 1; i >= 0; i--)
                    {
                        //mysplit[4]:�洢����������Ϊ����ı��ʽ;
                        //mysplit[5]:�洢������ʽָ��;
                        //mysplit[7]:�洢������ʽ��ֵ�����г���,��������֮��ı��ʽ���޷���ֵ�ĺ���
                        //��ʶ������$,����#,���ʽ^
                        mySplit = myValue[i].ToString().Split(b);
                        //����split[4]
                        if (mySplit[4].ToString().Trim() != "" && mySplit[4].ToString().Trim() != ".")
                        {
                            switch (mySplit[4].ToString().Trim().Substring(0, 1).ToString())
                            {
                                case "#"://����
                                    if (!In(mySplit[4].ToString().Trim().Substring(1).ToString(), mFunction))
                                    {
                                        mFunction.Add(mySplit[4].ToString().Trim().Substring(1).ToString());
                                    }
                                    break;
                                case "^"://���ʽ
                                    if (!In(mySplit[4].ToString().Trim().Substring(1).ToString(), mExpress))
                                    {
                                        mExpress.Add(mySplit[4].ToString().Trim().Substring(1).ToString());
                                    }
                                    break;
                                default:
                                    break;
                            }
                        }
                        //����split[7]
                        if (mySplit[7].ToString().Trim() != "" && mySplit[7].ToString().Trim() != ".")
                        {
                            switch (mySplit[7].ToString().Trim().Substring(0, 1).ToString())
                            {
                                case "#"://����
                                    if (!In(mySplit[7].ToString().Trim().Substring(1).ToString(), mFunction))
                                    {
                                        //if(mySplit[7].ToString().Trim().Substring(1).ToString()!="��ֵ")
                                        mFunction.Add(mySplit[7].ToString().Trim().Substring(1).ToString());
                                    }
                                    break;
                                case "^"://���ʽ
                                    if (!In(mySplit[7].ToString().Trim().Substring(1).ToString(), mExpress))
                                    {
                                        mExpress.Add(mySplit[7].ToString().Trim().Substring(1).ToString());
                                    }
                                    break;
                                case "$"://����
                                    if (!In(mySplit[7].ToString().Trim().Substring(1).ToString(), mConst) && mySplit[7].ToString().Trim().Substring(1).ToString() != "")
                                    {
                                        mConst.Add(mySplit[7].ToString().Trim().Substring(1).ToString());
                                    }
                                    break;
                                default:
                                    break;
                            }
                        }
                        //����split[5]
                        string temp;
                        if (mySplit[5].ToString().Trim() != ".")
                        {
                            //hjh 2004.12.29
                            if (mySplit[5].ToString().Length > 14)
                            {
                                break;
                            }
                            //end hjh
                            temp = mySplit[5].ToString().Trim().Substring(0, 4).ToString();
                            if (temp != "")
                            {
                                if (mySplit[5].ToString().Trim().Substring(0, 4).ToString() != m_strMainObject)
                                {
                                    if (!In(mySplit[5].ToString().Trim().Substring(0, 4).ToString(), mTable) && mySplit[5].ToString().Trim().Substring(0, 4).ToString() != "")
                                    {
                                        mTable.Add(mySplit[5].ToString().Trim().Substring(0, 4).ToString());
                                    }
                                }
                                if (!In(mySplit[5].ToString().Trim().Substring(0).ToString(), mField) && !In(mySplit[5].ToString().Trim().Substring(0).ToString(), mAssicate) && m_strMainObject + ".ZA0100" != mySplit[5].ToString().Trim().Substring(0).ToString() && mySplit[5].ToString().Trim().Substring(0).ToString() != "")
                                {
                                    mField.Add(mySplit[5].ToString().Trim().Substring(0).ToString());
                                }
                            }
                        }
                    }
                }

                //�ֽ���ʽ�ͳ���---------------------------------------------
            }
            objdataReader.Close();
        }
Пример #7
0
        //���ɺϲ����SQL���
        public string GetSQl(out string strWhere)
        {
            strWhere = "";
            try
            {
                dealData RptR_C = new dealData();
                SqlDataReader objRCReader;
                dealData Rpt4 = new dealData();
                SqlDataReader objRPT4Reader;
                objRCReader = RptR_C.getRC_R(m_TypeNo, m_SetTableNo, m_TableNo);
                Sequence First = new Sequence(-1, -1, 1, 1, "#");
                Sequence Second = new Sequence(-1, -1, 1, 1, "#");
                Sequence Result = new Sequence(-1, -1, 1, 1, "#");
                string RowExpr = "";//�������ı��ʽ
                string ColExpr = "";//�������ı��ʽ
                string RowItem = "";//����������
                string ColItem = "";//����������
                string RowChineseItem = "";//�е�����������ϵ
                string ColChineseItem = "";//�е�����������ϵ
                string ResultItem = "";//���Ľ��������
                string ResultExpr = "";//���Ľ���ı��ʽ
                string ResultChinese = "";//����������
                int sequenceRow = -1;
                int sequenceCol = -1;
                int getcount1 = 0;
                int getcount2 = 0;
                string[] strTempwl;
                char[] a;
                a = "~".ToCharArray();

                int i = 1;
                if (m_strMainObject == "")
                {
                    string strtmp = " select MainObject from r200 where typeno = " + m_TypeNo + " and settableno = " + m_SetTableNo + " and tableno = " + m_TableNo;
                    DataAccess.Data.GetSql getsql = new DataAccess.Data.GetSql();
                    DataTable dt = getsql.gsQuerySql(strtmp, "R200");
                    if (dt == null || dt.Rows.Count == 0)
                    {
                        m_strMainObject = "AA01";
                    }
                    else
                    {
                        m_strMainObject = dt.Rows[0]["MainObject"].ToString();
                    }
                }
                //������������
                while (objRCReader.Read())
                {
                    if (i == 1)
                    {
                        if ((int)(objRCReader["icount"]) != 0)
                        {
                            First.STARTROW = (int)(objRCReader["startrow"]) + 2;
                            First.ENDROW = (int)(objRCReader["startrow"]) + 2 + (int)(objRCReader["icount"]) - 1;
                            First.STARTCOL = (int)(objRCReader["startcol"]) + 2;
                            First.ENDCOL = (int)(objRCReader["startcol"]) + 2 + (int)(objRCReader["icount"]) - 1;
                            First.SEQUENCETYPE = objRCReader["serialtype"].ToString();
                        }
                    }
                    else
                    {
                        if ((int)(objRCReader["icount"]) != 0)
                        {
                            Second.STARTROW = (int)(objRCReader["startrow"]) + 2;
                            Second.ENDROW = (int)(objRCReader["startrow"]) + 2 + (int)(objRCReader["icount"]) - 1;
                            Second.STARTCOL = (int)(objRCReader["startcol"]) + 2;
                            Second.ENDCOL = (int)(objRCReader["startcol"]) + 2 + (int)(objRCReader["icount"]) - 1;
                            Second.SEQUENCETYPE = objRCReader["serialtype"].ToString();
                        }
                    }
                    i++;
                }
                objRCReader.Close();
                objRCReader = null;

                bool blnTemp;
                blnTemp = true;
                if (Second.STARTROW != -1 && First.STARTROW != -1)
                {
                    blnTemp = true;
                }
                else if (Second.STARTROW == -1 && First.STARTROW != -1)
                {
                    Result = First;
                    blnTemp = false;
                }
                else if (First.STARTROW == -1 && Second.STARTROW != -1)
                {
                    Result = Second;
                    blnTemp = false;
                }
                else
                {
                    sequenceRow = -1;
                    sequenceCol = -1;
                }
                //return "";
                if (blnTemp == false)//һ�л�һ��
                {
                    //Result.STARTROW = First.STARTROW;
                    //Result.ENDROW = First.ENDROW;
                    //Result.STARTCOL = First.STARTCOL;
                    //Result.ENDCOL = First.ENDCOL;
                    //Result.SEQUENCETYPE = First.SEQUENCETYPE;
                    sequenceRow = m_row - Result.STARTROW;
                    sequenceCol = m_col - Result.STARTCOL;
                    if (Result.SEQUENCETYPE == "1")
                    {
                        if (sequenceCol != 0)
                        {
                            sequenceCol = -1;
                        }
                    }
                    else
                    {
                        if (sequenceRow != 0)
                        {
                            sequenceRow = -1;
                        }
                    }
                }
                else if (First.STARTROW == Second.STARTROW && First.STARTCOL == Second.STARTCOL)//������
                {
                    Result.STARTROW = First.STARTROW;
                    if (First.SEQUENCETYPE == "1")
                    {
                        Result.ENDROW = First.ENDROW;
                    }
                    else
                    {
                        Result.ENDROW = Second.ENDROW;
                    }
                    Result.STARTCOL = First.STARTCOL;
                    if (First.SEQUENCETYPE == "2")
                    {
                        Result.ENDCOL = First.ENDCOL;
                    }
                    else
                    {
                        Result.ENDCOL = Second.ENDCOL;
                    }
                    Result.SEQUENCETYPE = "1&2";
                    sequenceRow = m_row - Result.STARTROW;
                    sequenceCol = m_col - Result.STARTCOL;
                    if (m_row > Result.ENDROW || m_col > Result.ENDCOL)
                    {
                        sequenceRow = -1;
                        sequenceCol = -1;
                    }
                }
                else//������û�д���
                {
                    Result.SEQUENCETYPE = "1|2";
                }
                //�ҳ����ڵ����е�λ��

                //if (First.SEQUENCETYPE == "1" && m_row - First.STARTROW >= 0 && m_row <= First.ENDROW)
                //{
                //    sequenceRow = m_row - First.STARTROW;
                //}
                //if (First.SEQUENCETYPE == "2" && m_col - First.STARTCOL >= 0 && m_col <= First.ENDCOL)
                //{
                //    sequenceCol = m_col - First.STARTCOL;
                //}
                //if (Second.SEQUENCETYPE == "1" && m_row - Second.STARTROW >= 0 && m_row <= Second.ENDROW)
                //{
                //    sequenceRow = m_row - Second.STARTROW;
                //}
                //if (Second.SEQUENCETYPE == "2" && m_col - Second.STARTCOL >= 0 && m_col <= Second.ENDCOL)
                //{
                //    sequenceCol = m_col - Second.STARTCOL;
                //}
                bool nullSequenceRow = false;
                bool nullSequenceCol = false;
                if (sequenceRow > -1 && sequenceCol > -1)//��������
                {
                    if (sequenceRow > -1)
                    {
                        dealData Rpt1 = new dealData();
                        SqlDataReader objRPT1Reader;
                        objRPT1Reader = Rpt1.getOneCondition(m_TypeNo, m_SetTableNo, m_TableNo, sequenceRow, "1");
                        while (objRPT1Reader.Read())
                        {
                            if (objRPT1Reader["sequenceType"].ToString() == "4")
                            {
                                return "";
                            }
                            else
                            {
                                RowExpr = objRPT1Reader["baseexpr"].ToString();
                                RowItem = objRPT1Reader["baseitem"].ToString();
                                RowChineseItem = objRPT1Reader["chineseitem"].ToString();
                                if (RowItem == null || RowItem == "")
                                {
                                    nullSequenceRow = true;
                                }
                            }
                        }
                        objRPT1Reader.Close();
                        //-----------------------------------------
                        dealData Rpt2 = new dealData();
                        SqlDataReader objRPT2Reader;
                        objRPT2Reader = Rpt2.getOneCondition(m_TypeNo, m_SetTableNo, m_TableNo, sequenceCol, "2");
                        while (objRPT2Reader.Read())
                        {
                            if (objRPT2Reader["sequenceType"].ToString() == "4")
                            {
                                return "";
                            }
                            else
                            {
                                ColExpr = objRPT2Reader["baseexpr"].ToString();
                                ColItem = objRPT2Reader["baseitem"].ToString();
                                ColChineseItem = objRPT2Reader["chineseitem"].ToString();
                                if (ColItem == null || ColItem == "")
                                {
                                    nullSequenceCol = true;
                                }
                            }
                        }
                        objRPT2Reader.Close();
                        //�������ڷָ��
                        if (RowItem != "")
                        {
                            strTempwl = RowItem.ToString().Split(a);
                            getcount1 = strTempwl.Length;
                        }
                        if (ColItem != "")
                        {
                            strTempwl = ColItem.ToString().Split(a);
                            getcount2 = strTempwl.Length;
                        }
                        //string ResultItem = "";//���Ľ��������
                        //string ResultExpr = "";//���Ľ���ı��ʽ
                        //string ResultChinese = "";//����������

                        if (getcount1 == 0 && getcount2 == 0 && nullSequenceRow == false && nullSequenceCol == false)
                        {//���뵥Ԫ����
                            //getUnitCondition
                            objRPT4Reader = Rpt4.getUnitCondition(m_TypeNo, m_SetTableNo, m_TableNo, "2", m_row, m_col);
                            while (objRPT4Reader.Read())
                            {
                                if (objRPT4Reader["sequenceType"].ToString() == "4")
                                {
                                    return "";
                                }
                                else
                                {
                                    ColExpr = objRPT4Reader["baseexpr"].ToString();
                                    ColItem = objRPT4Reader["baseitem"].ToString();
                                    ColChineseItem = objRPT4Reader["chineseitem"].ToString();
                                }
                            }
                            objRPT4Reader.Close();
                            if (ColExpr != "")
                            {
                                ResultItem = ColItem;
                                ResultExpr = ColExpr;
                                ResultChinese = ColChineseItem;
                            }
                            else
                            {
                                return "";
                            }
                        }
                        else if (getcount1 == 0 && getcount2 != 0)
                        {
                            ResultItem = ColItem;
                            ResultExpr = ColExpr;
                            ResultChinese = ColChineseItem;
                        }
                        else if (getcount1 != 0 && getcount2 == 0)
                        {
                            ResultItem = RowItem;
                            ResultExpr = RowExpr;
                            ResultChinese = RowChineseItem;
                        }
                        else
                        {
                            if (ColItem == "")
                            {
                                ColExpr = "";
                            }
                            if (RowItem == "")
                            {
                                RowExpr = "";
                            }

                            ResultExpr = gs_Comexpress(getcount1, getcount2, RowExpr, ColExpr);
                            ResultItem = RowItem + "~" + ColItem;
                            ResultChinese = RowChineseItem + "~" + ColChineseItem;
                        }
                        getcount1 = getcount2 + getcount1;
                    }
                }
                else
                {//��Ԫ����
                    objRPT4Reader = Rpt4.getUnitCondition(m_TypeNo, m_SetTableNo, m_TableNo, "3", m_row, m_col);
                    while (objRPT4Reader.Read())
                    {
                        ColExpr = objRPT4Reader["baseexpr"].ToString();
                        ColItem = objRPT4Reader["baseitem"].ToString();
                        ColChineseItem = objRPT4Reader["chineseitem"].ToString();
                    }
                    objRPT4Reader.Close();
                    if (ColExpr != "")
                    {
                        ResultItem = ColItem;
                        ResultExpr = ColExpr;
                        ResultChinese = ColChineseItem;
                        strTempwl = ResultItem.ToString().Split(a);
                        getcount1 = strTempwl.Length;
                    }
                    else
                    {
                        return "";
                    }
                }

                //����ȫ������

                dealData Rpt3 = new dealData();
                SqlDataReader objRPT3Reader;
                objRPT3Reader = Rpt3.getOneCondition(m_TypeNo, m_SetTableNo, m_TableNo, -1, "0");
                while (objRPT3Reader.Read())
                {
                    if (objRPT3Reader["sequenceType"].ToString() == "4")
                    {
                        return "";
                    }
                    else
                    {
                        ColExpr = objRPT3Reader["baseexpr"].ToString();
                        ColItem = objRPT3Reader["baseitem"].ToString();
                        ColChineseItem = objRPT3Reader["chineseitem"].ToString();
                    }
                }
                objRPT3Reader.Close();
                if (ColItem != "")
                {
                    if (ColItem == "")
                    {
                        ColExpr = "";
                    }
                    if (ResultItem == "")
                    {
                        ResultExpr = "";
                    }

                    strTempwl = ColItem.ToString().Split(a);
                    getcount2 = strTempwl.Length;
                    ResultExpr = gs_Comexpress(getcount1, getcount2, ResultExpr, ColExpr);
                    if (ResultItem != "" && ResultItem != "~")
                    {
                        ResultItem = ResultItem + "~" + ColItem;
                    }
                    else
                    {
                        ResultItem = ColItem;
                    }
                    if (ResultChinese != "" && ResultChinese != "~")
                    {
                        ResultChinese = ResultChinese + "~" + ColChineseItem;
                    }
                    else
                    {
                        ResultChinese = ColChineseItem;
                    }
                    getcount1 = getcount1 + getcount2;
                }
                //�����ⲿ����
                if (m_Item != null && this.m_Item != "")
                {
                    strTempwl = m_Item.ToString().Split(a);
                    getcount2 = strTempwl.Length;
                    ResultExpr = gs_Comexpress(getcount1, getcount2, ResultExpr, m_Expr);
                    ResultItem = ResultItem + "~" + m_Item;
                    //ResultChinese = ResultChinese + "~" + ColChineseItem;
                    //getcount1 = getcount1 + getcount2;
                }
                //if(ResultItem!="")
                //{
                QueryDeal dealCondition = new QueryDeal(m_strMainObject, ResultExpr, ResultItem, "");
                string strCondition = dealCondition.QueryResult();
                if (strCondition != "" && m_AB0110 != "-1")
                {
                    if (m_AB0110 != "" && m_AB0110 != "0")
                    {
                        if (m_strMainObject.ToUpper() != "AB01")
                        {
                            strCondition = strCondition + " and " + m_strMainObject + ".ab0110 like '" + m_AB0110 + "%'";
                        }
                        else
                        {
                            strCondition = strCondition + " and " + m_strMainObject + ".ab0110 = '" + m_AB0110 + "'";
                        }
                    }
                    else
                    {
                        if (m_AB0110 != "" && m_AB0110 != "0")
                        {
                            if (m_strMainObject.ToUpper() != "AB01")
                            {
                                strCondition = m_strMainObject + ".ab0110 like '" + m_AB0110 + "%'";
                            }
                            else
                            {
                                strCondition = m_strMainObject + ".ab0110 = '" + m_AB0110 + "'";
                            }
                        }
                    }
                }
                m_strFLD = dealCondition.FLD;
                Datastat RptLoad = new Datastat();
                RptLoad.MainObject = m_strMainObject;
                RptLoad.StatResult(m_TypeNo, m_SetTableNo, m_TableNo, false);
                string strTBL;
                string strFLD;
                string strASS;
                strTBL = RptLoad.TBL;
                strFLD = RptLoad.FLD;
                strASS = RptLoad.ASS;
                dealData dealRequery = new dealData();
                if (strCondition == "")
                {
                    if (m_AB0110 != "-1" && m_AB0110 != "0" && m_AB0110 != "")
                    {
                        if (m_strMainObject.ToUpper() != "AB01")
                        {
                            strCondition = "select " + m_strMainObject + ".ZA0100 from " + m_strMainObject + " where " + m_strMainObject + ".ZC9993 = '1' and " + m_strMainObject + ".ab0110 like '" + m_AB0110 + "%'";
                        }
                        else
                        {
                            strCondition = "select " + m_strMainObject + ".ZA0100 from " + m_strMainObject + " where " + m_strMainObject + ".ZC9993 = '1' and " + m_strMainObject + ".ab0110 = '" + m_AB0110 + "'";
                        }
                    }
                    else
                    {
                        strCondition = "select " + m_strMainObject + ".ZA0100 from " + m_strMainObject + " where " + m_strMainObject + ".ZC9993 = '1' ";
                    }
                }
                strWhere = strCondition;
                strCondition = dealRequery.ReQuery(m_strMainObject, strTBL, strFLD, strASS, strCondition);
                return strCondition;

                //�����Ԫ����
                //sequenceRow
            }
            catch (Exception ee)
            {
                return "";
                //return "getsql " + ee.Message;
            }
        }
Пример #8
0
        //���ɺϲ����SQL���
        public string GetSQl(string ColItem, string ColExpr, string RowItem, string RowExpr, string dealFieldname, out string reCondition)
        {
            int getcount1 = 0;
            int getcount2 = 0;
            string ResultItem = "";//���Ľ��������
            string ResultExpr = "";//���Ľ���ı��ʽ
            if (ColItem == "")
            {
                ColExpr = "";
            }
            if (RowItem == "")
            {
                RowExpr = "";
            }
            string[] strTempwl;
            char[] a;
            try
            {
                a = "~".ToCharArray();

                if (RowItem != "")
                {
                    strTempwl = RowItem.ToString().Split(a);
                    getcount1 = strTempwl.Length;
                }
                if (ColItem != "")
                {
                    strTempwl = ColItem.ToString().Split(a);
                    getcount2 = strTempwl.Length;
                }
                if (ColItem == "")
                {
                    ColExpr = "";
                }
                if (RowItem == "")
                {
                    RowExpr = "";
                }
                ResultExpr = gs_Comexpress(getcount1, getcount2, RowExpr, ColExpr);
                if (RowItem == "")
                {
                    ResultItem = ColItem;
                }
                else if (ColItem == "")
                {
                    ResultItem = RowItem;
                }
                else
                {
                    ResultItem = RowItem + "~" + ColItem;
                }
                getcount1 = getcount2 + getcount1;
                //--------------------------------------------
                Datastat RptLoad = new Datastat();
                RptLoad.MainObject = m_strMainObject;
                RptLoad.StatResult(ResultItem);
                string strTBL;
                string strFLD;
                string strASS;
                strTBL = RptLoad.TBL;
                strFLD = RptLoad.FLD;
                strASS = RptLoad.ASS;
                //-------------------------------------------------------------
                QueryDeal dealCondition = new QueryDeal(m_strMainObject, ResultExpr, ResultItem, "", dealFieldname);
                string strCondition = dealCondition.QueryResult();
                //return strCondition;

                dealData dealRequery = new dealData();
                reCondition = dealRequery.ReQuery(m_strMainObject, strTBL, strFLD, strASS, strCondition);
                return strCondition;
            }
            catch (Exception ee)
            {
                reCondition = "";
                return ee.Message;
            }
        }
Пример #9
0
        //处理SQL语句中的常量、表达式、函数,最后生成一个SQL语句,这中间调用存储过程,在存储过程中生成SQL语句。
        public int DealCEF(int serialNo, int sequenceNo)
        {
            //常量
            string m_strCON = "";
            //表达式
            string m_strEXP = "";
            //函数
            string m_strFUN = "";
            //表名 
            string m_strTBL = "";
            //字段名
            string m_strFLD = "";

            char[] a;
            //条件项内分隔符
            a = "(".ToCharArray();
            string[] strTempwl;

            //将常量生成一个字符串,形如'AA','BB'
            for (int i = 0; i <= mConst.Count - 1; i++)
            {
                if (m_strCON == "")
                {
                    m_strCON = m_strCON + "'" + mConst[i].ToString() + "'";
                }
                else
                {
                    m_strCON = m_strCON + ",'" + mConst[i].ToString() + "'";
                }
            }
            //将函数生成一个字符串,形如'AA','BB'
            for (int i = 0; i <= mFunction.Count - 1; i++)
            {
                if (m_strFUN == "")
                {
                    strTempwl = mFunction[i].ToString().Split(a);
                    m_strFUN  = m_strFUN + "'" + strTempwl[0].ToString() + "'";
                }
                else
                {
                    strTempwl = mFunction[i].ToString().Split(a);
                    m_strFUN  = m_strFUN + ",'" + strTempwl[0].ToString() + "'";
                }
            }

            //将表达式生成一个字符串,形如'AA','BB'
            for (int i = 0; i <= mExpress.Count - 1; i++)
            {
                if (m_strEXP == "")
                {
                    m_strEXP = m_strEXP + "'" + mExpress[i].ToString() + "'";
                }
                else
                {
                    m_strEXP = m_strEXP + ",'" + mExpress[i].ToString() + "'";
                }
            }
            //将表名生成一个字符串,形如AA,BB
            for (int i = 0; i <= mTable.Count - 1; i++)
            {
                if (m_strTBL == "")
                {
                    m_strTBL = mTable[i].ToString();
                }
                else
                {
                    m_strTBL = m_strTBL + "," + mTable[i].ToString();
                }
            }
            //将字段名生成一个字符串,形如AA,BB
            for (int i = 0; i <= mField.Count - 1; i++)
            {
                if (m_strFLD == "")
                {
                    m_strFLD = mField[i].ToString();
                }
                else
                {
                    m_strFLD = m_strFLD + "," + mField[i].ToString();
                }
            }
            //进行存储过程处理需要调用表达式字符串、函数字符串、常量字符串、处理前的SQL、表名、字段名,返回为处理后的SQL语句
            //调用存储过程生成SQL
            dealData createSQL = new dealData();

            if (m_serialNo == -1 && m_sequenceNo == -1)
            {
                strGetSql = createSQL.runQuery(m_strMainObject, m_strTBL, m_strFLD, m_strCON, m_strEXP, m_strFUN, strSQl, outstrSQL);
            }
            else
            {
                createSQL.UpdateCondition(m_serialNo, m_sequenceNo, m_strTBL, m_strFLD, m_strCON, m_strEXP, m_strFUN, strSQl);
            }
            return(0);
        }