getDataTableBySql() 공개 정적인 메소드

给定列名,where条件,及表明返回datatable
public static getDataTableBySql ( String fields, string where, string tableName ) : DataTable
fields String 需要查询出来的字段,sample:fields1,field2,field3
where string 查询条件,sample: where 1=1 and a1='jjj' order by CreateDate asc
tableName string 查询的表名,sample:DOC_FILE_LIST
리턴 System.Data.DataTable
예제 #1
0
        //添加扩展属性记录
        //private void InsertExtPro()
        //{
        //    StringBuilder valuesDetail = new StringBuilder();
        //    StringBuilder columnDetail = new StringBuilder();
        //    foreach (TextBox t in textBoxList)
        //    {
        //        valuesDetail.Append(" '").Append(t.Text.ToString()).Append("',");
        //        columnDetail.Append(t.Tag.ToString()).Append(",");
        //    }
        //    valuesDetail.Append("'").Append(tableName).Append("','").Append(pkColName).Append("','").Append(pkValue).Append("' ");
        //    columnDetail.Append("MASTER_TABLE_NAME, PK_COL_NAME, PK_VALUE ");
        //    ObjectParams.SaveParamBySql(columnDetail.ToString(), valuesDetail.ToString(), " PDM_Params_DETAIL");
        //}
        //更新扩展属性记录
        //private void UpDateExtPro() {
        //    string fields = "";
        //    string where = "";
        //    StringBuilder sb = new StringBuilder();

        //    //设置更新列
        //    foreach (TextBox t in textBoxList)
        //    {
        //        sb.Append(t.Tag.ToString()).Append("= '").Append(t.Text.ToString()).Append("',");
        //    }
        //    if (sb.Length<=0) return;
        //    sb.Length--;
        //    fields = sb.ToString();

        //    //设置条件
        //    sb.Length = 0;
        //    sb.Append(" WHERE  MASTER_TABLE_NAME ='").Append(tableName);
        //    sb.Append("' AND PK_COL_NAME ='").Append(pkColName);
        //    sb.Append("' AND PK_VALUE ='").Append(pkValue).Append("'");
        //    where = sb.ToString();
        //    ObjectParams.UpDateParamBySql(fields, where, " PDM_Params_DETAIL");
        //}
        #endregion
        private DataTable GetProperties()
        {
            return(ObjectParams.getDataTableBySql(
                       "PARAMS_NAME,PARAMS_DATA_TYPE,TARGET_COLNAME",
                       "WHERE   MASTER_TABLE_NAME ='ALL' OR  MASTER_TABLE_NAME ='" + tableName + "' ORDER BY TARGET_COLNAME",
                       "PDM_Params"));
        }
예제 #2
0
        private int  GetMaxCountForProperties()
        {
            DataTable dt = ObjectParams.getDataTableBySql(
                "MAX(convert(int,substring(TARGET_COLNAME,2,len(TARGET_COLNAME)-1)))  as ROWCNT  ",
                "WHERE   MASTER_TABLE_NAME ='ALL' OR  MASTER_TABLE_NAME ='" + tableName + "' ",
                "PDM_Params");

            if (dt == null || dt.Rows.Count == 0)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(dt.Rows[0]["ROWCNT"].ToString()));
            }
        }
예제 #3
0
        protected void CreateParams(Control ctl)
        {
            ctl.Controls.Clear();
            textBoxList.Clear();
            labelList.Clear();
            DataTable dtTemp = GetProperties();

            maxcolumns = dtTemp.Rows.Count;
            DataTable dtTempValue = ObjectParams.getDataTableBySql(
                " * ",
                "WHERE MASTER_TABLE_NAME ='" + tableName + "'  AND  PK_COL_NAME ='" + pkColName + "'  AND  PK_VALUE = '" + pkValue + "'  ",
                "PDM_Params_DETAIL");

            if (dtTemp == null || dtTemp.Rows.Count == 0)
            {
                return;  //没有记录的时候返回
            }
            else
            {
                int x = 10;
                int y = 10;
                if (dtTempValue == null || dtTempValue.Rows.Count == 0)
                {
                    isHaveValue = false;
                    foreach (DataRow dr in dtTemp.Rows)
                    {
                        ctl.Controls.Add(CreatePanel(dr, x, y, ""));
                        y += 25 + 5;
                    }
                }
                else
                {
                    isHaveValue = true;
                    foreach (DataRow dr in dtTemp.Rows)
                    {
                        ctl.Controls.Add(CreatePanel(dr, x, y, dtTempValue.Rows[0][dr["TARGET_COLNAME"].ToString()].ToString()));
                        y += 25 + 5;
                    }
                }
            }
        }
