void biDatabaseSave_ItemClick(object sender, DevExpress.Xpf.Bars.ItemClickEventArgs e) { if (txtTitle.Text != "" && richEdit.Text != "")//Neu noi dung va tieu de khong trong { //Tao file stream IsolatedStorageFileStream fs = new IsolatedStorageFileStream("Temp.doc", FileMode.OpenOrCreate, FileAccess.ReadWrite, str); //Save noi dung vao filestream richEdit.SaveDocument(fs, DocumentFormat.Doc); fs.Close(); fs.Dispose(); //Chuyen noi dung thanh dang binary filesave = ReadFile(); //Dua dang binary ve dang base64string noidungtam = Convert.ToBase64String(filesave); //Gui lenh luu xuong CSDL if (mathongbao == -1)//Nếu là thêm mới { ws.LuuThongBaoAsync(txtTitle.Text, noidungtam, Paradise5.MainPage.LoginID, mathongbao); } else//Nếu là cập nhật { Paradise5.ControlEXT.DialogResultCommon dialog = new Paradise5.ControlEXT.DialogResultCommon(); dialog.setthongdiep("Thông báo bạn muốn tạo đã có. Bạn có muốn cập nhật"); dialog.Closed += dialog_Closed;//Lay dialogresult khi dong form dialog.Show(); } } else { Paradise5.ControlEXT.DialogResultCommon dialog = new Paradise5.ControlEXT.DialogResultCommon(); dialog.setthongdiep("Lỗi"); dialog.Show(); } }
void dialog_Closed(object sender, EventArgs e) { Paradise5.ControlEXT.DialogResultCommon dialog = (Paradise5.ControlEXT.DialogResultCommon)sender; if (dialog.DialogResult == true) { ws.LuuThongBaoAsync(txtTitle.Text, noidungtam, Paradise5.MainPage.LoginID, mathongbao); } }
void ws_LuuThongBaoCompleted(object sender, LuuThongBaoCompletedEventArgs e) { if (e.Result != -1)//Neu luu thanh cong { mathongbao = e.Result; Paradise5.ControlEXT.DialogResultCommon dialog = new Paradise5.ControlEXT.DialogResultCommon(); dialog.setthongdiep("Lưu thông báo thành công"); dialog.Show(); } else//Neu luu khong thanh cong { Paradise5.ControlEXT.DialogResultCommon dialog = new Paradise5.ControlEXT.DialogResultCommon(); dialog.setthongdiep("Có lỗi xảy ra khi lưu thông báo"); dialog.Show(); } }