public bool Restore(Entities.SaoLuuHeThong slht1) { try { cl = new Server_Client.Client(); // gán TCPclient this.client1 = cl.Connect(Luu.IP, Luu.Ports); //truyền giá trị lên server clientstrem = cl.SerializeObj(this.client1, "Restore", slht1); //lấy giá trị về bool tv = (bool)cl.DeserializeHepper(clientstrem, null); return(tv); } catch { return(false); } }
private void toolStripStatus_ThemMoi_Click(object sender, EventArgs e) { try { if (dgvHienThi.SelectedRows.Count > 0) { DataGridViewRow item = dgvHienThi.SelectedRows[0]; Entities.SaoLuuHeThong slht1 = (Entities.SaoLuuHeThong)item.DataBoundItem; System.Windows.Forms.DialogResult giatri = System.Windows.Forms.MessageBox.Show("Bạn muốn phục hồi từ file " + slht1.Name + " hay tìm trên máy... ?\r\nYES: phục hồi từ file " + slht1.Name + "\r\nNO: Tìm file phục hồi trên máy\r\nCancel: Thoát", "Hệ Thống Thông Báo", System.Windows.Forms.MessageBoxButtons.YesNoCancel, MessageBoxIcon.Information); { if (giatri == System.Windows.Forms.DialogResult.Yes) {//Phục hồi từ file slht1.TenDangNhap = Common.Utilities.User.TenDangNhap; slht1.MaNhanVien = Common.Utilities.User.NhanVienID; if (!Restore(slht1)) { MessageBox.Show("Restore Thất Bại, hãy kiểm tra lại database"); } else { MessageBox.Show("Restore thành công lại thời gian ngày: " + slht1.ThoiGian); } } else if (giatri == System.Windows.Forms.DialogResult.No) {//Phục hồi từ file trên máy OpenFileDialog o = new OpenFileDialog(); o.Filter = "Tệp tin sao lưu|*.bak"; o.Title = "Chọn tệp tin cần phục hồi..."; if (o.ShowDialog() == DialogResult.OK) { bool kq = new BizLogic.SaoLuuHeThong().Restore(o.FileName); if (!kq) { MessageBox.Show("Restore Thất Bại, hãy kiểm tra lại file"); } else { MessageBox.Show("Restore thành công!"); } } } else if (giatri == System.Windows.Forms.DialogResult.Cancel) {//Thoát return; } } } else if (dgvHienThi.SelectedRows.Count == 0) { System.Windows.Forms.DialogResult giatri = System.Windows.Forms.MessageBox.Show("Bạn muốn phục hồi từ file không?", "Hệ Thống Thông Báo", System.Windows.Forms.MessageBoxButtons.YesNo, MessageBoxIcon.Question); { if (giatri == System.Windows.Forms.DialogResult.Yes) { OpenFileDialog o = new OpenFileDialog(); o.Filter = "Tệp tin sao lưu|*.bak"; o.Title = "Chọn tệp tin cần phục hồi..."; if (o.ShowDialog() == DialogResult.OK) { bool kq = new BizLogic.SaoLuuHeThong().Restore(o.FileName); if (!kq) { MessageBox.Show("Restore Thất Bại, hãy kiểm tra lại file"); } else { MessageBox.Show("Restore thành công!"); } } } else if (giatri == System.Windows.Forms.DialogResult.No) { } } } } catch { } }