Exemple #1
0
        public string Exec(HtnDataInfo p_info)
        {
            string _result = "OK";

            if (p_info == null)
            {
                return(_result);
            }

            string _sql = string.Empty;

            //Hashtable _ht = new Hashtable();
            foreach (DataRow _dr in _dt.Rows)
            {
                if (p_info.IsUpdate) //可更新
                {
                    _sql = p_info.IsRowExist(_dr) ? p_info.Update : p_info.Insert;
                }
                else if (!p_info.IsExist(_dr))
                {
                    _sql = p_info.Insert;
                }

                if (string.IsNullOrEmpty(_sql))
                {
                    continue;
                }

                //_ht.Add(_sql, GetParams(p_info, _dr));
                int r = HtnData.ExecNonQuery(_sql, GetParams(p_info, _dr));
            }

            //HtnData.ExecuteSqlTran(_ht);
            return(_result);
        }
Exemple #2
0
        /// <summary>
        /// 保存数据
        /// </summary>
        /// <param name="p_xml"></param>
        /// <returns></returns>
        public static string SaveData(string p_xml)
        {
            HtnSaveData _save = new HtnSaveData(p_xml);

            if (string.IsNullOrEmpty(_save.Key) || !_sqlinfo.ContainsKey(_save.Key))
            {
                return("No TableName");
            }

            HtnDataInfo _info = _sqlinfo[_save.Key];

            return(_save.Exec(_info));
        }
Exemple #3
0
        /// <summary>
        /// 获取参数
        /// </summary>
        /// <returns></returns>
        private List <OleDbParameter> GetParams(HtnDataInfo p_info, DataRow p_dr)
        {
            DataTable             _dt     = p_dr.Table;
            List <OleDbParameter> _params = new List <OleDbParameter>();

            for (int i = 0; i < _dt.Columns.Count; i++)
            {
                DataColumn _dc = _dt.Columns[i];
                _params.Add(new OleDbParameter()
                {
                    ParameterName = "V" + ((i + 1).ToString().PadLeft(3, '0')),
                    Value         = TrParamValue(p_dr.Str(_dc.ColumnName)),
                    DbType        = ConDbType(p_info.Model.Columns[_dc.ColumnName])
                });
            }

            return(_params);
        }