예제 #1
0
        private void buttonX_Insert_Click(object sender, EventArgs e)
        {
            TbCoupon voucher = new TbCoupon
            {
                MaCoupon = randomCode(),
                Member   = null,
                Voucher  = 15000
            };

            FilmDC.TbCoupons.InsertOnSubmit(voucher);
            FilmDC.SubmitChanges();
            load();
        }
예제 #2
0
 private void btnReg_Click(object sender, EventArgs e)
 {
     foreach (var item in Controls)
     {
         errorReg.SetError((Control)item, "");
     }
     sstReg.Text = "";
     if (!validate())
     {
         return;
     }
     else
     {
         TbCoupon coupon = new TbCoupon
         {
             MaCoupon = txtCode.Text,
             Member   = 15000,
             Voucher  = null
         };
         FilmDC.TbCoupons.InsertOnSubmit(coupon);
         FilmDC.SubmitChanges();
         TbMember member = new TbMember
         {
             HoTen    = txtTen.Text,
             NgaySinh = dateNgaySinh.Value,
             CMND     = Convert.ToInt32(txtCMND.Text),
             SDT      = Convert.ToInt32(txtDT.Text),
             MaCoupon = txtCode.Text
         };
         FilmDC.TbMembers.InsertOnSubmit(member);
         FilmDC.SubmitChanges();
         foreach (var item in Controls)
         {
             if (item is TextBox)
             {
                 ((TextBox)item).Text = "";
             }
             if (item is DateTimePicker)
             {
                 ((DateTimePicker)item).Value = DateTime.Now;
             }
         }
         MetroFramework.MetroMessageBox.Show(this, "Update completed", "MessageBox", MessageBoxButtons.OK, MessageBoxIcon.Hand);
         txtCode.Text = randomCode();
         if (main.Controls.Contains(pnlMM))
         {
             pnlMM.load();
         }
     }
 }