/// <summary> /// 以管理员权限打开指定程序,不需要后缀.exe /// </summary> /// <param name="processName">程序名字,要带后缀名</param> /// <param name="isKiddion">是否在Kiddion目录下</param> public static void OpenProcess(string processName, bool isKiddion) { try { if (IsAppRun(processName)) { MsgBoxUtil.Warning($"请不要重复打开,{processName} 已经在运行了"); } else { string path = string.Empty; if (isKiddion) { path = FileUtil.Kiddion_Path; } else { path = FileUtil.Cache_Path; } Directory.SetCurrentDirectory(path); path = Path.Combine(path, processName + ".exe"); Process.Start(new ProcessStartInfo(path) { UseShellExecute = true, Verb = "runas" }); } } catch (Exception ex) { MsgBoxUtil.Exception(ex); } }
/// <summary> /// 是否置顶指定窗口 /// </summary> public static void TopMostProcess(string processName, bool isTopMost) { try { if (!IsAppRun(processName)) { MsgBoxUtil.Warning($"未发现 {processName} 进程"); return; } var process = Process.GetProcessesByName(processName)[0]; var windowHandle = process.MainWindowHandle; if (isTopMost) { WinAPI.SetWindowPos(windowHandle, -1, 0, 0, 0, 0, 1 | 2); } else { WinAPI.SetWindowPos(windowHandle, -2, 0, 0, 0, 0, 1 | 2); } } catch (Exception ex) { MsgBoxUtil.Exception(ex); } }
private void updateLocation() { try { string query = @" UPDATE [dbo].[MST_Location] SET [Location_Name] =@location_name ,[Lattitude] = @lattitude ,[Longitude] = @longitude ,[Radius] = @radius ,[Location_Desc] = @location_desc ,[is_active] = @is_acitve WHERE location_id = @location_id"; using (SqlCommand cmd = new SqlCommand(query, ConnUtil.connection)) { cmd.Parameters.AddWithValue("@location_name", txtLocationName.Text); cmd.Parameters.AddWithValue("@lattitude", txtLatitude.DoubleValue); cmd.Parameters.AddWithValue("@longitude", txtLongitude.DoubleValue); cmd.Parameters.AddWithValue("@Radius", txtRadius.IntegerValue); cmd.Parameters.AddWithValue("@location_desc", txtLocationDesc.Text); cmd.Parameters.AddWithValue("@is_acitve", chkBoxActive.Checked); cmd.Parameters.AddWithValue("@location_id", loc_id); cmd.CommandType = CommandType.Text; cmd.ExecuteNonQuery(); MsgBoxUtil.MsgSuccessSave(); } } catch (Exception ex) { MsgBoxUtil.MsgError(ex.Message); } }
private void btnUpdateLocation_Click(object sender, EventArgs e) { if (MsgBoxUtil.MsgSave()) { updateLocation(); } }
protected override void OnDelete(SyncStatus status) { try { if (MsgBoxUtil.Confirm(this.SnapIn, Properties.Resources.DeleteFieldMessage) == true) { // get SSO application fields SSOAppFieldCollection appFields = SSOManager.GetApplicationFields(this.ScopeNode.DisplayName); // delete selected ones foreach (ResultNode resultNode in this.SelectedNodes) { appFields.Remove(resultNode.DisplayName); this.ResultNodes.Remove(resultNode); } // save fields SSOManager.UpdateApplicationFields(this.ScopeNode.DisplayName, appFields, true); // refresh view this.RefreshFields(); } } catch (Exception ex) { MsgBoxUtil.Show(this.SnapIn, ex); } }
private void PropertyPage_Save(object sender, ResultEventArgs <bool> e) { if (this.generalPropPage.IsValid() == false || this.accountsPropPage.IsValid() == false) { MsgBoxUtil.Show(this.generalPropPage.ParentSheet, "Some information is missing or incorrect. Please review and correct the information entered on each page."); e.Result = false; } else { if (this.generalPropPage.IsDirty() == true || this.accountsPropPage.IsDirty() == true) { // load app info from SSO this.appInfo = SSOManager.GetApplicationInfo(this.appInfo.Name); // update it with new information from property pages this.generalPropPage.Update(this.appInfo); this.accountsPropPage.Update(this.appInfo); // save changes into SSO SSOManager.UpdateApplicationInfo(this.appInfo); // notify subscribers the application has been saved this.OnSaved(EventArgs.Empty); } e.Result = true; } }
private void BtnUpdate_Click(object sender, EventArgs e) { if (DgvCategory.SelectedRows.Count == 1) { int index = DgvCategory.SelectedRows[0].Index; category = categories[index]; FrmCategoryUpdate fmu = new FrmCategoryUpdate { StartPosition = FormStartPosition.CenterParent }; fmu.ShowDialog(); if (category != null) { DgvCategory.Rows[index].Cells["Column1"].Value = category.CategoryID; DgvCategory.Rows[index].Cells["Column2"].Value = category.CategoryName; DgvCategory.Rows[index].Cells["Column3"].Value = category.ParentCategoryName; DgvCategory.Rows[index].Cells["Column7"].Value = category.Firm; DgvCategory.Rows[index].Cells["Column5"].Value = category.Unit; DgvCategory.Rows[index].Cells["Column6"].Value = category.Color; DgvCategory.Rows[index].Cells["Column10"].Value = category.ExpirationDate; DgvCategory.Rows[index].Cells["Column8"].Value = category.MinStock; DgvCategory.Rows[index].Cells["Column9"].Value = category.MaxStock; DgvCategory.Rows[index].Cells["Column11"].Value = category.IsValid; categories[index] = category; category = null; } hasUpdated = true; } else { MsgBoxUtil.ErrMsgBox("请选择要修改的商品信息!"); } }
private void Window_BlcokMsg_Loaded(object sender, RoutedEventArgs e) { if (File.Exists(FileUtil.BlockWords_Path)) { try { var file = new StreamReader(FileUtil.BlockWords_Path, Encoding.Default); string content = string.Empty; while (content != null) { content = file.ReadLine(); if (!string.IsNullOrEmpty(content)) { ListBox_BlcokWords.Items.Add(content); } } file.Close(); } catch (Exception ex) { MsgBoxUtil.Exception(ex); } } else { DefaultBlcokWords(); } }
private async void Translation() { try { var stringBuilder = new StringBuilder(); string result = await HttpHelper.HttpClientGET(youdaoAPI + TextBox_InputMessage.Text); if (!string.IsNullOrEmpty(result)) { var rb = JsonUtil.JsonDese <ReceiveObj>(result); foreach (var item in rb.translateResult) { foreach (var t in item) { stringBuilder.Append(t.tgt); } } TextBox_InputMessage.Text = stringBuilder.ToString(); } } catch (Exception ex) { MsgBoxUtil.Exception(ex); } }
private void Button_Translate_Click(object sender, RoutedEventArgs e) { AudioUtil.ClickSound(); try { if (TextBox_InputMessage.Text != "") { var str = (e.OriginalSource as Button).Content.ToString(); switch (str) { case "中英互译": Translation(); break; case "简转繁": TextBox_InputMessage.Text = ChineseConverter.ToTraditional(TextBox_InputMessage.Text); break; case "繁转简": TextBox_InputMessage.Text = ChineseConverter.ToSimplified(TextBox_InputMessage.Text); break; case "转拼音": TextBox_InputMessage.Text = Pinyin.GetString(TextBox_InputMessage.Text, PinyinFormat.WithoutTone); break; } } } catch (Exception ex) { MsgBoxUtil.Exception(ex); } }
private void BtnCommit_Click(object sender, EventArgs e) { try { if (TxtCategoryName.Text == "") { MsgBoxUtil.ErrMsgBox("商品名称不得为空!"); } else { FrmCategory.category = new EtCategory { CategoryID = FrmCategory.category.CategoryID, CategoryName = TxtCategoryName.Text, ParentCategoryID = (ECategory)CmbParentCategoryName.SelectedIndex, ParentCategoryName = ((ECategory)CmbParentCategoryName.SelectedIndex).ToString(), Unit = TxtUnit.Text, Color = TxtColor.Text, Firm = TxtFirm.Text, MinStock = int.Parse(TxtMinStock.Text), MaxStock = int.Parse(TxtMaxStock.Text), ExpirationDate = int.Parse(TxtExpirationDate.Text), IsValid = (EValid)CmbIsValid.SelectedIndex }; Close(); } } catch (Exception) { MsgBoxUtil.ErrMsgBox("商品信息输入错误!"); } }
private void txtNoReg_Validated(object sender, EventArgs e) { try { this.TxtNoSEP.Text = ""; if (txtNoReg.Text != "") { ClearVariable(false); this.Cursor = Cursors.WaitCursor; this.lblKondisiP.Text = "W A I T I N G . . . "; this.Refresh(); CariPasien(this.txtNoReg.Text); // this.TxtNoSEP.Text =ClsUtil.GetSettings("vc_no_regj", "vc_no_sep", "bpjs_sep", this.txtNoReg.Text, ""); this.TxtNoSEP.Text = ClsUtil.GetSetting("bpjs_sep", "vc_no_sep", "vc_no_regj", this.txtNoReg.Text); } else { ClearVariable(true); } SettingMenu(); vTglHariIni = clMain.DBConn.GetCurrentDate(); this.Cursor = Cursors.Default; } catch (Exception ex) { this.Cursor = Cursors.Default; MsgBoxUtil.MsgError("Proses Gagal, Informasi Tidak Dapat Ditampilkan!!" + Constants.vbCrLf + " Silakan Mengulang Pengisian No.Register.. " + Constants.vbCrLf + ex.Message); ClearVariable(false); } }
protected override void OnAction(MMCAction action, AsyncStatus status) { try { switch ((string)action.Tag) { case "Create": AppWizardForm appWizForm = new AppWizardForm(); appWizForm.TopMost = true; DialogResult ret = appWizForm.ShowDialog(); if (ret == DialogResult.OK) { this.RefreshApps(); this.OnListViewChanged(); } break; case "Import": this.Import(); this.RefreshApps(); this.OnListViewChanged(); break; } } catch (Exception ex) { MsgBoxUtil.Show(this.SnapIn, ex); } }
public void RefreshApps() { try { // load apps List <SSOAppInfo> applications = SSOManager.GetApplications(); this.ResultNodes.Clear(); foreach (SSOAppInfo app in applications) { ResultNode resultNode = new ResultNode(); resultNode.DisplayName = app.Name; resultNode.SubItemDisplayNames.AddRange(new string[5] { app.Status, app.Description, app.AdminAccounts, app.UserAccounts, app.Contact }); this.ResultNodes.Add(resultNode); } } catch (Exception ex) { MsgBoxUtil.Show(this.SnapIn, ex); } }
private void getImage() { DataTable dtImage = new DataTable(); dtImage = getImageString(); int i = 0; foreach (DataRow row in dtImage.Rows) { i = i + 1; try { byte[] bytes = Convert.FromBase64String(row["image_string"].ToString()); using (MemoryStream ms = new MemoryStream(bytes)) { Bitmap bm = new Bitmap(Image.FromStream(ms)); float source_aspect = bm.Width / (float)bm.Height; AddImageToImageList(listImage, bm, i.ToString(), listImage.ImageSize.Width, listImage.ImageSize.Height); } listViewImage.AddRow(i.ToString(), row["upload_date"].ToString()); // Year } catch (Exception ex) { MsgBoxUtil.MsgError(ex.Message.ToString()); } listViewImage.View = View.LargeIcon; } }
protected override void OnSelectionAction(MMCAction action, AsyncStatus status) { try { switch ((string)action.Tag) { case "AddField": this.currentPropertyPageTitle = "Add Field"; this.SelectionData.ShowPropertySheet("Add Field"); break; case "Export": string appName = this.SelectedNodes[0].DisplayName; this.Export(appName); break; default: this.ProcessMultipleApps((string)action.Tag); base.OnSelectionAction(action, status); this.OnListViewChanged(); break; } } catch (Exception ex) { MsgBoxUtil.Show(this.SnapIn, ex); } }
private void TampilDataGrid(string xStrSQL) { DataView ObjDataView; var ObjDataAdapter = new SqlDataAdapter(xStrSQL, clMain.DBConn.objConnection); var ObjDataSet = new DataSet(); try { lstItem.Columns.Clear(); ObjDataAdapter.Fill(ObjDataSet, "TbAkun"); ObjDataView = new DataView(ObjDataSet.Tables["TbAkun"]); this.lstItem.DataSource = ObjDataView; ObjDataAdapter.Dispose(); ObjDataSet.Dispose(); } catch (Exception ex) { MsgBoxUtil.MsgError(ex.Message); } finally { ObjDataAdapter = default; ObjDataSet = default; } }
private void BtnInsert_Click(object sender, EventArgs e) { try { string CategoryName = TxtCategoryName.Text; ECategory ParentCategoryEnum = (ECategory)CmbParentCategoryName.SelectedIndex; string ParentCategoryName = ParentCategoryEnum.ToString(); Console.WriteLine(ParentCategoryName); string Firm = TxtFirm.Text; string Unit = TxtUnit.Text; string Color = TxtColor.Text; int ExpirationDate = int.Parse(TxtExpirationDate.Text); int MinStock = int.Parse(TxtMinStock.Text); int MaxStock = int.Parse(TxtMaxStock.Text); FrmCategory.category = new EtCategory { CategoryName = CategoryName, ParentCategoryID = ParentCategoryEnum, ParentCategoryName = ParentCategoryName, Unit = Unit, Color = Color, Firm = Firm, MinStock = MinStock, MaxStock = MaxStock, ExpirationDate = ExpirationDate, IsValid = EValid.效 }; Close(); } catch (Exception) { MsgBoxUtil.ErrMsgBox("商品信息输入错误!"); } }
private void BtnMsDelete_Click(object sender, EventArgs e) { if (DgvMembership.SelectedRows.Count == 1) { int index = DgvMembership.SelectedRows[0].Index; Ms = mses[index]; if (EValid.效 == Ms.IsValid) { StringBuilder sb = new StringBuilder(); sb.Append("确定删除当前会员?\n"); sb.Append("会员编号" + Ms.MsID.ToString() + "\n"); sb.Append("会员姓名" + Ms.MsName + "\n"); sb.Append("联系方式" + Ms.MsPhone + "\n"); sb.Append("会员积分" + Ms.MsPoint); if (DialogResult.OK == MsgBoxUtil.QuestionMsgBox(sb.ToString())) { MembershipDao.DeleteByMsID(Ms.MsID); mses[index].IsValid = EValid.已删除; DgvMembership.Rows[index].Cells["ClnMsIsValid"].Value = EValid.已删除; Ms = null; } } } else { MsgBoxUtil.ErrMsgBox("请选择要删除的会员!"); } }
public static void SetDataTableRightOnMenu(string cUser, string cAppsID, string cOwner) { var objComm = new SqlCommand(); var objDS = new DataSet(); var objDT = new DataTable(); var objDA = new SqlDataAdapter(); try { objComm.Connection = clMain.DBConn.objConnection; objDS = clMain.DBConn.SetDataTableRightOnMenu(cUser, cAppsID, cOwner, ref objComm); objDA.SelectCommand = objComm; objDA.Fill(objDS); objDT = objDS.Tables[0]; clMain.dtAccess = objDT; } catch (Exception ex) { MsgBoxUtil.MsgError(ex.Message); } finally { objComm.Dispose(); objDS.Dispose(); objDA.Dispose(); objDT.Dispose(); } }
private void btnAddPerson_Click(object sender, EventArgs e) { if (txtEmployeeNumber.Text == "") { MsgBoxUtil.MsgInfo("Employee Number Belum Diisi!!"); return; } if (txtEmployeeName.Text == "") { MsgBoxUtil.MsgInfo("Employee Name Belum Diisi!!"); return; } if (txtPassword.Text == "") { MsgBoxUtil.MsgInfo("Password Belum Diisi!!"); return; } if (cmbGender.Text == "") { MsgBoxUtil.MsgInfo("Gender Belum Diisi!!"); return; } if (MsgBoxUtil.MsgSave()) { insertPEA(); } }
private void BtnMsUpdate_Click(object sender, EventArgs e) { if (DgvMembership.SelectedRows.Count == 1) { int index = DgvMembership.SelectedRows[0].Index; Ms = mses[index]; FrmMsUpdate fmu = new FrmMsUpdate { StartPosition = FormStartPosition.CenterParent }; fmu.ShowDialog(); if (Ms != null) { DgvMembership.Rows[index].Cells["ClnMsName"].Value = Ms.MsName; DgvMembership.Rows[index].Cells["ClnMsPhone"].Value = Ms.MsPhone; DgvMembership.Rows[index].Cells["ClnMsPoint"].Value = Ms.MsPoint; DgvMembership.Rows[index].Cells["ClnMsIsValid"].Value = Ms.IsValid; mses[index] = Ms; Ms = null; } hasUpdated = true; } else { MsgBoxUtil.ErrMsgBox("请选择要修改的会员信息!"); } }
private void btnAddLocation_Click(object sender, EventArgs e) { if (MsgBoxUtil.MsgSave()) { insertLocation(); } }
private void BtnStaffDelete_Click(object sender, EventArgs e) { if (DgvStaffData.SelectedRows.Count == 1) { int index = DgvStaffData.SelectedRows[0].Index; Staff = staffs[index]; StringBuilder sb = new StringBuilder(); sb.Append("确定删除当前员工?\n"); sb.Append("员工编号:" + Staff.StaffID.ToString() + "\n"); sb.Append("员工姓名:" + Staff.StaffName + "\n"); sb.Append("联系方式:" + Staff.StaffPhone + "\n"); sb.Append("员工职称:" + Staff.Role); if (DialogResult.OK == MsgBoxUtil.QuestionMsgBox(sb.ToString())) { StaffDao.DeleteByStaffID(Staff.StaffID); staffs.RemoveAt(index); DgvStaffData.Rows.RemoveAt(index); Staff = null; } } else { MsgBoxUtil.ErrMsgBox("请选择要删除的员工!"); } }
/// <summary> /// 故事模式完美存档 /// </summary> private void StoryModeArchiveClick() { var path = Path.Combine(FileUtil.MyDocuments_Path, @"Rockstar Games\GTA V\Profiles"); if (!Directory.Exists(path)) { MsgBoxUtil.Error("GTA5故事模式存档路径不存在"); return; } if (MessageBox.Show("你确定替换GTA5故事模式存档吗?", "警告", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes) { try { var dirs = Directory.GetDirectories(path); foreach (var dir in dirs) { var dirIf = new DirectoryInfo(dir); string fullName = Path.Combine(dirIf.FullName, "SGTA50000"); FileUtil.ExtractResFile(FileUtil.Resource_Path + "Other.SGTA50000", fullName); } MsgBoxUtil.Information($"GTA5故事模式存档替换成功,请前往我的文档查看\n\n{path}"); } catch (Exception ex) { MsgBoxUtil.Exception(ex); } } }
private void btnLoad_Click(object sender, EventArgs e) { if (cmbJenisPel.Text.Equals("")) { MsgBoxUtil.MsgError("Jenis Pelayanan Belum Dipilih"); return; } getData(); }
private void ShowData() { byte I; string vStrSQL; try { switch (this.m_frmSender) { case "frmTrsJurnalUmum": { vStrSQL = this.strSQL + " AND (DT_TGLJURNAL BETWEEN '" + ClsUtil.TglYMD(this.txtTglAwal.Text) + "' AND '" + ClsUtil.TglYMD(this.txtTglAkhir.Text) + "') " + " ORDER BY DT_TGLJURNAL, VC_NO_JURNAL"; break; } case "frmDaftarOperasi": { vStrSQL = this.strSQL + " AND (Convert(varchar(10),dt_tgl_trans,20) BETWEEN '" + ClsUtil.TglYMD(this.txtTglAwal.Text) + "' AND '" + ClsUtil.TglYMD(this.txtTglAkhir.Text) + "') " + " ORDER BY vc_no_trans "; break; } case "frmTrsBiayaLain": { vStrSQL = this.strSQL + " AND (Convert(varchar(10),dt_tgl_trans,20) BETWEEN '" + ClsUtil.TglYMD(this.txtTglAwal.Text) + "' AND '" + ClsUtil.TglYMD(this.txtTglAkhir.Text) + "') " + " ORDER BY vc_no_bukti "; break; } default: { vStrSQL = this.strSQL; break; } } this.TampilDataGrid(vStrSQL); var loopTo = (byte)Information.UBound(m_colName); for (I = 0; I < loopTo; I++) { if (m_colName[I] != "") { this.lstItem.Columns[I].HeaderText = m_colName[I]; } } } catch (Exception ex) { MsgBoxUtil.MsgError(ex.Message); } }
private void insertPEA() { DateTime now = ClsUtil.getCurrentDate(); var password = EncodeDecode.Encrypt(txtPassword.Text); var unitId = cmbUnit.SelectedValue; var positionId = cmbPosition.SelectedValue; var gender = cmbGender.Text; try { string query = @" INSERT INTO [dbo].[Employees] ([Employee_Number] ,[Employee_Name] ,[Gender] ,[Hire_Date] ,[Birth_Date] ,[Unit_Id] ,[Position_id] ,[created_date] ,[created_by] ,[Password]) VALUES (@Employee_Number ,@Employee_Name ,@Gender ,@Hire_Date ,@Birth_Date ,@Unit_Id ,@Position_id ,@created_date ,@created_by ,@Password)"; using (SqlCommand cmd = new SqlCommand(query, ConnUtil.connection)) { cmd.Parameters.AddWithValue("@Employee_Number", txtEmployeeNumber.IntegerValue); cmd.Parameters.AddWithValue("@Employee_Name", txtEmployeeName.Text); cmd.Parameters.AddWithValue("@Gender", gender); cmd.Parameters.AddWithValue("@Hire_Date", dtHireDate.Value.ToShortDateString()); cmd.Parameters.AddWithValue("@Birth_Date", dtBirthDate.Value.ToShortDateString()); cmd.Parameters.AddWithValue("@Unit_Id", unitId); cmd.Parameters.AddWithValue("@Position_id", positionId); cmd.Parameters.AddWithValue("@created_date", ClsUtil.currentDateTime); cmd.Parameters.AddWithValue("@created_by", ClsUtil.userLogin); cmd.Parameters.AddWithValue("@Password", password); cmd.CommandType = CommandType.Text; cmd.ExecuteNonQuery(); MsgBoxUtil.MsgSuccessSave(); } } catch (Exception ex) { MsgBoxUtil.MsgError(ex.Message); } }
private void BtnMsCancel_Click(object sender, EventArgs e) { if ("" == TxtMsName.Text && "" == TxtMsPhone.Text && "" == TxtMsPoint.Text) { Close(); } else if (DialogResult.OK == MsgBoxUtil.QuestionMsgBox("当前窗口有修改未保存,是否要退出?")) { Close(); } }
/// <summary> /// BigBaseV2配置目录 /// </summary> private void BigBaseV2DirectoryClick() { try { ProcessUtil.OpenLink(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"/BigBaseV2/"); } catch (Exception ex) { MsgBoxUtil.Exception(ex); } }