Example #1
0
        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());
            }
        }
Example #2
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            try
            {
                String       message = "";
                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;
                }
                train = db.tbl_Trains.FirstOrDefault(i => i.id_train == int.Parse(tbIdTrain.Text));
                if (train != null)
                {
                    message = "Update";
                    action("update");
                }

                else
                {
                    message = "Insert";
                    action("insert");
                }

                MessageBox.Show(message + " data success!", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information);
                loadGrid();
                va.clear("");
            }

            catch (Exception err)
            {
                MessageBox.Show(err.ToString());
            }
        }
Example #3
0
        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());
            }
        }
Example #4
0
        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("");
            }
        }