Пример #1
0
        //New Product Button Click
        private void NewProductCreateButton_Click(object sender, RoutedEventArgs e)
        {
            this.NewProductCreateButton.IsEnabled = false;
            Mouse.OverrideCursor = Cursors.Wait;
            MySqlNaceassaryElement mysqlNecessaryFunction = new MySqlNaceassaryElement();
            try
            {
                if (this.NewProductTextBoxCompanyName.Text != string.Empty && this.NewProductTextBoxProductName.Text != string.Empty && this.NewProductTextBoxModelNumber.Text != string.Empty && (this.NewProductTextBoxProductID.Text != string.Empty || this.NewProductCheckBoxAutoGenerate.IsChecked.Equals(true)))
                {

                    if (!this.NewProductCheckBoxAutoGenerate.IsChecked.Equals(true))
                    {
                        if (this.NewProductTextBoxProductID.Text != string.Empty)
                        {
                            if (!mysqlNecessaryFunction.MysqlValueChecker(string.Format("SELECT * FROM {0} WHERE {1}='{2}'", Variables.TABLE_NAME[11], Variables.COLUMN_NAME[4], this.NewProductTextBoxProductID.Text)))
                            {
                               throw new PetuniaException(Variables.ERROR_MESSAGES[0, 9]);
                            }
                        }
                        else
                        {
                            throw new PetuniaException(Variables.ERROR_MESSAGES[0, 5]);
                        }
                    }
                    else
                    {
                        this.NewProductTextBoxProductID.Text = mysqlNecessaryFunction.ProductIDIs(Variables.TABLE_NAME[11], Variables.COLUMN_NAME[4]);
                    }
                    this.NewProductTextBoxProductID.Text = new NecessaryFunction().SixDigitNumber(this.NewProductTextBoxProductID.Text);
                    if (!mysqlNecessaryFunction.MysqlValueChecker(string.Format("SELECT * FROM {0} WHERE {1}='{2}' AND {3}='{4}' AND {5}='{6}'", Variables.TABLE_NAME[11], Variables.COLUMN_NAME[7], this.NewProductTextBoxCompanyName.Text, Variables.COLUMN_NAME[10], this.NewProductTextBoxProductName.Text, Variables.COLUMN_NAME[11], this.NewProductTextBoxModelNumber.Text)) | !mysqlNecessaryFunction.DatabaseOperation(string.Format("SELECT * FROM {0} WHERE {1}='{2}'", Variables.TABLE_NAME[4], Variables.COLUMN_NAME[4], this.NewProductTextBoxProductID.Text)))
                    {
                        throw new PetuniaException(Variables.ERROR_MESSAGES[0, 10]);
                    }
                    else
                    {
                        if (mysqlNecessaryFunction.DatabaseOperation(string.Format("INSERT INTO {0} VALUES ('{1}','{2}','{3}','{4}','{5}','{6}')", Variables.TABLE_NAME[11], this.NewProductTextBoxProductID.Text, DateTime.Now.ToString("yyyy-MM-dd"), this.NewProductTextBoxCompanyName.Text, this.NewProductTextBoxProductName.Text, this.NewProductTextBoxModelNumber.Text, this.NewProductTextBoxDescription.Text)))
                        {
                            mysqlNecessaryFunction.DatabaseOperation(string.Format("INSERT INTO {0} VALUES ('{1}',0,0,0,NULL)", Variables.TABLE_NAME[4], this.NewProductTextBoxProductID.Text));
                            throw new SuccessfullException(Variables.ERROR_MESSAGES[0, 11]);
                        }
                        else
                        {
                            throw new PetuniaException(Variables.ERROR_MESSAGES[0, 2]);
                        }
                    }
                }
                else
                {
                    throw new PetuniaException(Variables.ERROR_MESSAGES[0, 5]);
                }
            }
            catch (SuccessfullException success)
            {
                Mouse.OverrideCursor = null;
                Microsoft.Windows.Controls.MessageBox.Show(success.Message, ProcestaVariables.Variables.ERROR_MESSAGES[0, 0], MessageBoxButton.OK, MessageBoxImage.Information);
            }
            catch (Exception error)
            {
                Mouse.OverrideCursor = null;
                Microsoft.Windows.Controls.MessageBox.Show(error.Message, ProcestaVariables.Variables.ERROR_MESSAGES[0, 0], MessageBoxButton.OK, MessageBoxImage.Stop);
            }
            finally
            {
                Mouse.OverrideCursor = null;
                this.NewProductCreateButton.IsEnabled = true;
                mysqlNecessaryFunction.Dispose();
            }
        }
Пример #2
0
 //Edit NewProduct Update Button
 private void EditNewProductUpdateClick(object sender, System.Windows.RoutedEventArgs e)
 {
     this.EditNewProductButtonUpdate.IsEnabled = false;
     MySqlNaceassaryElement mysqlNecessaryFunction = new MySqlNaceassaryElement();
     try
     {
         MessageBoxResult tempDiglogBoxResult = Microsoft.Windows.Controls.MessageBox.Show(Variables.ERROR_MESSAGES[1, 11], Variables.ERROR_MESSAGES[0, 0], MessageBoxButton.YesNo, MessageBoxImage.Question);
         Mouse.OverrideCursor = Cursors.Wait;
         if (tempDiglogBoxResult.Equals(MessageBoxResult.Yes))
         {
             if (this.EditNewProductTextBoxCompanyName.Text != string.Empty && this.EditNewProductTextBoxProductName.Text != string.Empty && this.EditNewProductTextBoxModelNumber.Text != string.Empty && this.EditNewProductProductInfo.ModelNumberIs != string.Empty)
             {
                 if (mysqlNecessaryFunction.MysqlValueChecker(string.Format("SELECT * FROM {0} WHERE {1}='{2}' AND {3}='{4}' AND {5}='{6}'", Variables.TABLE_NAME[11], Variables.COLUMN_NAME[7], this.EditNewProductTextBoxCompanyName.Text, Variables.COLUMN_NAME[10], this.EditNewProductTextBoxProductName.Text, Variables.COLUMN_NAME[11], this.EditNewProductTextBoxModelNumber.Text)))
                 {
                     mysqlNecessaryFunction.DatabaseOperation(string.Format("UPDATE {0} SET {1}='{2}',{3}='{4}',{5}='{6}' WHERE {7}='{8}'", Variables.TABLE_NAME[11], Variables.COLUMN_NAME[7], this.EditNewProductTextBoxCompanyName.Text, Variables.COLUMN_NAME[10], this.EditNewProductTextBoxProductName.Text, Variables.COLUMN_NAME[11], this.EditNewProductTextBoxModelNumber.Text, Variables.COLUMN_NAME[4], this.EditNewProductLabelProductID.Text));
                     this.EditNewProductProductInfo.CompanyNameLoader();
                     throw new SuccessfullException(Variables.ERROR_MESSAGES[0, 11]);
                 }
                 else
                 {
                     throw new PetuniaException(Variables.ERROR_MESSAGES[0, 10]);
                 }
             }
             else
             {
                 throw new PetuniaException(Variables.ERROR_MESSAGES[0, 5]);
             }
         }
     }
     catch (SuccessfullException success)
     {
         Mouse.OverrideCursor = null;
         Microsoft.Windows.Controls.MessageBox.Show(success.Message, Variables.ERROR_MESSAGES[0, 0], MessageBoxButton.OK, MessageBoxImage.Information);
     }
     catch (Exception error)
     {
         Mouse.OverrideCursor = null;
         Microsoft.Windows.Controls.MessageBox.Show(error.Message, Variables.ERROR_MESSAGES[0, 0], MessageBoxButton.OK, MessageBoxImage.Stop);
     }
     finally
     {
         Mouse.OverrideCursor = null;
         mysqlNecessaryFunction.Dispose();
         this.EditNewProductButtonUpdate.IsEnabled = true;
     }
 }
Пример #3
0
        //New Party Create Button
        private void NewPartyCreateClick(object sender, System.Windows.RoutedEventArgs e)
        {
            this.NewParyButtonCreate.IsEnabled = false;
            Mouse.OverrideCursor = Cursors.Wait;
            MySqlNaceassaryElement mysqlNecessaryFunction = new MySqlNaceassaryElement();
            try
            {
                if (this.NewParyTextBoxUserID.Text != string.Empty && this.NewParyComboBoxAccountType.Text != string.Empty)
                {

                    if (mysqlNecessaryFunction.MysqlValueChecker(string.Format("SELECT * FROM {0} WHERE {1}='{2}'", Variables.TABLE_NAME[10], Variables.COLUMN_NAME[3], this.NewParyTextBoxUserID.Text)))
                    {
                        mysqlNecessaryFunction.DatabaseOperation(string.Format("INSERT {0} VALUES ('{1}','{2}','{3}','{4}','{5}','{6}')", Variables.TABLE_NAME[10], this.NewParyTextBoxUserID.Text, this.NewParyComboBoxAccountType.Text, this.NewPartyTextBoxPhoneNumber.Text, this.NewPartyTextBoxEmail.Text, this.NewPartyTextBoxContractPerson.Text, this.NewpartyTextBoxAddress.Text));
                        mysqlNecessaryFunction.DatabaseOperation(string.Format("INSERT INTO {0} VALUES ('{1}',0)", Variables.TABLE_NAME[9], this.NewParyTextBoxUserID.Text));
                        throw new SuccessfullException(Variables.ERROR_MESSAGES[0, 11]);
                    }
                    else
                    {
                        throw new PetuniaException(Variables.ERROR_MESSAGES[1, 5]);
                    }
                }
                else
                {
                    throw new PetuniaException(Variables.ERROR_MESSAGES[0, 5]);
                }
            }
            catch (SuccessfullException success)
            {
                Mouse.OverrideCursor = null;
                Microsoft.Windows.Controls.MessageBox.Show(success.Message, Variables.ERROR_MESSAGES[0, 0], MessageBoxButton.OK, MessageBoxImage.Information);
            }
            catch (Exception error)
            {
                Mouse.OverrideCursor = null;
                Microsoft.Windows.Controls.MessageBox.Show(error.Message, Variables.ERROR_MESSAGES[0, 0], MessageBoxButton.OK, MessageBoxImage.Error);
            }
            finally
            {
                mysqlNecessaryFunction.Dispose();
                this.NewParyButtonCreate.IsEnabled = true;
                Mouse.OverrideCursor = null;
            }
        }