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_xhhbtzb model = Eva.Library.Format.FormatEntityTool.FormatJsonToModel <sara.dd.ldsw.model.tbl_ld_xhhbtzb>(json);

                columns              = FormatColumns(columns).Replace("^", ",");
                resultDic["result"]  = "true";
                resultDic["message"] = _idal_tbl_ld_xhhbtzb.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 Delete(string whereString, string clientInf)
        {
            Dictionary <string, string> resultDic = new Dictionary <string, string>();

            resultDic["result"]  = "";
            resultDic["message"] = "";
            try
            {
                //删除附件的功能
                string fileIDs       = "";
                string columnsString = "";

                columnsString += "f_khjsonid,";

                columnsString += "f_fj,";

                columnsString = columnsString.TrimEnd(',');
                List <sara.dd.ldsw.model.tbl_ld_xhhbtzb> l_tbl_ld_xhhbtzb = _idal_tbl_ld_xhhbtzb.GetList(whereString, "", columnsString, "", "", null);
                foreach (sara.dd.ldsw.model.tbl_ld_xhhbtzb model in l_tbl_ld_xhhbtzb)
                {
                    fileIDs += model.f_khjsonid + ",";

                    fileIDs += model.f_fj + ",";
                }
                fileIDs           = fileIDs.TrimEnd(',');
                _iAccessDataTrans = sara.dd.ldsw.commonclass.commonclass.CreateIAccessDataTrans();
                _iAccessDataTrans.getTrans().begin();
                sara.dd.ldsw.model.tbl_ld_xhhbtzb model_tbl_ld_xhhbtzb = new sara.dd.ldsw.model.tbl_ld_xhhbtzb();
                model_tbl_ld_xhhbtzb = _idal_tbl_ld_xhhbtzb.GetList(whereString, "", "*", "", "", null)[0];
                if (model_tbl_ld_xhhbtzb.f_khbhid != "" && model_tbl_ld_xhhbtzb.f_khbhid != null)
                {
                    string sql = " update tbl_ld_khb set f_value1 ='',f_value2 ='' where sys_id = '" + model_tbl_ld_xhhbtzb.f_khbhid + "'";
                    _iAccessDataTrans.ExecuteSql(sql);
                }
                sara.dd.ldsw.commonclass.filecontrol.deleteByFileName(fileIDs, null);

                //删除子表的方法

                //加入删除子表附件文件的方法

                resultDic["result"]  = "true";
                resultDic["message"] = _idal_tbl_ld_xhhbtzb.Delete(whereString, null);
                _iAccessDataTrans.getTrans().commit();
                NewLog("数据删除成功,删除的数据条件为:" + whereString, "sql_delete", clientInf);
            }
            catch (Exception ex)
            {
                if (_iAccessDataTrans != null)
                {
                    _iAccessDataTrans.getTrans().rollback();
                }
                resultDic["result"]  = "false";
                resultDic["message"] = Eva.Library.Format.FormatTextTool.ErrorMessageFormat(ex.Message + ex.StackTrace);

                NewLog("数据删除失败,删除的数据条件为:" + whereString + ",异常信息:" + Eva.Library.Format.FormatTextTool.ErrorMessageFormat(ex.Message + ex.StackTrace), "sql_delete", 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_xhhbtzb model = Eva.Library.Format.FormatEntityTool.FormatJsonToModel <sara.dd.ldsw.model.tbl_ld_xhhbtzb>(json);
                resultDic["result"]  = "true";
                resultDic["message"] = _idal_tbl_ld_xhhbtzb.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));
        }
