public int?Update_Lop(DanhSachLop lop) { int?result = null; using (SqlConnection conn = new SqlConnection(GetConnectionString())) { SqlCommand command = new SqlCommand("UPDATE_LOP", conn); command.CommandType = CommandType.StoredProcedure; command.Parameters.Add("@MALOP", SqlDbType.Decimal).Value = lop.MaLop; command.Parameters.Add("@TENLOP", SqlDbType.NVarChar).Value = lop.TenLop; command.Parameters.Add("@MAKHOILOP", SqlDbType.Decimal).Value = lop.MaKhoiLop; try { command.Connection.Open(); command.ExecuteNonQuery(); result = 1; command.Connection.Close(); } catch { command.Connection.Close(); } } return(result); }
private void Button_SuaLop_Click(object sender, EventArgs e) { if (currentMaLop == "") { MessageBox.Show("Chưa chọn lớp", "Đã xảy ra lỗi!", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (TextBox_TenLop.Text == "") { MessageBox.Show("Tên lớp không được để trống", "Đã xảy ra lỗi!", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } DanhSachLop dslop = new DanhSachLop(); dslop.MaLop = long.Parse(currentMaLop); dslop.TenLop = TextBox_TenLop.Text; dslop.MaKhoiLop = long.Parse(ComboBox_KhoiLop.SelectedValue.ToString()); int?result = danhsachlop.Update_Lop(dslop); if (result == 1) { MessageBox.Show("Dữ liệu đã được cập nhật", "Cập nhật thành công!", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Không thể cập nhật thông tin", "Đã xảy ra lỗi!", MessageBoxButtons.OK, MessageBoxIcon.Error); } LoadDSLop(); currentMaLop = ""; GridView_DSLop.ClearSelection(); }
private void Button_ThemLop_Click(object sender, EventArgs e) { if (TextBox_TenLop.Text == "") { MessageBox.Show("Tên lớp không được để trống", "Đã xảy ra lỗi!", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (danhsachlop.CheckTonTaiLop(TextBox_TenLop.Text) > 0) { MessageBox.Show("Đã tồn tại lớp này", "Đã xảy ra lỗi!", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } DanhSachLop dslop = new DanhSachLop(); dslop.TenLop = TextBox_TenLop.Text; dslop.SiSo = 0; dslop.MaKhoiLop = long.Parse(currentKhoiLop); int?result = danhsachlop.Insert_Lop(dslop); if (result == 1) { MessageBox.Show("Dữ liệu đã được cập nhật", "Thêm thành công!", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Không thể cập nhật thông tin", "Đã xảy ra lỗi!", MessageBoxButtons.OK, MessageBoxIcon.Error); } LoadDSLop(); currentMaLop = ""; GridView_DSLop.ClearSelection(); }
private void buttonLop_Click(object sender, EventArgs e) { this.Hide(); DanhSachLop formDSL = new DanhSachLop(); formDSL.FormClosed += FormDSL_FormClosed; formDSL.Show(); }
public void ResetLopDangHoc() { if (DanhSachLop.Any()) { LopDangHocId = DanhSachLop.LastOrDefault().LopId; } LopDangHocId = null; }
public void getMember(string course_id) { HttpWebRequest req = (HttpWebRequest)WebRequest.Create(string.Format("https://entool.azurewebsites.net/SEP21/GetMembers?courseID=" + course_id)); req.Method = "GET"; HttpWebResponse resp = (HttpWebResponse)req.GetResponse(); string jsonString; using (Stream stream = resp.GetResponseStream()) //modified from your code since the using statement disposes the stream automatically when done { StreamReader reader = new StreamReader(stream, System.Text.Encoding.UTF8); jsonString = reader.ReadToEnd(); } apiGetMemberModel.GetMembers members = JsonConvert.DeserializeObject <apiGetMemberModel.GetMembers>(jsonString); foreach (var item in members.data) { string mssv = item.id; string ho = item.lastname; string ten = item.firstname; string ngaysinh = item.birthday; if (db.SinhViens.Where(x => x.MSV == mssv).Count() == 0) { var sv = new SinhVien(); sv.MSV = mssv; sv.Ho = ho; sv.Ten = ten; sv.NgaySinh = DateTime.ParseExact(ngaysinh, "M/d/yyyy", null); sv.GioiTinh = true; db.SinhViens.Add(sv); db.SaveChanges(); } if (db.DanhSachLops.Where(x => x.MSV == mssv && x.MKH == course_id).Count() == 0) { var dslop = new DanhSachLop(); dslop.MSV = mssv; dslop.MKH = course_id; db.DanhSachLops.Add(dslop); db.SaveChanges(); } } }
public int?Update_Lop(DanhSachLop lop) { return(danhsachlop.Update_Lop(lop)); }
public int?Insert_Lop(DanhSachLop lop) { return(danhsachlop.Insert_Lop(lop)); }