public void CapNhatMon(Mon m) { Mon _mon = dbContext.Mons.Single <Mon>(x => x.id_mon == m.id_mon); _mon.tenmon = m.tenmon; _mon.LoaiMon = dbContext.LoaiMons.Single <LoaiMon>(l => l.id_loaimon == m.id_loaimon); _mon.gia = m.gia; _mon.tenviettat = m.tenviettat; _mon.trangthai = m.trangthai; // update dbContext.SubmitChanges(); }
public List <Mon> GetMon() { List <Mon> MonList = new List <Mon>(); DataTable data = DataProvider.Instance.ExecuteQuery("select * from mon"); foreach (DataRow item in data.Rows) { Mon mon = new Mon(item); MonList.Add(mon); } return(MonList); }
private void btn_LuuMon_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(txt_TenMon.Text.Trim())) { Mon obj = new Mon { TenMon = txt_TenMon.Text.Trim(), GiaBan = (double)num_updown_GiaBan.Value, IdThucDon = (int)cbb_ThucDon_Mon.SelectedValue }; if (!string.IsNullOrEmpty(txt_ID_Mon.Text)) { //MessageBox.Show("Ok Sua"); obj.Id = int.Parse(txt_ID_Mon.Text.Trim()); int kq = app.Mon.UpdateMon(obj); if (kq >= 1) { MessageBox.Show("Sửa món thành công"); LoadMon(); //if (updateMon != null) //{ // updateMon(this, new EventArgs()); //} } else { MessageBox.Show("Sửa món thất bại"); } } else { //MessageBox.Show("Themmoi"); int kq = app.Mon.AddMon(obj); if (kq >= 1) { MessageBox.Show("Thêm món thành công"); LoadMon(); //if (addMon != null) //{ // addMon(this, new EventArgs()); //} } else { MessageBox.Show("Thêm món thất bại"); } } } else { MessageBox.Show("Mời nhập tên món!"); } }
private void cboMon_SelectedIndexChanged(object sender, EventArgs e) { int idmon; int.TryParse(cboMon.SelectedValue.ToString(), out idmon); Mon mon = app.Mon.GetMonById(idmon); if (mon != null) { txtGia.Text = mon.GiaBan.ToString(); } }
public List <Mon> GetList() { List <Mon> list = new List <Mon>(); DataTable data = DataProvider.Instance.ExecuteQuery("SELECT * FROM Mon"); foreach (DataRow item in data.Rows) { Mon obj = new Mon(item); list.Add(obj); } return(list); }
public ActionResult DoBattle(int id) { Battle.DeleteAll(); Mon playerMon = Mon.Find(id); Battle newPlayer = playerMon.GetAllTrueStats(); newPlayer.Save(); newPlayer.SetPlayerMon(); newPlayer.SetActiveMon(); Battle.ComputerChoice(id); return(RedirectToAction("Combat")); }
public void Update(Mon mon1) { string sql = "update mon set Hoten ='" + mon1.Tenmon + "',sotc='" + mon1.Sotc + "' where mamon = '" + mon1.Mamon + "'"; SqlDataAdapter da = new SqlDataAdapter(sql, _cn); DataTable dt = new DataTable(); da.Fill(dt); da.Update(dt); dt.AcceptChanges(); }
private void btn_Luu_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { string error = ""; bool isUpdate = false; if (_listUpdate.Count > 1) { foreach (int id in _listUpdate) { Mon mon = new Mon(); mon.id_mon = int.Parse(gridView1.GetRowCellValue(id, "id_mon").ToString()); mon.tenmon = gridView1.GetRowCellValue(id, "tenmon").ToString(); mon.id_loaimon = int.Parse(gridView1.GetRowCellValue(id, "id_loaimon").ToString()); mon.tenviettat = gridView1.GetRowCellValue(id, "tenviettat").ToString(); mon.gia = decimal.Parse(gridView1.GetRowCellValue(id, "gia").ToString()); mon.trangthai = gridView1.GetRowCellValue(id, "trangthai").ToString(); if (!_monBll.KiemTraTenMonTonTai(mon.tenmon, mon.id_mon)) { _monBll.CapNhatMon(mon); isUpdate = true; } else { if (error == "") { error = mon.tenmon; } else { error += " | " + mon.tenmon; } } } } if (isUpdate == true) { if (error.Length == 0) { Notifications.Success("Cập dữ liệu thành công."); } else { Notifications.Error("Có lỗi xảy ra khi cập nhật dữ liệu. Các món chưa được cập nhật (" + error + "). Lỗi: Tên món đã tồn tại."); } } else { Notifications.Error("Có lỗi xảy ra khi cập nhật dữ liệu. Lỗi: Tên món đã tồn tại."); } btn_Luu.Enabled = false; LoadDataSource(); }
protected void Page_Load(object sender, EventArgs e) { if (Session["User_Id"] == null) { Response.Redirect("LoginPage.aspx"); } Calendar1.Visible = false; if (!IsPostBack) { SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["UniversityDatabaseConnectionString"].ConnectionString); //String value = Request.QueryString.ToString(); //Char delimiter = '&'; //String[] substrings = value.Split(delimiter); //if (substrings[0].StartsWith("EMPNO=")) //{ // substrings[0] = substrings[0].Remove(0, "EMPNO=".Length).Replace('+', ' ').Trim(); //} //if (substrings[1].StartsWith("MONTH=")) //{ // substrings[1] = substrings[1].Remove(0, "MONTH=".Length).Replace('+', ' ').Trim(); //} //if (substrings[2].StartsWith("YEAR=")) //{ // substrings[2] = substrings[2].Remove(0, "YEAR=".Length).Replace('+', ' ').Trim(); //} Int16 Emp = 0; string Mon, Yr; //if (Int16.TryParse(substrings[0], out emp)) //{ // Emp = emp; //} //Mon = substrings[1]; //Yr = substrings[2]; Emp = Convert.ToInt16(Request.QueryString["EMPNO"]); Mon = Request.QueryString["MONTH"]; Yr = Request.QueryString["YEAR"]; //Response.Write("<script>alert('EMPNO =" + Emp + "MONTH=" + Mon + " YEAR=" + Yr + "');</script>"); DataSet ds = SelectAllTesingDataById(Emp, Mon, Yr); Showempid.Text = Emp.ToString(); ShowMth.Text = Mon.ToString(); Showyr.Text = Yr.ToString(); TxtDAArrears.Text = ds.Tables[0].Rows[0]["DAARREARS"].ToString(); Txtincometax.Text = ds.Tables[0].Rows[0]["INC_TAX"].ToString(); LblnetDAArrears.Text = ds.Tables[0].Rows[0]["NET_DAARREARS"].ToString(); LblCal.Text = ds.Tables[0].Rows[0]["BANK_TRANDATE"].ToString(); } }
public void Insert(Mon mon1) { string sql = "insert into mon values('" + mon1.Mamon + "','" + mon1.Tenmon + "' ,'" + mon1.Sotc + "')"; SqlDataAdapter da = new SqlDataAdapter(sql, _cn); DataTable dt = new DataTable(); da.Fill(dt); da.Update(dt); dt.AcceptChanges(); }
public void KhoiTao(Mon mon) { db = new ModelQuanLiCafeDbContext(); LblTieuDe.Text = "Công thức định lượng của " + mon.TenMon; memoEditCongThuc.Text += "1 " + mon.DonViTinh.TenDVT + " " + mon.TenMon + " cần:" + Environment.NewLine; var listnl = db.DinhLuongs.Where(s => s.IdMon == mon.IdMon).ToList(); foreach (var item in listnl) { var nl = db.NguyenLieux.Find(item.IdNguyenLieu); memoEditCongThuc.Text += "-> " + item.SoLuongNguyenLieu + " " + nl.DonViTinh.TenDVT + " " + nl.TenNguyenLieu + Environment.NewLine; } }
public List <Mon> TimKiemMonAN(string tenhanghoa) { List <Mon> list = new List <Mon>(); string query = $"SELECT * FROM mon where tenhanghoa like N'%{tenhanghoa}%' "; DataTable data = DataProvider.Instance.ExecuteQuery(query); foreach (DataRow item in data.Rows) { Mon obj = new Mon(item); list.Add(obj); } return(list); }
public ActionResult View(int id) { Dictionary <string, object> model = new Dictionary <string, object>(); Mon selectedMon = Mon.Find(id); List <MonType> types = selectedMon.GetMonTypes(); List <Move> monsmoves = selectedMon.GetMoves(); model.Add("types", types); model.Add("mon", selectedMon); model.Add("moves", monsmoves); return(View(model)); }
private void cbTenHangHoa_SelectedIndexChanged(object sender, EventArgs e) { ComboBox cb = sender as ComboBox; if (cb.SelectedItem == null) { return; } Mon selected = cb.SelectedItem as Mon; mamon = selected.mamon; loadMonAnID(mamon); }
// Xóa một đối tượng public long Delete(long MaMon) { Mon dbEntry = fastfood.Mons.Find(MaMon); if (dbEntry == null) { return(0); } fastfood.Mons.Remove(dbEntry); fastfood.SaveChanges(); return(MaMon); }
public void GetTrueStat_Test() { //Arrange Mon newMon = new Mon("Rattata", 50, 30, 56, 35, 25, 35, 72); newMon.Save(); //Act int result = newMon.GetTrueStat(newMon.GetAttack()); //Assert Assert.AreEqual(76, result); }
public ActionResult QLDiem() { Mon m = new Mon(); Nganh ngh = new Nganh(); SinhVien sv = new SinhVien(); Diem d = new Diem(); ViewBag.ListMon = m.listmon(); ViewBag.ListNganh = ngh.listnganh(); ViewBag.SinhVien = sv.listSinhVien(); ViewBag.Diem = d.listdiem(); return(View()); }
public void GetTrueHP_Test() { //Arrange Mon newMon = new Mon("Rattata", 50, 30, 56, 35, 25, 35, 72); newMon.Save(); //Act int result = newMon.GetTrueHP(); //Assert Assert.AreEqual(105, result); }
public List <Mon> LoaiMonAn(int maloaimon) { List <Mon> list = new List <Mon>(); string query = $"SELECT * FROM mon where maloaimon like '%{maloaimon}%'"; DataTable data = DataProvider.Instance.ExecuteQuery(query); foreach (DataRow item in data.Rows) { Mon obj = new Mon(item); list.Add(obj); } return(list); }
public Mon GetMonByIdMon(int idMon) { Mon m = new Mon(); foreach (Mon i in GetAllMon()) { if (idMon == i.IdMon) { m = i; } } return(m); }
private void dgvData_CellClick(object sender, DataGridViewCellEventArgs e) { int index = dgvData.CurrentRow.Index; int mamon = int.Parse(dgvData.Rows[index].Cells[0].Value.ToString()); string tengv = dgvData.Rows[index].Cells[2].Value.ToString(); string tenhk = dgvData.Rows[index].Cells[3].Value.ToString(); string tenlop = dgvData.Rows[index].Cells[4].Value.ToString(); Mon x = db.Mon.Where(m => m.maMon == mamon && m.trangThai == true).FirstOrDefault(); mon = x; List <GiaoVien> lgv = db.GiaoVien.Where(m => m.trangThai == true).ToList(); List <Lop> ll = db.Lop.Where(m => m.trangThai == true).ToList(); List <HocKy> lhk = db.HocKy.ToList(); int vt1 = -1, vt2 = -1, vt3 = -1; for (int i = 0; i < lgv.Count; i++) { if (lgv[i].ten == tengv) { vt3 = i; break; } } for (int i = 0; i < ll.Count; i++) { if (ll[i].tenLop == tenlop) { vt1 = i; break; } } for (int i = 0; i < lhk.Count; i++) { if (lhk[i].tenHK == tenhk) { vt2 = i; break; } } cbbGVDay.SelectedIndex = vt3; cbbHocKy.SelectedIndex = vt2; cbbLop.SelectedIndex = vt1; txtMaMonHoc.Text = mamon.ToString(); txtTenMonHoc.Text = x.tenMon; }
// Sửa một đối tượng public long Update(Mon model) { Mon dbEntry = fastfood.Mons.Find(model.MaMon); if (dbEntry == null) { return(0); } fastfood.Entry(dbEntry).CurrentValues.SetValues(model); fastfood.SaveChanges(); return(model.MaMon); }
public bool ThemMon(string MaMon, string TenMon, string MaKhoa, int SoTinChi, string HK, ref string err) { QLSVDataContext qlSV = new QLSVDataContext(); Mon kh = new Mon(); kh.maMon = MaMon; kh.tenMon = TenMon; kh.maKhoa = MaKhoa; kh.soTinChi = SoTinChi; kh.hocKi = HK; qlSV.Mons.InsertOnSubmit(kh); qlSV.Mons.Context.SubmitChanges(); return(true); }
public bool EditMon(Mon Mon) { try { string query = "update Mon set TenMon = @name , GiaTien = @gia ," + " SoLanGoiMon = @solangoi , IdDanhMuc = @idDm , IdAnh = @idAnh where IdMon = @idmon "; object[] prams = { Mon.TenMon, Mon.GiaTien, Mon.SoLanGoiMon, Mon.IdDanhMuc, Mon.IdAnh }; return(DBHelper.Instance.ExecuteNonQuery(query, prams) > 0); } catch (Exception) { return(false); } }
public void Edit_Test() { //Arrange Mon newMon = new Mon("Electrode", 43, 24, 31, 61, 32, 23, 23); newMon.Save(); Mon expectedMon = new Mon("Electrode", 43, 24, 32, 61, 32, 23, 20, newMon.GetMonId()); //Act newMon.Edit("Electrode", 43, 24, 32, 61, 32, 23, 20); //Assert Assert.AreEqual(expectedMon, newMon); }
private void btn_Them_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { this.gridView1.FocusedRowHandle = GridControl.NewItemRowHandle; gridView1.SelectRow(gridView1.FocusedRowHandle); gridView1.FocusedColumn = gridView1.VisibleColumns[1]; gridView1.ShowEditor(); gridView1.PostEditor(); if (KiemTraHang()) { string tenmon = gridView1.GetFocusedRowCellValue(col_TenMon).ToString(); if (_monBll.KiemTraTenMonTonTai(tenmon) != -1) { try { Mon mon = new Mon(); mon.tenmon = gridView1.GetFocusedRowCellValue(col_TenMon).ToString(); mon.id_loaimon = int.Parse(gridView1.GetFocusedRowCellValue(col_LoaiMon).ToString()); mon.tenviettat = gridView1.GetFocusedRowCellValue(col_TenVietTat).ToString(); mon.trangthai = gridView1.GetFocusedRowCellValue(col_TrangThai).ToString(); mon.gia = decimal.Parse(gridView1.GetFocusedRowCellValue(col_Gia).ToString()); mon.id_donvi = int.Parse(gridView1.GetFocusedRowCellValue(col_DonVi).ToString()); if (_monBll.KiemTraTenMonTonTai(tenmon) == 1) { _monBll.ThemMonMoi(mon); } else { mon.id_mon = _monBll.LayIdMon(tenmon); _monBll.CapNhatMon(mon); } Notifications.Success("Thêm món mới thành công!"); LoadDataSource(); btn_Luu.Enabled = false; _listUpdate.Clear(); } catch (Exception) { Notifications.Error("Bạn chưa nhập đầy đủ thông tin món. Vui lòng nhập lại!"); } } else { Notifications.Error("Tên món đã tồn tại. Vui lòng nhập tên món lại."); } } else { Notifications.Error("Bạn chưa nhập đầy đủ thông tin món. Vui lòng nhập lại!"); } }
public ActionResult ThemHoaDon(ChiTietHoaDon model) { db.ChiTietHoaDons.Add(model); Mon a = db.Mons.Find(model.MaMon); HoaDon hd = db.HoaDons.Find(model.SoHD); Double?Tien = a.DonGia * model.SoLuong; double?TongtienHD = hd.TongTien + Tien; hd.SoHD = model.SoHD; hd.TongTien = Convert.ToDouble(TongtienHD); db.SaveChanges(); return(RedirectToAction("Index")); }
private void LuuViTri() { //lưu vị trí hiện tại của các bảng banLe = (BanLe)cardViewBan.GetFocusedRow(); mon = (Mon)gridViewMon.GetFocusedRow(); if (mon != null) { gridViewMonRowHandle = gridViewMon.LocateByValue("IdMon", mon.IdMon); } if (banLe != null) { cardViewBanRowHandle = cardViewBan.LocateByValue("IdBan", banLe.IdBan); } }
void QueuePlayer(Mon enemy, Mon player, int menu_index, bool hook_messageboxBackToDefault) { // Player use move var q = bs.QueueMove( new MoveArgs(player.GetMoves()[menu_index], player, enemy), this.Content); // Hook events q.AnimStarted += MessageBox_UsedMove; if (hook_messageboxBackToDefault) { q.Removed += MessageBox_BackToDefault; } }
public ActionResult Lose() { Dictionary <string, object> model = new Dictionary <string, object>(); Battle player = Battle.FindPlayer(); Battle computer = Battle.FindComputer(); List <Move> playerMoves = Mon.Find(player.GetMon_Id()).GetMoves(); List <Message> turnMessages = Message.GetAllMessages(); model.Add("player", player); model.Add("computer", computer); model.Add("playerMoves", playerMoves); model.Add("turnMessages", turnMessages); return(View(model)); }
public static int IDFromMon( Mon mon ) { return (int)mon.currentTypeType + ( (int)mon.currentAttack1Type ) * TypeTypeLength + ( (int)mon.currentAttack2Type ) * TypeTypeLength * Attack1TypeLength; }