Exemple #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_xhhbtzb 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_xhhbtzb set ");
            strSql_use.Append("update tbl_ld_xhhbtzb 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.fk_tbl_ld_xhhbt_sys_id != null && columsList.Contains("fk_tbl_ld_xhhbt_sys_id"))
            {
                strSql.Append("fk_tbl_ld_xhhbt_sys_id='" + (model.fk_tbl_ld_xhhbt_sys_id) + "',");
                strSql_use.Append("fk_tbl_ld_xhhbt_sys_id=:fk_tbl_ld_xhhbt_sys_id,");
                parameter       = new OracleParameter(":fk_tbl_ld_xhhbt_sys_id", OracleType.VarChar);
                parameter.Value = model.fk_tbl_ld_xhhbt_sys_id;
                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_khbhid != null && columsList.Contains("f_khbhid"))
            {
                strSql.Append("f_khbhid='" + (model.f_khbhid) + "',");
                strSql_use.Append("f_khbhid=:f_khbhid,");
                parameter       = new OracleParameter(":f_khbhid", OracleType.VarChar);
                parameter.Value = model.f_khbhid;
                parameterList.Add(parameter);
            }

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

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

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

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

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

            if (model.f_bz != null && columsList.Contains("f_bz"))
            {
                strSql.Append("f_bz='" + (model.f_bz) + "',");
                strSql_use.Append("f_bz=:f_bz,");
                parameter       = new OracleParameter(":f_bz", OracleType.VarChar);
                parameter.Value = model.f_bz;
                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());
                }
                List <string>          paraStrList = new List <string>();
                List <OracleParameter> pList       = new List <OracleParameter>();
                OracleParameter        p           = null;



                if (columsList.Contains("f_khjson"))
                {
                    if (model.f_khjson != null && model.f_khjson.Length > 0)
                    {
                        p       = new OracleParameter(":f_khjson", OracleType.Clob);
                        p.Value = (model.f_khjson);
                        pList.Add(p);
                        paraStrList.Add(" f_khjson = :f_khjson ");
                    }
                    else
                    {
                        paraStrList.Add(" f_khjson = null ");
                    }
                }



                if (paraStrList.Count > 0)
                {
                    string updateSqlString = " update tbl_ld_xhhbtzb set " + string.Join(" , ", paraStrList.ToArray()) + " where sys_id = '" + model.sys_id + "' ";
                    if (pList.Count > 0)
                    {
                        if (t == null)
                        {
                            columscount = _iAccessData.ExecuteSql(updateSqlString, pList.ToArray());
                        }
                        else
                        {
                            columscount = t.ExecuteSql(updateSqlString, pList.ToArray());
                        }
                    }
                }
                #endregion
            }
            return(columscount.ToString());
        }
