/// <summary> /// 得到一个对象实体 /// </summary> public Info_orderMode DataRowToModel(DataRow row) { Info_orderMode model = new Info_orderMode(); if (row != null) { if (row["orderID"] != null && row["orderID"].ToString() != "") { model.orderID = int.Parse(row["orderID"].ToString()); } if (row["orderNum"] != null) { model.orderNum = row["orderNum"].ToString(); } if (row["orderDate"] != null && row["orderDate"].ToString() != "") { model.orderDate = DateTime.Parse(row["orderDate"].ToString()); } if (row["staffID"] != null) { model.staffID = row["staffID"].ToString(); } if (row["deviceID"] != null) { model.deviceID = row["deviceID"].ToString(); } if (row["Count"] != null && row["Count"].ToString() != "") { model.Count = int.Parse(row["Count"].ToString()); } if (row["IsDelete"] != null && row["IsDelete"].ToString() != "") { if ((row["IsDelete"].ToString() == "1") || (row["IsDelete"].ToString().ToLower() == "true")) { model.IsDelete = true; } else { model.IsDelete = false; } } } return(model); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Info_orderMode model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update Info_order set "); strSql.Append("orderNum=SQL2012orderNum,"); strSql.Append("orderDate=SQL2012orderDate,"); strSql.Append("staffID=SQL2012staffID,"); strSql.Append("deviceID=SQL2012deviceID,"); strSql.Append("Count=SQL2012Count,"); strSql.Append("IsDelete=SQL2012IsDelete"); strSql.Append(" where orderID=SQL2012orderID"); SqlParameter[] parameters = { new SqlParameter("SQL2012orderNum", SqlDbType.VarChar, 50), new SqlParameter("SQL2012orderDate", SqlDbType.DateTime), new SqlParameter("SQL2012staffID", SqlDbType.VarChar, 50), new SqlParameter("SQL2012deviceID", SqlDbType.VarChar, 50), new SqlParameter("SQL2012Count", SqlDbType.Int, 4), new SqlParameter("SQL2012IsDelete", SqlDbType.Bit, 1), new SqlParameter("SQL2012orderID", SqlDbType.Int, 4) }; parameters[0].Value = model.orderNum; parameters[1].Value = model.orderDate; parameters[2].Value = model.staffID; parameters[3].Value = model.deviceID; parameters[4].Value = model.Count; parameters[5].Value = model.IsDelete; parameters[6].Value = model.orderID; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Info_orderMode model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into Info_order("); strSql.Append("orderNum,orderDate,staffID,deviceID,Count,IsDelete)"); strSql.Append(" values ("); strSql.Append("SQL2012orderNum,SQL2012orderDate,SQL2012staffID,SQL2012deviceID,SQL2012Count,SQL2012IsDelete)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("SQL2012orderNum", SqlDbType.VarChar, 50), new SqlParameter("SQL2012orderDate", SqlDbType.DateTime), new SqlParameter("SQL2012staffID", SqlDbType.VarChar, 50), new SqlParameter("SQL2012deviceID", SqlDbType.VarChar, 50), new SqlParameter("SQL2012Count", SqlDbType.Int, 4), new SqlParameter("SQL2012IsDelete", SqlDbType.Bit, 1) }; parameters[0].Value = model.orderNum; parameters[1].Value = model.orderDate; parameters[2].Value = model.staffID; parameters[3].Value = model.deviceID; parameters[4].Value = model.Count; parameters[5].Value = model.IsDelete; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Info_orderMode GetModel(int orderID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 orderID,orderNum,orderDate,staffID,deviceID,Count,IsDelete from Info_order "); strSql.Append(" where orderID=SQL2012orderID"); SqlParameter[] parameters = { new SqlParameter("SQL2012orderID", SqlDbType.Int, 4) }; parameters[0].Value = orderID; Info_orderMode model = new Info_orderMode(); 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 bool Update(Info_orderMode model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Info_orderMode model) { return(dal.Add(model)); }