public void UpdatePresenter_Cancel_Test() { var updateView = MockRepository.GenerateMock<IUpdateView>(); var saveFileView = MockRepository.GenerateStub<ISaveFileDialogView>(); updateView.Expect(x => x.CloseView()); var presenter = new UpdatePresenter(null, _update, null, updateView, saveFileView, null); presenter.CancelClick(); updateView.VerifyAllExpectations(); }
private void btnXoa_Click(object sender, EventArgs e) { String sql = "DELETE FROM nhanvien WHERE nhanvien.ID = " + ID_NHANVIEN; UpdatePresenter updatePresenter = new UpdatePresenter(this, sql); if (updatePresenter.getKiemtra() == true) { MessageBox.Show("Xóa thành công !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); XemNV("SELECT nhanvien.ID, phongban.TENPHONG, HOTEN, NGAYSINH, CMND, DIACHI, DIENTHOAI, QUOCTICH, LOAI_NV, LUONGNGAY, LUONGTHANG, BACLUONG, TONGLUONG FROM nhanvien, phongban WHERE (nhanvien.ID_PHONG = phongban.ID)"); reset(); } }
private void Initialize() { Common.CommonImpl.NotificationHandler.Instance.SetContext(this); ApplicationCore.Container.RegisterType <ISecureDataStorage, SecureStorageHandler>(this); ApplicationCore.Container.RegisterType <IDeviceHandler, DeviceHandler>(this); ApplicationCore.Container.RegisterInstance <INotificationService>(Common.CommonImpl.NotificationHandler.Instance); ApplicationCore.Container.RegisterSingletonType <IAnalytics, AnalyticsHandler>(); ApplicationCore.Instance.Initialize(); Common.CommonImpl.NotificationHandler.Instance.Register(); ApplicationCore.Container.Resolve <IAnalytics>().Initialize(); splashPresenter = new SplashPresenter(this); urlPresenter = new UrlPresenter(this); termsPresenter = new TermsPresenter(this as IStartupRouter); loginPresenter = new LoginPresenter(this); signupPresenter = new SignupPresenter(this); profilePresenter = new ProfilePresenter(this); mobilePhoneNumberPresenter = new MobilePhoneNumberPresenter(this); updatePresenter = new UpdatePresenter(this); }
public void StartAfterDevSettings() { var updatePresenter = new UpdatePresenter(this); updatePresenter.UpdateVersionCheckDetails().Forget(); }
public void UpdatePresenter_DownloadClick_CancelDownload_Test() { var updateView = MockRepository.GenerateMock<IUpdateView>(); var saveFileView = MockRepository.GenerateMock<ISaveFileDialogView>(); saveFileView.Expect(x => x.ShowDialog()).Return(DialogResult.OK); updateView.Expect(x => x.SetSelectDownloadLabelText(String.Empty)).IgnoreArguments(); updateView.Expect(x => x.SetDownloadButtonEnabled(false)); updateView.Expect(x => x.SetUpdateComboBoxVisible(false)); updateView.Expect(x => x.SetDownloadProgressValue(0)); updateView.Expect(x => x.SetDownloadProgressVisisble(true)); var webOperation = MockRepository.GenerateMock<IWebOperation>(); webOperation.Expect(x => x.Download(String.Empty)).IgnoreArguments().Do(new Action<string>(DownloadSleep)); webOperation.Expect(x => x.State).Return(WebOperationState.InProgress); webOperation.Expect(x => x.Cancel()); webOperation.Expect(x => x.Result).Return(WebOperationResult.Canceled); updateView.Expect(x => x.SetSelectDownloadLabelTextDefault()); updateView.Expect(x => x.SetDownloadButtonEnabled(true)); updateView.Expect(x => x.SetUpdateComboBoxVisible(true)); updateView.Expect(x => x.SetDownloadProgressVisisble(false)); var presenter = new UpdatePresenter(null, _update, null, updateView, saveFileView, webOperation); var are = new AutoResetEvent(false); presenter.DownloadFinished += delegate { are.Set(); }; presenter.DownloadClick(0); presenter.CancelClick(); // Wait until the event handler is invoked if (!(are.WaitOne(5000, false))) { Assert.Fail("Test timed out."); } updateView.VerifyAllExpectations(); saveFileView.VerifyAllExpectations(); webOperation.VerifyAllExpectations(); }
public void UpdatePresenter_DownloadClick_Test() { var updateView = MockRepository.GenerateMock<IUpdateView>(); var saveFileView = MockRepository.GenerateMock<ISaveFileDialogView>(); string localFilePath = Path.Combine(Environment.CurrentDirectory, "TestFileDownloaded.txt"); saveFileView.Expect(x => x.ShowDialog()).Return(DialogResult.OK); saveFileView.Stub(x => x.FileName).Return(localFilePath); updateView.Expect(x => x.SetSelectDownloadLabelText(String.Empty)).IgnoreArguments(); updateView.Expect(x => x.SetDownloadButtonEnabled(false)); updateView.Expect(x => x.SetUpdateComboBoxVisible(false)); updateView.Expect(x => x.SetDownloadProgressValue(0)); updateView.Expect(x => x.SetDownloadProgressVisisble(true)); updateView.Expect(x => x.CloseView()); // fixup the address to look in the running folder _update.UpdateFiles[0].HttpAddress = Path.Combine(Environment.CurrentDirectory, _update.UpdateFiles[0].HttpAddress); var presenter = new UpdatePresenter(null, _update, null, updateView, saveFileView, null); Assert.IsNull(presenter.SelectedUpdate); Assert.IsNull(presenter.LocalFilePath); Assert.AreEqual(false, presenter.UpdateReady); var are = new AutoResetEvent(false); presenter.DownloadFinished += delegate { are.Set(); }; presenter.DownloadClick(0); // Wait until the event handler is invoked if (!(are.WaitOne(5000, false))) { Assert.Fail("Test timed out."); } Assert.AreSame(_update.UpdateFiles[0], presenter.SelectedUpdate); Assert.AreEqual(localFilePath, presenter.LocalFilePath); Assert.AreEqual(true, presenter.UpdateReady); updateView.VerifyAllExpectations(); saveFileView.VerifyAllExpectations(); }
public void UpdatePresenter_DownloadClick_SaveFileDialogCanceled_Test() { var updateView = MockRepository.GenerateStub<IUpdateView>(); var saveFileView = MockRepository.GenerateMock<ISaveFileDialogView>(); saveFileView.Expect(x => x.ShowDialog()).Return(DialogResult.Cancel); var presenter = new UpdatePresenter(null, _update, null, updateView, saveFileView, null); Assert.IsNull(presenter.SelectedUpdate); Assert.IsNull(presenter.LocalFilePath); Assert.AreEqual(false, presenter.UpdateReady); presenter.DownloadClick(0); Assert.IsNull(presenter.SelectedUpdate); Assert.IsNull(presenter.LocalFilePath); Assert.AreEqual(false, presenter.UpdateReady); saveFileView.VerifyAllExpectations(); }
private void btnCapnhat_Click(object sender, EventArgs e) { //UPDATE table_name //SET column1 = value1, column2 = value2, ... //WHERE condition; int luongngay = int.Parse(txtLuongngay.Text); int luongthang = int.Parse(txtLuongthang.Text); int bacluong = int.Parse(txtBacluong.Text); int tongluong = 0; if (luongngay != 0) { tongluong = luongngay; } else { tongluong = luongthang * bacluong; } String sql = "UPDATE nhanvien " + "SET HOTEN = '" + txtHoten.Text + "'," + "NGAYSINH = '" + txtNgaysinh.Text + "'," + "CMND = '" + txtCMND.Text + "'," + "DIACHI = '" + txtDiachi.Text + "'," + "DIENTHOAI = '" + txtDienthoai.Text + "'," + "QUOCTICH = '" + txtQuoctich.Text + "'," + "LOAI_NV = '" + txtLoai.Text + "'," + "LUONGNGAY = '" + txtLuongngay.Text + "'," + "LUONGTHANG = '" + txtLuongthang.Text + "'," + "BACLUONG = '" + txtBacluong.Text + "'," + "TONGLUONG = '" + tongluong + "' " + "WHERE ID = " + ID_NHANVIEN; UpdatePresenter updatePresenter = new UpdatePresenter(this, sql); if (updatePresenter.getKiemtra() == true) { MessageBox.Show("Đã cập nhật !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } //try //{ // //This is my connection string i have assigned the database file address path // string MyConnection2 = "datasource=localhost;database=quanlynhanvien;port=3306;username=root;password=''"; // //This is my update query in which i am taking input from the user through windows forms and update the record. // //string Query = "update student.studentinfo set idStudentInfo='" + this.IdTextBox.Text + "',Name='" + this.NameTextBox.Text + "',Father_Name='" + this.FnameTextBox.Text + "',Age='" + this.AgeTextBox.Text + "',Semester='" + this.SemesterTextBox.Text + "' where idStudentInfo='" + this.IdTextBox.Text + "';"; // //This is MySqlConnection here i have created the object and pass my connection string. // MySqlConnection MyConn2 = new MySqlConnection(MyConnection2); // MySqlCommand MyCommand2 = new MySqlCommand(sql, MyConn2); // MySqlDataReader MyReader2; // MyConn2.Open(); // MyReader2 = MyCommand2.ExecuteReader(); // MessageBox.Show("Data Updated"); // while (MyReader2.Read()) // { // } // MyConn2.Close();//Connection closed here //} //catch (Exception ex) //{ // MessageBox.Show(ex.Message); //} }