Example #1
0
        public AddEmployee(Department dprt)
        {
            InitializeComponent();

            rdo_female.Checked = true;
            main_page          = (Microwave_v1._0.Forms.ShowEmployee)Application.OpenForms["ShowEmployee"];
            System.IO.Directory.CreateDirectory(pic_dest_path);
            picture_event         = new Picture_Events(pic_dest_path, picture_default_file, ref this.pic_employee);
            pic_new_source_path   = picture_event.Pic_source_file;
            this.lbl_message.Text = "";

            Fill_Comboboxes();


            if (dprt != null)
            {
                this.cb_department.SelectedIndex = cb_department.Items.IndexOf(dprt.Name);
                this.cb_department.Enabled       = false;
            }
            else
            {
                this.cb_department.SelectedIndex = 0;
                this.cb_department.Enabled       = true;
            }

            this.BringToFront();
        }
        public AddPublisher(Publisher pub)
        {
            InitializeComponent();
            this.btn_add.Image = global::Microwave_v1._0.Properties.Resources.pencil__1_;

            main_page = (Microwave)Application.OpenForms["Microwave"];
            System.IO.Directory.CreateDirectory(pic_dest_path);
            picture_event = new Picture_Events(pic_dest_path, pic_default_file, ref this.pic_publisher);

            publisher_to_edit         = pub;
            this.lbl_pub_message.Text = "";


            // Make other properties default
            this.tb_pub_name.Text           = pub.Pub_name;
            this.tb_pub_name.ForeColor      = Color.LightGray;
            this.tb_pub_email.Text          = pub.Pub_email;
            this.tb_pub_email.ForeColor     = Color.LightGray;
            this.tb_pub_phone_num.Text      = pub.Pub_phone_num;
            this.tb_pub_phone_num.ForeColor = Color.LightGray;
            this.pub_date_of_est            = pub.Pub_date_of_est;
            dtp_publisher.Value             = new DateTime(int.Parse(pub_date_of_est), 1, 1);


            pic_new_source_path = picture_event.Pic_source_file = pub.Pub_cover_path_file;
            pic_publisher.Image = Picture_Events.Get_Copy_Image_Bitmap(pub.Pub_cover_path_file);

            is_edit = true;
        }
Example #3
0
        public AddAuthor(Author author)
        {
            InitializeComponent();
            this.btn_add.Image = global::Microwave_v1._0.Properties.Resources.pencil__1_;

            main_page = (Microwave)Application.OpenForms["Microwave"];
            System.IO.Directory.CreateDirectory(pic_dest_path);
            picture_event         = new Picture_Events(pic_dest_path, pic_default_file, ref this.pic_author);
            this.lbl_message.Text = "";

            author_to_edit = author;

            this.tb_name.Text           = author.Author_name;
            this.tb_name.ForeColor      = Color.LightGray;
            this.tb_country.Text        = author.Author_country;
            this.tb_country.ForeColor   = Color.LightGray;
            this.tb_biography.Text      = author.Author_biography;
            this.tb_biography.ForeColor = Color.LightGray;
            this.gender = author.Author_gender;
            if (author.Author_gender == "Male")
            {
                rdo_male.Checked = true;
            }
            else
            {
                rdo_female.Checked = true;
            }
            this.year        = author.Author_birthday;
            dtp_author.Value = new DateTime(int.Parse(year), 1, 1);

            pic_new_source_path = picture_event.Pic_source_file = author.Author_cover_path_file;
            pic_author.Image    = Picture_Events.Get_Copy_Image_Bitmap(author.Author_cover_path_file);

            is_edit = true;
        }
        private void Receipt_Detail_Load(object sender, EventArgs e)
        {
            this.pb_book.Image          = Picture_Events.Get_Copy_Image_Bitmap(book.Cover_path_file);
            this.lbl_rcpt_name.Text     = receipt.Name;
            this.lbl_book_name_val.Text = book.Name;
            this.lbl_book_id_val.Text   = book.Book_id.ToString();

            this.lbl_user_name_val.Text  = user.Name + " " + user.Surname;
            this.lbl_user_email_val.Text = user.Email;
            this.lbl_user_id_val.Text    = user.User_id.ToString();

            this.lbl_lib_id_val.Text   = manager_id.ToString();
            this.lbl_lib_name_val.Text = manager_name;

            this.lbl_date.Text   = receipt.Creation_date.Substring(0, 10);
            this.tb_message.Text = receipt.Message;

            if (receipt.Pt_name != "NONE")
            {
                this.lbl_pt_name.Text = receipt.Pt_name;
            }
            else
            {
                this.lbl_pt_name.Text = "";
            }
        }
 public AddPublisher()
 {
     InitializeComponent();
     main_page = (Microwave)Application.OpenForms["Microwave"];
     System.IO.Directory.CreateDirectory(pic_dest_path);
     picture_event             = new Picture_Events(pic_dest_path, pic_default_file, ref this.pic_publisher);
     pic_new_source_path       = picture_event.Pic_source_file;
     this.lbl_pub_message.Text = "";
 }
