private void btnSodophong_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { Thongtin tt = new Thongtin(); tt.StartPosition = FormStartPosition.CenterScreen; var listdk = db.DK_Customers.Select(m => m.Sophong).ToList(); var list = db.Rooms.Where(x => !listdk.Contains(rooms.Sophong)).Count(); tt.dateCheckin.Enabled = false; tt.txtTimeCheckin.Enabled = false; if (list != 0) { var dt = DateTime.Now; tt.dateCheckin.EditValue = dt.ToShortDateString(); tt.txtTimeCheckin.EditValue = dt.ToShortTimeString(); } else { var roomdk = db.DK_Customers.FirstOrDefault(m => m.Sophong == rooms.Sophong && m.Daidien == true); tt.dateCheckin.EditValue = roomdk.DateCheckin.ToShortDateString(); tt.txtTimeCheckin.EditValue = roomdk.GioCheckin; } GetData mydate = new GetData(tt.PostData); mydate(rooms); tileView1_ItemCustomize(sender, s); tt.ShowDialog(); }
private void btnHosophong_Click(object sender, EventArgs e) { Thongtin tt = new Thongtin(); tt.StartPosition = FormStartPosition.CenterScreen; tt.ShowDialog(); }
private void btnLuu_Click(object sender, EventArgs e) { List <int> row = gvDichvu.GetSelectedRows().Where(m => m >= 0).ToList(); foreach (var i in lstdv) { foreach (var item in row) { if (i.Id == Convert.ToInt32(gvDichvu.GetRowCellValue(item, gvDichvu.Columns[5]))) { if (Convert.ToInt32(gvDichvu.GetRowCellValue(item, gvDichvu.Columns[4])) <= 0) { MessageBox.Show("Vui lòng chọn số lượng của dịch vụ!"); return; } Thongtin tt = new Thongtin(); PhongDV pdv = new PhongDV(); pdv.MaDV = gvDichvu.GetRowCellValue(item, gvDichvu.Columns[0]).ToString(); pdv.IdPhong = idphong; pdv.Soluong = Convert.ToInt32(gvDichvu.GetRowCellValue(item, gvDichvu.Columns[4])); pdv.Loaitien = loaitien; if (pdv.Loaitien == "USD") { pdv.DonGia = Convert.ToInt32(gvDichvu.GetRowCellValue(item, gvDichvu.Columns[3])) * 22000; } else { pdv.DonGia = Convert.ToInt32(gvDichvu.GetRowCellValue(item, gvDichvu.Columns[3])); } if (Convert.ToString(gvDichvu.GetRowCellValue(item, gvDichvu.Columns[2])) != "") { pdv.Thanhtien = pdv.Soluong * pdv.DonGia; } else { pdv.Thanhtien = pdv.DonGia; } pdv.Tygia = tygia; pdv.Ngay = DateTime.Now.Date; pdv.Gio = DateTime.Now.ToShortTimeString(); pdv.Ghichu = ""; var p_dv = db.PhongDVs.Where(m => m.MaDV == pdv.MaDV && m.IdPhong == pdv.IdPhong).Count(); if (p_dv != 0) { var editpdv = db.PhongDVs.Where(m => m.MaDV == pdv.MaDV && m.IdPhong == pdv.IdPhong).First(); editpdv.Soluong += pdv.Soluong; db.SaveChanges(); } else { db.PhongDVs.Add(pdv); db.SaveChanges(); } var sl = Convert.ToInt32(gvDichvu.GetRowCellValue(item, gvDichvu.Columns[4])); var dv = db.DichVu.Where(m => m.Id == i.Id).First(); dv.SoLuong = i.SoLuong - sl; db.SaveChanges(); MessageBox.Show("Thêm thành công!"); this.Close(); } else { var editsl = db.DichVu.Where(m => m.Id == i.Id).First(); editsl.SoLuong = i.SoLuong; db.SaveChanges(); } } } }