private void register(object sender, EventArgs e) { if (string.IsNullOrEmpty(shopId.Text) || string.IsNullOrEmpty(shopName.Text) || string.IsNullOrEmpty(outlet.Text)) { if (string.IsNullOrEmpty(shopId.Text)) { idallert.Visible = true; } else { idallert.Visible = false; } if (string.IsNullOrEmpty(shopName.Text)) { nameallert.Visible = true; } else { idallert.Visible = false; } if (string.IsNullOrEmpty(outlet.Text)) { locallert.Visible = true; } else { locallert.Visible = false; } MessageBox.Show("Please enter all information", "Restaurant Registration", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { try { var shop = new { Id = Convert.ToInt32(shopId.Text), Name = shopName.Text.Trim(), Location = outlet.Text.Trim() }; var result = ShopController.AddShop(shop); if (result) { MessageBox.Show("Shop Added", "Restaurant Registration", MessageBoxButtons.OK, MessageBoxIcon.None); shopId.Text = null; shopName.Text = null; outlet.Text = null; var shop1 = ShopController.GetAllShop(); dataGridView1.DataSource = shop1; } } catch (FormatException) { MessageBox.Show("Please use numeric number in shop id", "Restaurant Registration", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
///// <summary> ///// Update a Admin ///// </summary> ///// <param name="admin"></param> ///// <returns> ///// Return 1 if Admin was updated, else 0 ///// </returns> //public int UpdateAdmin(Admin admin) //{ // return AdminCtr.UpdateAdmin(admin); //} ///// <summary> ///// Delete a Admin ///// </summary> ///// <param name="id"></param> ///// <returns> ///// Return 1 if Admin was deleted, else 0 ///// </returns> //public int DeleteAdmin(int id) //{ // return AdminCtr.DeleteAdmin(id); //} /// <summary> /// Add a Shop /// </summary> /// <param name="shop"></param> /// <returns> /// Id of Shop if added, else 0 /// </returns> public int AddShop(Shop shop) { return(ShopController.AddShop(shop)); }