Пример #1
0
        /// <summary>
        /// 將Sql語法製作成DataTable 並且調整裡面的值
        /// </summary>
        /// <returns></returns>
        public DataTable Table_DataTable()
        {
            string sSql = "select top 10 mac_name,pro_name,pro_qty,MED07_0000.pro_unit,loc_code,ins_date,ins_time,usr_code " +
                          "  from MED07_0000" +
                          "   left join MEB15_0000 on MED07_0000.mac_code = MEB15_0000.mac_code " +
                          "   left join MEB20_0000 on MEB20_0000.pro_code = MED07_0000.pro_code " +
                          " where ins_date = @ins_date" +
                          "  order by ins_date desc,ins_time desc";
            var dtTmp = comm.Get_DataTable(sSql, "ins_date", DateTime.Now.ToString("yyyy/MM/dd"));

            for (int i = 0; i < dtTmp.Rows.Count; i++)
            {
                DataRow Row        = dtTmp.Rows[i];
                string  TableField = DT.Get_SqlField(dtTmp);
                for (int u = 0; u < TableField.Split(',').Length; u++)
                {
                    string sField = TableField.Split(',')[u]; //欄位
                    string sValue = Row[sField].ToString();   //欄位的值

                    switch (sField)
                    {
                    case "pro_qty":
                        Row[sField] = decimal.Parse(sValue).ToString("G29");
                        break;
                    }
                }
            }
            return(dtTmp);
        }