//���ɺϲ����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; } }
//���ɺϲ����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; } }