private void okButton_Click(object sender, EventArgs e) { if (textBox1.Text.Length != 0 && textBox2.Text.Length != 0 && textBox3.Text.Length != 0 && textBox4.Text.Length != 0 && textBox5.Text.Length != 0 && textBox6.Text.Length != 0 && textBox7.Text.Length != 0 && textBox8.Text.Length != 0 && textBox9.Text.Length != 0) { Customer customer = new Customer { Name = textBox1.Text, INN = textBox2.Text, KPP = textBox3.Text, Adress = textBox4.Text, Sender = textBox5.Text, CheckingAcc = textBox6.Text, BIK = textBox7.Text, BankName = textBox8.Text, CorpAcc = textBox9.Text }; DbEditor.AddCustomer(customer); Form1 MainForm = (Form1)this.Owner; MainForm.comboBox2.Items.Clear(); MainForm.comboBox2.Items.AddRange(DbEditor.GetAllCustomers()); this.Hide(); } else { MessageBox.Show("Присутствуют незаполненные поля", "Внимание", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
//public List<Product> ProductList; public AllProductForm() { InitializeComponent(); comboBoxItems.Items.Clear(); comboBoxItems.Items.AddRange(DbEditor.GetAllItems()); comboBox2.SelectedIndex = 1; }
private void comboBoxItems_SelectedValueChanged(object sender, EventArgs e) { var ResultItem = DbEditor.GetItem(comboBoxItems.SelectedItem.ToString()); textBoxPrice.Text = Convert.ToString(ResultItem.Item1); textBoxVAT.Text = Convert.ToString(ResultItem.Item2); labelUnit.Text = ResultItem.Item3; }
private void button1_Click(object sender, EventArgs e) { AllProductForm AllProductFrm = (AllProductForm)this.Owner; if (File.Exists(DbPath)) { Unit Unit = DbEditor.GetUnitById(comboBoxUnit.SelectedIndex + 1); DbEditor.AddItem(textBoxStuffName.Text, Convert.ToDouble(textBoxPrice.Text), Convert.ToDouble(textBoxVAT.Text), Unit.Name, Unit.Code); AllProductFrm.comboBoxItems.Items.Clear(); AllProductFrm.comboBoxItems.Items.AddRange(DbEditor.GetAllItems()); this.Hide(); } else { throw new Exception("Database \"BH.db\" not found"); } }
private void button5_Click(object sender, EventArgs e) { List <ProductInfo> ProductsInfo = new List <ProductInfo>(); for (int i = 0; i < dataGrid.Rows.Count - 1; i++) { ProductInfo ProductInfo = new ProductInfo { Product = DbEditor.GetItemByName(dataGrid[0, i].Value.ToString()), Count = Convert.ToInt32(dataGrid[1, i].Value), vatSumm = Convert.ToDouble(dataGrid[6, i].Value), summWithVat = Convert.ToDouble(dataGrid[5, i].Value) }; ProductsInfo.Add(ProductInfo); } textBox1.Text += ProductsInfo[0].Product.Name + Environment.NewLine; }
private void button1_Click(object sender, EventArgs e) { if (!String.IsNullOrEmpty(textBox1.Text) && !String.IsNullOrEmpty(textBox2.Text)) { DbEditor.AddUnit(new Unit { Name = textBox1.Text, Code = textBox2.Text }); AddProductForm AddProductForm = (AddProductForm)this.Owner; AddProductForm.comboBoxUnit.Items.Clear(); AddProductForm.comboBoxUnit.Items.AddRange(DbEditor.GetAllUnits()); this.Hide(); } else { MessageBox.Show("Поля ввода не могут быть пустыми", "Внимание", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void button1_Click(object sender, EventArgs e) { if (!String.IsNullOrEmpty(textBox1.Text) && !String.IsNullOrEmpty(textBox2.Text)) { DbEditor.AddCurrency(new Currency { Name = textBox1.Text, Code = textBox2.Text }); Form1 MainForm = (Form1)this.Owner; MainForm.comboBox3.Items.Clear(); MainForm.comboBox3.Items.AddRange(DbEditor.GetAllCurrency()); this.Hide(); } else { MessageBox.Show("Поля ввода не могут быть пустыми", "Внимание", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public Form1() { InitializeComponent(); AddToolStripMenuItem.Click += new EventHandler(OnAddItem); RemoveToolStripMenuItem.Click += new EventHandler(RemoveItem); // Подгрузка из БД продавцов comboBox1.Items.Clear(); comboBox1.Items.AddRange(DbEditor.GetAllSellers()); // Подгрузка из БД покупателей comboBox2.Items.Clear(); comboBox2.Items.AddRange(DbEditor.GetAllCustomers()); // Подгрузка из БД валюты comboBox3.Items.Clear(); comboBox3.Items.AddRange(DbEditor.GetAllCurrency()); //contextMenu.Click += new EventHandler(OnAddItem); }
private void button6_Click(object sender, EventArgs e) { int sellerId = comboBox1.SelectedIndex + 1; int customerId = comboBox2.SelectedIndex + 1; int currencyId = comboBox3.SelectedIndex + 1; int unitId = comboBox3.SelectedIndex + 1; if (sellerId <= 0 && customerId <= 0 && currencyId <= 0) { MessageBox.Show("Выберите продавца, покупателя и валюту из существующих или добавьте новые.", "Внимание", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { string examplePath = Directory.CreateDirectory(Application.StartupPath + "/Example").FullName; string filePath; if (!File.Exists($"{examplePath}/Factura.xlsx")) { File.WriteAllBytes($"{examplePath}/Factura.xlsx", Resource.Factura); } Seller Seller = DbEditor.GetSellerById(sellerId); Customer Customer = DbEditor.GetCustomerById(customerId); Currency Currency = DbEditor.GetCurrencyById(currencyId); List <ProductInfo> ProductsInfo = new List <ProductInfo>(); for (int i = 0; i < dataGrid.Rows.Count - 1; i++) { ProductInfo ProductInfo = new ProductInfo { Product = DbEditor.GetItemByName(dataGrid[0, i].Value.ToString()), Count = Convert.ToInt32(dataGrid[1, i].Value), vatSumm = Convert.ToDouble(dataGrid[6, i].Value), summWithVat = Convert.ToDouble(dataGrid[5, i].Value), summWithoutVat = Convert.ToDouble(dataGrid[7, i].Value) }; ProductsInfo.Add(ProductInfo); } ExcelWorkbook WorkBook = new ExcelWorkbook($"{examplePath}/Factura.xlsx", Seller, Customer, ProductsInfo); WorkBook.facturaNumber = numericUpDown1.Value.ToString(); WorkBook.facturaDate = dateTimePicker1.Value.ToString("dd MMMM yyyy"); WorkBook.payDocumentNumber = numericUpDown2.Value.ToString(); WorkBook.payDocumentDate = dateTimePicker2.Value.ToString("dd MMMM yyyy");; WorkBook.currencyCode = Currency.Code; WorkBook.Currency = Currency.Name; // WorkBook.Products = Datas.ProductList; using (SaveFileDialog SaveFileDialog = new SaveFileDialog()) { SaveFileDialog.Filter = "Файлы Excel (*.xlsx) | *.xlsx"; if (SaveFileDialog.ShowDialog() == DialogResult.OK) { filePath = SaveFileDialog.FileName; if (WorkBook.CreateFile(filePath) == null) { throw new Exception("Ошибка создания файла"); } } } } }