Example #6
0
        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);
            }
        }
Example #7
0
        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();
            }
        }
Example #8
0
        public AddDepartment()
        {
            InitializeComponent();
            main_page = (Microwave)Application.OpenForms["Microwave"];
            System.IO.Directory.CreateDirectory(pic_dest_path);
            picture_event         = new Picture_Events(pic_dest_path, pic_default_file, ref this.pic_department);
            pic_new_source_path   = picture_event.Pic_source_file;
            this.lbl_message.Text = "";

            this.BringToFront();
            main_page.SendToBack();
        }
Example #9
0
        public AddAuthor()
        {
            InitializeComponent();

            main_page = (Microwave)Application.OpenForms["Microwave"];
            System.IO.Directory.CreateDirectory(pic_dest_path);
            picture_event         = new Picture_Events(pic_dest_path, pic_default_file, ref this.pic_author);
            pic_new_source_path   = picture_event.Pic_source_file;
            this.lbl_message.Text = "";

            this.rdo_male.Checked = true;
            this.BringToFront();
        }
Example #10
0
        public AddEmployee(Employee employee)
        {
            InitializeComponent();



            main_page = (Microwave_v1._0.Forms.ShowEmployee)Application.OpenForms["ShowEmployee"];
            System.IO.Directory.CreateDirectory(pic_dest_path);
            picture_event         = new Picture_Events(pic_dest_path, picture_default_file, ref this.pic_employee);
            this.lbl_message.Text = "";

            employee_to_edit = employee;


            Fill_Comboboxes();

            this.cb_department.SelectedIndex = this.cb_department.Items.IndexOf(employee.Deparment_name);

            this.tb_name.Text         = employee.Name;
            this.tb_name.ForeColor    = Color.LightGray;
            this.tb_surname.Text      = employee.Surname;
            this.tb_surname.ForeColor = Color.LightGray;
            this.tb_email.Text        = employee.Email;
            this.tb_email.ForeColor   = Color.LightGray;
            this.dtp_time.Value       = employee.Birth_date_dt;

            if (employee.Gender == "Female")
            {
                rdo_female.Checked = true;
            }
            else
            {
                rdo_male.Checked = true;
            }



            pic_new_source_path = picture_event.Pic_source_file = employee.Cover_path_file;
            pic_employee.Image  = Picture_Events.Get_Copy_Image_Bitmap(pic_new_source_path);

            is_edit = true;

            this.BringToFront();
        }
Example #11
0
        public AddDepartment(Department department)
        {
            InitializeComponent();
            this.btn_add.Image = global::Microwave_v1._0.Properties.Resources.pencil__1_;

            main_page = (Microwave)Application.OpenForms["Microwave"];
            System.IO.Directory.CreateDirectory(pic_dest_path);
            picture_event         = new Picture_Events(pic_dest_path, pic_default_file, ref this.pic_department);
            this.lbl_message.Text = "";

            department_to_edit = department;

            this.tb_department.Text      = department.Name;
            this.tb_department.ForeColor = Color.LightGray;

            pic_new_source_path  = picture_event.Pic_source_file = department.Cover_path_file;
            pic_department.Image = Picture_Events.Get_Copy_Image_Bitmap(department.Cover_path_file);

            is_edit = true;
        }
