private void NewLogin_Click(object sender, EventArgs e) { string userName; try { user = new Employee(Log, Password); var databaseConnection = new DatabaseConnection(); databaseConnection.OpenNewConnection(user); LoginWriter writer = new LoginWriter(); writer.WriteToFile(user.Login); this.Hide(); Form1 form1 = new Form1(); form1.Visible = true; form1.TopMost = true; form1.Closed += (s, args) => this.Close(); form1.Show(); } catch (Exception exception) { MessageBox.Show(exception.Message); } }
private void Products_Click(object sender, EventArgs e) { newCon Check_amount = new newCon(Logon.Log, Logon.Password); check_amount = Check_amount.Check_Amount(ref P_name); int P_amount_test = Convert.ToInt32(P_amount); if (P_amount_test <= check_amount) { ListViewItem itm; IDatabaseConnection _databaseConnection = new DatabaseConnection(); _databaseConnection.OpenNewConnection(user); GetterPriceOfBeer getterPriceOfBeer = new GetterPriceOfBeer() int price = 0; newCon a = new newCon(Logon.Log, Logon.Password); price = a.GetPrice(ref P_name); string[] arr = new string[7]; if (price != 0) { if (serial_number != "0") { if (exp_date != "0") { newCon Check_Unit_of_measurement = new newCon(Logon.Log, Logon.Password); unit_of_measurement = Check_Unit_of_measurement.Get_unit_of_measurement(ref P_name); arr[0] = Convert.ToString(x); arr[1] = P_name; arr[2] = P_amount; arr[3] = Convert.ToString(price); arr[4] = unit_of_measurement; arr[5] = serial_number; arr[6] = exp_date; arr[7] = Convert.ToString(P_bar_code); itm = new ListViewItem(arr); listView1.Items.Add(itm); x++; } else { MessageBox.Show("Enter a expiration date."); } } else { MessageBox.Show("Enter a serial number."); } } else { MessageBox.Show("Incorrect name of beer"); } try { string Product_Name = P_name; newCon b = new newCon(Logon.Log, Logon.Password); Unit_price = b.GetPrice(ref Product_Name); sum += Unit_price * int.Parse(Amount.Text); amount_sum += int.Parse(Amount.Text); } catch { MessageBox.Show("Incorrect name of beer"); } Quantity_TextBox.Text = Convert.ToString(amount_sum); Invoice_value.Text = Convert.ToString(sum); } else { MessageBox.Show("Too much bottles."); } }