public Model.TT_PitheadBillExtend DataRowToModel(DataRow row) { TDTK.PlatForm.MVC4.Model.TT_PitheadBillExtend model = new TDTK.PlatForm.MVC4.Model.TT_PitheadBillExtend(); if (row != null) { if (row["PID"] != null && row["PID"].ToString() != "") { model.PID = int.Parse(row["PID"].ToString()); } if (row["Iedition"] != null) { model.Iedition = row["Iedition"].ToString(); } if (row["CollCode"] != null) { model.CollCode = row["CollCode"].ToString(); } if (row["DrawPerson"] != null) { model.DrawPerson = row["DrawPerson"].ToString(); } if (row["PayPerson"] != null) { model.PayPerson = row["PayPerson"].ToString(); } if (row["ExtendDate"] != null && row["ExtendDate"].ToString() != "") { model.ExtendDate = DateTime.Parse(row["ExtendDate"].ToString()); } } return model; }
public Model.TT_PitheadBillExtend GetModel(Model.TT_PitheadBillExtend t) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 PID,Iedition,CollCode,DrawPerson,PayPerson,ExtendDate from TT_PitheadBillExtend "); strSql.Append(" where "); strSql.Append("PID=@PID "); strSql.Append(" and Iedition=@Iedition and "); strSql.Append(" CollCode=@CollCode,"); SqlParameter[] parameters = { new SqlParameter("@PID", SqlDbType.Int,4), new SqlParameter("@Iedition", SqlDbType.VarChar,10), new SqlParameter("@CollCode", SqlDbType.VarChar,4)}; parameters[0].Value = t.PID; parameters[1].Value = t.Iedition; parameters[2].Value = t.CollCode; TDTK.PlatForm.MVC4.Model.TT_PitheadBillExtend model = new TDTK.PlatForm.MVC4.Model.TT_PitheadBillExtend(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return DataRowToModel(ds.Tables[0].Rows[0]); } else { return null; } }