public bool Add(ProgramOffered programOffered) { if (programOffered.ProgramName.Length > 20) { throw new UniversityException("Character length in program name is more than excepted"); } if (programOffered.Description.Length > 20) { throw new UniversityException("Character length in program Description is more than excepted"); } if (programOffered.ApllicationEligibility.Length > 20) { throw new UniversityException("Character length in program Eligibility is more than excepted"); } if (programOffered.DegreeCertificationOffered.Length > 20) { throw new UniversityException("Character length in program Degree Certificate is more than excepted"); } if (programOffered.Duration > 5) { throw new UniversityException("Duration Can not b be More than 5"); } bool addprogram = false; // DAL object will take programoffered ProgramOfferedDAL program = new ProgramOfferedDAL(); program.Add(programOffered.ProgramName, programOffered.Description, programOffered.ApllicationEligibility, programOffered.Duration, programOffered.DegreeCertificationOffered); addprogram = true; if (addprogram == false) { throw new UniversityException("addtion Failed "); } return(addprogram); }
public bool Update(string updateProgName, ProgramOffered program) { bool updtprog = false; ProgramOfferedDAL prog = new ProgramOfferedDAL(); prog.Update(updateProgName, program.Description, program.ApllicationEligibility, program.Duration, program.DegreeCertificationOffered); updtprog = true; if (updtprog == false) { throw new UniversityException("Updation Failed"); } return(updtprog); }
private void add_click(object sender, RoutedEventArgs e) { try { ProgramOffered program = new ProgramOffered(); ProgramsOfferedBL bL = new ProgramsOfferedBL(); // if(string.IsNullOrWhiteSpace(pname_txt.Text)) if (pname_txt.Text.Length == 0) { throw new UniversityException("Program Name Field Can not be Empty"); } if (Desc_txt.Text.Length == 0) { throw new UniversityException("Description Field Can not be Empty"); } if (elg_txt.Text.Length == 0) { throw new UniversityException("Application Eligibility Field Can not be Empty"); } if (dur_txt.Text.Length == 0) { throw new UniversityException("Duration Field Can not be Empty"); } if (deg_txt.Text.Length == 0) { throw new UniversityException("Degree Certificate Field Can not be Empty"); } program.ProgramName = pname_txt.Text; program.Description = Desc_txt.Text; program.ApllicationEligibility = elg_txt.Text; program.Duration = Convert.ToInt32(dur_txt.Text); program.DegreeCertificationOffered = deg_txt.Text; bool added = bL.Add(program); if (added) { MessageBox.Show("Added Succesfully"); } } catch (UniversityException ex) { MessageBox.Show(ex.Message); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private static void DeletProg() { ProgramOffered program = new ProgramOffered(); ProgramsOfferedBL programBl = new ProgramsOfferedBL(); bool progdeleted = programBl.Delete(program, "Btech Cs"); if (progdeleted) { Console.WriteLine("Deleted Succesfully"); } else { Console.WriteLine("not succesfully deleted"); } }
public List <ProgramOffered> GetAll() { ProgramOffered prog = new ProgramOffered(); List <ProgramOffered> progs = new List <ProgramOffered>(); using (SqlConnection con = new SqlConnection(@"Data Source = DESKTOP-1VJDA3L; Initial Catalog =University Management System(dm); User ID = sa; Password = admin123; Connect Timeout = 30; Encrypt = False; TrustServerCertificate = False; ApplicationIntent = ReadWrite")) { con.Open(); using (SqlCommand cmdSelect = new SqlCommand("select * from Programs_Offered", con)) { SqlDataReader dr = cmdSelect.ExecuteReader(); if (dr.HasRows) { while (dr.Read()) { progs.Add(new ProgramOffered { ProgramName = (string)dr["ProgramName"], Description = (string)dr["description"], ApllicationEligibility = (string)dr["applicant_eligibility"], Duration = (int)dr["duration"], DegreeCertificationOffered = (string)dr["degree_certificate_offered"] }); } dr.Close(); } else { throw new UniversityException("Table is Empty"); } } } if (progs.Count > 0) { } else { throw new UniversityException("Data retriving not succeded"); } return(progs); }
static void AddProg() { ProgramOffered program = new ProgramOffered() { ProgramName = "Btech Cs", Description = "computer study", ApllicationEligibility = "12th Pass", Duration = 3, DegreeCertificationOffered = "BCA Pass" }; ProgramsOfferedBL programBl = new ProgramsOfferedBL(); bool progadded = programBl.Add(program); if (progadded) { Console.WriteLine("added succesfully"); } else { Console.WriteLine("not added succesfully"); } }
private static void UpdateProg() { try { ProgramOffered program = new ProgramOffered() { ProgramName = "Btech Cs", Description = "computer study", ApllicationEligibility = "10th Pass", Duration = 3, DegreeCertificationOffered = "BCA Pass" }; ProgramsOfferedBL programBl = new ProgramsOfferedBL(); bool progadded = programBl.Update("BCA", program); if (progadded) { Console.WriteLine("Updated succesfully"); } else { Console.WriteLine("not Updated succesfully"); } } catch (UniversityException ex) { Console.WriteLine(ex.Message); } }