Exemple #5
0
        /// <summary>
        /// 重写添加addlayerconfig
        /// </summary>
        /// <param name="json"></param>
        /// <param name="clientInf"></param>
        /// <returns></returns>
        public string Add(sara.dd.ldsw.model.tbl_ld_xhhbtzb 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.fk_tbl_ld_xhhbt_sys_id != null)
            {
                strSql1.Append("fk_tbl_ld_xhhbt_sys_id,");
                strSql2.Append("'" + (model.fk_tbl_ld_xhhbt_sys_id) + "',");
                strSql3.Append(":fk_tbl_ld_xhhbt_sys_id,");
                parameter       = new OracleParameter(":fk_tbl_ld_xhhbt_sys_id", OracleType.VarChar);
                parameter.Value = model.fk_tbl_ld_xhhbt_sys_id;
                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_khbhid != null)
            {
                strSql1.Append("f_khbhid,");
                strSql2.Append("'" + (model.f_khbhid) + "',");
                strSql3.Append(":f_khbhid,");
                parameter       = new OracleParameter(":f_khbhid", OracleType.VarChar);
                parameter.Value = model.f_khbhid;
                parameterList.Add(parameter);
            }

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

            if (model.f_khjson != null && model.f_khjson.Length > 0)
            {
                strSql1.Append("f_khjson,");
                strSql2.Append("'" + (model.f_khjson) + "',");
                strSql3.Append(":f_khjson,");
                parameter       = new OracleParameter(":f_khjson", OracleType.Clob);
                parameter.Value = model.f_khjson;
                parameterList.Add(parameter);
            }

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

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

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

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

            strSql.Append("insert into tbl_ld_xhhbtzb(");
            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_xhhbtzb(");
            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 (model.f_khjson != null && model.f_khjson.Length > 0)
                {
                    p       = new OracleParameter(":f_khjson", OracleType.Clob);
                    p.Value = (model.f_khjson);
                    pList.Add(p);
                    paraStrList.Add(" f_khjson = :f_khjson ");
                }
                else
                {
                    paraStrList.Add(" f_khjson = null ");
                }



                if (paraStrList.Count > 0)
                {
                    string updateSqlString = " update tbl_ld_xhhbtzb 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);
        }
        public string GetKhJsonAndUpdate(string json, string khidString, string clearKhbhString, string czlxString, string czidString, string clientInf)
        {
            Dictionary <string, string> resultDic = new Dictionary <string, string>();

            resultDic["result"]  = "";
            resultDic["message"] = "";
            try
            {
                IDictionary <string, string> clientInfoDic = Eva.Library.Format.FormatEntityTool.FormatJsonToDic(clientInf);
                Dictionary <string, string>  khxxJsonDic   = new Dictionary <string, string>();


                DataTable dt = new DataTable();

                _iAccessDataTrans = sara.dd.ldsw.commonclass.commonclass.CreateIAccessDataTrans();
                _iAccessDataTrans.getTrans().begin();

                sara.dd.ldsw.idal.Itbl_ld_xhhbtzb idal_tbl_ld_xhhbtzb = new sara.dd.ldsw.dal.tbl_ld_xhhbtzb();

                sara.dd.ldsw.model.tbl_ld_xhhbtzb model = Eva.Library.Format.FormatEntityTool.FormatJsonToModel <sara.dd.ldsw.model.tbl_ld_xhhbtzb>(json);
                //调用commonclass的方法  拿到客户json
                List <DataTable> lt = new List <DataTable>();
                lt = sara.dd.ldsw.commonclass.commonclass.GetKhxxJsonAndSetCzlx(khidString, czlxString, czidString, _iAccessDataTrans);



                DataTable khxx = lt[0];
                DataTable yhxx = lt[1];
                DataTable sbxx = lt[2];

                if (khxx.Rows.Count > 0)
                {
                }
                DataRow dr     = khxx.Rows[0];//这是拿到第一行数据
                string  khbh   = dr["f_khbh"].ToString();
                string  khbhid = dr["sys_id"].ToString();
                string  yhm    = dr["f_yhm"].ToString();
                string  dz     = dr["f_dz"].ToString();
                string  dh     = dr["f_dh"].ToString();

                string khxx_yhm_dz = yhm + "," + dz + "," + dh;

                khxxJsonDic["khxx"] = Eva.Library.Format.FormatEntityTool.FormatDataTableToJson(khxx);;
                khxxJsonDic["yhxx"] = Eva.Library.Format.FormatEntityTool.FormatDataTableToJson(yhxx);
                khxxJsonDic["sbxx"] = Eva.Library.Format.FormatEntityTool.FormatDataTableToJson(sbxx);
                string khxxJson = Eva.Library.Format.FormatEntityTool.FormatDicToJson(khxxJsonDic);


                //2.取出用户民、地址 逗号分隔,放到数据库f_khxx

                //3.更新f_khbh,f_khbhid
                model.f_khbh   = khbh;
                model.f_khbhid = khbhid;
                model.f_khxx   = khxx_yhm_dz;

                model.f_khjson = khxxJson;

                //4.clearCzlxKhbh不等于json中的客户编号  那么清空上一个客户编号的f_value1和f_value2
                #region clearCzlx
                if (clearKhbhString != khbh)
                {
                    string sql = "update tbl_ld_khb set f_value1='" + "" + "',f_value2 = '" + "" + "' where f_khbh = '" + clearKhbhString + "'";
                    _iAccessDataTrans.ExecuteSql(sql);
                }
                #endregion

                idal_tbl_ld_xhhbtzb.Update(model, "f_khjson,f_khxx,f_khbh,f_khbhid", _iAccessDataTrans);

                _iAccessDataTrans.getTrans().commit();

                resultDic["result"]  = "true";
                resultDic["message"] = khxxJson;
            }
            catch (Exception ex)
            {
                if (_iAccessDataTrans != null)
                {
                    _iAccessDataTrans.getTrans().rollback();
                    _iAccessDataTrans = null;
                }
                resultDic["result"]  = "false";
                resultDic["message"] = Eva.Library.Format.FormatTextTool.ErrorMessageFormat(ex.Message + ex.StackTrace);
            }
            return(Eva.Library.Format.FormatEntityTool.FormatDicToJson(resultDic));
        }