public static void selectLoaiCauThu(string MaLoaiCauThu, out LOAICAUTHU loaict) { SqlConnection conn = DatabaseManager.Instance.getConnection(); string queryString = "SELECT TenLoaiCauThu, MaMuaGiai, CauThuNuocNgoai FROM LOAICAUTHU WHERE MaLoaiCauThu = @MaLoaiCauThu"; SqlCommand command = new SqlCommand(queryString); loaict = new LOAICAUTHU() { MaLoaiCauThu = MaLoaiCauThu }; try { command.Parameters.AddWithValue("@MaLoaiCauThu", MaLoaiCauThu); command.Connection = conn; SqlDataReader reader = command.ExecuteReader(); if (reader.Read()) { loaict.TenLoaiCauThu = reader.GetString(0); loaict.MaMuaGiai = reader.GetString(1); loaict.CauThuNuocNgoai = reader.GetBoolean(3); } reader.Close(); } catch (SqlException SQLex) { throw SQLex; } catch (Exception ex) { throw ex; } }
public static void updateLoaiCauThu(LOAICAUTHU loaict) { SqlConnection conn = DatabaseManager.Instance.getConnection(); string queryString = "UPDATE LOAICAUTHU SET TenLoaiCauThu = @TenLoaiCauThu, CauThuNuocNgoai = @CauThuNuocNgoai WHERE MaLoaiCauThu = @MaLoaiCauThu"; SqlCommand command = new SqlCommand(queryString); try { command.Parameters.AddWithValue("@MaLoaiCauThu", loaict.MaLoaiCauThu); command.Parameters.AddWithValue("@TenLoaiCauThu", loaict.TenLoaiCauThu); command.Parameters.AddWithValue("@CauThuNuocNgoai", loaict.CauThuNuocNgoai); command.Connection = conn; int res = command.ExecuteNonQuery(); if (res == 0) { throw new Exception(); } } catch (SqlException SQLex) { throw SQLex; } catch (Exception ex) { throw ex; } }
public static void createLoaiCauThu(LOAICAUTHU loaict) { SqlConnection conn = DatabaseManager.Instance.getConnection(); string queryString = "INSERT INTO LOAICAUTHU Values (NEWID(), @TenLoaiCauThu, @CauThuNuocNgoai, @MaMuaGiai)"; SqlCommand command = new SqlCommand(queryString); try { command.Parameters.AddWithValue("@MaMuaGiai", loaict.MaMuaGiai); command.Parameters.AddWithValue("@TenLoaiCauThu", loaict.TenLoaiCauThu); command.Parameters.AddWithValue("@CauThuNuocNgoai", loaict.CauThuNuocNgoai); command.Connection = conn; int res = command.ExecuteNonQuery(); if (res == 0) { throw new Exception(); } } catch (SqlException SQLex) { throw SQLex; } catch (Exception ex) { throw ex; } }
public ActionResult DeleteConfirmed(string id) { LOAICAUTHU lOAICAUTHU = db.LOAICAUTHUs.Find(id); db.LOAICAUTHUs.Remove(lOAICAUTHU); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "MaLoaiCauThu,LoaiCauThu1")] LOAICAUTHU lOAICAUTHU) { if (ModelState.IsValid) { db.Entry(lOAICAUTHU).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(lOAICAUTHU)); }
public ActionResult Create([Bind(Include = "MaLoaiCauThu,LoaiCauThu1")] LOAICAUTHU lOAICAUTHU) { if (ModelState.IsValid) { db.LOAICAUTHUs.Add(lOAICAUTHU); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(lOAICAUTHU)); }
// GET: LoaiCauThu/Delete/5 public ActionResult Delete(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } LOAICAUTHU lOAICAUTHU = db.LOAICAUTHUs.Find(id); if (lOAICAUTHU == null) { return(HttpNotFound()); } return(View(lOAICAUTHU)); }
private void ThemButton_Click(object sender, EventArgs e) { //myData(textBox.Text); //textBox.Text = ""; //check for label text to determine where should the form submit its data if (themDanhSachGroupBox.Text.Equals("Thêm Loại Bàn Thắng")) { try { LOAIBANTHANG loaibt = new LOAIBANTHANG() { MaMuaGiai = GlobalState.selectedSeasonId, TenLoaiBanThang = textBox.Text, TinhBanChoCauThu = checkBox.Checked }; Database.LoaiBanThang_DAO.createLoaiBanThang(loaibt); MessageBox.Show("Thêm thành công", "Thông báo"); this.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Lỗi xảy ra"); } } else if (themDanhSachGroupBox.Text.Equals("Thêm Loại Cầu Thủ")) { try { LOAICAUTHU loaict = new LOAICAUTHU() { MaMuaGiai = GlobalState.selectedSeasonId, TenLoaiCauThu = textBox.Text, CauThuNuocNgoai = checkBox.Checked }; Database.LoaiCauThu_DAO.createLoaiCauThu(loaict); MessageBox.Show("Thêm thành công", "Thông báo"); this.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Lỗi xảy ra"); } } }