using System; using System.Data; using System.Text; using System.Data.SqlClient; namespace Mtxfw.DAL { /// /// 数据访问类:city /// public partial class user_jjfp : Mtxfw.Utility.Myabstract { public user_jjfp() : base("user_jjfp") { } /// /// 增加一条数据 /// public int Add(Mtxfw.Model.user_jjfp model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into user_jjfp("); strSql.Append("addweek,addmonth,zjnum,count1,count2,count3,count4,count5,count6,count7,count8,TType,addweektime1,addweektime2,addtime,gtype)"); strSql.Append(" values ("); strSql.Append("@addweek,@addmonth,@zjnum,@count1,@count2,@count3,@count4,@count5,@count6,@count7,@count8,@TType,@addweektime1,@addweektime2,@addtime,@gtype)"); strSql.Append(";select SCOPE_IDENTITY()"); SqlParameter[] parameters = { new SqlParameter("@addweek", SqlDbType.Int), new SqlParameter("@addmonth", SqlDbType.Int), new SqlParameter("@zjnum", SqlDbType.VarChar,50), new SqlParameter("@count1", SqlDbType.Money), new SqlParameter("@count2", SqlDbType.Money), new SqlParameter("@count3", SqlDbType.Money), new SqlParameter("@count4", SqlDbType.Money), new SqlParameter("@count5", SqlDbType.Money), new SqlParameter("@count6", SqlDbType.Money), new SqlParameter("@count7", SqlDbType.Money), new SqlParameter("@count8", SqlDbType.Money), new SqlParameter("@TType", SqlDbType.Int), new SqlParameter("@addweektime1", SqlDbType.DateTime), new SqlParameter("@addweektime2", SqlDbType.DateTime), new SqlParameter("@addtime", SqlDbType.DateTime), new SqlParameter("@gtype", SqlDbType.Int)}; parameters[0].Value = model.addweek; parameters[1].Value = model.addmonth; parameters[2].Value = model.zjnum; parameters[3].Value = model.count1; parameters[4].Value = model.count2; parameters[5].Value = model.count3; parameters[6].Value = model.count4; parameters[7].Value = model.count5; parameters[8].Value = model.count6; parameters[9].Value = model.count7; parameters[10].Value = model.count8; parameters[11].Value = model.TType; parameters[12].Value = model.addweektime1; parameters[13].Value = model.addweektime2; parameters[14].Value = model.addtime; parameters[15].Value = model.gtype; string obj = Mtxfw.Utility.SqlDbHelper_U.GetObject(strSql.ToString(), parameters).ToString(); if (obj == "") { return 0; } else { return Convert.ToInt32(obj); } } /// /// 更新一条数据 /// public bool Updatecount(Double count1, Double count2, Double count3, Double count4, Double count5, Double count6, Double count7, Double count8, int gtype, int TType) { StringBuilder strSql = new StringBuilder(); strSql.Append("update user_jjfp set "); strSql.Append("count1=count1+@count1,"); strSql.Append("count2=count2+@count2,"); strSql.Append("count3=count3+@count3,"); strSql.Append("count4=count4+@count4,"); strSql.Append("count5=count5+@count5,"); strSql.Append("count6=count6+@count6,"); strSql.Append("count7=count7+@count7,"); strSql.Append("count8=count8+@count8"); strSql.Append(" where gtype=@gtype and TType=@TType"); SqlParameter[] parameters = { new SqlParameter("@count1", SqlDbType.Money), new SqlParameter("@count2", SqlDbType.Money), new SqlParameter("@count3", SqlDbType.Money), new SqlParameter("@count4", SqlDbType.Money), new SqlParameter("@count5", SqlDbType.Money), new SqlParameter("@count6", SqlDbType.Money), new SqlParameter("@count7", SqlDbType.Money), new SqlParameter("@count8", SqlDbType.Money), new SqlParameter("@gtype", SqlDbType.Int), new SqlParameter("@TType", SqlDbType.Int)}; parameters[0].Value = count1; parameters[1].Value = count2; parameters[2].Value = count3; parameters[3].Value = count4; parameters[4].Value = count5; parameters[5].Value = count6; parameters[6].Value = count7; parameters[7].Value = count8; parameters[8].Value = gtype; parameters[9].Value = TType; int rows = Mtxfw.Utility.SqlDbHelper_U.ExecuteCmd(strSql.ToString(), parameters); if (rows > 0) { return true; } else { return false; } } /// /// 更新一条数据 /// public bool Updatecount(Double count1, Double count2, Double count3, Double count4, Double count5, Double count6, int jjfpid) { StringBuilder strSql = new StringBuilder(); strSql.Append("update user_jjfp set "); strSql.Append("count1=count1+@count1,"); strSql.Append("count2=count2+@count2,"); strSql.Append("count3=count3+@count3,"); strSql.Append("count4=count4+@count4,"); strSql.Append("count5=count5+@count5,"); strSql.Append("count6=count6+@count6"); strSql.Append(" where id=@jjfpid"); SqlParameter[] parameters = { new SqlParameter("@count1", SqlDbType.Money), new SqlParameter("@count2", SqlDbType.Money), new SqlParameter("@count3", SqlDbType.Money), new SqlParameter("@count4", SqlDbType.Money), new SqlParameter("@count5", SqlDbType.Money), new SqlParameter("@count6", SqlDbType.Money), new SqlParameter("@jjfpid", SqlDbType.Int)}; parameters[0].Value = count1; parameters[1].Value = count2; parameters[2].Value = count3; parameters[3].Value = count4; parameters[4].Value = count5; parameters[5].Value = count6; parameters[6].Value = jjfpid; int rows = Mtxfw.Utility.SqlDbHelper_U.ExecuteCmd(strSql.ToString(), parameters); if (rows > 0) { return true; } else { return false; } } /// /// 更新一条数据 /// public bool Updatecount(string countSel, Double countSelValue, int gtype, int TType) { StringBuilder strSql = new StringBuilder(); strSql.Append("update user_jjfp set "); strSql.Append(countSel + "=" + countSel + "+@countSelValue"); strSql.Append(" where gtype=@gtype and TType=@TType"); SqlParameter[] parameters = { new SqlParameter("@countSelValue", SqlDbType.Money), new SqlParameter("@gtype", SqlDbType.Int), new SqlParameter("@TType", SqlDbType.Int)}; parameters[0].Value = countSelValue; parameters[1].Value = gtype; parameters[2].Value = TType; int rows = Mtxfw.Utility.SqlDbHelper_U.ExecuteCmd(strSql.ToString(), parameters); if (rows > 0) { return true; } else { return false; } } /// /// 更新一条数据 /// public bool UpdateBcount(string countSel, Double countSelValue, int gtype, int TType) { StringBuilder strSql = new StringBuilder(); strSql.Append("update user_jjfp set "); strSql.Append(countSel + "=" + countSel + "+@countSelValue"); strSql.Append(" where gtype=@gtype and TType=@TType"); SqlParameter[] parameters = { new SqlParameter("@countSelValue", SqlDbType.Money), new SqlParameter("@gtype", SqlDbType.Int), new SqlParameter("@TType", SqlDbType.Int)}; parameters[0].Value = countSelValue; parameters[1].Value = gtype; parameters[2].Value = TType; int rows = Mtxfw.Utility.SqlDbHelper_U.ExecuteBCmd(strSql.ToString(), parameters); if (rows > 0) { return true; } else { return false; } } /// /// 更新一条数据 /// public bool Updatecount0(string countSel, Double countSelValue, int gtype, int TType) { StringBuilder strSql = new StringBuilder(); strSql.Append("update user_jjfp set "); strSql.Append(countSel + "=@countSelValue"); strSql.Append(" where gtype=@gtype and TType=@TType"); SqlParameter[] parameters = { new SqlParameter("@countSelValue", SqlDbType.Money), new SqlParameter("@gtype", SqlDbType.Int), new SqlParameter("@TType", SqlDbType.Int)}; parameters[0].Value = countSelValue; parameters[1].Value = gtype; parameters[2].Value = TType; int rows = Mtxfw.Utility.SqlDbHelper_U.ExecuteCmd(strSql.ToString(), parameters); if (rows > 0) { return true; } else { return false; } } /// /// 更新一条数据 /// public bool Updatecount1(string countSel, Double countSelValue, int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("update user_jjfp set "); strSql.Append(countSel + "=@countSelValue"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@countSelValue", SqlDbType.Money), new SqlParameter("@id", SqlDbType.Int)}; parameters[0].Value = countSelValue; parameters[1].Value = id; int rows = Mtxfw.Utility.SqlDbHelper_U.ExecuteCmd(strSql.ToString(), parameters); if (rows > 0) { return true; } else { return false; } } /// /// 更新一条数据 /// public bool Updatecount2(string countSel, Double countSelValue, int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("update user_jjfp set "); strSql.Append(countSel + "="+ countSel + "+@countSelValue"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@countSelValue", SqlDbType.Money), new SqlParameter("@id", SqlDbType.Int)}; parameters[0].Value = countSelValue; parameters[1].Value = id; int rows = Mtxfw.Utility.SqlDbHelper_U.ExecuteCmd(strSql.ToString(), parameters); if (rows > 0) { return true; } else { return false; } } /// /// 更新一条数据 /// public bool Updateaddmonth(int addmonth, int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("update user_jjfp set "); strSql.Append("addmonth=@addmonth"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@addmonth", SqlDbType.Int), new SqlParameter("@id", SqlDbType.Int)}; parameters[0].Value = addmonth; parameters[1].Value = id; int rows = Mtxfw.Utility.SqlDbHelper_U.ExecuteCmd(strSql.ToString(), parameters); if (rows > 0) { return true; } else { return false; } } /// /// 更新一条数据 /// public bool Updateaddweektime(DateTime addweektime1, DateTime addweektime2, int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("update user_jjfp set "); strSql.Append("addweektime1=@addweektime1,addweektime2=@addweektime2"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@addweektime1", SqlDbType.DateTime), new SqlParameter("@addweektime2", SqlDbType.DateTime), new SqlParameter("@id", SqlDbType.Int)}; parameters[0].Value = addweektime1; parameters[1].Value = addweektime2; parameters[2].Value = id; int rows = Mtxfw.Utility.SqlDbHelper_U.ExecuteCmd(strSql.ToString(), parameters); if (rows > 0) { return true; } else { return false; } } /// /// 删除一条数据 /// public bool Delete(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("delete from user_jjfp "); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int,4) }; parameters[0].Value = id; int rows = Mtxfw.Utility.SqlDbHelper_U.ExecuteCmd(strSql.ToString(), parameters); if (rows > 0) { return true; } else { return false; } } /// /// 获得数据列表 /// public DataSet GetList(string strWhere) { StringBuilder strSql = new StringBuilder(); strSql.Append("select * "); strSql.Append(" FROM user_jjfp a"); if (strWhere.Trim() != "") { strSql.Append(" where " + strWhere); } return Mtxfw.Utility.SqlDbHelper_U.GetDataSet(strSql.ToString()); } /// /// 获得数据列表 /// public Double GetJYJG() { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 count8"); strSql.Append(" FROM user_jjfp a where TType=0"); Double JYJG = 0.00; DataSet ds = Mtxfw.Utility.SqlDbHelper_U.GetDataSet(strSql.ToString()); if (ds.Tables[0].Rows.Count > 0) { JYJG = Convert.ToDouble(ds.Tables[0].Rows[0]["count8"]); } ds.Clear(); return JYJG; } } }