public string Update(string json, string columns, string clientInf)
        {
            Dictionary <string, string> resultDic = new Dictionary <string, string>();

            resultDic["result"]  = "";
            resultDic["message"] = "";
            try
            {
                sara.dd.ldsw.model.tbl_ld_xgsbdszb model = Eva.Library.Format.FormatEntityTool.FormatJsonToModel <sara.dd.ldsw.model.tbl_ld_xgsbdszb>(json);

                columns              = FormatColumns(columns).Replace("^", ",");
                resultDic["result"]  = "true";
                resultDic["message"] = _idal_tbl_ld_xgsbdszb.Update(model, columns, null);

                NewLog("数据更新成功,更新的数据为:json:" + json + ",columns:" + columns, "sql_update", clientInf);
            }
            catch (Exception ex)
            {
                resultDic["result"]  = "false";
                resultDic["message"] = Eva.Library.Format.FormatTextTool.ErrorMessageFormat(ex.Message + ex.StackTrace);

                NewLog("数据更新失败,更新的数据为:json:" + json + ",columns:" + columns + ",异常信息:" + Eva.Library.Format.FormatTextTool.ErrorMessageFormat(ex.Message + ex.StackTrace), "sql_update", clientInf);
            }
            return(Eva.Library.Format.FormatEntityTool.FormatDicToJson(resultDic));
        }
        public string Add(string json, string clientInf)
        {
            Dictionary <string, string> resultDic = new Dictionary <string, string>();

            resultDic["result"]  = "";
            resultDic["message"] = "";
            try
            {
                sara.dd.ldsw.model.tbl_ld_xgsbdszb model = Eva.Library.Format.FormatEntityTool.FormatJsonToModel <sara.dd.ldsw.model.tbl_ld_xgsbdszb>(json);
                resultDic["result"]  = "true";
                resultDic["message"] = _idal_tbl_ld_xgsbdszb.Add(model, null);

                NewLog("数据创建成功,创建的数据为:" + json, "sql_insert", clientInf);
            }
            catch (Exception ex)
            {
                resultDic["result"]  = "false";
                resultDic["message"] = Eva.Library.Format.FormatTextTool.ErrorMessageFormat(ex.Message + ex.StackTrace);
                NewLog("数据创建失败,创建的数据为:" + json + ",异常信息:" + Eva.Library.Format.FormatTextTool.ErrorMessageFormat(ex.Message + ex.StackTrace), "sql_insert", clientInf);
            }
            return(Eva.Library.Format.FormatEntityTool.FormatDicToJson(resultDic));
        }
Esempio n. 3
0
        /// <summary>
        /// 重写添加addlayerconfig
        /// </summary>
        /// <param name="json"></param>
        /// <param name="clientInf"></param>
        /// <returns></returns>
        public string Add(sara.dd.ldsw.model.tbl_ld_xgsbdszb model, Eva.Library.Data.AccessDataTrans.IAccessDataTrans t)
        {
            StringBuilder strSql     = new StringBuilder();
            StringBuilder strSql_use = new StringBuilder();
            StringBuilder strSql1    = new StringBuilder();
            StringBuilder strSql2    = new StringBuilder();
            StringBuilder strSql3    = new StringBuilder();

            if (Eva.Library.Configuration.ConfigurationManager.AppSettings["SqlEditMode"].ToString() == "parameter")
            {
            }
            else //如果是sql形式的话,则进行textFormat
            {
                model = Eva.Library.Format.FormatTextTool.ModelFormat(model);
            }
            List <OracleParameter> parameterList = new List <OracleParameter>();
            OracleParameter        parameter     = null;

            string sid = "";

            if (model.sys_id <= 0)
            {
                if (t == null)
                {
                    sid = GetMaxId(null).ToString();
                }
                else
                {
                    sid = GetMaxId(t).ToString();
                }
                model.sys_id = int.Parse(sid);
            }
            else
            {
                sid = model.sys_id.ToString();
            }

            #region sqlString
            strSql1.Append("sys_id,");
            strSql2.Append("'" + sid + "',");
            strSql3.Append(":sys_id,");
            parameter       = new OracleParameter(":sys_id", OracleType.Number);
            parameter.Value = sid;
            parameterList.Add(parameter);

            if (model.sys_orderid != null)
            {
                strSql1.Append("sys_orderid,");
                strSql2.Append("'" + (model.sys_orderid) + "',");
                strSql3.Append(":sys_orderid,");
                parameter       = new OracleParameter(":sys_orderid", OracleType.VarChar);
                parameter.Value = model.sys_orderid;
                parameterList.Add(parameter);
            }

            if (model.sys_creatuserid != null)
            {
                strSql1.Append("sys_creatuserid,");
                strSql2.Append("'" + (model.sys_creatuserid) + "',");
                strSql3.Append(":sys_creatuserid,");
                parameter       = new OracleParameter(":sys_creatuserid", OracleType.VarChar);
                parameter.Value = model.sys_creatuserid;
                parameterList.Add(parameter);
            }

            if (model.sys_creatusername != null)
            {
                strSql1.Append("sys_creatusername,");
                strSql2.Append("'" + (model.sys_creatusername) + "',");
                strSql3.Append(":sys_creatusername,");
                parameter       = new OracleParameter(":sys_creatusername", OracleType.VarChar);
                parameter.Value = model.sys_creatusername;
                parameterList.Add(parameter);
            }

            if (model.sys_creatdate != null)
            {
                strSql1.Append("sys_creatdate,");
                strSql2.Append("to_date('" + model.sys_creatdate.ToString("yyyy-MM-dd HH:mm:ss") + "','yyyy-MM-dd hh24:mi:ss'),");
                strSql3.Append(":sys_creatdate,");
                parameter       = new OracleParameter(":sys_creatdate", OracleType.DateTime);
                parameter.Value = model.sys_creatdate;
                parameterList.Add(parameter);
            }

            if (model.sys_lastedituserid != null)
            {
                strSql1.Append("sys_lastedituserid,");
                strSql2.Append("'" + (model.sys_lastedituserid) + "',");
                strSql3.Append(":sys_lastedituserid,");
                parameter       = new OracleParameter(":sys_lastedituserid", OracleType.VarChar);
                parameter.Value = model.sys_lastedituserid;
                parameterList.Add(parameter);
            }

            if (model.sys_lasteditusername != null)
            {
                strSql1.Append("sys_lasteditusername,");
                strSql2.Append("'" + (model.sys_lasteditusername) + "',");
                strSql3.Append(":sys_lasteditusername,");
                parameter       = new OracleParameter(":sys_lasteditusername", OracleType.VarChar);
                parameter.Value = model.sys_lasteditusername;
                parameterList.Add(parameter);
            }

            if (model.sys_lasteditdate != null)
            {
                strSql1.Append("sys_lasteditdate,");
                strSql2.Append("to_date('" + model.sys_lasteditdate.ToString("yyyy-MM-dd HH:mm:ss") + "','yyyy-MM-dd hh24:mi:ss'),");
                strSql3.Append(":sys_lasteditdate,");
                parameter       = new OracleParameter(":sys_lasteditdate", OracleType.DateTime);
                parameter.Value = model.sys_lasteditdate;
                parameterList.Add(parameter);
            }

            if (model.sys_deluserid != null)
            {
                strSql1.Append("sys_deluserid,");
                strSql2.Append("'" + (model.sys_deluserid) + "',");
                strSql3.Append(":sys_deluserid,");
                parameter       = new OracleParameter(":sys_deluserid", OracleType.VarChar);
                parameter.Value = model.sys_deluserid;
                parameterList.Add(parameter);
            }

            if (model.sys_delusername != null)
            {
                strSql1.Append("sys_delusername,");
                strSql2.Append("'" + (model.sys_delusername) + "',");
                strSql3.Append(":sys_delusername,");
                parameter       = new OracleParameter(":sys_delusername", OracleType.VarChar);
                parameter.Value = model.sys_delusername;
                parameterList.Add(parameter);
            }

            if (model.sys_deldate != null)
            {
                strSql1.Append("sys_deldate,");
                strSql2.Append("to_date('" + model.sys_deldate.ToString("yyyy-MM-dd HH:mm:ss") + "','yyyy-MM-dd hh24:mi:ss'),");
                strSql3.Append(":sys_deldate,");
                parameter       = new OracleParameter(":sys_deldate", OracleType.DateTime);
                parameter.Value = model.sys_deldate;
                parameterList.Add(parameter);
            }

            if (model.sys_delflag != null)
            {
                strSql1.Append("sys_delflag,");
                strSql2.Append("'" + (model.sys_delflag) + "',");
                strSql3.Append(":sys_delflag,");
                parameter       = new OracleParameter(":sys_delflag", OracleType.VarChar);
                parameter.Value = model.sys_delflag;
                parameterList.Add(parameter);
            }

            if (model.f_value1 != null)
            {
                strSql1.Append("f_value1,");
                strSql2.Append("'" + (model.f_value1) + "',");
                strSql3.Append(":f_value1,");
                parameter       = new OracleParameter(":f_value1", OracleType.VarChar);
                parameter.Value = model.f_value1;
                parameterList.Add(parameter);
            }

            if (model.f_value2 != null)
            {
                strSql1.Append("f_value2,");
                strSql2.Append("'" + (model.f_value2) + "',");
                strSql3.Append(":f_value2,");
                parameter       = new OracleParameter(":f_value2", OracleType.VarChar);
                parameter.Value = model.f_value2;
                parameterList.Add(parameter);
            }

            if (model.f_value3 != null)
            {
                strSql1.Append("f_value3,");
                strSql2.Append("'" + (model.f_value3) + "',");
                strSql3.Append(":f_value3,");
                parameter       = new OracleParameter(":f_value3", OracleType.VarChar);
                parameter.Value = model.f_value3;
                parameterList.Add(parameter);
            }

            if (model.f_value4 != null)
            {
                strSql1.Append("f_value4,");
                strSql2.Append("'" + (model.f_value4) + "',");
                strSql3.Append(":f_value4,");
                parameter       = new OracleParameter(":f_value4", OracleType.VarChar);
                parameter.Value = model.f_value4;
                parameterList.Add(parameter);
            }

            if (model.f_value5 != null)
            {
                strSql1.Append("f_value5,");
                strSql2.Append("'" + (model.f_value5) + "',");
                strSql3.Append(":f_value5,");
                parameter       = new OracleParameter(":f_value5", OracleType.VarChar);
                parameter.Value = model.f_value5;
                parameterList.Add(parameter);
            }

            if (model.f_value6 != null)
            {
                strSql1.Append("f_value6,");
                strSql2.Append("'" + (model.f_value6) + "',");
                strSql3.Append(":f_value6,");
                parameter       = new OracleParameter(":f_value6", OracleType.VarChar);
                parameter.Value = model.f_value6;
                parameterList.Add(parameter);
            }

            if (model.f_value7 != null)
            {
                strSql1.Append("f_value7,");
                strSql2.Append("'" + (model.f_value7) + "',");
                strSql3.Append(":f_value7,");
                parameter       = new OracleParameter(":f_value7", OracleType.VarChar);
                parameter.Value = model.f_value7;
                parameterList.Add(parameter);
            }

            if (model.f_value8 != null)
            {
                strSql1.Append("f_value8,");
                strSql2.Append("'" + (model.f_value8) + "',");
                strSql3.Append(":f_value8,");
                parameter       = new OracleParameter(":f_value8", OracleType.VarChar);
                parameter.Value = model.f_value8;
                parameterList.Add(parameter);
            }

            if (model.f_value9 != null)
            {
                strSql1.Append("f_value9,");
                strSql2.Append("'" + (model.f_value9) + "',");
                strSql3.Append(":f_value9,");
                parameter       = new OracleParameter(":f_value9", OracleType.VarChar);
                parameter.Value = model.f_value9;
                parameterList.Add(parameter);
            }

            if (model.f_value10 != null)
            {
                strSql1.Append("f_value10,");
                strSql2.Append("'" + (model.f_value10) + "',");
                strSql3.Append(":f_value10,");
                parameter       = new OracleParameter(":f_value10", OracleType.VarChar);
                parameter.Value = model.f_value10;
                parameterList.Add(parameter);
            }

            if (model.f_khbh != null)
            {
                strSql1.Append("f_khbh,");
                strSql2.Append("'" + (model.f_khbh) + "',");
                strSql3.Append(":f_khbh,");
                parameter       = new OracleParameter(":f_khbh", OracleType.VarChar);
                parameter.Value = model.f_khbh;
                parameterList.Add(parameter);
            }

            if (model.f_yhm != null)
            {
                strSql1.Append("f_yhm,");
                strSql2.Append("'" + (model.f_yhm) + "',");
                strSql3.Append(":f_yhm,");
                parameter       = new OracleParameter(":f_yhm", OracleType.VarChar);
                parameter.Value = model.f_yhm;
                parameterList.Add(parameter);
            }

            if (model.f_dz != null)
            {
                strSql1.Append("f_dz,");
                strSql2.Append("'" + (model.f_dz) + "',");
                strSql3.Append(":f_dz,");
                parameter       = new OracleParameter(":f_dz", OracleType.VarChar);
                parameter.Value = model.f_dz;
                parameterList.Add(parameter);
            }

            if (model.f_dh != null)
            {
                strSql1.Append("f_dh,");
                strSql2.Append("'" + (model.f_dh) + "',");
                strSql3.Append(":f_dh,");
                parameter       = new OracleParameter(":f_dh", OracleType.VarChar);
                parameter.Value = model.f_dh;
                parameterList.Add(parameter);
            }

            if (model.f_ysbds != null)
            {
                strSql1.Append("f_ysbds,");
                strSql2.Append("'" + (model.f_ysbds) + "',");
                strSql3.Append(":f_ysbds,");
                parameter       = new OracleParameter(":f_ysbds", OracleType.VarChar);
                parameter.Value = model.f_ysbds;
                parameterList.Add(parameter);
            }

            if (model.f_xsbds != null)
            {
                strSql1.Append("f_xsbds,");
                strSql2.Append("'" + (model.f_xsbds) + "',");
                strSql3.Append(":f_xsbds,");
                parameter       = new OracleParameter(":f_xsbds", OracleType.VarChar);
                parameter.Value = model.f_xsbds;
                parameterList.Add(parameter);
            }

            if (model.f_sbbh != null)
            {
                strSql1.Append("f_sbbh,");
                strSql2.Append("'" + (model.f_sbbh) + "',");
                strSql3.Append(":f_sbbh,");
                parameter       = new OracleParameter(":f_sbbh", OracleType.VarChar);
                parameter.Value = model.f_sbbh;
                parameterList.Add(parameter);
            }

            if (model.fk_tbl_ld_xgsbds_sys_id != null)
            {
                strSql1.Append("fk_tbl_ld_xgsbds_sys_id,");
                strSql2.Append("'" + (model.fk_tbl_ld_xgsbds_sys_id) + "',");
                strSql3.Append(":fk_tbl_ld_xgsbds_sys_id,");
                parameter       = new OracleParameter(":fk_tbl_ld_xgsbds_sys_id", OracleType.VarChar);
                parameter.Value = model.fk_tbl_ld_xgsbds_sys_id;
                parameterList.Add(parameter);
            }

            strSql.Append("insert into tbl_ld_xgsbdszb(");
            strSql.Append(strSql1.ToString().Remove(strSql1.Length - 1));
            strSql.Append(")");
            strSql.Append(" values (");
            strSql.Append(strSql2.ToString().Remove(strSql2.Length - 1));
            strSql.Append(")");

            strSql_use.Append("insert into tbl_ld_xgsbdszb(");
            strSql_use.Append(strSql1.ToString().Remove(strSql1.Length - 1));
            strSql_use.Append(")");
            strSql_use.Append(" values (");
            strSql_use.Append(strSql3.ToString().Remove(strSql3.Length - 1));
            strSql_use.Append(")");

            #endregion
            if (Eva.Library.Configuration.ConfigurationManager.AppSettings["SqlEditMode"].ToString() == "parameter")
            {
                #region parameter
                if (parameterList.Count > 0)
                {
                    if (t == null)
                    {
                        _iAccessData.ExecuteSql(strSql_use.ToString(), parameterList.ToArray());
                    }
                    else
                    {
                        t.ExecuteSql(strSql_use.ToString(), parameterList.ToArray());
                    }
                }
                #endregion
            }
            else
            {
                #region sql
                if (t == null)
                {
                    _iAccessData.ExecuteSql(strSql.ToString());
                }
                else
                {
                    t.ExecuteSql(strSql.ToString());
                }
                List <string>          paraStrList = new List <string>();
                List <OracleParameter> pList       = new List <OracleParameter>();
                OracleParameter        p           = null;



                if (paraStrList.Count > 0)
                {
                    string updateSqlString = " update tbl_ld_xgsbdszb set " + string.Join(" , ", paraStrList.ToArray()) + " where sys_id = '" + sid + "' ";
                    if (pList.Count > 0)
                    {
                        if (t == null)
                        {
                            _iAccessData.ExecuteSql(updateSqlString, pList.ToArray());
                        }
                        else
                        {
                            t.ExecuteSql(updateSqlString, pList.ToArray());
                        }
                    }
                }
                #endregion
            }


            return(sid);
        }
