/// <summary> /// 得到一个对象实体 /// </summary> public Model.StockCwInfo GetModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 id,Code,ReportDate,JBMGSY,MGJZC,MGJYHDCSXJLJE,ZYYWSR,ZYYWLR,YYLR,TZSY,YYEYSZJE,LRZE,JLR,JLROUT,JYHDCSDXJLJE,XJJXJDJWJCJE,ZZC,LDZC,ZFZ,LDFZ,GDQYBHSSGDQY,JZCSYLJQ from StockCwInfo "); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = id; Model.StockCwInfo model = new Model.StockCwInfo(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Model.StockCwInfo model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into StockCwInfo("); strSql.Append("Code,ReportDate,JBMGSY,MGJZC,MGJYHDCSXJLJE,ZYYWSR,ZYYWLR,YYLR,TZSY,YYEYSZJE,LRZE,JLR,JLROUT,JYHDCSDXJLJE,XJJXJDJWJCJE,ZZC,LDZC,ZFZ,LDFZ,GDQYBHSSGDQY,JZCSYLJQ)"); strSql.Append(" values ("); strSql.Append("@Code,@ReportDate,@JBMGSY,@MGJZC,@MGJYHDCSXJLJE,@ZYYWSR,@ZYYWLR,@YYLR,@TZSY,@YYEYSZJE,@LRZE,@JLR,@JLROUT,@JYHDCSDXJLJE,@XJJXJDJWJCJE,@ZZC,@LDZC,@ZFZ,@LDFZ,@GDQYBHSSGDQY,@JZCSYLJQ)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@Code", SqlDbType.NVarChar, 10), new SqlParameter("@ReportDate", SqlDbType.DateTime), new SqlParameter("@JBMGSY", SqlDbType.Decimal, 9), new SqlParameter("@MGJZC", SqlDbType.Decimal, 9), new SqlParameter("@MGJYHDCSXJLJE", SqlDbType.Decimal, 9), new SqlParameter("@ZYYWSR", SqlDbType.NVarChar, 50), new SqlParameter("@ZYYWLR", SqlDbType.NVarChar, 50), new SqlParameter("@YYLR", SqlDbType.NVarChar, 50), new SqlParameter("@TZSY", SqlDbType.NVarChar, 50), new SqlParameter("@YYEYSZJE", SqlDbType.NVarChar, 50), new SqlParameter("@LRZE", SqlDbType.NVarChar, 50), new SqlParameter("@JLR", SqlDbType.NVarChar, 50), new SqlParameter("@JLROUT", SqlDbType.NVarChar, 50), new SqlParameter("@JYHDCSDXJLJE", SqlDbType.NVarChar, 50), new SqlParameter("@XJJXJDJWJCJE", SqlDbType.NVarChar, 50), new SqlParameter("@ZZC", SqlDbType.NVarChar, 50), new SqlParameter("@LDZC", SqlDbType.NVarChar, 50), new SqlParameter("@ZFZ", SqlDbType.NVarChar, 50), new SqlParameter("@LDFZ", SqlDbType.NVarChar, 50), new SqlParameter("@GDQYBHSSGDQY", SqlDbType.NVarChar, 50), new SqlParameter("@JZCSYLJQ", SqlDbType.Decimal, 9) }; parameters[0].Value = model.Code; parameters[1].Value = model.ReportDate; parameters[2].Value = model.JBMGSY; parameters[3].Value = model.MGJZC; parameters[4].Value = model.MGJYHDCSXJLJE; parameters[5].Value = model.ZYYWSR; parameters[6].Value = model.ZYYWLR; parameters[7].Value = model.YYLR; parameters[8].Value = model.TZSY; parameters[9].Value = model.YYEYSZJE; parameters[10].Value = model.LRZE; parameters[11].Value = model.JLR; parameters[12].Value = model.JLROUT; parameters[13].Value = model.JYHDCSDXJLJE; parameters[14].Value = model.XJJXJDJWJCJE; parameters[15].Value = model.ZZC; parameters[16].Value = model.LDZC; parameters[17].Value = model.ZFZ; parameters[18].Value = model.LDFZ; parameters[19].Value = model.GDQYBHSSGDQY; parameters[20].Value = model.JZCSYLJQ; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Model.StockCwInfo DataRowToModel(DataRow row) { Model.StockCwInfo model = new Model.StockCwInfo(); if (row != null) { if (row["id"] != null && row["id"].ToString() != "") { model.id = int.Parse(row["id"].ToString()); } if (row["Code"] != null) { model.Code = row["Code"].ToString(); } if (row["ReportDate"] != null && row["ReportDate"].ToString() != "") { model.ReportDate = DateTime.Parse(row["ReportDate"].ToString()); } if (row["JBMGSY"] != null && row["JBMGSY"].ToString() != "") { model.JBMGSY = decimal.Parse(row["JBMGSY"].ToString()); } if (row["MGJZC"] != null && row["MGJZC"].ToString() != "") { model.MGJZC = decimal.Parse(row["MGJZC"].ToString()); } if (row["MGJYHDCSXJLJE"] != null && row["MGJYHDCSXJLJE"].ToString() != "") { model.MGJYHDCSXJLJE = decimal.Parse(row["MGJYHDCSXJLJE"].ToString()); } if (row["ZYYWSR"] != null) { model.ZYYWSR = row["ZYYWSR"].ToString(); } if (row["ZYYWLR"] != null) { model.ZYYWLR = row["ZYYWLR"].ToString(); } if (row["YYLR"] != null) { model.YYLR = row["YYLR"].ToString(); } if (row["TZSY"] != null) { model.TZSY = row["TZSY"].ToString(); } if (row["YYEYSZJE"] != null) { model.YYEYSZJE = row["YYEYSZJE"].ToString(); } if (row["LRZE"] != null) { model.LRZE = row["LRZE"].ToString(); } if (row["JLR"] != null) { model.JLR = row["JLR"].ToString(); } if (row["JLROUT"] != null) { model.JLROUT = row["JLROUT"].ToString(); } if (row["JYHDCSDXJLJE"] != null) { model.JYHDCSDXJLJE = row["JYHDCSDXJLJE"].ToString(); } if (row["XJJXJDJWJCJE"] != null) { model.XJJXJDJWJCJE = row["XJJXJDJWJCJE"].ToString(); } if (row["ZZC"] != null) { model.ZZC = row["ZZC"].ToString(); } if (row["LDZC"] != null) { model.LDZC = row["LDZC"].ToString(); } if (row["ZFZ"] != null) { model.ZFZ = row["ZFZ"].ToString(); } if (row["LDFZ"] != null) { model.LDFZ = row["LDFZ"].ToString(); } if (row["GDQYBHSSGDQY"] != null) { model.GDQYBHSSGDQY = row["GDQYBHSSGDQY"].ToString(); } if (row["JZCSYLJQ"] != null && row["JZCSYLJQ"].ToString() != "") { model.JZCSYLJQ = decimal.Parse(row["JZCSYLJQ"].ToString()); } } return(model); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Model.StockCwInfo model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update StockCwInfo set "); strSql.Append("Code=@Code,"); strSql.Append("ReportDate=@ReportDate,"); strSql.Append("JBMGSY=@JBMGSY,"); strSql.Append("MGJZC=@MGJZC,"); strSql.Append("MGJYHDCSXJLJE=@MGJYHDCSXJLJE,"); strSql.Append("ZYYWSR=@ZYYWSR,"); strSql.Append("ZYYWLR=@ZYYWLR,"); strSql.Append("YYLR=@YYLR,"); strSql.Append("TZSY=@TZSY,"); strSql.Append("YYEYSZJE=@YYEYSZJE,"); strSql.Append("LRZE=@LRZE,"); strSql.Append("JLR=@JLR,"); strSql.Append("JLROUT=@JLROUT,"); strSql.Append("JYHDCSDXJLJE=@JYHDCSDXJLJE,"); strSql.Append("XJJXJDJWJCJE=@XJJXJDJWJCJE,"); strSql.Append("ZZC=@ZZC,"); strSql.Append("LDZC=@LDZC,"); strSql.Append("ZFZ=@ZFZ,"); strSql.Append("LDFZ=@LDFZ,"); strSql.Append("GDQYBHSSGDQY=@GDQYBHSSGDQY,"); strSql.Append("JZCSYLJQ=@JZCSYLJQ"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@Code", SqlDbType.NVarChar, 10), new SqlParameter("@ReportDate", SqlDbType.DateTime), new SqlParameter("@JBMGSY", SqlDbType.Decimal, 9), new SqlParameter("@MGJZC", SqlDbType.Decimal, 9), new SqlParameter("@MGJYHDCSXJLJE", SqlDbType.Decimal, 9), new SqlParameter("@ZYYWSR", SqlDbType.NVarChar, 50), new SqlParameter("@ZYYWLR", SqlDbType.NVarChar, 50), new SqlParameter("@YYLR", SqlDbType.NVarChar, 50), new SqlParameter("@TZSY", SqlDbType.NVarChar, 50), new SqlParameter("@YYEYSZJE", SqlDbType.NVarChar, 50), new SqlParameter("@LRZE", SqlDbType.NVarChar, 50), new SqlParameter("@JLR", SqlDbType.NVarChar, 50), new SqlParameter("@JLROUT", SqlDbType.NVarChar, 50), new SqlParameter("@JYHDCSDXJLJE", SqlDbType.NVarChar, 50), new SqlParameter("@XJJXJDJWJCJE", SqlDbType.NVarChar, 50), new SqlParameter("@ZZC", SqlDbType.NVarChar, 50), new SqlParameter("@LDZC", SqlDbType.NVarChar, 50), new SqlParameter("@ZFZ", SqlDbType.NVarChar, 50), new SqlParameter("@LDFZ", SqlDbType.NVarChar, 50), new SqlParameter("@GDQYBHSSGDQY", SqlDbType.NVarChar, 50), new SqlParameter("@JZCSYLJQ", SqlDbType.Decimal, 9), new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = model.Code; parameters[1].Value = model.ReportDate; parameters[2].Value = model.JBMGSY; parameters[3].Value = model.MGJZC; parameters[4].Value = model.MGJYHDCSXJLJE; parameters[5].Value = model.ZYYWSR; parameters[6].Value = model.ZYYWLR; parameters[7].Value = model.YYLR; parameters[8].Value = model.TZSY; parameters[9].Value = model.YYEYSZJE; parameters[10].Value = model.LRZE; parameters[11].Value = model.JLR; parameters[12].Value = model.JLROUT; parameters[13].Value = model.JYHDCSDXJLJE; parameters[14].Value = model.XJJXJDJWJCJE; parameters[15].Value = model.ZZC; parameters[16].Value = model.LDZC; parameters[17].Value = model.ZFZ; parameters[18].Value = model.LDFZ; parameters[19].Value = model.GDQYBHSSGDQY; parameters[20].Value = model.JZCSYLJQ; parameters[21].Value = model.id; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }