Пример #1
0
        private void addItemButton_Click(object sender, EventArgs e)
        {
            string convertedImage = ImageClass.prepareImageToString(imgLocation);

            int result = 0;

            if (ValidateForm())
            {
                ItemModel model = new ItemModel(
                    itemItemText.Text,      // check length, pattern
                    itemAssetText.Text,     // check length
                    itemArrivedText.Text,   // check length, pattern
                    itemInvoiceText.Text,   // check length, pattern

                    // TODO - complete CCD, NameRus and all below
                    itemCcdText.Text,         // check length, pattern
                    itemNameRusText.Text,
                    itemPositionCcdText.Text, // check length, pattern
                    itemStatusText.Text,      // check length
                    itemBoxText.Text,         // check length
                    itemContainerText.Text,   // check length
                    itemCommentText.Text,     // check length
                    convertedImage
                    );

                //MessageBox.Show(BitConverter.ToString(model.ItemImage).Replace("-", ""));
                result = ApiHelpers.ApiConnectorHelper.SaveData <ItemModel>(model, pathItemsAdd);
                if (result != 0)
                {
                    MessageBox.Show($"{ itemItemText.Text } { itemAssetText.Text } added");
                }
                else
                {
                    MessageBox.Show("Smth went wrong");
                }
            }
            else
            {
                ErrorForm errorForm = new ErrorForm(errorsItem);
                errorForm.Show();
            }
        }
Пример #2
0
        private void addBatteryButton_Click(object sender, EventArgs e)
        {
            int result = 0;

            if (ValidateForm().Keys.First())
            {
                BatteryModel model = new BatteryModel(
                    batteryBoxNumberText.Text,     // check length, pattern
                    conditionComboBox.Text,
                    batterySerialOneText.Text,     // check length, pattern
                    batterySerialTwoText.Text,     // check length, pattern
                    batterySerialThreeText.Text,   // check length, pattern
                    batteryCcdText.Text,
                    batteryInvoiceText.Text,       // check length, pattern
                    batteryStatusText.Text,        // check length
                    batteryArrivedText.Text,       // check length
                    batteryContainerText.Text,     // check length
                    batteryCommentText.Text        // check length
                    );

                result = ApiHelpers.ApiConnectorHelper.SaveData <BatteryModel>(model, pathBatteriesAdd);
                if (result != 0)
                {
                    MessageBox.Show($"Battery { batterySerialOneText.Text } added");
                }
                else
                {
                    MessageBox.Show("Smth went wrong");
                }
            }
            else
            {
                ErrorForm errorForm = new ErrorForm(ValidateForm().Values.First());
                errorForm.Show();
            }
        }