public void setTextbox() { if (!String.IsNullOrEmpty(tbIdCustomer.Text)) { cust = db.tbl_Customers.FirstOrDefault(i => i.id_customer == int.Parse(tbIdCustomer.Text)); if (cust != null) { tbIdCustomer.Text = cust.id_customer.ToString(); tbFirstname.Text = cust.firstname; tbLastname.Text = cust.lastname; rtbAddress.Text = cust.address; tbTown.Text = cust.town; tbCountry.Text = cust.country; tbPostCode.Text = cust.postcode; tbEmail.Text = cust.email; btnAdd.Text = "UPDATE"; } else { va.clear("tbIdCustomer"); btnAdd.Text = "ADD"; } } }
private void btnAdd_Click(object sender, EventArgs e) { try { String message = "Insert"; DialogResult fc = MessageBox.Show("Are you sure want to add this data?", Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (fc == DialogResult.No) { return; } if (va.doValidation() == false) { return; } if (cmbIdDepart.Text == cmbIdArrival.Text) { MessageBox.Show("You cant choose same station with departure station", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } action(); MessageBox.Show(message + " data success!", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information); loadGrid(); va.clear(""); } catch (Exception err) { MessageBox.Show(err.ToString()); } }
private void setTextBox() { if (!String.IsNullOrEmpty(tbIdClass.Text)) { tick = db.tbl_Tickets.FirstOrDefault(i => i.id_ticket == int.Parse(tbIdClass.Text)); if (tick != null) { tbClassname.Text = tick.class_ticket; btnAdd.Text = "UPDATE"; } else { va.clear("tbIdClass"); btnAdd.Text = "ADD"; } } }
private void setTextbox() { if (!String.IsNullOrEmpty(tbIdTrain.Text)) { train = db.tbl_Trains.FirstOrDefault(i => i.id_train == int.Parse(tbIdTrain.Text)); if (train != null) { tbTrainname.Text = train.train_name; nudTotalSeat.Value = train.train_seat; btnAdd.Text = "UPDATE"; } else { va.clear("tbIdTrain"); btnAdd.Text = "ADD"; } } }
private void setTextBox() { if (!String.IsNullOrEmpty(tbIdStation.Text)) { stat = db.tbl_Stations.FirstOrDefault(i => i.id_station == int.Parse(tbIdStation.Text)); if (stat != null) { tbStationname.Text = stat.station_name; tbStationlocation.Text = stat.station_location; btnAdd.Text = "UPDATE"; } else { va.clear("tbIdStation"); btnAdd.Text = "ADD"; } } }
private void btnAdd_Click(object sender, EventArgs e) { try { String message = "Insert"; DialogResult fc = MessageBox.Show("Are you sure want to add this data?", Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (fc == DialogResult.No) { return; } if (va.doValidation() == false) { return; } action(); if (pay.paid < pay.total_payment) { MessageBox.Show("Your money is not sufficient", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); tbPaid.Text = ""; tbPaid.Focus(); return; } db.tbl_Payments.InsertOnSubmit(pay); db.SubmitChanges(); MessageBox.Show(message + " data success!", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information); frmPayment fr = new frmPayment(); fr.btnSearch_Click(sender, e); this.Close(); va.clear(""); } catch (Exception err) { MessageBox.Show(err.ToString()); } }
private void btnSubmit_Click(object sender, EventArgs e) { adm = db.tbl_Admins.FirstOrDefault(i => i.username == tbUsername.Text && i.password == tbPassword.Text); if (va.doValidation() == false) { return; } if (adm != null) { tbl_HistoryLogin add = new tbl_HistoryLogin { username = tbUsername.Text, login_date = DateTime.Now }; //db.tbl_HistoryLogins.InsertOnSubmit(add); try { //db.SubmitChanges(); frmMain frm = new frmMain(); frm.Show(); this.Hide(); } catch (Exception err) { MessageBox.Show(err.ToString()); } } else { MessageBox.Show("Data does not exist in the database", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information); va.clear(""); } }