/// <summary> /// 更新一条Salesorderdetail记录 /// </summary> /// <param name="db">DataBase对象</param> /// <param name="tran">一个有效的DbTransaction</param> /// <param name="salesorderdetail">Salesorderdetail对象</param> /// <param name="whLoginID">要查询的仓库的前缀</param> /// <returns>执行更新对数据库影响的行数</returns> public int UpdateSalesorderdetail(Database db, DbTransaction tran, SalesorderdetailInfo salesorderdetailInfo) { int result = 0; SqlParameter[] paras = Set_Salesorderdetail_Parameters(salesorderdetailInfo); if (paras != null) { result += DBHelper.ExecuteNonQuery(db, tran, CommandType.Text, SQL_UPDATE_SALESORDERDETAIL, paras); } return(result); }
/// <summary> /// 新增一条Salesorderdetail记录 /// </summary> /// <param name="salesorderdetail">Salesorderdetail对象</param> /// <param name="whLoginID">要查询的仓库的前缀</param> /// <returns>执行新增对数据库影响的行数</returns> public int InsertSalesorderdetail(SalesorderdetailInfo salesorderdetailInfo) { int result = 0; SqlParameter[] paras = Set_Salesorderdetail_Parameters(salesorderdetailInfo); if (paras != null) { result = DBHelper.ExecuteNonQuery(CommandType.Text, SQL_INSERT_SALESORDERDETAIL, paras); } return(result); }
/// <summary> /// 设置SQL参数表 /// </summary> /// <param name="Salesorderdetail">Salesorderdetail对象</param> /// <returns>Salesorderdetail参数数组</returns> private SqlParameter[] Set_Salesorderdetail_Parameters(SalesorderdetailInfo salesorderdetailInfo) { SqlParameter[] paramArray = new SqlParameter[] { new SqlParameter("@DetailID", salesorderdetailInfo.DetailID), new SqlParameter("@SoID", salesorderdetailInfo.SoID), new SqlParameter("@ItemID", salesorderdetailInfo.ItemID), new SqlParameter("@Qty", salesorderdetailInfo.Qty), new SqlParameter("@Price", salesorderdetailInfo.Price), new SqlParameter("@TotalAmount", salesorderdetailInfo.TotalAmount), new SqlParameter("@Remark", string.IsNullOrEmpty(salesorderdetailInfo.Remark)?"":salesorderdetailInfo.Remark), new SqlParameter("@CreatedBy", string.IsNullOrEmpty(salesorderdetailInfo.CreatedBy)?"":salesorderdetailInfo.CreatedBy), new SqlParameter("@UpdatedBy", string.IsNullOrEmpty(salesorderdetailInfo.UpdatedBy)?"":salesorderdetailInfo.UpdatedBy) }; return(paramArray); }
/// <summary> /// 初始化SalesorderdetailInfo /// </summary> private SalesorderdetailInfo InitSalesorderdetailInfoByDataReader(SalesorderdetailInfo salesorderdetailInfo, IDataReader reader) { salesorderdetailInfo = new SalesorderdetailInfo(reader["DetailID"].ToString() != "" ? Int32.Parse(reader["DetailID"].ToString()) : 0, reader["SoID"].ToString() != "" ? Int32.Parse(reader["SoID"].ToString()) : 0, reader["ItemID"].ToString() != "" ? Int32.Parse(reader["ItemID"].ToString()) : 0, reader["Qty"].ToString() != "" ? Int32.Parse(reader["Qty"].ToString()) : 0, reader["Price"].ToString() != "" ? Decimal.Parse(reader["Price"].ToString()) : 0, reader["TotalAmount"].ToString() != "" ? Decimal.Parse(reader["TotalAmount"].ToString()) : 0, reader["Remark"].ToString(), reader["Ts"], reader["CreatedBy"].ToString(), reader["CreatedDate"].ToString() != "" ? DateTime.Parse(reader["CreatedDate"].ToString()) : new DateTime(), reader["UpdatedBy"].ToString(), reader["UpdatedDate"].ToString() != "" ? DateTime.Parse(reader["UpdatedDate"].ToString()) : new DateTime()); return(salesorderdetailInfo); }
/// <summary> /// 根据salesorderdetailID得到一条Salesorderdetail记录 /// </summary> /// <param name="salesorderdetailID">salesorderdetailID</param> /// <param name="whLoginID">要查询的仓库的前缀</param> /// <returns>根据salesorderdetailID得到一条Salesorderdetail记录</returns> public SalesorderdetailInfo GetSalesorderdetailByID(string salesorderdetailID) { string sql = SQL_SELECT_ALL_SALESORDERDETAIL + " AND DETAILID = @DETAILID "; SqlParameter[] paras = new SqlParameter[] { new SqlParameter("@DETAILID", salesorderdetailID) }; SalesorderdetailInfo salesorderdetailInfo = null; using (IDataReader reader = DBHelper.ExecuteReader(CommandType.Text, sql, paras)) { if (reader.Read()) { salesorderdetailInfo = InitSalesorderdetailInfoByDataReader(salesorderdetailInfo, reader); } } return(salesorderdetailInfo); }
/// <summary> /// 根据salesorderdetailID得到一条Salesorderdetail记录 /// </summary> /// <param name="db">DataBase对象</param> /// <param name="tran">一个有效的DbTransaction</param> /// <param name="salesorderdetailID">salesorderdetailID</param> /// <param name="whLoginID">要查询的仓库的前缀</param> /// <returns>根据salesorderdetailID得到一条Salesorderdetail记录</returns> public SalesorderdetailInfo GetSalesorderdetailByID(Database db, DbTransaction tran, string salesorderdetailID) { string sql = SQL_SELECT_ALL_SALESORDERDETAIL + " AND DETAILID = @DETAILID "; SqlParameter[] paras = new SqlParameter[] { new SqlParameter("@DETAILID", salesorderdetailID) }; SalesorderdetailInfo salesorderdetailInfo = null; IDataReader reader = DBHelper.ExecuteReader(db, tran, CommandType.Text, sql, paras); if (reader.Read()) { salesorderdetailInfo = InitSalesorderdetailInfoByDataReader(salesorderdetailInfo, reader); } if (!reader.IsClosed) { reader.Close(); } return(salesorderdetailInfo); }
/// <summary> /// 新增一条Salesorderdetail记录 /// </summary> /// <param name="salesorderdetail">Salesorderdetail对象</param> /// <param name="whLoginID">要查询的仓库的前缀</param> /// <returns>执行新增对数据库影响的行数</returns> public int InsertSalesorderdetail(SalesorderdetailInfo salesorderdetailInfo) { return(salesorderdetailDA.InsertSalesorderdetail(salesorderdetailInfo)); }
/// <summary> /// 更新一条Salesorderdetail记录 /// </summary> /// <param name="salesorderdetail">Salesorderdetail对象</param> /// <param name="whLoginID">要查询的仓库的前缀</param> /// <returns>执行更新对数据库影响的行数</returns> public int UpdateSalesorderdetail(SalesorderdetailInfo salesorderdetailInfo) { return(salesorderdetailDA.UpdateSalesorderdetail(salesorderdetailInfo)); }