private void Submit_Click(object sender, EventArgs e) { ShorashimCourse sc = Program.seekCourse(this.courseNumber1); string data = string.Empty; foreach (DataGridViewRow row in dataGridView1.Rows) { data = Convert.ToString(row.Cells[1].Value); int quantity1 = Convert.ToInt32(row.Cells[3].Value); Product pnew = Program.seekProductByName(data); if (pnew != null) { ProductInCourse NewPIC = new ProductInCourse(sc, pnew, quantity1, true); pnew.setProductQuantity(pnew.get_productQuantity() - quantity1); // change to new quantity attribute pnew.update_product(); // update sql messageBoxForInventoryAlert(); } } foreach (OrderFromSupplier o in Program.ordersFromSuppliers) //check of hahalot - products of every order { o.PrintAll(); } foreach (Product p in Program.products) //check of hahalot - orders of this product { Console.WriteLine("printing ProductInCourse lists of products"); p.printAllthisProductsInCourses(); } }
public ProductInCourse(ShorashimCourse course, Product product, int quantity, bool is_new) { this.product = product; // הכלה this.course = course; //הכלה this.quantity = quantity; this.course.addProductsToCourse(this); this.product.addProductToCourse(this); if (is_new) { this.createProductInCourse(); } }
public CustomerInCourse(ShorashimCourse course1, Customer customer1, bool is_new) { this.course = course1; //הכלה this.customer = customer1; // הכלה this.course.addCustomerToCourse(this); this.customer.addCustomerToCourse(this); if (is_new) { this.createCustomerInCourse(); } }
public static void init_Courses()//מילוי המערך מתוך בסיס הנתונים { SqlCommand c = new SqlCommand(); c.CommandText = "EXECUTE dbo.Get_All_Courses"; SQL_CON SC = new SQL_CON(); SqlDataReader rdr = SC.execute_query(c); Shorashim_Courses = new List <ShorashimCourse>(); while (rdr.Read()) { ShorashimCourse cou = new ShorashimCourse(rdr.GetValue(0).ToString(), rdr.GetValue(1).ToString(), DateTime.Parse(rdr.GetValue(2).ToString()), rdr.GetValue(3).ToString(), rdr.GetValue(4).ToString(), int.Parse(rdr.GetValue(5).ToString()), int.Parse(rdr.GetValue(6).ToString()), rdr.GetValue(7).ToString(), rdr.GetValue(8).ToString(), false); Shorashim_Courses.Add(cou); } }
private void Submit_Click(object sender, EventArgs e) { //Customer C = Program.seekCustomer(Convert.ToInt32(CID.Text)); //ShorashimCourse sc = Program.seekCourse(this.courseNumber1); string data = string.Empty; foreach (DataGridViewRow row in dataGridView1.Rows) { data = Convert.ToString(row.Cells[1].Value); int customer1 = Convert.ToInt32(row.Cells[0].Value); Customer chosenCustomer = Program.seekCustomer(customer1); ShorashimCourse chosenCourse = Program.seekCourseByName(data); if (chosenCustomer != null && chosenCourse != null) { CustomerInCourse NewCIC = new CustomerInCourse(chosenCourse, chosenCustomer, true); } } //EMAIL HERE this.Close(); Main_Menu mainMenu1 = new Main_Menu(EID); mainMenu1.Enabled = true; mainMenu1.Show(); foreach (ShorashimCourse o in Program.Shorashim_Courses) //check of hahalot - products of every order { o.printAllcustomersInThisCourse(); } foreach (Customer c in Program.customers) //check of hahalot - orders of this product { Console.WriteLine("printing CustomersInCourse lists of Customers"); c.printAllCustomersInCourse(); } }
private void CN_SelectedIndexChanged(object sender, EventArgs e) { foreach (ShorashimCourse SC in Program.Shorashim_Courses) { if (SC.get_CourseName().Equals(CN.Text)) { DateTime.Text = SC.get_CourseDateTime().ToString(); CustomersinCourse = SC.get_customersInThisCourse().Count; } } ShorashimCourse SC1 = Program.seekCourseByName(CN.Text); DescrriptionBox.Text = SC1.get_Description() + Environment.NewLine + "Location:" + SC1.get_location(); }
private void Donebutton_Click(object sender, EventArgs e) { int value; var list = new string[] { CourseNameInput.Text, LecturerNameInput.Text, LecturerNameInput.Text, participantPrice.Text, LocationBox.Text, courseDescriptionInput.Text }; string v = ""; if (int.TryParse(courseNumberInput.Text, out value) == false) // Dont Continue if null or String { MessageBox.Show(" Please enter a vaild ID Course!", "Numbers Only", MessageBoxButtons.OK); courseNumberInput.Clear(); } else if (int.TryParse(participantPriceInput.Text, out value) == false || Int32.Parse(participantPriceInput.Text) <= 0) // Dont Continue if null or String { MessageBox.Show(" Please enter a vaild Participant Price", "Numbers Only", MessageBoxButtons.OK); courseNumberInput.Clear(); } else if (list.Contains(v)) { MessageBox.Show(" Please enter a values in all fields", "Error", MessageBoxButtons.OK); } else if (Program.seekCourse(courseNumberInput.Text.ToString()) == null)// that a new course { DateTime Date = Convert.ToDateTime(courseDateTimeInput.Value, CultureInfo.InvariantCulture); ShorashimCourse cou = new ShorashimCourse(courseNumberInput.Text.ToString(), CourseNameInput.Text.ToString(), Date, LecturerNameInput.Text.ToString(), LecturerPhoneInput.Text.ToString(), int.Parse(participantPriceInput.Text.ToString()), 300, LocationBox.Text.ToString(), courseDescriptionInput.Text.ToString(), true); InsertProductsToCourse New_page = new InsertProductsToCourse(this.courseNumberInput.Text, EID); New_page.Enabled = true;//maybe not needed New_page.Show(); this.Hide(); } else { MessageBox.Show("הקורס קיים במערכת", "המשך", MessageBoxButtons.OK); } }
private void Add_Click(object sender, EventArgs e) { int value; ShorashimCourse SC = GetSC(); if (int.TryParse(CID.Text, out value) == false || string.IsNullOrWhiteSpace(CID.Text) || IDCustomer() == false) { MessageBox.Show(" Please enter right CustomerID", "Error", MessageBoxButtons.OK); } else if (MaxCustomes < CustomersinCourse) { MessageBox.Show(" this curse is full. please try another course", "Error", MessageBoxButtons.OK); } else { string data1 = string.Empty; string data2 = string.Empty; bool isExist = false; foreach (DataGridViewRow row in dataGridView1.Rows) ///check if already exists - only 1 register of a person to same course !! { data1 = Convert.ToString(row.Cells[0].Value); data2 = Convert.ToString(row.Cells[1].Value); if (Equals(CID.Text, data1) == true && Equals(CN.SelectedValue, data2) == true) { isExist = true; } } if (isExist == false) { dataGridView1.Rows.Add(CID.Text, CN.Text, DateTime.Text, SC.get_participantPrice()); } else { MessageBox.Show(" You already registered this person to this course!", "Invaild Input", MessageBoxButtons.OK); } } }