public bool themThang(ChamSocThangDTO thang) { string query = string.Empty; query += "INSERT INTO [CHIPHICHAMSOCTHANG] ([machiphithang],[thang]) "; query += "VALUES (@machiphithang,@thang)"; using (SqlConnection con = new SqlConnection(ConnectionString)) { using (SqlCommand cmd = new SqlCommand()) { cmd.Connection = con; cmd.CommandType = System.Data.CommandType.Text; cmd.CommandText = query; cmd.Parameters.AddWithValue("@machiphithang", thang.MaChiPhiThangPT); cmd.Parameters.AddWithValue("@thang", thang.ThangPT); try { con.Open(); cmd.ExecuteNonQuery(); con.Close(); con.Dispose(); } catch (Exception ex) { con.Close(); return(false); } } } return(true); }
public bool them(ChamSocThangDTO thang) { bool result = ThangDAL.themThang(thang); return(result); }