Esempio n. 4
0
        /// <summary>
        /// 重写更新updatepaper
        /// </summary>
        /// <param name="json"></param>
        /// <param name="columns"></param>
        /// <param name="clientInf"></param>
        /// <returns></returns>
        public string Update(sara.dd.ldsw.model.tbl_ld_xgsbdszb model, string columns, Eva.Library.Data.AccessDataTrans.IAccessDataTrans t)
        {
            String[]               columnsArray  = columns.Split(',');
            List <string>          columsList    = new List <string>(columnsArray);
            List <OracleParameter> parameterList = new List <OracleParameter>();
            OracleParameter        parameter     = null;

            #region sqlString
            StringBuilder strSql     = new StringBuilder();
            StringBuilder strSql_use = new StringBuilder();
            strSql.Append("update tbl_ld_xgsbdszb set ");
            strSql_use.Append("update tbl_ld_xgsbdszb set ");
            if (Eva.Library.Configuration.ConfigurationManager.AppSettings["SqlEditMode"].ToString() == "parameter")
            {
            }
            else //如果是sql形式的话,则进行textReturn
            {
                model = Eva.Library.Format.FormatTextTool.ModelFormat(model);
            }


            if (model.sys_orderid != null && columsList.Contains("sys_orderid"))
            {
                strSql.Append("sys_orderid='" + (model.sys_orderid) + "',");
                strSql_use.Append("sys_orderid=:sys_orderid,");
                parameter       = new OracleParameter(":sys_orderid", OracleType.VarChar);
                parameter.Value = model.sys_orderid;
                parameterList.Add(parameter);
            }

            if (model.sys_creatuserid != null && columsList.Contains("sys_creatuserid"))
            {
                strSql.Append("sys_creatuserid='" + (model.sys_creatuserid) + "',");
                strSql_use.Append("sys_creatuserid=:sys_creatuserid,");
                parameter       = new OracleParameter(":sys_creatuserid", OracleType.VarChar);
                parameter.Value = model.sys_creatuserid;
                parameterList.Add(parameter);
            }

            if (model.sys_creatusername != null && columsList.Contains("sys_creatusername"))
            {
                strSql.Append("sys_creatusername='******',");
                strSql_use.Append("sys_creatusername=:sys_creatusername,");
                parameter       = new OracleParameter(":sys_creatusername", OracleType.VarChar);
                parameter.Value = model.sys_creatusername;
                parameterList.Add(parameter);
            }

            if (model.sys_creatdate != null && columsList.Contains("sys_creatdate"))
            {
                strSql.Append("sys_creatdate=to_date('" + model.sys_creatdate.ToString("yyyy-MM-dd HH:mm:ss") + "','yyyy-MM-dd hh24:mi:ss'),");
                strSql_use.Append("sys_creatdate=:sys_creatdate,");
                parameter       = new OracleParameter(":sys_creatdate", OracleType.DateTime);
                parameter.Value = model.sys_creatdate;
                parameterList.Add(parameter);
            }

            if (model.sys_lastedituserid != null && columsList.Contains("sys_lastedituserid"))
            {
                strSql.Append("sys_lastedituserid='" + (model.sys_lastedituserid) + "',");
                strSql_use.Append("sys_lastedituserid=:sys_lastedituserid,");
                parameter       = new OracleParameter(":sys_lastedituserid", OracleType.VarChar);
                parameter.Value = model.sys_lastedituserid;
                parameterList.Add(parameter);
            }

            if (model.sys_lasteditusername != null && columsList.Contains("sys_lasteditusername"))
            {
                strSql.Append("sys_lasteditusername='******',");
                strSql_use.Append("sys_lasteditusername=:sys_lasteditusername,");
                parameter       = new OracleParameter(":sys_lasteditusername", OracleType.VarChar);
                parameter.Value = model.sys_lasteditusername;
                parameterList.Add(parameter);
            }

            if (model.sys_lasteditdate != null && columsList.Contains("sys_lasteditdate"))
            {
                strSql.Append("sys_lasteditdate=to_date('" + model.sys_lasteditdate.ToString("yyyy-MM-dd HH:mm:ss") + "','yyyy-MM-dd hh24:mi:ss'),");
                strSql_use.Append("sys_lasteditdate=:sys_lasteditdate,");
                parameter       = new OracleParameter(":sys_lasteditdate", OracleType.DateTime);
                parameter.Value = model.sys_lasteditdate;
                parameterList.Add(parameter);
            }

            if (model.sys_deluserid != null && columsList.Contains("sys_deluserid"))
            {
                strSql.Append("sys_deluserid='" + (model.sys_deluserid) + "',");
                strSql_use.Append("sys_deluserid=:sys_deluserid,");
                parameter       = new OracleParameter(":sys_deluserid", OracleType.VarChar);
                parameter.Value = model.sys_deluserid;
                parameterList.Add(parameter);
            }

            if (model.sys_delusername != null && columsList.Contains("sys_delusername"))
            {
                strSql.Append("sys_delusername='******',");
                strSql_use.Append("sys_delusername=:sys_delusername,");
                parameter       = new OracleParameter(":sys_delusername", OracleType.VarChar);
                parameter.Value = model.sys_delusername;
                parameterList.Add(parameter);
            }

            if (model.sys_deldate != null && columsList.Contains("sys_deldate"))
            {
                strSql.Append("sys_deldate=to_date('" + model.sys_deldate.ToString("yyyy-MM-dd HH:mm:ss") + "','yyyy-MM-dd hh24:mi:ss'),");
                strSql_use.Append("sys_deldate=:sys_deldate,");
                parameter       = new OracleParameter(":sys_deldate", OracleType.DateTime);
                parameter.Value = model.sys_deldate;
                parameterList.Add(parameter);
            }

            if (model.sys_delflag != null && columsList.Contains("sys_delflag"))
            {
                strSql.Append("sys_delflag='" + (model.sys_delflag) + "',");
                strSql_use.Append("sys_delflag=:sys_delflag,");
                parameter       = new OracleParameter(":sys_delflag", OracleType.VarChar);
                parameter.Value = model.sys_delflag;
                parameterList.Add(parameter);
            }

            if (model.f_value1 != null && columsList.Contains("f_value1"))
            {
                strSql.Append("f_value1='" + (model.f_value1) + "',");
                strSql_use.Append("f_value1=:f_value1,");
                parameter       = new OracleParameter(":f_value1", OracleType.VarChar);
                parameter.Value = model.f_value1;
                parameterList.Add(parameter);
            }

            if (model.f_value2 != null && columsList.Contains("f_value2"))
            {
                strSql.Append("f_value2='" + (model.f_value2) + "',");
                strSql_use.Append("f_value2=:f_value2,");
                parameter       = new OracleParameter(":f_value2", OracleType.VarChar);
                parameter.Value = model.f_value2;
                parameterList.Add(parameter);
            }

            if (model.f_value3 != null && columsList.Contains("f_value3"))
            {
                strSql.Append("f_value3='" + (model.f_value3) + "',");
                strSql_use.Append("f_value3=:f_value3,");
                parameter       = new OracleParameter(":f_value3", OracleType.VarChar);
                parameter.Value = model.f_value3;
                parameterList.Add(parameter);
            }

            if (model.f_value4 != null && columsList.Contains("f_value4"))
            {
                strSql.Append("f_value4='" + (model.f_value4) + "',");
                strSql_use.Append("f_value4=:f_value4,");
                parameter       = new OracleParameter(":f_value4", OracleType.VarChar);
                parameter.Value = model.f_value4;
                parameterList.Add(parameter);
            }

            if (model.f_value5 != null && columsList.Contains("f_value5"))
            {
                strSql.Append("f_value5='" + (model.f_value5) + "',");
                strSql_use.Append("f_value5=:f_value5,");
                parameter       = new OracleParameter(":f_value5", OracleType.VarChar);
                parameter.Value = model.f_value5;
                parameterList.Add(parameter);
            }

            if (model.f_value6 != null && columsList.Contains("f_value6"))
            {
                strSql.Append("f_value6='" + (model.f_value6) + "',");
                strSql_use.Append("f_value6=:f_value6,");
                parameter       = new OracleParameter(":f_value6", OracleType.VarChar);
                parameter.Value = model.f_value6;
                parameterList.Add(parameter);
            }

            if (model.f_value7 != null && columsList.Contains("f_value7"))
            {
                strSql.Append("f_value7='" + (model.f_value7) + "',");
                strSql_use.Append("f_value7=:f_value7,");
                parameter       = new OracleParameter(":f_value7", OracleType.VarChar);
                parameter.Value = model.f_value7;
                parameterList.Add(parameter);
            }

            if (model.f_value8 != null && columsList.Contains("f_value8"))
            {
                strSql.Append("f_value8='" + (model.f_value8) + "',");
                strSql_use.Append("f_value8=:f_value8,");
                parameter       = new OracleParameter(":f_value8", OracleType.VarChar);
                parameter.Value = model.f_value8;
                parameterList.Add(parameter);
            }

            if (model.f_value9 != null && columsList.Contains("f_value9"))
            {
                strSql.Append("f_value9='" + (model.f_value9) + "',");
                strSql_use.Append("f_value9=:f_value9,");
                parameter       = new OracleParameter(":f_value9", OracleType.VarChar);
                parameter.Value = model.f_value9;
                parameterList.Add(parameter);
            }

            if (model.f_value10 != null && columsList.Contains("f_value10"))
            {
                strSql.Append("f_value10='" + (model.f_value10) + "',");
                strSql_use.Append("f_value10=:f_value10,");
                parameter       = new OracleParameter(":f_value10", OracleType.VarChar);
                parameter.Value = model.f_value10;
                parameterList.Add(parameter);
            }

            if (model.f_khbh != null && columsList.Contains("f_khbh"))
            {
                strSql.Append("f_khbh='" + (model.f_khbh) + "',");
                strSql_use.Append("f_khbh=:f_khbh,");
                parameter       = new OracleParameter(":f_khbh", OracleType.VarChar);
                parameter.Value = model.f_khbh;
                parameterList.Add(parameter);
            }

            if (model.f_yhm != null && columsList.Contains("f_yhm"))
            {
                strSql.Append("f_yhm='" + (model.f_yhm) + "',");
                strSql_use.Append("f_yhm=:f_yhm,");
                parameter       = new OracleParameter(":f_yhm", OracleType.VarChar);
                parameter.Value = model.f_yhm;
                parameterList.Add(parameter);
            }

            if (model.f_dz != null && columsList.Contains("f_dz"))
            {
                strSql.Append("f_dz='" + (model.f_dz) + "',");
                strSql_use.Append("f_dz=:f_dz,");
                parameter       = new OracleParameter(":f_dz", OracleType.VarChar);
                parameter.Value = model.f_dz;
                parameterList.Add(parameter);
            }

            if (model.f_dh != null && columsList.Contains("f_dh"))
            {
                strSql.Append("f_dh='" + (model.f_dh) + "',");
                strSql_use.Append("f_dh=:f_dh,");
                parameter       = new OracleParameter(":f_dh", OracleType.VarChar);
                parameter.Value = model.f_dh;
                parameterList.Add(parameter);
            }

            if (model.f_ysbds != null && columsList.Contains("f_ysbds"))
            {
                strSql.Append("f_ysbds='" + (model.f_ysbds) + "',");
                strSql_use.Append("f_ysbds=:f_ysbds,");
                parameter       = new OracleParameter(":f_ysbds", OracleType.VarChar);
                parameter.Value = model.f_ysbds;
                parameterList.Add(parameter);
            }

            if (model.f_xsbds != null && columsList.Contains("f_xsbds"))
            {
                strSql.Append("f_xsbds='" + (model.f_xsbds) + "',");
                strSql_use.Append("f_xsbds=:f_xsbds,");
                parameter       = new OracleParameter(":f_xsbds", OracleType.VarChar);
                parameter.Value = model.f_xsbds;
                parameterList.Add(parameter);
            }

            if (model.f_sbbh != null && columsList.Contains("f_sbbh"))
            {
                strSql.Append("f_sbbh='" + (model.f_sbbh) + "',");
                strSql_use.Append("f_sbbh=:f_sbbh,");
                parameter       = new OracleParameter(":f_sbbh", OracleType.VarChar);
                parameter.Value = model.f_sbbh;
                parameterList.Add(parameter);
            }

            if (model.fk_tbl_ld_xgsbds_sys_id != null && columsList.Contains("fk_tbl_ld_xgsbds_sys_id"))
            {
                strSql.Append("fk_tbl_ld_xgsbds_sys_id='" + (model.fk_tbl_ld_xgsbds_sys_id) + "',");
                strSql_use.Append("fk_tbl_ld_xgsbds_sys_id=:fk_tbl_ld_xgsbds_sys_id,");
                parameter       = new OracleParameter(":fk_tbl_ld_xgsbds_sys_id", OracleType.VarChar);
                parameter.Value = model.fk_tbl_ld_xgsbds_sys_id;
                parameterList.Add(parameter);
            }

            int n = strSql.ToString().LastIndexOf(",");
            strSql.Remove(n, 1);
            strSql.Append(" where sys_id='" + model.sys_id + "'");

            n = strSql_use.ToString().LastIndexOf(",");
            strSql_use.Remove(n, 1);
            strSql_use.Append(" where sys_id='" + model.sys_id + "'");
            #endregion
            int columscount = 0;
            if (Eva.Library.Configuration.ConfigurationManager.AppSettings["SqlEditMode"].ToString() == "parameter")
            {
                #region parameter
                if (parameterList.Count > 0)
                {
                    if (t == null)
                    {
                        columscount = _iAccessData.ExecuteSql(strSql_use.ToString(), parameterList.ToArray());
                    }
                    else
                    {
                        columscount = t.ExecuteSql(strSql_use.ToString(), parameterList.ToArray());
                    }
                }
                #endregion
            }
            else
            {
                #region sql
                if (t == null)
                {
                    columscount = _iAccessData.ExecuteSql(strSql.ToString());
                }
                else
                {
                    columscount = t.ExecuteSql(strSql.ToString());
                }
                #endregion
            }
            return(columscount.ToString());
        }
        public string Analysis(string json, string columns, string clientInf, string czlx)
        {
            //首先保存数据

            Dictionary <string, string> resultDic = new Dictionary <string, string>();

            resultDic["result"]  = "";
            resultDic["message"] = "";
            try
            {
                _t = sara.dd.ldsw.commonclass.commonclass.CreateIAccessDataTrans();
                _t.getTrans().begin();
                sara.dd.ldsw.model.tbl_ld_xgsbds model = Eva.Library.Format.FormatEntityTool.FormatJsonToModel <sara.dd.ldsw.model.tbl_ld_xgsbds>(json);
                //获取附件根路径
                string FileUpLoadRootPath = Eva.Library.Configuration.ConfigurationManager.AppSettings["FileUpLoadRootPath"].ToString() + "fileuploadpath/";
                FileUpLoadRootPath = Eva.Library.Format.FormatTextTool.GetMapPath(FileUpLoadRootPath, HttpContext.Current.Server);

                //获取附件名称
                //_iAccessData = sara.dd.ldsw.commonclass.commonclass.CreateIAccessData();
                string sqlString = "";
                string sql       = "";

                sqlString = "SELECT fileuploadname FROM tbl_file_content WHERE menuid='" + model.f_drwj + "'";
                DataTable dt = _t.Query(sqlString).Tables[0];

                //判断是否上传附件
                if (dt.Rows.Count > 0 && dt.Rows[0]["fileuploadname"] != null && dt.Rows[0]["fileuploadname"].ToString().Length > 0)
                {
                    DataTable importfile = commonclass.commonclass.ReadExcel(FileUpLoadRootPath + dt.Rows[0]["fileuploadname"].ToString()).Tables[0];

                    //判断是否为正确的导入模板
                    if (importfile.Columns[0].ColumnName == "客户编号" && importfile.Columns[1].ColumnName == "新水表底数")
                    {
                        sqlString = "DELETE FROM tbl_ld_xgsbdszb WHERE fk_tbl_ld_xgsbds_sys_id='" + model.sys_id + "'";
                        string aa = _t.ExecuteSql(sqlString).ToString();
                        //创建子表对象list

                        DateTimeFormatInfo dtFormat = new DateTimeFormatInfo();

                        dtFormat.ShortDatePattern = "yyyy/MM/dd";

                        IDictionary <String, String> userInfDic = Eva.Library.Format.FormatEntityTool.FormatJsonToDic(clientInf);

                        System.DateTime currentTime = new System.DateTime();
                        currentTime = System.DateTime.Now;

                        DateTime blankTime = Convert.ToDateTime("1900/01/01", dtFormat);
                        #region 循环Excel实例化子表对象
                        for (int i = 0; i < importfile.Rows.Count; i++)
                        {
                            DataRow dr = importfile.Rows[i];
                            if (dr[0].ToString() == "" || dr[1].ToString() == "")
                            {
                                resultDic["result"]  = "false";
                                resultDic["message"] = "客户编号或新水表底数未填写,请重新确认!";
                            }
                            else
                            {
                                sara.dd.ldsw.model.tbl_ld_khb model_tbl_ld_khb = new sara.dd.ldsw.model.tbl_ld_khb();
                                string khbh = dr[0].ToString().PadLeft(10, '0');
                                IList <sara.dd.ldsw.model.tbl_ld_khb> ml = _idal_tbl_ld_khb.GetList(" f_khbh = '" + khbh + "'and f_value1 is null and f_value2 is null and f_ztid='0' ", "", "*", "", "", _t);
                                if (ml.Count > 0)
                                {
                                    sara.dd.ldsw.model.tbl_ld_khb khmodel = ml[0];
                                    //创建子表实例化对象
                                    sara.dd.ldsw.model.tbl_ld_xgsbdszb tempmodel = new sara.dd.ldsw.model.tbl_ld_xgsbdszb();
                                    tempmodel.sys_id = 0;
                                    tempmodel.fk_tbl_ld_xgsbds_sys_id = model.sys_id.ToString();
                                    tempmodel.sys_creatuserid         = userInfDic["userid"].ToString();
                                    tempmodel.sys_creatusername       = userInfDic["username"].ToString();
                                    tempmodel.sys_lastedituserid      = userInfDic["userid"].ToString();
                                    tempmodel.sys_lasteditusername    = userInfDic["username"].ToString();
                                    tempmodel.sys_creatdate           = currentTime;
                                    tempmodel.sys_lasteditdate        = currentTime;
                                    tempmodel.sys_deldate             = blankTime;
                                    tempmodel.sys_delflag             = "0";
                                    #region 对象赋值
                                    tempmodel.f_khbh  = khbh;
                                    tempmodel.f_xsbds = dr[1].ToString();
                                    tempmodel.f_dh    = khmodel.f_dh;
                                    tempmodel.f_dz    = khmodel.f_dz;
                                    tempmodel.f_yhm   = khmodel.f_yhm;
                                    tempmodel.f_sbbh  = khmodel.f_sbbh;
                                    tempmodel.f_ysbds = khmodel.f_bqzm;
                                    string sys_id = _idal_tbl_ld_xgsbdszb.Add(tempmodel, _t);
                                    #endregion
                                    sql = "update tbl_ld_khb set f_value1='" + czlx + "',f_value2 = '" + model.sys_id + "' where sys_id = '" + model_tbl_ld_khb.sys_id + "'";
                                    _t.ExecuteSql(sql);
                                }
                                #endregion
                            }
                        }
                        _t.getTrans().commit();
                        string result1 = this.Update(json, columns, clientInf);
                        resultDic["result"]  = "true";
                        resultDic["message"] = result1;
                    }

                    else
                    {
                        resultDic["result"]  = "false";
                        resultDic["message"] = "导入模板错误,请下载正确的导入模板进行导入!";
                    }
                }
                else
                {
                    resultDic["result"]  = "false";
                    resultDic["message"] = "请先上传导入文件再进行分析!";
                }

                NewLog("数据更新成功,更新的数据为:json:" + json + ",columns:" + columns, "sql_update", clientInf);
            }
            catch (Exception ex)
            {
                if (_t != null)
                {
                    _t.getTrans().rollback();
                }
                resultDic["result"]  = "false";
                resultDic["message"] = Eva.Library.Format.FormatTextTool.ErrorMessageFormat(ex.Message + ex.StackTrace);

                NewLog("数据更新失败,更新的数据为:json:" + json + ",columns:" + columns + ",异常信息:" + Eva.Library.Format.FormatTextTool.ErrorMessageFormat(ex.Message + ex.StackTrace), "sql_update", clientInf);
            }
            return(Eva.Library.Format.FormatEntityTool.FormatDicToJson(resultDic));
        }