// Update Doan public bool UpdateDoan(Doan d) { string query = "Update Doan set MaTour = @MaTour, GioDi=@GioDi, GioVe=@GioVe,TenDoan=@TenDoan where MaDoan=@MaDoan"; SqlConnection connect = conn.getConnect(); try { cmd = new SqlCommand(query, connect); connect.Open(); cmd.Parameters.Add("@MaDoan", SqlDbType.Int).Value = d.MaDoan; cmd.Parameters.Add("@MaTour", SqlDbType.Int).Value = d.MaTour; cmd.Parameters.Add("@TenDoan", SqlDbType.NVarChar).Value = d.TenDoan; cmd.Parameters.Add("@GioDi", SqlDbType.NVarChar).Value = d.GioDi; cmd.Parameters.Add("@GioVe", SqlDbType.NVarChar).Value = d.GioVe; cmd.ExecuteNonQuery(); connect.Close(); } catch (Exception e) { return(false); } return(true); }
// Insert Doan public bool insertDoan(Doan d) { string query = "insert into Doan (GioDi,GioVe,MaTour,TenDoan) values(@GioDi,@GioVe,@MaTour,@TenDoan)"; SqlConnection connect = conn.getConnect(); try { cmd = new SqlCommand(query, connect); connect.Open(); // cmd.Parameters.Add("@MaDoan", SqlDbType.Int).Value =d.MaDoan; cmd.Parameters.Add("@GioDi", SqlDbType.DateTime).Value = d.GioDi; cmd.Parameters.Add("@GioVe", SqlDbType.DateTime).Value = d.GioVe; cmd.Parameters.Add("@MaTour", SqlDbType.Int).Value = d.MaTour; cmd.Parameters.Add("@TenDoan", SqlDbType.NVarChar).Value = d.TenDoan; cmd.ExecuteNonQuery(); connect.Close(); } catch (Exception e) { return(false); } return(true); }