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(); } } }
private void button_ProfSave_Click(object sender, EventArgs e) { foreach (var item in Controls) { errorReg.SetError((Control)item, ""); } sstReg.Text = ""; validate(); if (!validate()) { return; } else { ThongTinCaNhan ttcn = thongtincanhan.Single(tt => tt.TenDangNhap == TDN); ttcn.HoTen = txtHoTen.Text; ttcn.NgaySinh = dateNgaySinh.Value; ttcn.DiaChi = txtDiachi.Text; ttcn.CMND = Convert.ToInt32(txtCMND.Text); ttcn.SDT = Convert.ToInt32(txtDT.Text); ttcn.Email = txtEmail.Text; MemoryStream ms = new MemoryStream(); pictureBox_Prof.Image.Save(ms, ImageFormat.Gif); ttcn.ImageByte = new Binary(ms.ToArray()); filmDC.SubmitChanges(); MessageBox.Show("Lưu thành công!", "Thông Báo"); } }
private void button_Confirm_Click(object sender, EventArgs e) { int count = 0, gia = 0; foreach (Button seat in pnl.seats) { if (seat.Text[0] == 'C' ^ seat.Text[0] == 'D') { int number = Convert.ToInt32(seat.Text.Substring(1, seat.Text.Length - 1)); if (number >= 5 && number <= 10) { gia = 70000; } } else { gia = 50000; } count++; if (label_MemberID.Text != "") { TbBanVe ticket = new TbBanVe { MaVe = (TicketID + "_" + count).ToString(), MaLichChieu = pnl.malichchieu, TenDangNhap = pnl.tendangnhap, Ghe = seat.Text, GiaVe = gia, MaThanhVien = Convert.ToInt32(label_MemberID.Text), Discount = discount / pnl.seats.Count }; FilmDC.TbBanVes.InsertOnSubmit(ticket); } else { TbBanVe ticket = new TbBanVe { MaVe = (TicketID + "_" + count).ToString(), MaLichChieu = pnl.malichchieu, TenDangNhap = pnl.tendangnhap, Ghe = seat.Text, GiaVe = gia, MaThanhVien = null, Discount = discount / pnl.seats.Count }; FilmDC.TbBanVes.InsertOnSubmit(ticket); } FilmDC.SubmitChanges(); } pnl.seats.Clear(); MetroFramework.MetroMessageBox.Show(this, "Done", "MessageBox", MessageBoxButtons.OK, MessageBoxIcon.Hand); button_X.PerformClick(); }
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(); }
private void metroButton_Save_Click(object sender, EventArgs e) { if (!validate()) { return; } else { MemoryStream ms = new MemoryStream(); pictureBox_AddMovie.Image.Save(ms, ImageFormat.Gif); TbPhim update = filmDC.TbPhims.SingleOrDefault(up => up.MaPhim == PhimID); if (update != null) { update.TenPhim = metroTextBox_Title.Text; update.TheLoai = metroTextBox_Genre.Text; update.DaoDien = metroTextBox_Director.Text; update.DienVien = metroTextBox_Stars.Text; update.NgayKhoiChieu = metroDateTime_ReleaseDate.Value; update.MoTaPhim = metroTextBox_Storyline.Text; update.ImgPhim = new Binary(ms.ToArray()); filmDC.SubmitChanges(); MetroFramework.MetroMessageBox.Show(this, "Update completed", "MessageBox", MessageBoxButtons.OK, MessageBoxIcon.Hand); } else { TbPhim film = new TbPhim { TenPhim = metroTextBox_Title.Text, TheLoai = metroTextBox_Genre.Text, DaoDien = metroTextBox_Director.Text, DienVien = metroTextBox_Stars.Text, NgayKhoiChieu = metroDateTime_ReleaseDate.Value, MoTaPhim = metroTextBox_Storyline.Text, ImgPhim = new Binary(ms.ToArray()) }; filmDC.TbPhims.InsertOnSubmit(film); filmDC.SubmitChanges(); foreach (var item in Controls) { if (item is MetroFramework.Controls.MetroTextBox) { ((MetroFramework.Controls.MetroTextBox)item).Text = ""; } if (item is MetroFramework.Controls.MetroDateTime) { ((MetroFramework.Controls.MetroDateTime)item).Value = DateTime.Now; } if (item is PictureBox) { ((PictureBox)item).Image = null; ((PictureBox)item).BackgroundImage = Properties.Resources.initial; } } MetroFramework.MetroMessageBox.Show(this, "Upload completed", "MessageBox", MessageBoxButtons.OK, MessageBoxIcon.Hand); } } }