private static Tab_QA_Type ToModel(DataRow row) { Tab_QA_Type model = new Tab_QA_Type(); model.Idx = row.IsNull("Idx")?null:(System.Int32?)row["Idx"]; model.QaTypeName = row.IsNull("QaTypeName")?null:(System.String)row["QaTypeName"]; model.SortNumb = row.IsNull("SortNumb")?null:(System.Int32?)row["SortNumb"]; return(model); }
public int AddNew(Tab_QA_Type model) { string sql = "insert into Tab_QA_Type(QaTypeName,SortNumb) values(@QaTypeName,@SortNumb); select @@identity ;"; int Idx = Convert.ToInt32(SqlHelper.ExecuteScalar(CommandType.Text, sql , new SqlParameter("@QaTypeName", model.QaTypeName) , new SqlParameter("@SortNumb", model.SortNumb) )); return(Idx); }
public bool Update(Tab_QA_Type model) { string sql = "update Tab_QA_Type set QaTypeName=@QaTypeName,SortNumb=@SortNumb where Idx=@Idx"; int rows = SqlHelper.ExecuteNonQuery(CommandType.Text, sql , new SqlParameter("@QaTypeName", model.QaTypeName) , new SqlParameter("@SortNumb", model.SortNumb) , new SqlParameter("Idx", model.Idx) ); return(rows > 0); }
public Tab_QA_Type Get(string Idx) { DataTable dt = SqlHelper.ExecuteDataset(CommandType.Text, "select * from Tab_QA_Type where Idx=@Idx", new SqlParameter("Idx", Idx)).Tables[0]; if (dt.Rows.Count > 1) { throw new Exception("more than 1 row was found"); } if (dt.Rows.Count <= 0) { return(null); } DataRow row = dt.Rows[0]; Tab_QA_Type model = ToModel(row); return(model); }