コード例 #1
0
ファイル: FormBegun.cs プロジェクト: JustKaneri/SYBD_MARATHON
        private void BtnCancelSel_Click(object sender, EventArgs e)
        {
            if (DgvYourMaraph.CurrentRow == null)
            {
                MessageBox.Show("Выберите марафон", "Внимание", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            var res = MessageBox.Show("Вы хотите отменить запись на текущий марафон?", "Внимание", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (res == DialogResult.No)
            {
                return;
            }

            double prise = Convert.ToDouble(DgvYourMaraph.CurrentRow.Cells[4].Value);
            double chet  = Convert.ToDouble(LblSum.Text);

            DgvYourMaraph.Rows.Remove(DgvYourMaraph.CurrentRow);

            chet       += prise;
            LblSum.Text = chet.ToString();

            BsBegun.EndEdit();
            this.begunTableAdapter.Update(this.u37_1DataSet1.Begun);

            BsSorevn.EndEdit();
            this.sorevnovaniaTableAdapter.Update(this.u37_1DataSet1.Sorevnovania);

            MessageBox.Show("Запись была отменена", "Внимание", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
コード例 #2
0
ファイル: FormBegun.cs プロジェクト: JustKaneri/SYBD_MARATHON
        private void BtnSelect_Click(object sender, EventArgs e)
        {
            string idMar = DgvAllMarap.CurrentRow.Cells[0].Value.ToString();

            BsSorevn.Filter = $"IdMaraphon = '{idMar}'";

            if (BsSorevn.Count > 0)
            {
                BsSorevn.Filter = "";
                MessageBox.Show("Вы уже записаны на данный марафон", "Внимание", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            BsSorevn.Filter = "";

            double prise = Convert.ToDouble(DgvAllMarap.CurrentRow.Cells[4].Value);
            double chet  = Convert.ToDouble(LblSum.Text);

            if (prise > chet)
            {
                MessageBox.Show("Не достаточно средств для записи на марафон", "Внимание", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            chet       -= prise;
            LblSum.Text = chet.ToString();

            BsSorevn.AddNew();

            DgvYourMaraph.CurrentRow.Cells[0].Value = idMar;

            BsSorevn.EndEdit();
            this.sorevnovaniaTableAdapter.Update(this.u37_1DataSet1.Sorevnovania);

            BsBegun.EndEdit();
            this.begunTableAdapter.Update(this.u37_1DataSet1.Begun);

            MessageBox.Show("Вы успешно записались на марафон.", "Внимание", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }