/// <summary> /// 得到一个对象实体 /// </summary> public Ferrero.Model.ICInventory DataRowToModel(DataRow row) { Ferrero.Model.ICInventory model = new Ferrero.Model.ICInventory(); if (row != null) { if (row["FBrNo"] != null) { model.FBrNo = row["FBrNo"].ToString(); } if (row["FItemID"] != null && row["FItemID"].ToString() != "") { model.FItemID = int.Parse(row["FItemID"].ToString()); } if (row["FBatchNo"] != null) { model.FBatchNo = row["FBatchNo"].ToString(); } if (row["FStockID"] != null && row["FStockID"].ToString() != "") { model.FStockID = int.Parse(row["FStockID"].ToString()); } if (row["FQty"] != null && row["FQty"].ToString() != "") { model.FQty = decimal.Parse(row["FQty"].ToString()); } if (row["FBal"] != null && row["FBal"].ToString() != "") { model.FBal = decimal.Parse(row["FBal"].ToString()); } if (row["FStockPlaceID"] != null && row["FStockPlaceID"].ToString() != "") { model.FStockPlaceID = int.Parse(row["FStockPlaceID"].ToString()); } if (row["FKFPeriod"] != null && row["FKFPeriod"].ToString() != "") { model.FKFPeriod = int.Parse(row["FKFPeriod"].ToString()); } if (row["FKFDate"] != null) { model.FKFDate = row["FKFDate"].ToString(); } if (row["FQtyLock"] != null && row["FQtyLock"].ToString() != "") { model.FQtyLock = decimal.Parse(row["FQtyLock"].ToString()); } if (row["FAuxPropID"] != null && row["FAuxPropID"].ToString() != "") { model.FAuxPropID = int.Parse(row["FAuxPropID"].ToString()); } if (row["FSecQty"] != null && row["FSecQty"].ToString() != "") { model.FSecQty = decimal.Parse(row["FSecQty"].ToString()); } } return(model); }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(string sConnectionName, Ferrero.Model.ICInventory model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into ICInventory("); strSql.Append("FBrNo,FItemID,FBatchNo,FStockID,FQty,FBal,FStockPlaceID,FKFPeriod,FKFDate,FQtyLock,FAuxPropID,FSecQty)"); strSql.Append(" values ("); strSql.Append("@FBrNo,@FItemID,@FBatchNo,@FStockID,@FQty,@FBal,@FStockPlaceID,@FKFPeriod,@FKFDate,@FQtyLock,@FAuxPropID,@FSecQty)"); SqlParameter[] parameters = { new SqlParameter("@FBrNo", SqlDbType.VarChar, 10), new SqlParameter("@FItemID", SqlDbType.Int, 4), new SqlParameter("@FBatchNo", SqlDbType.VarChar, 200), new SqlParameter("@FStockID", SqlDbType.Int, 4), new SqlParameter("@FQty", SqlDbType.Decimal, 13), new SqlParameter("@FBal", SqlDbType.Decimal, 13), new SqlParameter("@FStockPlaceID", SqlDbType.Int, 4), new SqlParameter("@FKFPeriod", SqlDbType.Int, 4), new SqlParameter("@FKFDate", SqlDbType.VarChar, 20), new SqlParameter("@FQtyLock", SqlDbType.Decimal, 13), new SqlParameter("@FAuxPropID", SqlDbType.Int, 4), new SqlParameter("@FSecQty", SqlDbType.Decimal, 13) }; parameters[0].Value = model.FBrNo; parameters[1].Value = model.FItemID; parameters[2].Value = model.FBatchNo; parameters[3].Value = model.FStockID; parameters[4].Value = model.FQty; parameters[5].Value = model.FBal; parameters[6].Value = model.FStockPlaceID; parameters[7].Value = model.FKFPeriod; parameters[8].Value = model.FKFDate; parameters[9].Value = model.FQtyLock; parameters[10].Value = model.FAuxPropID; parameters[11].Value = model.FSecQty; int rows = SqlHelper.ExecuteSql(SqlHelper.GetConnectionString(sConnectionName), strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Ferrero.Model.ICInventory GetModel(string sConnectionName, string FBrNo, int FAuxPropID, int FItemID, string FBatchNo, int FStockID, int FStockPlaceID, int FKFPeriod, string FKFDate) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 FBrNo,FItemID,FBatchNo,FStockID,FQty,FBal,FStockPlaceID,FKFPeriod,FKFDate,FQtyLock,FAuxPropID,FSecQty from ICInventory "); strSql.Append(" where FBrNo=@FBrNo and FAuxPropID=@FAuxPropID and FItemID=@FItemID and FBatchNo=@FBatchNo and FStockID=@FStockID and FStockPlaceID=@FStockPlaceID and FKFPeriod=@FKFPeriod and FKFDate=@FKFDate "); SqlParameter[] parameters = { new SqlParameter("@FBrNo", SqlDbType.VarChar, 10), new SqlParameter("@FAuxPropID", SqlDbType.Int, 4), new SqlParameter("@FItemID", SqlDbType.Int, 4), new SqlParameter("@FBatchNo", SqlDbType.VarChar, 200), new SqlParameter("@FStockID", SqlDbType.Int, 4), new SqlParameter("@FStockPlaceID", SqlDbType.Int, 4), new SqlParameter("@FKFPeriod", SqlDbType.Int, 4), new SqlParameter("@FKFDate", SqlDbType.VarChar, 20) }; parameters[0].Value = FBrNo; parameters[1].Value = FAuxPropID; parameters[2].Value = FItemID; parameters[3].Value = FBatchNo; parameters[4].Value = FStockID; parameters[5].Value = FStockPlaceID; parameters[6].Value = FKFPeriod; parameters[7].Value = FKFDate; Ferrero.Model.ICInventory model = new Ferrero.Model.ICInventory(); DataSet ds = SqlHelper.Query(SqlHelper.GetConnectionString(sConnectionName), strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }