private void button2_Click(object sender, EventArgs e) //button sửa giá phòng { if (txt_maph.Text == "") { MessageBox.Show("Thông tin phòng chưa được hiển thị."); } phong ph = new phong(); ph.maloaiphong = cmb_maloaiphong.SelectedValue.ToString(); ph.maphong = txt_maph.Text; ph.giaphong = int.Parse(txt_giaphong.Text.ToString()); ph.tinhtrangphong = txt_tinhtrangphong.Text; if (MessageBox.Show(string.Format("Bạn có muốn sửa giá phòng ?"), "", MessageBoxButtons.OKCancel) == DialogResult.OK) { if (Bus.UpdateProfile(ph) > 0) { MessageBox.Show("Phòng đã được sửa."); Phieudangki_Load_1(sender, e); } else { MessageBox.Show("Error"); } } }
public static int DeleteProfile(phong ph) { SqlParameter[] para = new SqlParameter[] { new SqlParameter("@maphong", ph.maphong) }; return(DataProvider.ExecuteNonQuery("xoaphong", para)); }
//phong da = new phong(); // vieest ham lay thong va dua len datagrivew public DataTable hienthiphong() { try { phong ph = new phong(); return(ph.getTable()); } catch { throw; } }
public static int InsertProfile(phong ph) { SqlParameter[] para = new SqlParameter[] { new SqlParameter("@maphong", ph.maphong), new SqlParameter("@maloaiphong", ph.maloaiphong), new SqlParameter("@giaphong", ph.giaphong), new SqlParameter("@tinhtrangphong", ph.tinhtrangphong) }; return(DataProvider.ExecuteNonQuery("themphong", para)); }
private void button2_Click(object sender, EventArgs e) { phong ph = new phong(); ph.setMaPhong(textBox2.Text); phongBusiness pb = new phongBusiness(); int rm = pb.xoa(ph); if (rm == 1) { MessageBox.Show("Xoa thanh cong"); loadData(); } }
private void cmbMaPT_SelectedIndexChanged(object sender, EventArgs e) { phieuthuephong phieuthuephong = dt.phieuthuephongs.Where(p => p.matp == cmbMaPT.SelectedValue.ToString()).FirstOrDefault(); if (phieuthuephong != null) { txtNgayThuePhong.Text = phieuthuephong.ngaythue.ToString(); s = phieuthuephong.maphong; phong phong = dt.phongs.Where(p => p.maphong == s.ToString()).FirstOrDefault(); string c = phong.maloai; loaiphong loaiphong = dt.loaiphongs.Where(p => p.maloai == c).FirstOrDefault(); d = Convert.ToInt32(loaiphong.gia); labGia.Text = d.ToString(); } }
//Thêm phòng public int insertPhong(PhongDTO pDTO) { try { phong p = new phong(); p.maphong = pDTO.Maphong; p.maloai = pDTO.Maloai; p.dadat = (bool)pDTO.Dadat; p.danhan = (bool)pDTO.Danhan; htDataContext.phongs.InsertOnSubmit(p); htDataContext.SubmitChanges(); return(1); } catch { return(0); } }
private void button3_Click(object sender, EventArgs e) { phong ph = new phong(); ph.setMaPhong(textBox2.Text); // e phai set them may cai truong kia nua chu ph.setTinhTrang(textBox1.Text); ph.setGiaPhong(Int32.Parse(textBox3.Text)); ph.setLoaiPhong(textBox4.Text); phongBusiness pb = new phongBusiness(); int sa = pb.sua(ph); if (sa == 1) { MessageBox.Show("Sua thanh cong"); loadData(); } }
private void button1_Click(object sender, EventArgs e) { phong ph = new phong(); ph.setMaPhong(textBox2.Text); ph.setGiaPhong(Int32.Parse(textBox3.Text)); ph.setTinhTrang(textBox1.Text); ph.setLoaiPhong(textBox4.Text); phongBusiness pb = new phongBusiness(); ph.setMaPhong(textBox2.Text); int ms = pb.them(ph); if (ms == 1) { MessageBox.Show("Them thanh cong"); loadData(); } }
public bool ThemPhong(string idphong, string gia, string tinhtrang, string ghichu) { try { DataDataContext data = new DataDataContext(); phong ph = new phong(); ngph ngph = new ngph(); diennuoc dn = new diennuoc(); tienno no = new tienno(); ph.idphong = Convert.ToInt32(idphong); ph.gia = gia; ph.tinhtrang = tinhtrang; ph.ghichu = ghichu; ngph.idphong = Convert.ToInt32(idphong); dn.idphong = Convert.ToInt32(idphong); no.idphong = Convert.ToInt32(idphong); data.phongs.InsertOnSubmit(ph); data.ngphs.InsertOnSubmit(ngph); data.diennuocs.InsertOnSubmit(dn); data.tiennos.InsertOnSubmit(no); data.SubmitChanges(); return(true); } catch { return(false); } }
//Thêm phòng public int insertPhong(PhongDTO pDTO) { try { phong p = new phong(); p.maphong = pDTO.Maphong; p.maloai = pDTO.Maloai; p.dadat = (bool)pDTO.Dadat; p.danhan = (bool)pDTO.Danhan; htDataContext.phongs.InsertOnSubmit(p); htDataContext.SubmitChanges(); return 1; } catch { return 0; } }
public int xoa(phong ph) { return(ph.xoaPhong(ph)); }
//public void delete(string maphong) //{ // string sql = " delete phonghop where maphong = '" + maphong + "' "; // da.ExcuteNonQuery(sql); //} //public void sua(string tang, string size, string maphong) //{ // string sql = "update phonghop set tang = '" + tang + "',size = '" + size + "'where maphong= '" + maphong + "'"; // da.ExcuteNonQuery(sql); //} public int them(phong ph) { return(ph.themPhong(ph)); }
public static int DeleteProfile(phong ph) { return(Dao.DeleteProfile(ph)); }
public static int InsertProfile(phong ph) { return(Dao.InsertProfile(ph)); }
//PHÒNG #region public static int UpdateProfile(phong ph) { return(Dao.UpdateProfile(ph)); }
public int sua(phong ph) { return(ph.sua(ph)); }
public static void vaoPhong(object obj)// cho 1 client vào phòng { int pos = (Int32)obj; while (true) { try { byte[] buff = new byte[1024]; int rcv = socket_vaophong[pos].Receive(buff); string sig = ""; for (int i = 0; i < rcv; i += 2) { sig += Convert.ToChar(buff[i]).ToString(); } if (sig.Contains("Create")) { string[] t = sig.Split('_'); phong temp = new phong(); numberOfRoom++; temp.betMoney = Convert.ToInt32(t[1]); temp.soPhong = numberOfRoom - 1; temp.indexOfClient.Add(pos); temp.managerOfTheGame.clientOfRoom.Add(client[pos]); temp.managerOfTheGame.numOfPlayers++; client[pos].room = temp.soPhong; dsPhong.Add(temp); socket_vaophong[pos].Send(Encoding.Unicode.GetBytes("Create" + "_" + (temp.soPhong + 1).ToString() + "_" + temp.betMoney.ToString())); Thread.Sleep(1000); socket_status[pos].Send(Encoding.Unicode.GetBytes(temp.indexOfClient.Count.ToString())); } else { string[] t = sig.Split('_'); bool check = false; foreach (phong item in dsPhong) { if (item.indexOfClient.Count < 4 && Convert.ToInt32(t[1]) == item.betMoney) { client[pos].room = item.soPhong; item.indexOfClient.Add(pos); item.managerOfTheGame.clientOfRoom.Add(client[pos]); item.managerOfTheGame.numOfPlayers++; socket_vaophong[pos].Send(Encoding.Unicode.GetBytes("Find" + "_" + (item.soPhong + 1).ToString() + "_" + item.betMoney.ToString())); Thread.Sleep(1000); foreach (int x in item.indexOfClient) { socket_status[x].Send(Encoding.Unicode.GetBytes(item.indexOfClient.Count.ToString())); } break; } } if (check == false) { socket_vaophong[pos].Send(Encoding.Unicode.GetBytes("Not found")); } } } catch { break; } } }