Example #12
0
        public AddCategory(Category category)
        {
            InitializeComponent();
            this.btn_add.Image = global::Microwave_v1._0.Properties.Resources.pencil__1_;

            main_page = (Microwave)Application.OpenForms["Microwave"];
            System.IO.Directory.CreateDirectory(pic_dest_path);
            picture_event = new Picture_Events(pic_dest_path, pic_default_file, ref this.pic_category);
            this.lbl_category_message.Text = "";

            category_to_edit = category;

            this.tb_category_name.Text      = category.Category_name;
            this.tb_category_name.ForeColor = Color.LightGray;
            //this.tb_category_description.Text = category.Category_description ;
            //this.tb_category_name.ForeColor = Color.LightGray;

            pic_new_source_path = picture_event.Pic_source_file = category.Category_cover_path_file;
            pic_category.Image  = Picture_Events.Get_Copy_Image_Bitmap(category.Category_cover_path_file);

            is_edit = true;
        }
Example #13
0
        private void Add_Click_Func(bool is_edit)
        {
            name    = tb_name.Text.Replace('\'', ' ');
            surname = tb_surname.Text;
            email   = tb_email.Text;

            department_id = int.Parse(cb_department.SelectedIndex.ToString());
            password      = Generate_Auto_Password();


            lbl_message.Text = "";


            if (tb_name.Text.Trim() == "Employee's Name" || tb_name.Text.Trim() == "")
            {
                lbl_message.Text      = "* Please enter name.";
                lbl_message.ForeColor = Color.Red;
                tb_name.Focus();
                return;
            }
            if (tb_surname.Text.Trim() == "Employee's Surname" || tb_surname.Text.Trim() == "")
            {
                lbl_message.Text      = "* Please enter surname.";
                lbl_message.ForeColor = Color.Red;
                tb_surname.Focus();
                return;
            }
            if (tb_email.Text.Trim() == "Employee's E-mail" || tb_email.Text.Trim() == "")
            {
                lbl_message.Text      = "* Please enter e-mail.";
                lbl_message.ForeColor = Color.Red;
                tb_name.Focus();
                return;
            }
            if (!is_a_valid_email(email))
            {
                return;
            }

            if (rdo_male.Checked)
            {
                gender = "Male";
            }
            else if (rdo_female.Checked)
            {
                gender = "Female";
            }
            else
            {
                lbl_message.Text      = "*Please select gender";
                lbl_message.ForeColor = Color.Red;
                return;
            }


            if (is_edit == false)
            {
                if (picture_event.Pic_source_file != null && picture_event.Pic_source_file != picture_default_file)
                {
                    picture_event.Copy_The_Picture(name);
                    pic_new_source_path = picture_event.Pic_source_file;
                }
                else
                {
                    pic_new_source_path = picture_default_file;
                }


                if (Employee.Contains_Email(email) != -1)
                {
                    lbl_message.Text      = "*That email is used by another employee";
                    lbl_message.ForeColor = Color.Red;
                    return;
                }


                lbl_message.Text      = "*Employee added successfully";
                lbl_message.ForeColor = Color.Green;

                Employee employee = new Employee(0, department_id, name, surname, password, email, gender, dtp_time.Value, pic_new_source_path);
                employee.Add();



                Clear();
            }
            else
            {
                if (Employee.Contains_Email(email) != employee_to_edit.Employee_id && Employee.Contains_Email(email) != -1)
                {
                    lbl_message.Text      = "*That email is used by another employee";
                    lbl_message.ForeColor = Color.Red;
                    return;
                }

                if (change_image)
                {
                    if (employee_to_edit.Cover_path_file != picture_default_file)
                    {
                        Picture_Events.Delete_The_Picture(employee_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      = "*Employee changed successfully";
                lbl_message.ForeColor = Color.LightGreen;

                employee_to_edit.Name            = name;
                employee_to_edit.Surname         = surname;
                employee_to_edit.Gender          = gender;
                employee_to_edit.Email           = email;
                employee_to_edit.Department_id   = department_id;
                employee_to_edit.Cover_path_file = picture_event.Pic_source_file;
                employee_to_edit.Birth_date_dt   = dtp_time.Value;

                employee_to_edit.Edit();

                main_page.Pnl_employee_list.VerticalScroll.Value = 0;
                main_page.Main_employee_list.Delete_All_List();
                Employee.Show_All_Employees(main_page.Department);
                main_page.Main_tag.lbl_author.Text      = " ";
                main_page.Main_tag.lbl_bookname.Text    = " ";
                main_page.Main_tag.pic_book.Visible     = false;
                main_page.Main_tag.lbl_description.Text = " ";
            }
        }
Example #14
0
        private void Add_Click_Func(bool is_edit)
        {
            name                = (tb_name.Text.Trim()).Replace('\'', ' ');
            country             = (tb_country.Text.Trim()).Replace('\'', ' ');
            year                = dtp_author.Value.Year.ToString();
            biography           = tb_biography.Text.Replace('\'', ' ');
            pic_new_source_path = picture_event.Pic_source_file;



            lbl_message.Text = "";

            if (tb_name.Text.Trim() == "Name" || tb_name.Text.Trim() == "")
            {
                lbl_message.Text      = "* Please enter name.";
                lbl_message.ForeColor = Color.Red;
                tb_name.Focus();
                return;
            }

            if (tb_country.Text.Trim() == "Country" || tb_country.Text.Trim() == "")
            {
                lbl_message.Text      = "* Please country name.";
                lbl_message.ForeColor = Color.Red;
                tb_country.Focus();
                return;
            }

            if (dtp_author.Text.Trim() == "Year" || dtp_author.Text.Trim() == "")
            {
                lbl_message.Text      = "* Please enter birth year.";
                lbl_message.ForeColor = Color.Red;
                dtp_author.Focus();
                return;
            }

            if (tb_biography.Text.Trim() == "Biography..." || tb_biography.Text.Trim() == "")
            {
                lbl_message.Text      = "* Please enter biography.";
                lbl_message.ForeColor = Color.Red;
                tb_biography.Focus();
                return;
            }

            if (rdo_male.Checked)
            {
                gender = "Male";
            }
            else if (rdo_female.Checked)
            {
                gender = "Female";
            }
            else
            {
                lbl_message.Text      = "* Please select gender";
                lbl_message.ForeColor = Color.Red;
                return;
            }

            if (is_edit == false)
            {
                /* IMPORTANT */
                if (picture_event.Pic_source_file != null && picture_event.Pic_source_file != pic_default_file)
                {
                    picture_event.Copy_The_Picture(name);
                    pic_new_source_path = picture_event.Pic_source_file;
                }
                else
                {
                    pic_new_source_path = pic_default_file;
                }

                Author author = new Author(0, 0, name, country, gender, year, biography, pic_new_source_path);
                author.Add();

                Clear();
            }
            else
            {
                if (change_image)
                {
                    /* IMPORTANT */
                    if (author_to_edit.Author_cover_path_file != pic_default_file)
                    {
                        Picture_Events.Delete_The_Picture(author_to_edit.Author_cover_path_file);
                    }
                    picture_event.Copy_The_Picture(name);
                    pic_new_source_path = picture_event.Pic_source_file;
                    change_image        = false;
                }

                lbl_message.Text      = "*Author changed successfully";
                lbl_message.ForeColor = Color.LightGreen;

                author_to_edit.Author_name            = name;
                author_to_edit.Author_country         = country;
                author_to_edit.Author_gender          = gender;
                author_to_edit.Author_birthday        = year;
                author_to_edit.Author_biography       = biography;
                author_to_edit.Author_cover_path_file = pic_new_source_path;
                author_to_edit.Edit();

                main_page.Pnl_author_list.VerticalScroll.Value = 0;
                main_page.Author_search_list.Delete_All_List();
                main_page.Main_author_list.Hide_All_Author_Objects();
                main_page.Main_author_list.Draw_All_Authors();
                main_page.Author_searched_already = false;

                main_page.Main_book_list.Delete_All_List();
                Book.Show_All_Books(main_page);
            }
        }
Example #15
0
        private void Pub_Add_Click_Func(bool is_edit)
        {
            pub_name            = tb_pub_name.Text.Replace('\'', ' ');
            pub_email           = tb_pub_email.Text.Replace('\'', ' ');
            pub_phone_number    = tb_pub_phone_num.Text.Replace('\'', ' ');
            pic_new_source_path = picture_event.Pic_source_file;
            pub_date_of_est     = dtp_publisher.Value.ToString("yyyy");

            lbl_pub_message.Text = "";

            // Validations
            if (tb_pub_name.Text.Trim() == "Publisher's Name" || tb_pub_name.Text.Trim() == "")
            {
                lbl_pub_message.Text      = "* Please enter publisher's name.";
                lbl_pub_message.ForeColor = Color.Red;
                tb_pub_name.Focus();
                return;
            }
            if (tb_pub_email.Text.Trim() == "Publisher's Email" || tb_pub_email.Text.Trim() == "")
            {
                lbl_pub_message.Text      = "* Please enter publisher's email.";
                lbl_pub_message.ForeColor = Color.Red;
                tb_pub_email.Focus();
                return;
            }
            if (!is_a_valid_email(pub_email))
            {
                return;
            }

            if (tb_pub_phone_num.Text.Trim() == "Publisher's Phone Number" || tb_pub_phone_num.Text.Trim() == "")
            {
                lbl_pub_message.Text      = "* Please enter publisher's phone number.";
                lbl_pub_message.ForeColor = Color.Red;
                tb_pub_phone_num.Focus();
                return;
            }


            if (is_edit == false)
            {
                if (picture_event.Pic_source_file != null && picture_event.Pic_source_file != pic_default_file)
                {
                    picture_event.Copy_The_Picture(pub_name);
                    pic_new_source_path = picture_event.Pic_source_file;
                }
                else
                {
                    pic_new_source_path = pic_default_file;
                }

                Publisher publisher = new Publisher(0, pub_name, pub_email, pub_phone_number, pub_date_of_est, pic_new_source_path);
                publisher.Add();



                Clear();
            }
            else
            {
                if (change_image)
                {
                    if (publisher_to_edit.Pub_cover_path_file != pic_default_file)
                    {
                        Picture_Events.Delete_The_Picture(publisher_to_edit.Pub_cover_path_file);
                    }
                    picture_event.Copy_The_Picture(pub_name);
                    pic_new_source_path = picture_event.Pic_source_file;
                    change_image        = false;
                }

                lbl_pub_message.Text      = "*Publisher changed successfully";
                lbl_pub_message.ForeColor = Color.LightGreen;

                publisher_to_edit.Pub_name            = pub_name;
                publisher_to_edit.Pub_email           = pub_email;
                publisher_to_edit.Pub_phone_num       = pub_phone_number;
                publisher_to_edit.Pub_date_of_est     = pub_date_of_est;
                publisher_to_edit.Pub_cover_path_file = picture_event.Pic_source_file;

                publisher_to_edit.Edit();

                main_page.Pnl_pub_list.VerticalScroll.Value = 0;
                main_page.Publisher_search_list.Delete_All_List();
                main_page.Main_pub_list.Draw_All_Publishers();
                main_page.Publisher_searched_already = false;

                main_page.Main_book_list.Delete_All_List();
                Book.Show_All_Books(main_page);
            }
        }