diff --git a/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormClient.Designer.cs b/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormClient.Designer.cs index 8032931..523b0ae 100644 --- a/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormClient.Designer.cs +++ b/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormClient.Designer.cs @@ -30,13 +30,11 @@ { labelName = new Label(); labelType = new Label(); - labelOptovik = new Label(); textBoxName = new TextBox(); buttonSave = new Button(); buttonCancel = new Button(); - radioButtonOptYes = new RadioButton(); - radioButtonOptNo = new RadioButton(); comboBoxClientType = new ComboBox(); + checkBoxOptYes = new CheckBox(); SuspendLayout(); // // labelName @@ -57,15 +55,6 @@ labelType.TabIndex = 1; labelType.Text = "Тип клиента:"; // - // labelOptovik - // - labelOptovik.AutoSize = true; - labelOptovik.Location = new Point(38, 179); - labelOptovik.Name = "labelOptovik"; - labelOptovik.Size = new Size(75, 20); - labelOptovik.TabIndex = 2; - labelOptovik.Text = "Оптовик?"; - // // textBoxName // textBoxName.Location = new Point(157, 36); @@ -95,28 +84,6 @@ buttonCancel.UseVisualStyleBackColor = false; buttonCancel.Click += ButtonCancel_Click; // - // radioButtonOptYes - // - radioButtonOptYes.AutoSize = true; - radioButtonOptYes.Location = new Point(157, 177); - radioButtonOptYes.Name = "radioButtonOptYes"; - radioButtonOptYes.Size = new Size(48, 24); - radioButtonOptYes.TabIndex = 8; - radioButtonOptYes.TabStop = true; - radioButtonOptYes.Text = "Да"; - radioButtonOptYes.UseVisualStyleBackColor = true; - // - // radioButtonOptNo - // - radioButtonOptNo.AutoSize = true; - radioButtonOptNo.Location = new Point(227, 177); - radioButtonOptNo.Name = "radioButtonOptNo"; - radioButtonOptNo.Size = new Size(55, 24); - radioButtonOptNo.TabIndex = 9; - radioButtonOptNo.TabStop = true; - radioButtonOptNo.Text = "Нет"; - radioButtonOptNo.UseVisualStyleBackColor = true; - // // comboBoxClientType // comboBoxClientType.FormattingEnabled = true; @@ -125,18 +92,27 @@ comboBoxClientType.Size = new Size(125, 28); comboBoxClientType.TabIndex = 10; // + // checkBoxOptYes + // + checkBoxOptYes.AutoSize = true; + checkBoxOptYes.CheckAlign = ContentAlignment.MiddleRight; + checkBoxOptYes.Location = new Point(45, 185); + checkBoxOptYes.Name = "checkBoxOptYes"; + checkBoxOptYes.Size = new Size(90, 24); + checkBoxOptYes.TabIndex = 12; + checkBoxOptYes.Text = "Оптивик"; + checkBoxOptYes.UseVisualStyleBackColor = true; + // // FormClient // AutoScaleDimensions = new SizeF(8F, 20F); AutoScaleMode = AutoScaleMode.Font; ClientSize = new Size(329, 324); + Controls.Add(checkBoxOptYes); Controls.Add(comboBoxClientType); - Controls.Add(radioButtonOptNo); - Controls.Add(radioButtonOptYes); Controls.Add(buttonCancel); Controls.Add(buttonSave); Controls.Add(textBoxName); - Controls.Add(labelOptovik); Controls.Add(labelType); Controls.Add(labelName); Name = "FormClient"; @@ -150,12 +126,10 @@ private Label labelName; private Label labelType; - private Label labelOptovik; private TextBox textBoxName; private Button buttonSave; private Button buttonCancel; - private RadioButton radioButtonOptYes; - private RadioButton radioButtonOptNo; private ComboBox comboBoxClientType; + private CheckBox checkBoxOptYes; } } \ No newline at end of file diff --git a/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormClient.cs b/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormClient.cs index 10b1c13..3bf819a 100644 --- a/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormClient.cs +++ b/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormClient.cs @@ -32,11 +32,7 @@ namespace ProjectCompanyFurniture.Forms comboBoxClientType.SelectedItem = client.ClientType; if (client.Optovik) { - radioButtonOptYes.Checked = true; - } - else - { - radioButtonOptNo.Checked = true; + checkBoxOptYes.Checked = true; } _clientId = value; } @@ -60,7 +56,7 @@ namespace ProjectCompanyFurniture.Forms try { if (string.IsNullOrWhiteSpace(textBoxName.Text) - || (radioButtonOptYes.Checked == false && radioButtonOptNo.Checked == false) + || checkBoxOptYes.Checked == false || comboBoxClientType.SelectedIndex < 1) { throw new Exception("Имеются незаполненные поля"); @@ -85,6 +81,6 @@ namespace ProjectCompanyFurniture.Forms private void ButtonCancel_Click(object sender, EventArgs e) => Close(); private Client CreateClient(int id) => Client.CreateEntity(id, textBoxName.Text, - (ClientType)comboBoxClientType.SelectedItem!, radioButtonOptYes.Checked); + (ClientType)comboBoxClientType.SelectedItem!, checkBoxOptYes.Checked); } } \ No newline at end of file diff --git a/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormInvoice.Designer.cs b/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormInvoice.Designer.cs index 4c3fe30..9979d0d 100644 --- a/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormInvoice.Designer.cs +++ b/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormInvoice.Designer.cs @@ -28,8 +28,6 @@ /// private void InitializeComponent() { - label5 = new Label(); - dateTimePickerDateInvoice = new DateTimePicker(); buttonCancel = new Button(); buttonSave = new Button(); groupBoxProducts = new GroupBox(); @@ -37,41 +35,23 @@ ColumnProduct = new DataGridViewComboBoxColumn(); ColumnCount = new DataGridViewTextBoxColumn(); labelClientName = new Label(); - radioButtonPromYes = new RadioButton(); - radioButtonPromNot = new RadioButton(); - label1 = new Label(); label2 = new Label(); numericUpDownDiscPercentage = new NumericUpDown(); comboBoxClient = new ComboBox(); label3 = new Label(); numericUpDownSellingPrice = new NumericUpDown(); + checkBoxPromYes = new CheckBox(); groupBoxProducts.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)dataGridViewProducts).BeginInit(); ((System.ComponentModel.ISupportInitialize)numericUpDownDiscPercentage).BeginInit(); ((System.ComponentModel.ISupportInitialize)numericUpDownSellingPrice).BeginInit(); SuspendLayout(); // - // label5 - // - label5.AutoSize = true; - label5.Location = new Point(27, 251); - label5.Name = "label5"; - label5.Size = new Size(44, 20); - label5.TabIndex = 4; - label5.Text = "Дата:"; - // - // dateTimePickerDateInvoice - // - dateTimePickerDateInvoice.Location = new Point(216, 246); - dateTimePickerDateInvoice.Name = "dateTimePickerDateInvoice"; - dateTimePickerDateInvoice.Size = new Size(151, 27); - dateTimePickerDateInvoice.TabIndex = 10; - // // buttonCancel // buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; buttonCancel.BackColor = Color.FromArgb(192, 255, 192); - buttonCancel.Location = new Point(270, 691); + buttonCancel.Location = new Point(270, 548); buttonCancel.Name = "buttonCancel"; buttonCancel.Size = new Size(102, 29); buttonCancel.TabIndex = 11; @@ -83,7 +63,7 @@ // buttonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; buttonSave.BackColor = Color.FromArgb(192, 255, 192); - buttonSave.Location = new Point(24, 691); + buttonSave.Location = new Point(24, 548); buttonSave.Name = "buttonSave"; buttonSave.Size = new Size(102, 29); buttonSave.TabIndex = 12; @@ -95,9 +75,9 @@ // groupBoxProducts.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; groupBoxProducts.Controls.Add(dataGridViewProducts); - groupBoxProducts.Location = new Point(24, 306); + groupBoxProducts.Location = new Point(24, 236); groupBoxProducts.Name = "groupBoxProducts"; - groupBoxProducts.Size = new Size(348, 366); + groupBoxProducts.Size = new Size(348, 291); groupBoxProducts.TabIndex = 13; groupBoxProducts.TabStop = false; groupBoxProducts.Text = "Продукты"; @@ -111,7 +91,7 @@ dataGridViewProducts.Location = new Point(3, 23); dataGridViewProducts.Name = "dataGridViewProducts"; dataGridViewProducts.RowHeadersWidth = 51; - dataGridViewProducts.Size = new Size(342, 340); + dataGridViewProducts.Size = new Size(342, 265); dataGridViewProducts.TabIndex = 0; // // ColumnProduct @@ -137,37 +117,6 @@ labelClientName.TabIndex = 14; labelClientName.Text = "ФИО клиента:"; // - // radioButtonPromYes - // - radioButtonPromYes.AutoSize = true; - radioButtonPromYes.Location = new Point(213, 89); - radioButtonPromYes.Name = "radioButtonPromYes"; - radioButtonPromYes.Size = new Size(48, 24); - radioButtonPromYes.TabIndex = 16; - radioButtonPromYes.TabStop = true; - radioButtonPromYes.Text = "Да"; - radioButtonPromYes.UseVisualStyleBackColor = true; - // - // radioButtonPromNot - // - radioButtonPromNot.AutoSize = true; - radioButtonPromNot.Location = new Point(309, 89); - radioButtonPromNot.Name = "radioButtonPromNot"; - radioButtonPromNot.Size = new Size(55, 24); - radioButtonPromNot.TabIndex = 17; - radioButtonPromNot.TabStop = true; - radioButtonPromNot.Text = "Нет"; - radioButtonPromNot.UseVisualStyleBackColor = true; - // - // label1 - // - label1.AutoSize = true; - label1.Location = new Point(27, 93); - label1.Name = "label1"; - label1.Size = new Size(156, 20); - label1.TabIndex = 18; - label1.Text = "Наличие промокода:"; - // // label2 // label2.AutoSize = true; @@ -209,25 +158,32 @@ numericUpDownSellingPrice.Size = new Size(151, 27); numericUpDownSellingPrice.TabIndex = 23; // + // checkBoxPromYes + // + checkBoxPromYes.AutoSize = true; + checkBoxPromYes.CheckAlign = ContentAlignment.MiddleRight; + checkBoxPromYes.Location = new Point(27, 94); + checkBoxPromYes.Name = "checkBoxPromYes"; + checkBoxPromYes.Size = new Size(175, 24); + checkBoxPromYes.TabIndex = 24; + checkBoxPromYes.Text = "Наличие промокода"; + checkBoxPromYes.UseVisualStyleBackColor = true; + // // FormInvoice // AutoScaleDimensions = new SizeF(8F, 20F); AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(403, 747); + ClientSize = new Size(403, 589); + Controls.Add(checkBoxPromYes); Controls.Add(numericUpDownSellingPrice); Controls.Add(label3); Controls.Add(comboBoxClient); Controls.Add(numericUpDownDiscPercentage); Controls.Add(label2); - Controls.Add(label1); - Controls.Add(radioButtonPromNot); - Controls.Add(radioButtonPromYes); Controls.Add(labelClientName); Controls.Add(groupBoxProducts); Controls.Add(buttonSave); Controls.Add(buttonCancel); - Controls.Add(dateTimePickerDateInvoice); - Controls.Add(label5); Name = "FormInvoice"; StartPosition = FormStartPosition.CenterScreen; Text = "Накладная"; @@ -240,8 +196,6 @@ } #endregion - private Label label5; - private DateTimePicker dateTimePickerDateInvoice; private Button buttonCancel; private Button buttonSave; private GroupBox groupBoxProducts; @@ -250,12 +204,10 @@ private DataGridViewTextBoxColumn ColumnCount; private Label label2; private Label labelClientName; - private RadioButton radioButtonPromYes; - private RadioButton radioButtonPromNot; - private Label label1; private NumericUpDown numericUpDownDiscPercentage; private ComboBox comboBoxClient; private Label label3; private NumericUpDown numericUpDownSellingPrice; + private CheckBox checkBoxPromYes; } } \ No newline at end of file diff --git a/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormInvoice.cs b/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormInvoice.cs index ab54160..41b6eab 100644 --- a/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormInvoice.cs +++ b/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormInvoice.cs @@ -36,29 +36,26 @@ namespace ProjectCompanyFurniture.Forms { try { - if (dataGridViewProducts.RowCount < 1 || comboBoxClient.SelectedIndex < 0 || - (radioButtonPromYes.Checked == false && radioButtonPromNot.Checked == false)) + if (dataGridViewProducts.RowCount < 1 || comboBoxClient.SelectedIndex < 0 || checkBoxPromYes.Checked == false) { throw new Exception("Имеются незаполненные поля"); } - if (radioButtonPromYes.Checked && numericUpDownDiscPercentage.Value == 0) + if (checkBoxPromYes.Checked && numericUpDownDiscPercentage.Value == 0) { throw new Exception("Не указан процент скидки"); } - if (radioButtonPromYes.Checked) + if (checkBoxPromYes.Checked) { _invoiceRepository.CreateInvoice(Invoice.CreateOperation(0, (int)comboBoxClient.SelectedValue!, 1, Convert.ToInt32(numericUpDownDiscPercentage.Value), - Convert.ToInt32(numericUpDownSellingPrice.Value), - /*dateTimePickerDateInvoice.Value,*/ - CreateListInvoiceProductFromDataGrid())); + Convert.ToInt32(numericUpDownSellingPrice.Value), CreateListInvoiceProductFromDataGrid())); } else { _invoiceRepository.CreateInvoice(Invoice.CreateOperation(0, (int)comboBoxClient.SelectedValue!, 0, 0, Convert.ToInt32(numericUpDownSellingPrice.Value), - /*dateTimePickerDateInvoice.Value,*/ CreateListInvoiceProductFromDataGrid())); + CreateListInvoiceProductFromDataGrid())); } Close(); diff --git a/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormInvoice.resx b/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormInvoice.resx index 9746ebf..f7cc2cb 100644 --- a/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormInvoice.resx +++ b/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormInvoice.resx @@ -123,10 +123,4 @@ True - - True - - - True - \ No newline at end of file diff --git a/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormProductMovement.Designer.cs b/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormProductMovement.Designer.cs index 3fd8de1..ba704f8 100644 --- a/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormProductMovement.Designer.cs +++ b/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormProductMovement.Designer.cs @@ -30,8 +30,6 @@ { labelProductID = new Label(); labelMovement = new Label(); - labelDate = new Label(); - dateTimePickerProductMovementDate = new DateTimePicker(); buttonCancel = new Button(); buttonSave = new Button(); checkedListBoxMovement = new CheckedListBox(); @@ -56,27 +54,11 @@ labelMovement.TabIndex = 1; labelMovement.Text = "Тип движения:"; // - // labelDate - // - labelDate.AutoSize = true; - labelDate.Location = new Point(31, 232); - labelDate.Name = "labelDate"; - labelDate.Size = new Size(44, 20); - labelDate.TabIndex = 2; - labelDate.Text = "Дата:"; - // - // dateTimePickerProductMovementDate - // - dateTimePickerProductMovementDate.Enabled = false; - dateTimePickerProductMovementDate.Location = new Point(267, 232); - dateTimePickerProductMovementDate.Name = "dateTimePickerProductMovementDate"; - dateTimePickerProductMovementDate.Size = new Size(181, 27); - dateTimePickerProductMovementDate.TabIndex = 3; - // // buttonCancel // + buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; buttonCancel.BackColor = Color.FromArgb(255, 192, 192); - buttonCancel.Location = new Point(286, 296); + buttonCancel.Location = new Point(286, 232); buttonCancel.Name = "buttonCancel"; buttonCancel.Size = new Size(162, 29); buttonCancel.TabIndex = 6; @@ -86,8 +68,9 @@ // // buttonSave // + buttonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; buttonSave.BackColor = Color.FromArgb(255, 192, 192); - buttonSave.Location = new Point(31, 296); + buttonSave.Location = new Point(31, 232); buttonSave.Name = "buttonSave"; buttonSave.Size = new Size(162, 29); buttonSave.TabIndex = 7; @@ -116,13 +99,11 @@ // AutoScaleDimensions = new SizeF(8F, 20F); AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(485, 399); + ClientSize = new Size(485, 290); Controls.Add(comboBoxProduct); Controls.Add(checkedListBoxMovement); Controls.Add(buttonSave); Controls.Add(buttonCancel); - Controls.Add(dateTimePickerProductMovementDate); - Controls.Add(labelDate); Controls.Add(labelMovement); Controls.Add(labelProductID); Name = "FormProductMovement"; @@ -136,8 +117,6 @@ private Label labelProductID; private Label labelMovement; - private Label labelDate; - private DateTimePicker dateTimePickerProductMovementDate; private Button buttonCancel; private Button buttonSave; private CheckedListBox checkedListBoxMovement; diff --git a/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormProductMovement.cs b/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormProductMovement.cs index 5e1c41e..1ab5ff5 100644 --- a/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormProductMovement.cs +++ b/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormProductMovement.cs @@ -50,7 +50,7 @@ namespace ProjectCompanyFurniture.Forms movement |= (Movement)elem; } _productMovementRepository.CreateProductMovement(ProductMovement.CreateOperation(0, - (int)comboBoxProduct.SelectedValue!, movement)); //dateTimePickerProductMovementDate.Value)); + (int)comboBoxProduct.SelectedValue!, movement)); Close(); } diff --git a/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormProducts.Designer.cs b/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormProducts.Designer.cs index 8860492..e342b04 100644 --- a/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormProducts.Designer.cs +++ b/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormProducts.Designer.cs @@ -111,6 +111,7 @@ Name = "FormProducts"; StartPosition = FormStartPosition.CenterScreen; Text = "Продукты"; + Load += FormProducts_Load; panel1.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit(); ResumeLayout(false); diff --git a/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormProducts.cs b/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormProducts.cs index f737ca2..3f37393 100644 --- a/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormProducts.cs +++ b/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormProducts.cs @@ -25,6 +25,19 @@ namespace ProjectCompanyFurniture.Forms _productRepository = productRepository ?? throw new ArgumentNullException(nameof(productRepository)); } + private void FormProducts_Load(object sender, EventArgs e) + { + try + { + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + } + private void ButtonAdd_Click(object sender, EventArgs e) { try