//--------------------------------------------------------------------------------------- // 1.ID : Gf_DD_Display // 2.Input Value : Conn Connection, sQuery String, [MsgChk Boolean] // 3.Return Value : Boolean // 4.Create Date : // 5.Modify Date : // 6.Comment : Data Dictionary Result Data Display //--------------------------------------------------------------------------------------- public static bool Gf_Common_DD(Keys KeyCode) { SpreadCommon SpreadCommon = new SpreadCommon(); string sOld_Code = ""; string sNew_Code = ""; // string sOld_Name = ""; string sNew_Name = ""; /* 如果退出F4窗口. */ if (KeyCode == Keys.Return || KeyCode == Keys.Escape || GeneralCommon.GF_DbConnect() == false) { GeneralCommon.Gp_DD_New_Clear(); return(false); } GeneralCommon.DD_New.DicRefType = "C"; //Active Form DataDic Call try { if (GeneralCommon.DD_New.sWitch == "MS" || GeneralCommon.DD_New.sWitch == "CUS") { if (!string.IsNullOrEmpty(GeneralCommon.DD_New.sCusCode)) { GeneralCommon.DD_New.sQuery = GeneralCommon.DD_New.sCusCode; GeneralCommon.DD_New.sWhere = ""; } else if (!string.IsNullOrEmpty(GeneralCommon.DD_New.sPrcoCode)) { string callSql = "{call " + GeneralCommon.DD_New.sPrcoCode + "("; string Par = ""; for (int i = 0; i < GeneralCommon.DD_New.sContrl.Count; i++) { if (GeneralCommon.DD_New.sCtlAttr[i].ToString().ToUpper().Contains("R")) { Par += "'" + MasterCommon.GetControlValue(GeneralCommon.DD_New.sContrl[i]).ToString().Replace("'", "''") + "',"; } } if (Par.Length > 0) { Par = Par.Substring(0, Par.Length - 1); } callSql = callSql + Par + ")}"; GeneralCommon.DD_New.sQuery = callSql; GeneralCommon.DD_New.sWhere = ""; } else { string sQuery_temp = " "; string sWhere_after = ""; string sWhere_before = ""; string sOrder_Temp = " "; if (GeneralCommon.DD_New.sKeyName.Trim().Length > 0 && GeneralCommon.DD_New.sKey.Trim().Length > 0) { sWhere_before = "where " + GeneralCommon.DD_New.sKeyName.Trim() + "='" + GeneralCommon.DD_New.sKey.Trim() + "' and "; } else { sWhere_before = "where "; } GeneralCommon.DD_New.sQuery = " SELECT "; //拼Where 后面的限制条件 和 Select 后的字段 for (int i = 0; i < GeneralCommon.DD_New.sContrl.Count; i++) { if (!string.IsNullOrEmpty(Convert.ToString(GeneralCommon.DD_New.sBackName[i]))) { if (GeneralCommon.DD_New.sCtlAttr[i].ToString().ToUpper().Contains("R") && !GeneralCommon.DD_New.sCtlAttr[i].ToString().ToUpper().Contains("P")) { sWhere_after += "and nvl(" + GeneralCommon.DD_New.sBackName[i].ToString().Trim() + ",f_nullvalue('" + GeneralCommon.DD_New.sBackTableName + "','" + GeneralCommon.DD_New.sBackName[i].ToString().Trim() + "')) LIKE '%" + MasterCommon.GetControlValue(GeneralCommon.DD_New.sContrl[i]).ToString().Trim().Replace("'", "''") + "%' "; } else if (GeneralCommon.DD_New.sCtlAttr[i].ToString().ToUpper().Contains("P")) { sWhere_after += "and " + GeneralCommon.DD_New.sBackName[i].ToString().Trim() + " LIKE '%" + MasterCommon.GetControlValue(GeneralCommon.DD_New.sContrl[i]).ToString().Trim().Replace("'", "''") + "%' "; sOrder_Temp += " " + GeneralCommon.DD_New.sBackName[i].ToString().Trim() + " Asc ,"; } if (string.IsNullOrEmpty(Convert.ToString(GeneralCommon.DD_New.sColName[i]))) { sQuery_temp += " " + GeneralCommon.DD_New.sBackName[i] + " \" " + GeneralCommon.DD_New.sBackName[i] + " \","; } sQuery_temp += " " + GeneralCommon.DD_New.sBackName[i] + " \" " + GeneralCommon.DD_New.sColName[i] + " \","; } } GeneralCommon.DD_New.sQuery += sQuery_temp.Substring(0, sQuery_temp.Length - 1) + " FROM " + GeneralCommon.DD_New.sBackTableName + " "; GeneralCommon.DD_New.sQuery += sWhere_before; sWhere_after += " "; // if (!sWhere_before.Contains("=")) { sWhere_after = sWhere_after.Substring(4); } GeneralCommon.DD_New.sWhere += sWhere_after + " "; GeneralCommon.DD_New.sWhere += " " + GeneralCommon.DD_New.sJoin; if (!string.IsNullOrEmpty(GeneralCommon.DD_New.sOrderBy)) { GeneralCommon.DD_New.sWhere += " " + GeneralCommon.DD_New.sOrderBy; } else { GeneralCommon.DD_New.sWhere += " order by " + sOrder_Temp.Substring(0, sOrder_Temp.Length - 1); } } } else {//带检查 if (!string.IsNullOrEmpty(GeneralCommon.DD_New.sCusCode)) { GeneralCommon.DD_New.sQuery = GeneralCommon.DD_New.sCusCode; GeneralCommon.DD_New.sWhere = ""; } else if (!string.IsNullOrEmpty(GeneralCommon.DD_New.sPrcoCode)) { string callSql = "{call " + GeneralCommon.DD_New.sPrcoCode + "("; string Par = ""; for (int i = 0; i < GeneralCommon.DD_New.sContrl.Count; i++) { if (GeneralCommon.DD_New.sCtlAttr[i].ToString().ToUpper().Contains("R")) { Par += "'" + SpreadCommon.GetColValue((C1.Win.C1FlexGrid.Column)GeneralCommon.DD_New.sContrl[i]).ToString().Replace("'", "''") + "',"; } } if (Par.Length > 0) { Par = Par.Substring(0, Par.Length - 1); } callSql = callSql + Par + ")}"; GeneralCommon.DD_New.sQuery = callSql; GeneralCommon.DD_New.sWhere = ""; } else { string sQuery_temp = " "; string sWhere_after = ""; string sWhere_before = ""; string sOrder_Temp = " "; if (GeneralCommon.DD_New.sKeyName.Trim().Length > 0 && GeneralCommon.DD_New.sKey.Trim().Length > 0) { sWhere_before = "where " + GeneralCommon.DD_New.sKeyName.Trim() + "='" + GeneralCommon.DD_New.sKey.Trim() + "' "; } else { sWhere_before = "where "; } GeneralCommon.DD_New.sQuery = " SELECT "; //拼Where 后面的限制条件 和 Select 后的字段 for (int i = 0; i < GeneralCommon.DD_New.sContrl.Count; i++) { if (!string.IsNullOrEmpty(Convert.ToString(GeneralCommon.DD_New.sBackName[i]))) { if (GeneralCommon.DD_New.sCtlAttr[i].ToString().ToUpper().Contains("R") && !GeneralCommon.DD_New.sCtlAttr[i].ToString().ToUpper().Contains("P")) { sWhere_after += "and nvl(" + GeneralCommon.DD_New.sBackName[i].ToString().Trim() + ",'%') LIKE '%" + SpreadCommon.GetCellValue((FlexGrid_User)GeneralCommon.DD_New.sPname, ((FlexGrid_User)GeneralCommon.DD_New.sPname).RowSel, ((C1.Win.C1FlexGrid.Column)GeneralCommon.DD_New.sContrl[i]).Index).ToString().Trim().Replace("'", "''") + "%' "; } else if (GeneralCommon.DD_New.sCtlAttr[i].ToString().ToUpper().Contains("P")) { sWhere_after += "and " + GeneralCommon.DD_New.sBackName[i].ToString().Trim() + " LIKE '%" + SpreadCommon.GetCellValue((FlexGrid_User)GeneralCommon.DD_New.sPname, ((FlexGrid_User)GeneralCommon.DD_New.sPname).RowSel, ((C1.Win.C1FlexGrid.Column)GeneralCommon.DD_New.sContrl[i]).Index).ToString().Trim().Replace("'", "''") + "%' "; sOrder_Temp += " " + GeneralCommon.DD_New.sBackName[i].ToString().Trim() + " Asc ,"; } if (string.IsNullOrEmpty(Convert.ToString(GeneralCommon.DD_New.sColName[i]))) { sQuery_temp += " " + GeneralCommon.DD_New.sBackName[i] + " \" " + GeneralCommon.DD_New.sBackName[i] + " \","; } sQuery_temp += " " + GeneralCommon.DD_New.sBackName[i] + " \" " + GeneralCommon.DD_New.sColName[i] + " \","; } } GeneralCommon.DD_New.sQuery += sQuery_temp.Substring(0, sQuery_temp.Length - 1) + " FROM " + GeneralCommon.DD_New.sBackTableName + " "; GeneralCommon.DD_New.sQuery += sWhere_before; sWhere_after += " "; // if (!sWhere_before.Contains("=")) { sWhere_after = sWhere_after.Substring(4); } GeneralCommon.DD_New.sWhere += sWhere_after + " "; GeneralCommon.DD_New.sWhere += " " + GeneralCommon.DD_New.sJoin; if (!string.IsNullOrEmpty(GeneralCommon.DD_New.sOrderBy)) { GeneralCommon.DD_New.sWhere += " " + GeneralCommon.DD_New.sOrderBy; } else { GeneralCommon.DD_New.sWhere += " order by " + sOrder_Temp.Substring(0, sOrder_Temp.Length - 1); } } //FlexGrid_User oFlexGrid = (FlexGrid_User)GeneralCommon.DD_New.sPname; ///* 取出当前单元格编辑的内容. */ //sOld_Code = "";//oFlexGrid[oFlexGrid.RowSel, Convert.ToInt32(GeneralCommon.rControl[0])].ToString(); //GeneralCommon.DD_New.sQuery = " SELECT CD \"代码\", CD_SHORT_NAME \"代码简称\", CD_NAME \"代码名称\", "; //GeneralCommon.DD_New.sQuery += " CD_SHORT_ENG \"代码英文简称\", CD_FULL_ENG \"代码英文名称\" FROM TZ_CD "; //GeneralCommon.DD_New.sQuery += " WHERE CD_MANA_NO = '" + GeneralCommon.DD.sKey.Trim() + "' "; //GeneralCommon.DD_New.sWhere += " and CD LIKE '" + sOld_Code.Trim() + "%' "; ///* 判断当前传入查询参数的个数. */ //if (GeneralCommon.rControl.Count > 0) //{ // //sOld_Code = oFlexGrid[oFlexGrid.RowSel, Convert.ToInt32(((System.Windows.Forms.TextBox)(GeneralCommon.rControl[2])).Text)].ToString(); // sOld_Code = oFlexGrid[oFlexGrid.RowSel, Convert.ToInt32(GeneralCommon.rControl[0])].ToString(); // //} // GeneralCommon.DD_New.sWhere += " and NVL(CD_NAME,'%') LIKE '" + sOld_Name.Trim() + "%' "; // GeneralCommon.DD_New.sWhere += " AND CD != ' ' "; // GeneralCommon.DD_New.sWhere += " AND APLY_STD = '1' "; // if (!string.IsNullOrEmpty(GeneralCommon.DD_New.sJoin)) // { // GeneralCommon.DD_New.sWhere += " and " + GeneralCommon.DD_New.sJoin + "Order by CD"; // } //} } if (Gf_DD_Display(GeneralCommon.DD_New.sQuery + GeneralCommon.DD_New.sWhere, false)) { /* F4 窗口退出处理程序 [FlexGrid中的F4功能] */ if (GeneralCommon.DD_New.sWitch == "SP") { /* 如果当前为 Spread F4 控件. */ FlexGrid_User oFlexGrid = (FlexGrid_User)GeneralCommon.DD_New.sPname; sNew_Code = oFlexGrid[oFlexGrid.RowSel, Convert.ToInt32((GeneralCommon.rControl[0]))].ToString(); if (GeneralCommon.rControl.Count > 0) { sNew_Name = oFlexGrid[oFlexGrid.RowSel, Convert.ToInt32((GeneralCommon.rControl[0]))].ToString(); } switch (oFlexGrid.Rows[oFlexGrid.RowSel].Caption) { case "插入": break; case "删除": break; case "修改": break; default: { //ss.ActiveSheet.RowHeader.Cells[ss.ActiveSheet.ActiveRowIndex, 0].Text = "Update"; oFlexGrid.Rows[oFlexGrid.RowSel].Caption = "修改"; break; } } if (GeneralCommon.DD_New.sSelect) { if (sOld_Code != sNew_Code) { SpreadCommon.Gp_Sp_UpdateMark(oFlexGrid, true); } } } } GeneralCommon.Gp_DD_New_Clear(); return(true); } catch (Exception ex) { GeneralCommon.Gp_DD_Clear(); GeneralCommon.Gp_MsgBoxDisplay("DataDic 查询出错啦...!!!" + ex.Message, "I"); return(false); } }