private void btnXoa_Click(object sender, EventArgs e) { DM_Intent_Type data = mListViewData.SelectedObject as DM_Intent_Type; if (data != null && data.DM_Intent_TypeID > 0) { if (SanitaMessageBox.Show("Bạn có chắc chắn muốn xóa loại chủ đề này không ?", "Thông Báo", System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes) { //Check xem có Entity nào ko IList <DM_Entity_Type> listcheck = DM_Entity_Type.GetDefaultList(0).Where(p => p.DM_Entity_TypeID == data.DM_Intent_TypeID).ToList(); if (listcheck.Count == 0) { if (DM_Intent_TypePresenter.DeleteDM_Intent_Type(data) > 0) { DoRefresh(); } } else { SanitaMessageBox.Show("Loại chủ đề đã tồn tại đối tượng !", "Thông Báo".Translate()); return; } } } }
private void bwAsync_WorkerChanged(object sender, ProgressChangedEventArgs e) { try { if (e.ProgressPercentage == -123456) { mProgress = new FormProgress(); mProgress.Progress.TextVisible = false; mProgress.ShowDialog(); } else if (e.ProgressPercentage == 0) { mProgress.Progress.Value = 0; mProgress.Progress.Maximum = (int)e.UserState; } else if (e.ProgressPercentage > 0) { mProgress.Progress.Value = e.ProgressPercentage; mProgress.Progress.Text = string.Format("{0}%", (mProgress.Progress.Value * 100) / mProgress.Progress.Maximum); } else if (e.ProgressPercentage < 0) { SanitaMessageBox.Show("Có lỗi xảy ra !", "Thông Báo".Translate()); } } catch { } }
private void btnSave_Click(object sender, EventArgs e) { //Validate if (String.IsNullOrEmpty(txtHovaTen.Text.Trim()) || (radioButtonNam.Checked == false && radioButtonNu.Checked == false)) { SanitaMessageBox.Show("Chưa nhập đủ thông tin!!!", "Thông Báo".Translate()); txtHovaTen.Focus(); return; } //mHocSinh.HovaTen = txtHovaTen.Text; //if (radioButtonNam.Checked == true) //{ // mHocSinh.GioiTinh = "Nam"; //} //else mHocSinh.GioiTinh = "Nữ"; //CultureInfo ci = new CultureInfo("en-IE"); //DateTime a = new DateTime(); //if (!DateTime.TryParseExact(maskedTextBox1.Text, "dd/MM/yyyy", ci, DateTimeStyles.None, out a)) //{ // SanitaMessageBox.Show("Lỗi ngày tháng năm sinh !", "Thông Báo".Translate()); //} //else //{ // mHocSinh.NamSinh = String.Format("'{0:d}'", a); ; // bwAsync_Start(ProcessingType.SaveData); //} }
private void btnKiemTraKetNoi_Click(object sender, EventArgs e) { if (SoftUpdatePresenter.CheckConnection(local_txtServer.Text, local_txtUser.Text, local_txtPassword.Text, local_txtDatabase.Text, MyVar.DEFAULT_PORT)) { SanitaMessageBox.Show("Kết nối cơ sở dữ liệu thành công !", "Thông Báo"); } else { SanitaMessageBox.Show("Kết nối cơ sở dữ liệu không thành công !", "Thông Báo"); } }
private void btnXoa_Click(object sender, EventArgs e) { Room data = mListViewData.SelectedObject as Room; if (data != null && data.RoomID > 0) { if (SanitaMessageBox.Show("Bạn có chắc chắn muốn xóa không ?", "Thông Báo", System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes) { if (RoomPresenter.DeleteRoom(data) > 0) { DoRefresh(); } } } }
private void bwAsync_WorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { if (isOK) { result = System.Windows.Forms.DialogResult.OK; if (!isFromStartup) { SanitaMessageBox.Show("Đã nâng cấp thành công !", "Nâng Cấp Cơ Sở Dữ Liệu"); } } this.DialogResult = result; this.Close(); }
private void btnSave_Click(object sender, EventArgs e) { //Validate if (String.IsNullOrEmpty(txtLoaiChuDe.Text.Trim())) { SanitaMessageBox.Show("Chưa nhập loại chủ đề !", "Thông Báo".Translate()); txtLoaiChuDe.Focus(); return; } mDM_Intent_Type.DM_Intent_TypeName = txtLoaiChuDe.Text; mDM_Intent_Type.DM_Intent_TypeDisable = txtDisable.Checked ? 1 : 0; bwAsync_Start(ProcessingType.SaveData); }
private void btnSave_Click(object sender, EventArgs e) { //Validate if (String.IsNullOrEmpty(txtUserCode.Text.Trim())) { SanitaMessageBox.Show("Chưa nhập mã người dùng !", "Thông Báo".Translate()); txtUserCode.Focus(); return; } if (String.IsNullOrEmpty(txtUserName.Text.Trim())) { SanitaMessageBox.Show("Chưa nhập tên người dùng !", "Thông Báo".Translate()); txtUserName.Focus(); return; } if (mListUser.Any(p => p.UserID != mUser.UserID && txtUserCode.Text.Trim() == p.UserCode)) { SanitaMessageBox.Show("Mã người dùng đã được sử dụng !", "Thông Báo".Translate()); txtUserCode.Focus(); return; } if (mListUser.Any(p => p.UserID != mUser.UserID && txtUserName.Text.Trim() == p.UserName)) { SanitaMessageBox.Show("Tên người dùng đã được sử dụng !", "Thông Báo".Translate()); txtUserName.Focus(); return; } mUser.UserCode = txtUserCode.Text; mUser.UserName = txtUserName.Text; mUser.UserPassword = txtPass.Text; mUser.APIKey = txtAPIKey.Text; mUser.LocaltionName = txtLocaltionName.Text; mUser.Latitude = txtLatitude.Text; mUser.Longitude = txtLongitude.Text; mUser.HassIO_URL = txtHassIO_URL.Text; mUser.HassIO_KEY = txtHassIO_KEY.Text; bwAsync_Start(ProcessingType.SaveData); }
private void btnSave_Click(object sender, EventArgs e) { //Validate if (String.IsNullOrEmpty(txtDeviceCode.Text.Trim())) { SanitaMessageBox.Show("Chưa nhập code !", "Thông Báo".Translate()); txtDeviceCode.Focus(); return; } mDevice.DeviceCode = txtDeviceCode.Text; mDevice.DeviceName = txtDeviceName.Text; mDevice.DeviceName_Short = txtTenRutGon.Text; mDevice.HomeID = Home.GetID(txtHome.Text.Trim()); mDevice.RoomID = Room.GetID(txtRoom.Text.Trim()); mDevice.UserID = User.GetID(txtUser.Text.Trim()); bwAsync_Start(ProcessingType.SaveData); }
private void btnSave_Click(object sender, EventArgs e) { //Validate if (String.IsNullOrEmpty(txtHomeName.Text.Trim())) { SanitaMessageBox.Show("Chưa nhập home !", "Thông Báo".Translate()); txtHomeName.Focus(); return; } if (mListHome.Any(p => p.HomeID != mHome.HomeID && txtHomeName.Text.Trim() == p.HomeName)) { SanitaMessageBox.Show("Tên đã được sử dụng !", "Thông Báo".Translate()); txtHomeName.Focus(); return; } mHome.HomeName = txtHomeName.Text; mHome.UserID = User.GetID(txtUser.Text.Trim()); bwAsync_Start(ProcessingType.SaveData); }
private void bwAsync_WorkerChanged(object sender, ProgressChangedEventArgs e) { try { if (e.ProgressPercentage == 0) { printProgress.TextVisible = true; printProgress.Value = 0; if (e.UserState is int) { printProgress.Maximum = (int)e.UserState; } } else if (e.ProgressPercentage < 0) { if (e.UserState is string) { txtStatus.Text = e.UserState.ToString(); } isOK = false; SanitaMessageBox.Show("Không thể nâng cấp cơ sở dữ liệu !", "Nâng Cấp Cơ Sở Dữ Liệu"); } else { if (e.UserState is string) { txtStatus.Text = e.UserState.ToString(); } printProgress.Value = e.ProgressPercentage; printProgress.Text = string.Format("{0}%", (printProgress.Value * 100) / printProgress.Maximum); } } catch { } }
static void Main(string[] args) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); SanitaLog.SetLogName("Medibox"); SanitaLogEx.SetLogName("Medibox"); //Create temp if (!Directory.Exists(Path.Combine(Application.StartupPath, "Data"))) { Directory.CreateDirectory(Path.Combine(Application.StartupPath, "Data")); } if (!Directory.Exists(Path.Combine(Application.StartupPath, "Log"))) { Directory.CreateDirectory(Path.Combine(Application.StartupPath, "Log")); } //Get info object[] customAttributes = Assembly.GetExecutingAssembly().GetCustomAttributes(false); foreach (object attribute in customAttributes) { if (attribute.GetType() == typeof(AssemblyDescriptionAttribute)) { MyVar.mAppDescription = ((AssemblyDescriptionAttribute)attribute).Description; SanitaLog.d(TAG, "Description:" + MyVar.mAppDescription); } if (attribute.GetType() == typeof(AssemblyTitleAttribute)) { MyVar.mAppName = ((AssemblyTitleAttribute)attribute).Title; SanitaLog.d(TAG, "Name:" + MyVar.mAppName); } if (attribute.GetType() == typeof(AssemblyFileVersionAttribute)) { MyVar.mAppVersion = ((AssemblyFileVersionAttribute)attribute).Version; SanitaLog.d(TAG, "Version:" + MyVar.mAppVersion); } } //Init Toast ToastNotification.DefaultToastGlowColor = eToastGlowColor.Red; ToastNotification.DefaultToastPosition = eToastPosition.MiddleCenter; ToastNotification.ToastFont = new System.Drawing.Font("Tahoma", 10); //Load setting try { MyVar.mMediboxSetting = JsonConvert.DeserializeObject <MediboxSetting>(File.ReadAllText(MyVar.SettingsFileName)); if (MyVar.mMediboxSetting.DB_ENCRIPT) { MyVar.mMediboxSetting.DB_ENCRIPT = false; MyVar.mMediboxSetting.DB_SERVER = CryptorEngine.Decrypt(MyVar.mMediboxSetting.DB_SERVER, true); MyVar.mMediboxSetting.DB_USERID = CryptorEngine.Decrypt(MyVar.mMediboxSetting.DB_USERID, true); MyVar.mMediboxSetting.DB_PORT = CryptorEngine.Decrypt(MyVar.mMediboxSetting.DB_PORT, true); MyVar.mMediboxSetting.DB_USERPASSWORD = CryptorEngine.Decrypt(MyVar.mMediboxSetting.DB_USERPASSWORD, true); MyVar.mMediboxSetting.DB_NAME = CryptorEngine.Decrypt(MyVar.mMediboxSetting.DB_NAME, true); } } catch (Exception ex) { SanitaLog.e(TAG, ex); } //Start application { //Check database while (true) { String Localserver = MyVar.mMediboxSetting.DB_SERVER; String Localdatabase = MyVar.mMediboxSetting.DB_NAME; String Localuserid = MyVar.mMediboxSetting.DB_USERID; String Localpassword = MyVar.mMediboxSetting.DB_USERPASSWORD; SystemInfo.DatabaseType = Sanita.Utility.Database.Utility.DatabaseUtility.DATABASE_TYPE.POSTGRESQL; SoftUpdatePresenter.SetConnectionConfig(Localserver, Localuserid, Localpassword, Localdatabase, MyVar.DEFAULT_PORT); //Init database SoftUpdatePresenter.InitDatabase(); //Check database OK if (!SoftUpdatePresenter.IsDatabaseOK()) { using (FormConfigDatabase form = new FormConfigDatabase()) { if (form.ShowDialog() == DialogResult.OK) { continue; } else { SanitaMessageBox.Show("Lỗi kết nối cơ sở dữ liệu !", "Thông Báo"); return; } } } break; } //Start main form FormLogin mFormLogin = new FormLogin(); Application.Run(mFormLogin); } }