private void Add_Click_Function(bool is_edit) { category_name = (tb_category_name.Text.Trim()).Replace('\'', ' '); pic_new_source_path = picture_event.Pic_source_file; lbl_category_message.Text = ""; if (tb_category_name.Text.Trim() == "Category's Name" || tb_category_name.Text.Trim() == "") { lbl_category_message.Text = "* Please enter your category's name"; lbl_category_message.ForeColor = Color.Red; lbl_category_message.Focus(); return; } if (pic_new_source_path == null || pic_new_source_path == pic_default_file) { lbl_category_message.Text = "* Please choose a picture."; lbl_category_message.ForeColor = Color.Red; picture_event.Choose_Image(); return; } if (is_edit == false) { picture_event.Copy_The_Picture(category_name); pic_new_source_path = picture_event.Pic_source_file; Category category = new Category(0, category_name, 0, popularity_score, pic_new_source_path); category.Add(); tb_category_name.Text = "Category's Name"; } else { if (change_image) { if (category_to_edit.Category_cover_path_file != pic_default_file) { Picture_Events.Delete_The_Picture(category_to_edit.Category_cover_path_file); } picture_event.Copy_The_Picture(category_name); pic_new_source_path = picture_event.Pic_source_file; change_image = false; } lbl_category_message.Text = "* Category changed succesfully"; lbl_category_message.ForeColor = Color.LightGreen; category_to_edit.Category_name = category_name; category_to_edit.Category_cover_path_file = picture_event.Pic_source_file; category_to_edit.Edit(); main_page.Main_book_list.Delete_All_List(); Book.Show_All_Books(main_page); } }
private void Add_Click_Function(bool is_edit) { name = (tb_department.Text.Trim()).Replace('\'', ' '); pic_new_source_path = picture_event.Pic_source_file; lbl_message.Text = ""; if (tb_department.Text.Trim() == "Department's Name" || tb_department.Text.Trim() == "") { lbl_message.Text = "* Please enter your department's name"; lbl_message.ForeColor = Color.Red; tb_department.Focus(); return; } if (pic_new_source_path == null || pic_new_source_path == pic_default_file) { lbl_message.Text = "* Please choose a picture."; lbl_message.ForeColor = Color.Red; picture_event.Choose_Image(); return; } if (is_edit == false) { picture_event.Copy_The_Picture(name); pic_new_source_path = picture_event.Pic_source_file; Department department = new Department(0, name, pic_new_source_path); department.Add(); tb_department.Text = "Department's Name"; } else { if (change_image) { if (department_to_edit.Cover_path_file != pic_default_file) { Picture_Events.Delete_The_Picture(department_to_edit.Cover_path_file); } picture_event.Copy_The_Picture(name); pic_new_source_path = picture_event.Pic_source_file; change_image = false; } lbl_message.Text = "* Department changed succesfully"; lbl_message.ForeColor = Color.LightGreen; department_to_edit.Name = name; department_to_edit.Cover_path_file = picture_event.Pic_source_file; department_to_edit.Edit(); } }
private void btn_add_pic_Click(object sender, EventArgs e) { change_image = true; picture_event.Choose_Image(); }