예제 #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="ctl">容器</param>
        protected void CreateParams1(Control ctl)
        {
            ctl.Controls.Clear();
            textBoxList.Clear();
            labelList.Clear();
            DataTable dtTemp = GetProperties();

            maxcolumns = dtTemp.Rows.Count;
            DataTable dtTempValue = ObjectParams.getDataTableBySql(
                " * ",
                "WHERE MASTER_TABLE_NAME ='" + tableName + "'  AND  PK_COL_NAME ='" + pkColName + "'  AND  PK_VALUE = '" + pkValue + "'  ",
                "PDM_Params_DETAIL");

            if (dtTemp == null || dtTemp.Rows.Count == 0)
            {
                return;  //没有记录的时候返回
            }
            else
            {
                if (dtTempValue == null || dtTempValue.Rows.Count == 0)
                {
                    isHaveValue = false;
                    int x = 10;
                    int y = 10;
                    foreach (DataRow dr in dtTemp.Rows)
                    {
                        System.Windows.Forms.Panel pnl = new Panel();
                        pnl.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
                        //  pnl.Location = new System.Drawing.Point(10, 10);
                        pnl.Location = new System.Drawing.Point(x, y);
                        pnl.Name     = "pnl" + dr["PARAMS_NAME"].ToString();
                        pnl.Size     = new System.Drawing.Size(338, 25);


                        //
                        // txtCC
                        //
                        TextBox txt = new TextBox();
                        txt.Location = new System.Drawing.Point(85, 1);
                        txt.Name     = "txt" + dr["PARAMS_NAME"].ToString();
                        txt.Size     = new System.Drawing.Size(250, 21);
                        txt.Tag      = dr["TARGET_COLNAME"].ToString(); //存放该列名称对应的detail表中的列名
                        textBoxList.Add(txt);
                        String str    = txt.Tag.ToString();
                        int    temMax = Convert.ToInt32(str.Substring(1, str.Length));

                        if (maxcolumns < temMax)
                        {
                            maxcolumns = temMax;
                        }
                        //if (y == 10)
                        //{
                        //    txtFocus = txt;
                        //}
                        //
                        // lblCC
                        //
                        Label lbl = new Label();
                        lbl.AutoSize = true;
                        lbl.Location = new System.Drawing.Point(3, 5);
                        lbl.Name     = "lbl" + dr["PARAMS_NAME"].ToString();
                        lbl.Size     = new System.Drawing.Size(35, 12);
                        lbl.TabIndex = 2;
                        lbl.Text     = dr["PARAMS_NAME"].ToString() + ":";
                        labelList.Add(lbl);

                        pnl.Controls.Add(lbl);
                        pnl.Controls.Add(txt);
                        ctl.Controls.Add(pnl);
                        y += 25 + 5;
                    }
                }
                else
                {
                    isHaveValue = true;
                    int x = 10;
                    int y = 10;
                    foreach (DataRow dr in dtTemp.Rows)
                    {
                        System.Windows.Forms.Panel pnl = new Panel();
                        pnl.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
                        //  pnl.Location = new System.Drawing.Point(10, 10);
                        pnl.Location = new System.Drawing.Point(x, y);
                        pnl.Name     = "pnl" + dr["PARAMS_NAME"].ToString();
                        pnl.Size     = new System.Drawing.Size(338, 25);


                        //
                        // txtCC
                        //
                        TextBox txt = new TextBox();
                        txt.Location = new System.Drawing.Point(85, 1);
                        txt.Name     = "txt" + dr["PARAMS_NAME"].ToString();
                        txt.Size     = new System.Drawing.Size(250, 21);
                        txt.Tag      = dr["TARGET_COLNAME"].ToString(); //存放该列名称对应的detail表中的列名
                        txt.Text     = dtTempValue.Rows[0][dr["TARGET_COLNAME"].ToString()].ToString();
                        textBoxList.Add(txt);

                        String str    = txt.Tag.ToString().Substring(1, txt.Tag.ToString().Length - 1);
                        int    temMax = Convert.ToInt32(str);

                        if (maxcolumns < temMax)
                        {
                            maxcolumns = temMax;
                        }
                        //if (y == 10)
                        //{
                        //    txtFocus = txt;
                        //}
                        //
                        // lblCC
                        //
                        Label lbl = new Label();
                        lbl.AutoSize = true;
                        lbl.Location = new System.Drawing.Point(3, 5);
                        lbl.Name     = "lbl" + dr["PARAMS_NAME"].ToString();
                        lbl.Size     = new System.Drawing.Size(35, 12);
                        lbl.TabIndex = 2;
                        lbl.Text     = dr["PARAMS_NAME"].ToString() + ":";
                        labelList.Add(lbl);

                        pnl.Controls.Add(lbl);
                        pnl.Controls.Add(txt);
                        ctl.Controls.Add(pnl);
                        y += 25 + 5;
                    }
                }
            }
        }