private void button6_Click(object sender, EventArgs e) { if (BarCode.Length > 6) { Hashtable Certificate = admin.model.GetCertificate(BarCode); if (Certificate.Count > 0) { int pilot_id = 0; if (Convert.ToInt32(Certificate["user_id"]) == 0) { pilot_id = Convert.ToInt32(foundPilots_dataGridView3.SelectedRows[0].Cells[0].Value); } else { pilot_id = Convert.ToInt32(Certificate["user_id"]); } double paidAmount = 0; CashOperations form = new CashOperations(pilot_id, CurrRace, admin, Sale); if ((pilot_id > 0 && !IsCertificateSale) || (IsCertificateSale && form.ShowDialog() == System.Windows.Forms.DialogResult.OK)) { paidAmount = Convert.ToDouble(form.priceForCurrentRace_textBox5.Text); int MonthRace = checkBox2.Checked ? 1 : 0; int Reserv = checkBox1.Checked ? 1 : 0; int Kart = comboBox1.SelectedIndex > 0 ? admin.model.GetKartID(comboBox1.Items[comboBox1.SelectedIndex].ToString()) : 0; if (comboBox1.SelectedIndex > 0) { CurrRace.Karts.Add(comboBox1.Items[comboBox1.SelectedIndex].ToString()); } admin.model.AddPilotToRace(pilot_id, CurrRace.RaceID, CurrRace.Light_mode == 1, paidAmount, MonthRace, Reserv, Kart); admin.model.DelRaceFromCertificate(textBox6.Text.Trim(), (Convert.ToInt32(Certificate["count"]) - 1)); this.DialogResult = System.Windows.Forms.DialogResult.OK; if (Convert.ToBoolean(admin.Settings["print_check"]) && !IsCertificateSale) { print_check(pilot_id, CurrRace, (Convert.ToInt32(Certificate["count"]) - 1)); try { printDocument1.Print(); } catch (Exception ex) { MessageBox.Show("Не удалось распечатать документ. Ошибка: " + ex.Message); } // printPreviewDialog1.ShowDialog(); } this.Close(); } } } }
// Кнопка добавления пилота в рейс private void button2_Click(object sender, EventArgs e) { if (foundPilots_dataGridView3.Rows.Count > 0) { this.DialogResult = System.Windows.Forms.DialogResult.Cancel; int pilot_id = Convert.ToInt32(foundPilots_dataGridView3.SelectedRows[0].Cells[0].Value ?? 0); //this.Visible = false; //if (this.Owner != null) this.Owner.Activate(); bool ret = false; double paidAmount = 0; int discountCardId = -1; int idRaceMode = Convert.ToInt32(admin.Settings["default_race_mode_id"]); if (admin.model.IsDoublePilot(pilot_id, CurrRace.RaceID)) { MessageBox.Show(@"Данный пилот уже добавлен в текущий рейс."); return; } if (!checkBox1.Checked) { // форма принятия денег CashOperations form = new CashOperations(pilot_id, CurrRace, admin); if (form.ShowDialog() == System.Windows.Forms.DialogResult.OK) { if (form.discountCard != null) { discountCardId = form.discountCard.Id; } ret = true; paidAmount = Convert.ToDouble(form.priceForCurrentRace_textBox5.Text); idRaceMode = ci.getSelectedValue(form.halfModes_comboBox); } } else { ret = true; } if (ret) { int MonthRace = checkBox2.Checked ? 1 : 0; int Reserv = checkBox1.Checked ? 1 : 0; int Kart = comboBox1.SelectedIndex > 0 ? admin.model.GetKartID(comboBox1.Items[comboBox1.SelectedIndex].ToString()) : 0; if (comboBox1.SelectedIndex > 0) { CurrRace.Karts.Add(comboBox1.Items[comboBox1.SelectedIndex].ToString()); } admin.model.AddPilotToRace(pilot_id, CurrRace.RaceID, CurrRace.Light_mode == 1, paidAmount, discountCardId, idRaceMode, MonthRace, Reserv, Kart); this.DialogResult = System.Windows.Forms.DialogResult.OK; } this.Close(); } }