public void loadInfo(TextBox txtCTDT, ComboBox cbbNguoiTaoCTDT, CheckBox chkEnable, ComboBox cbbCopyCTDT, DataGridView lstCTDT) { DBEntities db = new DBEntities(); ChuongTrinhDaoTao ctdt = new ChuongTrinhDaoTao(); if (lstCTDT.SelectedRows.Count == 1) { var row = lstCTDT.SelectedRows[0]; var cell = row.Cells["id"]; int ID = (int)cell.Value; ctdt = db.ChuongTrinhDaoTaos.Single(st => st.Id == ID); txtCTDT.Text = ctdt.TenCTDT.ToString(); cbbNguoiTaoCTDT.SelectedValue = ctdt.NguoiPhuTrach_Id; if (ctdt.CopyTuCTDT == null) { chkEnable.Checked = false; cbbCopyCTDT.Enabled = false; } else { chkEnable.Checked = true; cbbCopyCTDT.Enabled = true; cbbCopyCTDT.SelectedValue = ctdt.CopyTuCTDT; } } }
public ChuongTrinhDaoTao GetChuongTrinhDaoTao(string maMonHoc, string maKhoiLop) { OpenConnection(); SqlCommand com = new SqlCommand(); com.CommandType = CommandType.Text; com.CommandText = "select * from ChuongTrinhDaoTao where mamonhoc=@ma and makhoilop=@makl"; com.Parameters.Add("@ma", SqlDbType.VarChar).Value = maMonHoc; com.Parameters.Add("@makl", SqlDbType.VarChar).Value = maKhoiLop; com.Connection = conn; SqlDataReader reader = com.ExecuteReader(); ChuongTrinhDaoTao ctdt = null; if (reader.Read()) { string maKhoi = reader.GetString(0); string maMon = reader.GetString(1); int heSo = reader.GetInt32(2); ctdt = new ChuongTrinhDaoTao(maKhoi, maMon, heSo); } reader.Close(); return(ctdt); }
public List <ChuongTrinhDaoTao> GetAllCTDT() { OpenConnection(); List <ChuongTrinhDaoTao> listCTDT = new List <ChuongTrinhDaoTao>(); SqlCommand com = new SqlCommand(); com.CommandType = CommandType.Text; com.CommandText = "Select * from ChuongTrinhDaoTao"; com.Connection = conn; SqlDataReader reader = com.ExecuteReader(); while (reader.Read()) { string maLop = reader.GetString(0); string maMon = reader.GetString(1); int heSo = reader.GetInt32(2); ChuongTrinhDaoTao ctdt = new ChuongTrinhDaoTao(maLop, maMon, heSo); listCTDT.Add(ctdt); } reader.Close(); CloseConnection(); return(listCTDT); }
public async Task <string> Create(ChuongTrinhDaoTaoCreateRequest request) { //STT mặc định là 1 //STT = số thứ tự cuối cùng năm đó + 1 int soThuTu = 1; var sttCuoiCung_CuaNam = _context.ChuongTrinhDaoTaos .Where(x => x.Nam == request.Nam) .Select(x => x.SoThuTu) .ToArray() .LastOrDefault(); soThuTu += sttCuoiCung_CuaNam; //Lấy năm hiện tại string year = request.Nam.ToString(); //Ghép chuỗi tạo ID string Id = year + "CNTT" + soThuTu.ToString().PadLeft(2, '0'); var chuongTrinhDaoTao = new ChuongTrinhDaoTao() { ID = Id, SoThuTu = soThuTu, Nam = request.Nam, Id_Khoa = request.Id_Khoa ?? "CNTT", TenChuongTrinh = request.TenChuongTrinh }; _context.ChuongTrinhDaoTaos.Add(chuongTrinhDaoTao); await _context.SaveChangesAsync(); return(chuongTrinhDaoTao.ID); }
public ErrorType ThemCTDT(string khoi, string mon, string heso) { ChuongTrinhDaoTaoAccess ct = new ChuongTrinhDaoTaoAccess(); if (string.IsNullOrEmpty(khoi) || string.IsNullOrEmpty(mon) || string.IsNullOrEmpty(heso)) { return(ErrorType.KI_TU_RONG); } ChuongTrinhDaoTao ctdt = ct.GetChuongTrinhDaoTao(mon, khoi); if (ctdt != null) { return(ErrorType.DA_TON_TAI); } return(ct.ThemCTDT(khoi, mon, Int32.Parse(heso))); }
private void lvDanhSachMonHoc_SelectedIndexChanged(object sender, EventArgs e) { if (lvDanhSachMonHoc.SelectedItems.Count > 0) { ListViewItem lv = lvDanhSachMonHoc.SelectedItems[0]; string ma = lv.SubItems[1].Text; string ten = lv.SubItems[2].Text; tbMaMH_DSMH.Text = ma; tbTenMH_DSMH.Text = ten; try { ChuongTrinhDaoTaoBLL ctdt = new ChuongTrinhDaoTaoBLL(); ChuongTrinhDaoTao ct = ctdt.GetChuongTrinhDaoTao(ma); tbHeSoMH_DSMH.Text = ct.HeSoMon.ToString(); } catch { tbHeSoMH_DSMH.Text = ""; } } }