/// <summary> /// 得到一个对象实体 /// </summary> public DingDanInfoModel GetModel(string DingDanId) { StringBuilder strSql = new StringBuilder(); strSql.Append("select DingDanId, AddressId, UseJiFen, DingDanAttr, PeiSongTime1, PeiSongTime2, PeiSongTypeId, PaiSongUserId, PeiHuoUserId, PayTypeId, DingDanTitle, SourseTypeId, PeiHuoTime, BranchId, CreateMember, MerchantId, CreateTime, EnTime, Status, IsDone, Memo "); strSql.Append(" from CORE.dbo.DingDanInfo "); strSql.Append(" where DingDanId=@DingDanId "); SqlParameter[] parameters = { new SqlParameter("@DingDanId", SqlDbType.VarChar, 50) }; parameters[0].Value = DingDanId; DingDanInfoModel model = new DingDanInfoModel(); DataSet ds = helper.ExecSqlReDs(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { model.DingDanId = ds.Tables[0].Rows[0]["DingDanId"].ToString(); if (ds.Tables[0].Rows[0]["AddressId"].ToString() != "") { model.AddressId = decimal.Parse(ds.Tables[0].Rows[0]["AddressId"].ToString()); } if (ds.Tables[0].Rows[0]["UseJiFen"].ToString() != "") { model.UseJiFen = decimal.Parse(ds.Tables[0].Rows[0]["UseJiFen"].ToString()); } model.DingDanAttr = ds.Tables[0].Rows[0]["DingDanAttr"].ToString(); if (ds.Tables[0].Rows[0]["PeiSongTime1"].ToString() != "") { model.PeiSongTime1 = DateTime.Parse(ds.Tables[0].Rows[0]["PeiSongTime1"].ToString()); } if (ds.Tables[0].Rows[0]["PeiSongTime2"].ToString() != "") { model.PeiSongTime2 = DateTime.Parse(ds.Tables[0].Rows[0]["PeiSongTime2"].ToString()); } if (ds.Tables[0].Rows[0]["PeiSongTypeId"].ToString() != "") { model.PeiSongTypeId = decimal.Parse(ds.Tables[0].Rows[0]["PeiSongTypeId"].ToString()); } model.PaiSongUserId = ds.Tables[0].Rows[0]["PaiSongUserId"].ToString(); model.PeiHuoUserId = ds.Tables[0].Rows[0]["PeiHuoUserId"].ToString(); if (ds.Tables[0].Rows[0]["PayTypeId"].ToString() != "") { model.PayTypeId = int.Parse(ds.Tables[0].Rows[0]["PayTypeId"].ToString()); } model.DingDanTitle = ds.Tables[0].Rows[0]["DingDanTitle"].ToString(); if (ds.Tables[0].Rows[0]["SourseTypeId"].ToString() != "") { model.SourseTypeId = int.Parse(ds.Tables[0].Rows[0]["SourseTypeId"].ToString()); } if (ds.Tables[0].Rows[0]["PeiHuoTime"].ToString() != "") { model.PeiHuoTime = DateTime.Parse(ds.Tables[0].Rows[0]["PeiHuoTime"].ToString()); } model.BranchId = ds.Tables[0].Rows[0]["BranchId"].ToString(); if (ds.Tables[0].Rows[0]["CreateMember"].ToString() != "") { model.CreateMember = decimal.Parse(ds.Tables[0].Rows[0]["CreateMember"].ToString()); } if (ds.Tables[0].Rows[0]["MerchantId"].ToString() != "") { model.MerchantId = decimal.Parse(ds.Tables[0].Rows[0]["MerchantId"].ToString()); } if (ds.Tables[0].Rows[0]["CreateTime"].ToString() != "") { model.CreateTime = DateTime.Parse(ds.Tables[0].Rows[0]["CreateTime"].ToString()); } if (ds.Tables[0].Rows[0]["EnTime"].ToString() != "") { model.EnTime = DateTime.Parse(ds.Tables[0].Rows[0]["EnTime"].ToString()); } if (ds.Tables[0].Rows[0]["Status"].ToString() != "") { model.Status = int.Parse(ds.Tables[0].Rows[0]["Status"].ToString()); } if (ds.Tables[0].Rows[0]["IsDone"].ToString() != "") { if ((ds.Tables[0].Rows[0]["IsDone"].ToString() == "1") || (ds.Tables[0].Rows[0]["IsDone"].ToString().ToLower() == "true")) { model.IsDone = true; } else { model.IsDone = false; } } model.Memo = ds.Tables[0].Rows[0]["Memo"].ToString(); return(model); } else { return(model); } }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(DingDanInfoModel model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into CORE.dbo.DingDanInfo ("); strSql.Append("DingDanId,AddressId,UseJiFen,DingDanAttr,PeiSongTime1,PeiSongTime2,PeiSongTypeId,PaiSongUserId,PeiHuoUserId,PayTypeId,DingDanTitle,SourseTypeId,PeiHuoTime,BranchId,CreateMember,MerchantId,CreateTime,EnTime,Status,IsDone,Memo"); strSql.Append(") values ("); strSql.Append("@DingDanId,@AddressId,@UseJiFen,@DingDanAttr,@PeiSongTime1,@PeiSongTime2,@PeiSongTypeId,@PaiSongUserId,@PeiHuoUserId,@PayTypeId,@DingDanTitle,@SourseTypeId,@PeiHuoTime,@BranchId,@CreateMember,@MerchantId,@CreateTime,@EnTime,@Status,@IsDone,@Memo"); strSql.Append(") "); SqlParameter[] parameters = { new SqlParameter("@DingDanId", SqlDbType.VarChar, 50), new SqlParameter("@AddressId", SqlDbType.Decimal, 9), new SqlParameter("@UseJiFen", SqlDbType.Decimal, 9), new SqlParameter("@DingDanAttr", SqlDbType.Xml, -1), new SqlParameter("@PeiSongTime1", SqlDbType.DateTime), new SqlParameter("@PeiSongTime2", SqlDbType.DateTime), new SqlParameter("@PeiSongTypeId", SqlDbType.Decimal, 9), new SqlParameter("@PaiSongUserId", SqlDbType.VarChar, 50), new SqlParameter("@PeiHuoUserId", SqlDbType.VarChar, 50), new SqlParameter("@PayTypeId", SqlDbType.Int, 4), new SqlParameter("@DingDanTitle", SqlDbType.VarChar, 200), new SqlParameter("@SourseTypeId", SqlDbType.Int, 4), new SqlParameter("@PeiHuoTime", SqlDbType.DateTime), new SqlParameter("@BranchId", SqlDbType.VarChar, 50), new SqlParameter("@CreateMember", SqlDbType.Decimal, 9), new SqlParameter("@MerchantId", SqlDbType.Decimal, 9), new SqlParameter("@CreateTime", SqlDbType.DateTime), new SqlParameter("@EnTime", SqlDbType.DateTime), new SqlParameter("@Status", SqlDbType.Int, 4), new SqlParameter("@IsDone", SqlDbType.Bit, 1), new SqlParameter("@Memo", SqlDbType.VarChar, 1000) }; parameters[0].Value = model.DingDanId; parameters[1].Value = model.AddressId; parameters[2].Value = model.UseJiFen; parameters[3].Value = model.DingDanAttr; parameters[4].Value = model.PeiSongTime1; parameters[5].Value = model.PeiSongTime2; parameters[6].Value = model.PeiSongTypeId; parameters[7].Value = model.PaiSongUserId; parameters[8].Value = model.PeiHuoUserId; parameters[9].Value = model.PayTypeId; parameters[10].Value = model.DingDanTitle; parameters[11].Value = model.SourseTypeId; parameters[12].Value = model.PeiHuoTime; parameters[13].Value = model.BranchId; parameters[14].Value = model.CreateMember; parameters[15].Value = model.MerchantId; parameters[16].Value = model.CreateTime; parameters[17].Value = model.EnTime; parameters[18].Value = model.Status; parameters[19].Value = model.IsDone; parameters[20].Value = model.Memo; bool result = false; try { helper.ExecSqlReInt(strSql.ToString(), parameters); result = true; } catch (Exception ex) { this.helper.Close(); throw ex; } finally { } return(result); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(DingDanInfoModel model) { bool reValue = true; int reCount = 0; StringBuilder strSql = new StringBuilder(); strSql.Append("update CORE.dbo.DingDanInfo set "); strSql.Append(" DingDanId = @DingDanId , "); strSql.Append(" AddressId = @AddressId , "); strSql.Append(" UseJiFen = @UseJiFen , "); strSql.Append(" DingDanAttr = @DingDanAttr , "); strSql.Append(" PeiSongTime1 = @PeiSongTime1 , "); strSql.Append(" PeiSongTime2 = @PeiSongTime2 , "); strSql.Append(" PeiSongTypeId = @PeiSongTypeId , "); strSql.Append(" PaiSongUserId = @PaiSongUserId , "); strSql.Append(" PeiHuoUserId = @PeiHuoUserId , "); strSql.Append(" PayTypeId = @PayTypeId , "); strSql.Append(" DingDanTitle = @DingDanTitle , "); strSql.Append(" SourseTypeId = @SourseTypeId , "); strSql.Append(" PeiHuoTime = @PeiHuoTime , "); strSql.Append(" BranchId = @BranchId , "); strSql.Append(" CreateMember = @CreateMember , "); strSql.Append(" MerchantId = @MerchantId , "); strSql.Append(" CreateTime = @CreateTime , "); strSql.Append(" EnTime = @EnTime , "); strSql.Append(" Status = @Status , "); strSql.Append(" IsDone = @IsDone , "); strSql.Append(" Memo = @Memo "); strSql.Append(" where DingDanId=@DingDanId "); SqlParameter[] parameters = { new SqlParameter("@DingDanId", SqlDbType.VarChar, 50), new SqlParameter("@AddressId", SqlDbType.Decimal, 9), new SqlParameter("@UseJiFen", SqlDbType.Decimal, 9), new SqlParameter("@DingDanAttr", SqlDbType.Xml, -1), new SqlParameter("@PeiSongTime1", SqlDbType.DateTime), new SqlParameter("@PeiSongTime2", SqlDbType.DateTime), new SqlParameter("@PeiSongTypeId", SqlDbType.Decimal, 9), new SqlParameter("@PaiSongUserId", SqlDbType.VarChar, 50), new SqlParameter("@PeiHuoUserId", SqlDbType.VarChar, 50), new SqlParameter("@PayTypeId", SqlDbType.Int, 4), new SqlParameter("@DingDanTitle", SqlDbType.VarChar, 200), new SqlParameter("@SourseTypeId", SqlDbType.Int, 4), new SqlParameter("@PeiHuoTime", SqlDbType.DateTime), new SqlParameter("@BranchId", SqlDbType.VarChar, 50), new SqlParameter("@CreateMember", SqlDbType.Decimal, 9), new SqlParameter("@MerchantId", SqlDbType.Decimal, 9), new SqlParameter("@CreateTime", SqlDbType.DateTime), new SqlParameter("@EnTime", SqlDbType.DateTime), new SqlParameter("@Status", SqlDbType.Int, 4), new SqlParameter("@IsDone", SqlDbType.Bit, 1), new SqlParameter("@Memo", SqlDbType.VarChar, 1000) }; parameters[0].Value = model.DingDanId; parameters[1].Value = model.AddressId; parameters[2].Value = model.UseJiFen; parameters[3].Value = model.DingDanAttr; parameters[4].Value = model.PeiSongTime1; parameters[5].Value = model.PeiSongTime2; parameters[6].Value = model.PeiSongTypeId; parameters[7].Value = model.PaiSongUserId; parameters[8].Value = model.PeiHuoUserId; parameters[9].Value = model.PayTypeId; parameters[10].Value = model.DingDanTitle; parameters[11].Value = model.SourseTypeId; parameters[12].Value = model.PeiHuoTime; parameters[13].Value = model.BranchId; parameters[14].Value = model.CreateMember; parameters[15].Value = model.MerchantId; parameters[16].Value = model.CreateTime; parameters[17].Value = model.EnTime; parameters[18].Value = model.Status; parameters[19].Value = model.IsDone; parameters[20].Value = model.Memo; try {//异常处理 reCount = this.helper.ExecSqlReInt(strSql.ToString(), parameters); } catch (Exception ex) { this.helper.Close(); throw ex; } if (reCount <= 0) { reValue = false; } return(reValue); }