public Model.TT_LoadWeight DataRowToModel(DataRow row) { TDTK.PlatForm.MVC4.Model.TT_LoadWeight model = new TDTK.PlatForm.MVC4.Model.TT_LoadWeight(); if (row != null) { if (row["WeightCode"] != null) { model.WeightCode = row["WeightCode"].ToString(); } if (row["TrafficCode"] != null) { model.TrafficCode = row["TrafficCode"].ToString(); } if (row["NavicertCode"] != null) { model.NavicertCode = row["NavicertCode"].ToString(); } if (row["MarkedCardCode"] != null) { model.MarkedCardCode = row["MarkedCardCode"].ToString(); } if (row["RemoteCardCode"] != null) { model.RemoteCardCode = row["RemoteCardCode"].ToString(); } if (row["EmptyCode"] != null) { model.EmptyCode = row["EmptyCode"].ToString(); } if (row["CollCode"] != null) { model.CollCode = row["CollCode"].ToString(); } if (row["CollName"] != null) { model.CollName = row["CollName"].ToString(); } if (row["CoalKindCode"] != null) { model.CoalKindCode = row["CoalKindCode"].ToString(); } if (row["CoalKindName"] != null) { model.CoalKindName = row["CoalKindName"].ToString(); } if (row["CarOwnerName"] != null) { model.CarOwnerName = row["CarOwnerName"].ToString(); } if (row["CarNo"] != null) { model.CarNo = row["CarNo"].ToString(); } if (row["CarType"] != null) { model.CarType = row["CarType"].ToString(); } if (row["LoadWeight"] != null && row["LoadWeight"].ToString() != "") { model.LoadWeight = decimal.Parse(row["LoadWeight"].ToString()); } if (row["EmptyWeight"] != null && row["EmptyWeight"].ToString() != "") { model.EmptyWeight = decimal.Parse(row["EmptyWeight"].ToString()); } if (row["NetWeight"] != null && row["NetWeight"].ToString() != "") { model.NetWeight = decimal.Parse(row["NetWeight"].ToString()); } if (row["OverWeight"] != null && row["OverWeight"].ToString() != "") { model.OverWeight = decimal.Parse(row["OverWeight"].ToString()); } if (row["TaxAmount"] != null && row["TaxAmount"].ToString() != "") { model.TaxAmount = decimal.Parse(row["TaxAmount"].ToString()); } if (row["FundAmount"] != null && row["FundAmount"].ToString() != "") { model.FundAmount = decimal.Parse(row["FundAmount"].ToString()); } if (row["RoomCode"] != null) { model.RoomCode = row["RoomCode"].ToString(); } if (row["RoomName"] != null) { model.RoomName = row["RoomName"].ToString(); } if (row["BangType"] != null) { model.BangType = row["BangType"].ToString(); } if (row["Operator"] != null) { model.Operator = row["Operator"].ToString(); } if (row["WeightTime"] != null && row["WeightTime"].ToString() != "") { model.WeightTime = DateTime.Parse(row["WeightTime"].ToString()); } if (row["RandomCode"] != null) { model.RandomCode = row["RandomCode"].ToString(); } if (row["CustomerName"] != null) { model.CustomerName = row["CustomerName"].ToString(); } if (row["TaxType"] != null) { model.TaxType = row["TaxType"].ToString(); } if (row["IsFirstSite"] != null) { model.IsFirstSite = row["IsFirstSite"].ToString(); } if (row["FrontImage"] != null) { model.FrontImage = row["FrontImage"].ToString(); } if (row["BackImage"] != null) { model.BackImage = row["BackImage"].ToString(); } if (row["UpImage"] != null) { model.UpImage = row["UpImage"].ToString(); } if (row["RoomImage"] != null) { model.RoomImage = row["RoomImage"].ToString(); } if (row["TaxGroup"] != null && row["TaxGroup"].ToString() != "") { model.TaxGroup = decimal.Parse(row["TaxGroup"].ToString()); } if (row["IsSealed"] != null) { model.IsSealed = row["IsSealed"].ToString(); } } return model; }
public Model.TT_LoadWeight GetModel(Model.TT_LoadWeight t) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 WeightCode,TrafficCode,NavicertCode,MarkedCardCode,RemoteCardCode,EmptyCode,CollCode,CollName,CoalKindCode,CoalKindName,CarOwnerName,CarNo,CarType,LoadWeight,EmptyWeight,NetWeight,OverWeight,TaxAmount,FundAmount,RoomCode,RoomName,BangType,Operator,WeightTime,RandomCode,CustomerName,TaxType,IsFirstSite,FrontImage,BackImage,UpImage,RoomImage,TaxGroup,IsSealed from TT_LoadWeight "); strSql.Append(" where WeightCode=@WeightCode "); SqlParameter[] parameters = { new SqlParameter("@WeightCode", SqlDbType.VarChar,35) }; parameters[0].Value = t.WeightCode; TDTK.PlatForm.MVC4.Model.TT_LoadWeight model = new TDTK.PlatForm.MVC4.Model.TT_LoadWeight(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return DataRowToModel(ds.Tables[0].Rows[0]); } else { return null; } }