コード例 #1
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            OfficeService areaService = new OfficeService(new CoffeShopContext());

            if (areaService.Insert(tbNameTable.Text))
            {
                MessageBox.Show("Thêm Thành Công", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.Dispose();
            }
            else
            {
                MessageBox.Show("Thất Bại", "Thông Báo", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
            }
        }
コード例 #2
0
 public ActionResult Create(OfficeViewModel ofc)
 {
     if (ModelState.IsValid)
     {
         Office newOffice = new Office();
         string division  = ofc.Division;
         int    count     = officeService.getRowCount() + 1;
         string offcieid  = division[0].ToString() + division[1].ToString() + division[2].ToString() + "-" + ofc.Area + "-" + count;
         newOffice.OfficeId       = offcieid;
         newOffice.Location       = "House : " + ofc.House + ", Road : " + ofc.Road + ", " + ofc.Area + ", " + division;
         newOffice.OfficialNumber = ofc.OfficialNumber;
         officeService.Insert(newOffice);
         return(RedirectToAction("Index", "Office"));
     }
     return(View(ofc));
 }