/// <summary> /// 增加一条数据 /// </summary> public int Add(Hownet.Model.MoneyInOrOut model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into MoneyInOrOut("); strSql.Append("Num,DateTime,CompanyID,Money,Remark,TypeID,IsVerify,VerifyMan,VerifyDate,LastMoney,ChangMoney,FillMan,FillDate,KJKMID,Fees)"); strSql.Append(" values ("); strSql.Append("@Num,@DateTime,@CompanyID,@Money,@Remark,@TypeID,@IsVerify,@VerifyMan,@VerifyDate,@LastMoney,@ChangMoney,@FillMan,@FillDate,@KJKMID,@Fees)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@Num", SqlDbType.Int, 4), new SqlParameter("@DateTime", SqlDbType.DateTime), new SqlParameter("@CompanyID", SqlDbType.Int, 4), new SqlParameter("@Money", SqlDbType.Decimal, 9), new SqlParameter("@Remark", SqlDbType.NVarChar, 255), new SqlParameter("@TypeID", SqlDbType.TinyInt, 1), new SqlParameter("@IsVerify", SqlDbType.TinyInt, 1), new SqlParameter("@VerifyMan", SqlDbType.Int, 4), new SqlParameter("@VerifyDate", SqlDbType.DateTime), new SqlParameter("@LastMoney", SqlDbType.Decimal, 9), new SqlParameter("@ChangMoney", SqlDbType.Decimal, 9), new SqlParameter("@FillMan", SqlDbType.Int, 4), new SqlParameter("@FillDate", SqlDbType.DateTime), new SqlParameter("@KJKMID", SqlDbType.Int, 4), new SqlParameter("@Fees", SqlDbType.Decimal, 9) }; parameters[0].Value = model.Num; parameters[1].Value = model.DateTime; parameters[2].Value = model.CompanyID; parameters[3].Value = model.Money; parameters[4].Value = model.Remark; parameters[5].Value = model.TypeID; parameters[6].Value = model.IsVerify; parameters[7].Value = model.VerifyMan; parameters[8].Value = model.VerifyDate; parameters[9].Value = model.LastMoney; parameters[10].Value = model.ChangMoney; parameters[11].Value = model.FillMan; parameters[12].Value = model.FillDate; parameters[13].Value = model.KJKMID; parameters[14].Value = model.Fees; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Hownet.Model.MoneyInOrOut GetModel(int ID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 ID,Num,DateTime,CompanyID,Money,Remark,TypeID,IsVerify,VerifyMan,VerifyDate,LastMoney,ChangMoney,FillMan,FillDate,KJKMID,Fees from MoneyInOrOut "); strSql.Append(" where ID=@ID"); SqlParameter[] parameters = { new SqlParameter("@ID", SqlDbType.Int, 4) }; parameters[0].Value = ID; Hownet.Model.MoneyInOrOut model = new Hownet.Model.MoneyInOrOut(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["ID"] != null && ds.Tables[0].Rows[0]["ID"].ToString() != "") { model.ID = int.Parse(ds.Tables[0].Rows[0]["ID"].ToString()); } if (ds.Tables[0].Rows[0]["Num"] != null && ds.Tables[0].Rows[0]["Num"].ToString() != "") { model.Num = int.Parse(ds.Tables[0].Rows[0]["Num"].ToString()); } if (ds.Tables[0].Rows[0]["DateTime"] != null && ds.Tables[0].Rows[0]["DateTime"].ToString() != "") { model.DateTime = DateTime.Parse(ds.Tables[0].Rows[0]["DateTime"].ToString()); } if (ds.Tables[0].Rows[0]["CompanyID"] != null && ds.Tables[0].Rows[0]["CompanyID"].ToString() != "") { model.CompanyID = int.Parse(ds.Tables[0].Rows[0]["CompanyID"].ToString()); } if (ds.Tables[0].Rows[0]["Money"] != null && ds.Tables[0].Rows[0]["Money"].ToString() != "") { model.Money = decimal.Parse(ds.Tables[0].Rows[0]["Money"].ToString()); } model.Remark = ds.Tables[0].Rows[0]["Remark"].ToString(); if (ds.Tables[0].Rows[0]["TypeID"] != null && ds.Tables[0].Rows[0]["TypeID"].ToString() != "") { model.TypeID = int.Parse(ds.Tables[0].Rows[0]["TypeID"].ToString()); } if (ds.Tables[0].Rows[0]["IsVerify"] != null && ds.Tables[0].Rows[0]["IsVerify"].ToString() != "") { model.IsVerify = int.Parse(ds.Tables[0].Rows[0]["IsVerify"].ToString()); } if (ds.Tables[0].Rows[0]["VerifyMan"] != null && ds.Tables[0].Rows[0]["VerifyMan"].ToString() != "") { model.VerifyMan = int.Parse(ds.Tables[0].Rows[0]["VerifyMan"].ToString()); } if (ds.Tables[0].Rows[0]["VerifyDate"] != null && ds.Tables[0].Rows[0]["VerifyDate"].ToString() != "") { model.VerifyDate = DateTime.Parse(ds.Tables[0].Rows[0]["VerifyDate"].ToString()); } if (ds.Tables[0].Rows[0]["LastMoney"] != null && ds.Tables[0].Rows[0]["LastMoney"].ToString() != "") { model.LastMoney = decimal.Parse(ds.Tables[0].Rows[0]["LastMoney"].ToString()); } if (ds.Tables[0].Rows[0]["ChangMoney"] != null && ds.Tables[0].Rows[0]["ChangMoney"].ToString() != "") { model.ChangMoney = decimal.Parse(ds.Tables[0].Rows[0]["ChangMoney"].ToString()); } if (ds.Tables[0].Rows[0]["FillMan"] != null && ds.Tables[0].Rows[0]["FillMan"].ToString() != "") { model.FillMan = int.Parse(ds.Tables[0].Rows[0]["FillMan"].ToString()); } if (ds.Tables[0].Rows[0]["FillDate"] != null && ds.Tables[0].Rows[0]["FillDate"].ToString() != "") { model.FillDate = DateTime.Parse(ds.Tables[0].Rows[0]["FillDate"].ToString()); } if (ds.Tables[0].Rows[0]["KJKMID"] != null && ds.Tables[0].Rows[0]["KJKMID"].ToString() != "") { model.KJKMID = int.Parse(ds.Tables[0].Rows[0]["KJKMID"].ToString()); } if (ds.Tables[0].Rows[0]["Fees"] != null && ds.Tables[0].Rows[0]["Fees"].ToString() != "") { model.Fees = decimal.Parse(ds.Tables[0].Rows[0]["Fees"].ToString()); } model.A = 1; return(model); } else { return(null); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Hownet.Model.MoneyInOrOut model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update MoneyInOrOut set "); strSql.Append("Num=@Num,"); strSql.Append("DateTime=@DateTime,"); strSql.Append("CompanyID=@CompanyID,"); strSql.Append("Money=@Money,"); strSql.Append("Remark=@Remark,"); strSql.Append("TypeID=@TypeID,"); strSql.Append("IsVerify=@IsVerify,"); strSql.Append("VerifyMan=@VerifyMan,"); strSql.Append("VerifyDate=@VerifyDate,"); strSql.Append("LastMoney=@LastMoney,"); strSql.Append("ChangMoney=@ChangMoney,"); strSql.Append("FillMan=@FillMan,"); strSql.Append("FillDate=@FillDate,"); strSql.Append("KJKMID=@KJKMID,"); strSql.Append("Fees=@Fees"); strSql.Append(" where ID=@ID"); SqlParameter[] parameters = { new SqlParameter("@Num", SqlDbType.Int, 4), new SqlParameter("@DateTime", SqlDbType.DateTime), new SqlParameter("@CompanyID", SqlDbType.Int, 4), new SqlParameter("@Money", SqlDbType.Decimal, 9), new SqlParameter("@Remark", SqlDbType.NVarChar, 255), new SqlParameter("@TypeID", SqlDbType.TinyInt, 1), new SqlParameter("@IsVerify", SqlDbType.TinyInt, 1), new SqlParameter("@VerifyMan", SqlDbType.Int, 4), new SqlParameter("@VerifyDate", SqlDbType.DateTime), new SqlParameter("@LastMoney", SqlDbType.Decimal, 9), new SqlParameter("@ChangMoney", SqlDbType.Decimal, 9), new SqlParameter("@FillMan", SqlDbType.Int, 4), new SqlParameter("@FillDate", SqlDbType.DateTime), new SqlParameter("@KJKMID", SqlDbType.Int, 4), new SqlParameter("@Fees", SqlDbType.Decimal, 9), new SqlParameter("@ID", SqlDbType.Int, 4) }; parameters[0].Value = model.Num; parameters[1].Value = model.DateTime; parameters[2].Value = model.CompanyID; parameters[3].Value = model.Money; parameters[4].Value = model.Remark; parameters[5].Value = model.TypeID; parameters[6].Value = model.IsVerify; parameters[7].Value = model.VerifyMan; parameters[8].Value = model.VerifyDate; parameters[9].Value = model.LastMoney; parameters[10].Value = model.ChangMoney; parameters[11].Value = model.FillMan; parameters[12].Value = model.FillDate; parameters[13].Value = model.KJKMID; parameters[14].Value = model.Fees; parameters[15].Value = model.ID; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }