예제 #1
0
        private void EditProject(object sender, EventArgs e)
        {
            string date = DateHandler.GetDate(dtp_Edit_Project_Deadline);
            int    result;

            if (!int.TryParse(txtb_Edit_Project_AOI.Text, out result))
            {
                MessageBox.Show("Amount of Invoices not a number!");
            }
            else if (txtb_Edit_Project_P_Name.Text == "" || txtb_Edit_Project_OS.Text == "" || txtb_Edit_Project_Software.Text == "" || txtb_Edit_Project_Hardware.Text == "")
            {
                MessageBox.Show("Make sure all fields are filled in correctly!");
            }
            else if (dtp_Edit_Project_Deadline.Value <= DateTime.Now)
            {
                MessageBox.Show("Deadline date cannot be today or in the past!");
            }
            else
            {
                dbh.OpenConnection();

                if (dbh.EditProject(lbl_Edit_Project_P_Id.Text, txtb_Edit_Project_P_Name.Text, cb_Edit_Project_P_Status.SelectedIndex.ToString(), cb_Edit_Project_M_C.SelectedIndex.ToString(), txtb_Edit_Project_OS.Text, txtb_Edit_Project_Hardware.Text, txtb_Edit_Project_Software.Text, txtb_Edit_Project_AOI.Text, date))
                {
                    MessageBox.Show("Succesfully added a project!");
                }
                else
                {
                    MessageBox.Show("An error occcured while adding a project.");
                }

                dbh.CloseConnection();
            }
        }
예제 #2
0
        private void AddProject(object sender, EventArgs e)
        {
            int result;

            if (txtb_Amount_Invoices.Text == "" || txtb_Contact_Person.Text == "" || txtb_Operating_System.Text == "" || txtb_Project_Name.Text == "" || txtb_Software.Text == "" || txtb_Hardware.Text == "" || !int.TryParse(txtb_Amount_Invoices.Text, out result))
            {
                MessageBox.Show("Please make sure all the fields are filled in correctly.");
            }
            else if (dtp_Deadline.Value <= DateTime.Now)
            {
                MessageBox.Show("Date cannot be today or in the past.");
            }
            else
            {
                dbh.OpenConnection();
                string date = DateHandler.GetDate(dtp_Deadline);

                if (dbh.AddProject(cb_Select_Customer.SelectedValue.ToString(), txtb_Project_Name.Text, cbox_Project_Status.SelectedIndex, txtb_Operating_System.Text, txtb_Software.Text, txtb_Amount_Invoices.Text, txtb_Contact_Person.Text, cbox_Maintenance_Contract.SelectedIndex, date, txtb_Hardware.Text))
                {
                    MessageBox.Show("Succesfully added a project!");
                }
                else
                {
                    MessageBox.Show("An error occcured while adding a project.");
                }

                dbh.CloseConnection();
            }
        }
예제 #3
0
 public void SetDateTillLabel(object sender, EventArgs e)
 {
     if (tc_Main.SelectedIndex == 0)
     {
         DateTimePicker dtp = (DateTimePicker)sender;
         lbl_Date_Till.Text = DateHandler.GetDateWithMinus(dtp).ToString();
     }
     else
     {
         DateTimePicker dtp = (DateTimePicker)sender;
         lbl_Appointment_DateTill.Text = dtp.Value.ToString();
     }
 }
예제 #4
0
        private void EditCustomer(object sender, EventArgs e)
        {
            int  result;
            bool check    = true;
            int  optional = 0;

            foreach (Control a in tcp_EditCustomer.Controls)
            {
                if (a is TextBox)
                {
                    if (a.AccessibleName != "OptionalLocation" && a.AccessibleName != "VeryOptional")
                    {
                        if (a.Text == "")
                        {
                            check = false;
                        }
                    }
                    else if (a.AccessibleName == "OptionalLocation")
                    {
                        if (a.Text != "")
                        {
                            ++optional;
                        }
                    }
                }
            }

            if (!int.TryParse(txtbCustomerFax.Text, out result) && !int.TryParse(txtbCustomerPhonenumber1.Text, out result) && !int.TryParse(txtbCustomerPhonenumber2.Text, out result))
            {
                MessageBox.Show("fax or phonenumber are not numbers");
            }
            else if (!check)
            {
                MessageBox.Show("Not all fields are filled in.");
            }
            else if (optional != 0 && optional != 4)
            {
                MessageBox.Show("All address details have to be filled in!");
            }
            else if (dtpCustomerNextContact.Value < DateTime.Now)
            {
                MessageBox.Show("Next action date cannot be in the past!");
            }
            else if (txtb_customer_email.Text.Contains("@") == false)
            {
                MessageBox.Show("Your email is invalid");
            }
            else if (txtbCustomerPhonenumber1.Text.Length < 10)
            {
                MessageBox.Show("Your phone number is invalid");
            }
            else if (txtbCustomerPhonenumber2.Text != "" && txtbCustomerPhonenumber2.Text.Length < 10)
            {
                MessageBox.Show("Your 2nd phone number is invalid");
            }
            else
            {
                string nextContact = DateHandler.GetDate(dtpCustomerNextContact);
                string lastContact = DateHandler.GetDate(dtpCustomerLastContact);
                dbh.OpenConnection();

                if (dbh.EditCustomer(lblCustomerId.Text, txtbCustomerCompanyName.Text, txtbCustomerMail.Text, txtbCustomerFax.Text, txtbCustomerStreetName1.Text, txtbCustomerHousenumber1.Text, txtbCustomerResidence1.Text, txtbCustomerZipcode1.Text, txtbCustomerPhonenumber1.Text, txtbCustomerStreetName2.Text, txtbCustomerHousenumber2.Text, txtbCustomerResidence2.Text, txtbCustomerZipcode2.Text, txtbCustomerPhonenumber2.Text, txtbCustomerLastAction.Text, txtbCustomerNextAction.Text, lastContact, nextContact))
                {
                    MessageBox.Show("Succesfully edited customer!");
                }
                else
                {
                    MessageBox.Show("An error occcured while editing a customer!");
                }
                dbh.CloseConnection();
            }
        }
예제 #5
0
        private void AddCustomer(object sender, EventArgs e)
        {
            int  result;
            bool check    = true;
            int  optional = 0;

            foreach (Control a in tcp_AddCustomer.Controls)
            {
                if (a is TextBox)
                {
                    if (a.AccessibleName != "OptionalLocation" && a.AccessibleName != "VeryOptional")
                    {
                        if (a.Text == "")
                        {
                            check = false;
                        }
                    }
                    else if (a.AccessibleName == "OptionalLocation")
                    {
                        if (a.Text != "")
                        {
                            ++optional;
                        }
                    }
                }
            }

            string nextContact = DateHandler.GetDate(dtp_customer_nextcontact);
            string lastContact = DateHandler.GetDate(dtp_customer_lastcontact);

            if (!check)
            {
                MessageBox.Show("Please make sure all the neccesary fields are filled in.");
            }
            else if (optional != 0 && optional != 4)
            {
                MessageBox.Show("All address details have to be filled in!");
            }
            else if (!int.TryParse(txtb_customer_fax.Text, out result) && !int.TryParse(txtb_customer_phonenumber_1.Text, out result) && !int.TryParse(txtb_customer_phonenumber_2.Text, out result))
            {
                MessageBox.Show("fax or phonenumber are not numbers");
            }
            else if (dtp_customer_nextcontact.Value.Date < DateTime.Now.Date)
            {
                MessageBox.Show("Date of next contact cannot be in the past.");
            }
            else if (txtb_customer_email.Text.Contains("@") == false)
            {
                MessageBox.Show("Your email is invalid");
            }
            else if (txtb_customer_phonenumber_1.Text.Length < 10)
            {
                MessageBox.Show("Your phone number is invalid");
            }
            else if (txtb_customer_phonenumber_2.Text != "" && txtb_customer_phonenumber_2.Text.Length < 10)
            {
                MessageBox.Show("Your 2nd phone number is invalid");
            }
            else if (!Regex.IsMatch(txtb_customer_zipcode_1.Text, @"^[1-9][0-9]{3}\s?[a-zA-Z]{2}$"))
            {
                MessageBox.Show("Invalid zipcode");
            }
            else if (txtb_customer_zipcode_2.Text != "" && !Regex.IsMatch(txtb_customer_zipcode_1.Text, @"^[1-9][0-9]{3}\s?[a-zA-Z]{2}$"))
            {
                MessageBox.Show("Invalid 2nd zipcode");
            }
            else
            {
                dbh.OpenConnection();

                if (dbh.AddCustomer(txtb_customer_firstname.Text, txtb_customer_lastname.Text, txtb_customer_company_name.Text, txtb_customer_email.Text, txtb_customer_fax.Text, txtb_customer_streetname_1.Text, txtb_customer_housenumber_1.Text, txtb_customer_residence_1.Text, txtb_customer_zipcode_1.Text, txtb_customer_phonenumber_1.Text, txtb_customer_streetname_2.Text, txtb_customer_housenumber_2.Text, txtb_customer_residence_2.Text, txtb_customer_zipcode_2.Text, txtb_customer_phonenumber_2.Text, lastContact, txtb_customer_last_action.Text, nextContact, txtb_customer_next_action.Text))
                {
                    MessageBox.Show("Succesfully added a customer!");
                }
                else
                {
                    MessageBox.Show("An error occcured while adding a customer.");
                }

                dbh.AddNotification(txtb_customer_firstname.Text, "Creditworthy check", "Finance", " needs to be checked on creditworthyness.");
                dbh.AddNotification(txtb_customer_firstname.Text, "Add financial details", "Finance", " needs his financial details to be added");
                dbh.CloseConnection();
            }
        }