private LopHP GetLopHP(int?IDNamHoc, IXLRow row) { try { var smh = row.Cell("C").Value.ToString(); var mh = db.MonHocs.FirstOrDefault(q => q.TenMonHoc.Trim().ToLower() == smh.Trim().ToLower()); if (mh == null) { return(null); } var res = new LopHP { IDNamHoc = IDNamHoc, Active = true, SoTietTKB = int.Parse(row.Cell("F").Value.ToString()), Kip = row.Cell("H").Value.ToString(), DiaDiem = row.Cell("K").Value.ToString(), TenLop = row.Cell("J").Value.ToString(), MaHocPhan = row.Cell("B").Value.ToString(), SiSo = int.Parse(row.Cell("I").Value.ToString()), }; res.MaMH = mh.MaMH; DateTime dateTime = DateTime.Now; if (DateTime.TryParseExact(row.Cell("P").Value.ToString(), new string[] { "dd/MM/yyyy", "dd/M/yyyy" }, System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None, out dateTime)) { res.TGTHIKT = dateTime; } res.IDNamHoc = IDNamHoc; return(res); } catch (Exception ex) { return(null); } }
public JsonResult Delete(int id) { LopHP lopHP = db.LopHPs.Find(id); lopHP.Active = false; return(Json(db.SaveChanges())); }
private void Button2_Click(object sender, EventArgs e) { if (textBox2.Text == "" || textBox3.Text == "" || textBox4.Text == "") { MessageBox.Show("Vui lòng điền đầy đủ thông tin"); } if (LopHP.CheckTen(textBox2.Text) == 1) { MessageBox.Show("Tên này đã tồn tại"); } var lop = new LopHP { malhp = malop, tenlhp = textBox2.Text, dmsv = Int32.Parse(textBox3.Text), gv = textBox4.Text, mamh = mamon, }; LopHP.Update(lop); MessageBox.Show("Đã Sửa Lớp Học phần có tên là: " + lop.tenlhp, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); DialogResult = System.Windows.Forms.DialogResult.OK; }
public SuaLHP(string mh, object t) { InitializeComponent(); mamon = mh; lopht = (LopHP)t; malop = lopht.malhp; textBox2.Text = lopht.tenlhp; textBox3.Text = lopht.dmsv.ToString(); textBox4.Text = lopht.gv; }
public List <LopHP> GetListLopHP() { List <LopHP> list = new List <LopHP>(); DataTable data = DataProvider.Instance.ExecuteQuery("USP_GetLopHPList"); foreach (DataRow item in data.Rows) { LopHP lophp = new LopHP(item); list.Add(lophp); } return(list); }
private void ToolStripLabel4_Click(object sender, EventArgs e) { if (MessageBox.Show("Bạn có thực sự muốn xóa?", "Thông báo", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == System.Windows.Forms.DialogResult.OK) { var t = (LopHP)bindingSource1.Current; LopHP.Remove(t); MessageBox.Show("Xóa thành công ", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); DialogResult = System.Windows.Forms.DialogResult.OK; Load1(); } }
public ActionResult Edit(LopHP lopHP) { _fillHeSo(lopHP); if (lopHP.MaHP > 0) { db.Entry(lopHP).State = EntityState.Modified; } else { db.LopHPs.Add(lopHP); } db.SaveChanges(); return(RedirectToAction("Index", new { lopHP.IDNamHoc })); }
public List <LopHP> SearchLopHPByTenHP(string mahocphan) { List <LopHP> list = new List <LopHP>(); string query = string.Format("select * from LOPHP where [dbo].[GetUnsignString](MAHOCPHAN) " + "like N'%'+[dbo].[GetUnsignString](N'{0}')+'%' ", mahocphan); DataTable data = DataProvider.Instance.ExecuteQuery(query); foreach (DataRow item in data.Rows) { LopHP lophp = new LopHP(item); list.Add(lophp); } return(list); }
private void CmbMonhoc_SelectedIndexChanged(object sender, EventArgs e) { var ma = MonHoc.GetMaMH(cmbMonhoc.SelectedItem.ToString()); lop = LopHP.GetListFromDB(ma); bindingSource1.DataSource = lop; var t = (LopHP)bindingSource1.Current; label5.Text = t.malhp; label6.Text = t.dmsv.ToString(); label8.Text = t.gv; ds = CTLopHP.GetListFromDB(t.malhp); bindingSource2.DataSource = ds; label7.Text = ds.Count.ToString(); }
public void Load1() { dataGridView1.AutoGenerateColumns = false; var ma = MonHoc.GetMaMH(cmbMonhoc.SelectedItem.ToString()); lop = LopHP.GetListFromDB(ma); bindingSource1.DataSource = lop; var t = (LopHP)bindingSource1.Current; label5.Text = t.malhp; label6.Text = t.dmsv.ToString(); label8.Text = t.gv; ds = CTLopHP.GetListFromDB(t.malhp); bindingSource2.DataSource = ds; label7.Text = ds.Count.ToString(); }
public ActionResult Edit(int?MaHP) { LopHP lopHP; if (MaHP == null) { lopHP = new LopHP(); } else { lopHP = db.LopHPs.Find(MaHP); } var MaBoMon = LoginHelper.GetAccount().MaBoMon; ViewBag.MaMH = db.MonHocs.Where(q => q.MaBoMon == MaBoMon).CreateSelectList(q => q.MaMH, q => q.TenMonHoc, lopHP.MaMH); ViewBag.IDNamHocs = db.NamHocs.Where(q => q.Active != false && (q.TrangThai == "INIT" || q.TrangThai == "RUNNING")).CreateSelectList(q => q.IDNamHoc, q => q.mNamHoc, lopHP.IDNamHoc); return(View(lopHP)); }
private void Button2_Click(object sender, EventArgs e) { try { if (textBox1.Text == "" || textBox2.Text == "" || textBox3.Text == "" || textBox4.Text == "") { MessageBox.Show("Vui lòng điền đầy đủ thông tin"); } else if (LopHP.CheckMa(textBox1.Text) == 1) { MessageBox.Show("Mã này đã tồn tại"); } else if (LopHP.CheckTen(textBox2.Text) == 1) { MessageBox.Show("Tên này đã tồn tại"); } else { var lop = new LopHP { malhp = textBox1.Text, tenlhp = textBox2.Text, dmsv = Int32.Parse(textBox3.Text), gv = textBox4.Text, mamh = mamon, }; LopHP.Add(lop); MessageBox.Show("Đã thêm Lớp Học phần có tên là: " + lop.tenlhp, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); DialogResult = System.Windows.Forms.DialogResult.OK; } } catch { MessageBox.Show("Dữ liệu không chính xác"); } }
private void _fillHeSo(LopHP q) { q.HeSoKip = q.Kip == "N" ? 0 : 0.5; q.HeSoDD = q.DiaDiem == "HN" ? 0 : 0.5; switch (q.LHDT) { case "DH": q.HeSoLHDT = 0; break; case "CH": q.HeSoLHDT = 0.6; break; case "LT": q.HeSoLHDT = 0.2; break; case "CD": q.HeSoLHDT = 0; break; case "AT": q.HeSoLHDT = 0.2; break; default: q.HeSoLHDT = 0; break; } if (q.SiSo <= 50) { q.HeSoQS = 0; } else if (q.SiSo > 100) { q.HeSoQS = 0.6; } else { q.HeSoQS = Math.Ceiling(((q.SiSo ?? 0) - 50) / 10.0) * 0.1; } q.TongHeSo = q.HeSoDD + q.HeSoKip + q.HeSoLHDT + q.HeSoQS + 1; if (q.MonHoc == null) { q.MonHoc = db.MonHocs.Find(q.MaMH); } switch (q.MonHoc.M) { case "A": q.SoTietQuyChuan = (int)((1 + q.HeSoKip + q.HeSoLHDT + q.HeSoDD) * (15 + Math.Max(0, (float)((q.SiSo - 20) / 4))) * q.SoTietTKB); break; case "TT": q.SoTietQuyChuan = (int)((1 + q.HeSoKip + q.HeSoLHDT + q.HeSoDD) * q.SiSo * 0.5); break; case "M": default: q.SoTietQuyChuan = (int?)(q.TongHeSo * q.SoTietTKB); break; } }