static void Main() { APIClient.Connect(); Application.SetHighDpiMode(HighDpiMode.SystemAware); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); var form = new FormAuthorization(); form.ShowDialog(); if (Provider != null) { Application.Run(new FormMain()); } }
private void LoadData() { try { dataGridViewParts.DataSource = APIClient.GetRequest <List <PartViewModel> >($"api/main/getpartlist"); dataGridViewParts.Columns[0].Visible = false; dataGridViewParts.Columns[1].Visible = false; dataGridViewParts.Columns[2].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; dataGridViewParts.Columns[3].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; dataGridViewParts.Columns[4].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; dataGridViewParts.Columns[5].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; dataGridViewParts.Columns[6].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; dataGridViewParts.Columns[7].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; dataGridViewParts.Columns[8].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; } catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void buttonToPdf_Click(object sender, EventArgs e) { if (dateTimePickerFrom.Value.Date >= dateTimePickerTo.Value.Date) { MessageBox.Show("Дата начала должна быть меньше даты окончания", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } try { using (var dialog = new SaveFileDialog { Filter = "pdf|*.pdf" }) { if (dialog.ShowDialog() == DialogResult.OK) { try { APIClient.PostRequest("api/main/createpdfreport", new ReportBindingModel { Email = Program.Provider.Email, FileName = dialog.FileName, Date = dateTimePickerFrom.Value.Date, DateTo = dateTimePickerTo.Value.Date }); MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void buttonMake_Click(object sender, EventArgs e) { if (dateTimePickerFrom.Value.Date >= dateTimePickerTo.Value.Date) { MessageBox.Show("Дата начала должна быть меньше даты окончания", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } try { List <PartViewModel> parts = APIClient.GetRequest <List <PartViewModel> >($"api/main/getpartlist"); List <string> partsType = new List <string>() { }; if (parts != null) { decimal count = 0; dataGridViewParts.Rows.Clear(); foreach (var part in parts.Where(rec => (rec.DateRecieve.Date >= dateTimePickerFrom.Value.Date && rec.DateRecieve.Date <= dateTimePickerTo.Value.Date) && rec.DateTransfer == null)) { if (!partsType.Contains(part.PartType)) { decimal countRecieve = 0; foreach (var partTransfer in parts.Where(recT => recT.PartType == part.PartType && recT.DateTransfer != null && recT.DateTransfer.Value.Date >= dateTimePickerFrom.Value.Date && recT.DateTransfer.Value.Date <= dateTimePickerTo.Value.Date)) { dataGridViewParts.Rows.Add(new object[] { partTransfer.DateTransfer.Value.Date.ToShortDateString(), partTransfer.PartType, partTransfer.PartColor, partTransfer.PartCount.ToString(), partTransfer.PartStatus.ToString() }); countRecieve += partTransfer.PartCount; } dataGridViewParts.Rows.Add(new object[] { part.DateRecieve.Date.ToShortDateString(), part.PartType, part.PartColor, (part.PartCount + countRecieve).ToString(), part.PartStatus.ToString() }); count += part.PartCount + countRecieve; dataGridViewParts.Rows.Add(new object[] { }); partsType.Add(part.PartType); } } dataGridViewParts.Rows.Add(new object[] { "", "", "", "Всего прибыло:", count.ToString() }); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void buttonOrder_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(textBoxPartType.Text)) { MessageBox.Show("Заполните поле Тип детали", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (string.IsNullOrEmpty(textBoxPartColor.Text)) { MessageBox.Show("Заполните поле Цвет детали", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (string.IsNullOrEmpty(textBoxCount.Text)) { MessageBox.Show("Заполните поле Количество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } try { List <PartViewModel> parts = APIClient.GetRequest <List <PartViewModel> >($"api/main/getpartlist"); bool flag = false; foreach (var part in parts.Where(rec => rec.PartType == textBoxPartType.Text && rec.PartColor == textBoxPartColor.Text && rec.PartStatus == PartStatus.Прибыл)) { APIClient.PostRequest("api/main/orderpart", new PartBindingModel { ProviderId = Program.Provider.Id, ProviderFIO = Program.Provider.FIO, PartType = textBoxPartType.Text, PartColor = textBoxPartColor.Text, PartCount = part.PartCount + Convert.ToInt32(textBoxCount.Text), PartStatus = PartStatus.Прибыл, DateRecieve = DateTime.Now }); flag = true; } if (!flag) { APIClient.PostRequest("api/main/orderpart", new PartBindingModel { ProviderId = Program.Provider.Id, ProviderFIO = Program.Provider.FIO, PartType = textBoxPartType.Text, PartColor = textBoxPartColor.Text, PartCount = Convert.ToInt32(textBoxCount.Text), PartStatus = PartStatus.Прибыл, DateRecieve = DateTime.Now }); } MessageBox.Show("Заказ создан", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information); DialogResult = DialogResult.OK; Close(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void buttonOrderPart_Click(object sender, EventArgs e) { if (comboBoxForm.SelectedValue == null) { MessageBox.Show("Выберите формат документа", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } var form = new FormOrderPart(); if (dataGridViewRequests.SelectedRows != null) { form.PartType = dataGridViewRequests.SelectedRows[0].Cells[3].Value.ToString(); form.PartColor = dataGridViewRequests.SelectedRows[0].Cells[4].Value.ToString(); form.PartCount = (int)dataGridViewRequests.SelectedRows[0].Cells[5].Value; } DateTime nowTime = DateTime.Now; if (form.ShowDialog() == DialogResult.OK) { try { APIClient.PostRequest("api/main/changerequeststatus", new RequestBindingModel { Id = (int)dataGridViewRequests.SelectedRows[0].Cells[0].Value, ProviderId = Program.Provider.Id, ProviderFIO = Program.Provider.FIO, PartType = dataGridViewRequests.SelectedRows[0].Cells[3].Value.ToString(), PartColor = dataGridViewRequests.SelectedRows[0].Cells[4].Value.ToString(), PartCount = (int)dataGridViewRequests.SelectedRows[0].Cells[5].Value, RequestStatus = RequestStatus.Выполненный, DateExecution = nowTime }); if (comboBoxForm.SelectedValue == ".docx") { using (var dialog = new SaveFileDialog { Filter = "docx|*.docx" }) { if (dialog.ShowDialog() == DialogResult.OK) { APIClient.PostRequest("api/main/createwordreport", new ReportBindingModel { Email = Program.Provider.Email, FileName = dialog.FileName.ToString(), Date = nowTime, PartType = dataGridViewRequests.SelectedRows[0].Cells[3].Value.ToString(), PartColor = dataGridViewRequests.SelectedRows[0].Cells[4].Value.ToString(), PartCount = (int)dataGridViewRequests.SelectedRows[0].Cells[5].Value }); MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } else if (comboBoxForm.SelectedValue == ".xlsx") { using (var dialog = new SaveFileDialog { Filter = "xlsx|*.xlsx" }) { if (dialog.ShowDialog() == DialogResult.OK) { APIClient.PostRequest("api/main/createexcelreport", new ReportBindingModel { Email = Program.Provider.Email, FileName = dialog.FileName.ToString(), Date = nowTime, PartType = dataGridViewRequests.SelectedRows[0].Cells[3].Value.ToString(), PartColor = dataGridViewRequests.SelectedRows[0].Cells[4].Value.ToString(), PartCount = (int)dataGridViewRequests.SelectedRows[0].Cells[5].Value }); MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } LoadData(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } } LoadData(); }