/// <summary> /// 提交权限设置数据 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSubmit_Click(object sender, EventArgs e) { int rId = cboRoles.SelectedValue.GetInt(); CheckIsAdmin(rId); if (rId == 0) { MsgBoxHelper.MsgErrorShow("请选择要设置权限的角色!"); return; } else { //1.获取菜单编号,工具栏菜单编号 List <int> tMenuIds = GetToolMenuIds(rId); List <int> menuIds = new List <int>(); menuIds = GetMenuIds(rId, menuIds, tvMenus.Nodes[0]); bool bl = false;//执行结果 if (menuIds.Count == 0 && tMenuIds.Count == 0) { MsgBoxHelper.MsgErrorShow("请设置该角色的菜单和工具栏权限!"); return; } else if (menuIds.Count == 0 && tMenuIds.Count > 0) { if (MsgBoxHelper.MsgBoxConfirm("权限设置", "您没有设置系统菜单权限,将会无法使用系统菜单功能!是否继续?") == DialogResult.Yes) { //设置工具栏权限 bl = RequestStar.SetRoleRight(rId, null, tMenuIds, uName); } } else if (menuIds.Count > 0 && tMenuIds.Count == 0) { if (MsgBoxHelper.MsgBoxConfirm("权限设置", "您没有设置工具菜单权限,将会无法使用工具栏菜单功能!是否继续?") == DialogResult.Yes) { //设置菜单权限 bl = RequestStar.SetRoleRight(rId, menuIds, null, uName); } } else { //设置菜单和工具栏权限 bl = RequestStar.SetRoleRight(rId, menuIds, tMenuIds, uName); } if (bl) { MsgBoxHelper.MsgBoxShow("权限设置", "权限设置保存成功!"); } else { MsgBoxHelper.MsgErrorShow("权限设置保存失败!"); return; } } }
/// <summary> /// try catch 异常处理 /// </summary> /// <param name="act"></param> /// <param name="message"></param> public static void TryCatch(this Action act, string message) { try { act.Invoke(); } catch (Exception ex) { MsgBoxHelper.MsgErrorShow(ex.Message); } }
private static void Application_ThreadException(object sender, ThreadExceptionEventArgs e) { try { MsgBoxHelper.Error(e.Exception.Message); } catch (Exception ex) { MsgBoxHelper.Error(ex.Message); } }
private void MainIndex_FormClosing(object sender, FormClosingEventArgs e) { if (MsgBoxHelper.MsgBoxConfirm("提示", "是否退出?") == DialogResult.Yes) { Application.ExitThread(); } else { e.Cancel = true; } }
private void btnGotoPage_Click(object sender, EventArgs e) { try { int pageNum = Convert.ToInt32(txtGotoPageNum.Text); GotoPage(pageNum); } catch { MsgBoxHelper.ShowError("頁號必需輸入整數!"); } }
public static void TryOpenFile(string fileName, Control parentControl = null) { try { Process.Start(fileName); } catch (Exception ex) { LoggerInstance.Log(ex); MsgBoxHelper.ShowWarning(parentControl, "Cannot open the specified file."); } }
internal static void Main(string[] args) { #if !DEBUG // Only allows starting from launcher, because otherwise: // * if the current one is not the latest version, data loss might occur because of // the updater. // * the launcher start this program with admin permission. Without this // some issues may occur. try { var latest = UsingLatestVersion(); if (!latest || !Windows.IsAdministrator()) { MsgBoxHelper.ShowError(null, "Please start QSimPlanner via Launcher.exe."); return; } } catch (Exception e) { MsgBoxHelper.ShowError(null, "An error occurred.\n" + e.Message); return; } #endif CultureInfo.DefaultThreadCurrentCulture = CultureInfo.InvariantCulture; using (var mutex = new Mutex(false, $"Global\\{GetGuid()}")) { if (!mutex.WaitOne(0, false)) { MsgBoxHelper.ShowError(null, "QSimPlanner is already running."); return; } config = XDocument.Load("./config.xml").Root; #if !DEBUG // We want the debugger to break when having an unhandled exception. SetExceptionHandler(); #endif Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); #if !DEBUG UpdateOnFirstRun(); MoveNavData(); #endif ShowLicenseIfNeeded(); WebRequests.SetSecuityProtocol(); var mainFrm = new QspForm(); mainFrm.Init(); Application.Run(mainFrm); } }
// Event Handler private void btnCreate_Click(object sender, EventArgs e) { if (this.NewConnection.IsValid()) { this.DialogResult = DialogResult.OK; this.Close(); } else { MsgBoxHelper.Warning("Please fill all info!"); } }
/// <summary> /// 修改 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void tsbtnEdit_Click(object sender, EventArgs e) { if (dgvGUnitList.SelectedRows.Count == 0) { MsgBoxHelper.MsgErrorShow("请选择要修改的单位信息"); return; } //SelectedRows.Count>0 GoodsUnitInfoModel guInfo = dgvGUnitList.SelectedRows[0].DataBoundItem as GoodsUnitInfoModel; InitEditInfo(guInfo); }
/// <summary> /// 縮放顯示比例。 /// </summary> /// <param name="ratio"></param> private void Zoom(int ratio) { if (!m_IsInitialized) { return; } if (ratio > 200 || ratio < 30) { MsgBoxHelper.ShowInfo("指定的縮放比例太小或太大: " + ratio.ToString() + "%"); return; } double r = ratio / 100.0; float size = 0.0f; StatusText = "正在調整顯示比例..."; CursorHelper.ShowWaitCursor(); try { // 標題字型 size = (float)(DualEditForm.DefaultHeaderFontSize * r); m_HeaderView.Font = new Font(brGrid.Font.FontFamily, size); //brGrid[0, 1].View.Font = new Font(brGrid[0, 1].View.Font.FontFamily, size); m_HeaderView2.Font = m_HeaderView.Font; // 點字字型 size = (float)(DualEditForm.DefaultBrailleFontSize * r); m_BrView.Font = new Font(m_BrView.Font.FontFamily, size); //brGrid[1, 1].View.Font = new Font(brGrid[1, 1].View.Font.FontFamily, size); // 明眼字字型 size = (float)(DualEditForm.DefaultTextFontSize * r); m_MingView.Font = new Font(m_MingFont.FontFamily, size, m_MingFont.Style, m_MingFont.Unit); m_MingViewCJK.Font = new Font("PMingLiU", size, m_MingFontCJK.Style, m_MingFontCJK.Unit, 1); //brGrid[2, 1].View.Font = new Font(brGrid[2, 1].View.Font.FontFamily, size); // 注音符號字型 size = (float)(DualEditForm.DefaultPhoneticFontSize * r); m_PhonView.Font = new Font(m_PhonView.Font.FontFamily, size, m_PhonView.Font.Style, m_PhonView.Font.Unit, m_PhonView.Font.GdiCharSet); m_PhonView2.Font = m_PhonView.Font; m_PhonView3.Font = m_PhonView.Font; //brGrid[3, 1].View.Font = new Font(brGrid[3, 1].View.Font.FontFamily, size); brGrid.Columns.AutoSizeView(); } finally { CursorHelper.RestoreCursor(); StatusText = ""; } }
private void OpenFile() { if (Modified) { DialogResult result = MsgBoxHelper.ShowYesNoCancel("目前的文件尚未儲存,是否儲存?"); if (result == DialogResult.Cancel) { return; } if (result == DialogResult.Yes) { SaveFile(); } } var dlg = new OpenFileDialog { Filter = "文字檔(*.txt)|*.txt|雙視檔案(*.btx)|*.btx|所有檔案|*.*" }; if (dlg.ShowDialog() == DialogResult.OK) { Modified = false; if (dlg.FileName.ToLower().EndsWith(".btx")) { string s = dlg.FileName.Replace(".btx", ".txt"); if (File.Exists(s)) { this.FileName = s; if (FileHelper.IsUTF8Encoded(FileName)) { rtbOrg.Text = File.ReadAllText(FileName, Encoding.UTF8); } rtbOrg.LoadFile(FileName, RichTextBoxStreamType.PlainText); } OpenBrailleFileInEditor(dlg.FileName); } else { this.FileName = dlg.FileName; if (FileHelper.IsUTF8Encoded(FileName)) { rtbOrg.Text = File.ReadAllText(FileName, Encoding.UTF8); } else { rtbOrg.LoadFile(FileName, RichTextBoxStreamType.PlainText); } } } }
private void btnLogout_Click(object sender, EventArgs e) { if (MsgBoxHelper.Confirm("注销所有用户会自动关闭最后未完成的任务,你确定要注销“{0}”吗?", "注销确认")) { control.Logout(); dgvLoginUser.DataSource = control.LoginUsers; if (control.UserCount < 1 && handle != null) { handle(); } } }
/// <summary> /// 修改 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void tsbtnEdit_Click(object sender, EventArgs e) { if (dgvUnitTypeList.CurrentRow != null) { UnitTypeInfoModel utInfo = dgvUnitTypeList.CurrentRow.DataBoundItem as UnitTypeInfoModel; ShowEditTypeInfo(utInfo); } else { MsgBoxHelper.MsgErrorShow("请选择要修改的类别信息!"); return; } }
/// <summary> /// 打开工具菜单详情 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void tsbtnInfo_Click(object sender, EventArgs e) { if (dgvTMenus.SelectedRows.Count > 0) { ToolMenuInfoModel tmInfo = dgvTMenus.SelectedRows[0].DataBoundItem as ToolMenuInfoModel; ShowTMenuInfoPage(tmInfo.TMenuId, 4); } else { MsgBoxHelper.MsgErrorShow("请选择要查看的工具菜单项!"); return; } }
private void EndPrintBraille(bool toBrailler, bool toFile) { StringBuilder sb = new StringBuilder("點字已輸出至指定的"); if (toBrailler && toFile) { sb.Append("點字印表機和檔案。"); } else { sb.Append(toBrailler ? "點字印表機。" : "檔案。"); } MsgBoxHelper.ShowInfo(sb.ToString()); }
private void DoPrint() { if (m_BrDoc.LineCount < 1) { MsgBoxHelper.ShowInfo("沒有資料可供列印!"); return; } m_BrDoc.UpdateTitlesLineIndex(); DualPrintDialog prnDlg = new DualPrintDialog(m_BrDoc); prnDlg.ShowDialog(); }
/// <summary> /// 顯示無法轉換的字元。 /// </summary> private void ShowInvlaidCharForm(int errorCount) { MsgBoxHelper.ShowError("共有 " + errorCount.ToString() + " 個字元無法轉換!\r\n" + "請逐一修正後再執行轉換程序。"); m_InvalidCharForm.Show(); m_InvalidCharForm.Left = this.Left + this.Width - m_InvalidCharForm.Width - 4; m_InvalidCharForm.Top = rtbOrg.PointToScreen(new Point(0, 0)).Y; m_InvalidCharForm.Height = 400; if (m_InvalidCharForm.Bottom > (this.Bottom - 30)) { m_InvalidCharForm.Height = this.Bottom - 30 - m_InvalidCharForm.Top; } }
/// <summary> /// 修改菜单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void tsbtnEdit_Click(object sender, EventArgs e) { if (dgvMenus.SelectedRows.Count > 0) { DataGridViewRow row = dgvMenus.SelectedRows[0]; MenuInfoModel menuInfo = row.DataBoundItem as MenuInfoModel; ShowMenuInfoPage(2, menuInfo.MId); } else { MsgBoxHelper.MsgErrorShow("请选择你要修改的菜单信息!"); return; } }
private void tsbtnClose_Click(object sender, EventArgs e) { if (actType == 1) { if (MsgBoxHelper.MsgBoxConfirm("期初入库单", "该单据并未保存,你确定要关闭期初入库单页面吗?") == DialogResult.Yes) { this.CloseForm(); } } else { this.CloseForm(); } }
private void btnConnTest_Click(object sender, EventArgs e) { try { using (var connection = new SqlConnection(NewConnection.Str)) { connection.Open(); MsgBoxHelper.Done("SQL Connection successful."); } } catch (Exception ex) { MsgBoxHelper.Warning("Failure: " + ex.Message); } }
private void btnRemoveConnection_Click(object sender, EventArgs e) { if (cbConnection.SelectedIndex > -1) { if (MsgBoxHelper.Confirm("Remove this connection?") == DialogResult.OK) { cbConnection.Items.RemoveAt(cbConnection.SelectedIndex); cbConnection.Text = string.Empty; txtConnStr.Text = string.Empty; } } else { MsgBoxHelper.Warning("Please choose a connection!"); } }
private void tsbtnInfo_Click(object sender, EventArgs e) { if (dgvUnitList.CurrentRow != null) { ViewUnitInfoModel unitInfo = dgvUnitList.CurrentRow.DataBoundItem as ViewUnitInfoModel; if (unitInfo != null) { ShowUnitInfoPage(4, unitInfo.UnitId); } } else { MsgBoxHelper.MsgErrorShow("请选择要查看的单位信息!"); return; } }
private void btnPickBraille_Click(object sender, EventArgs e) { PickBrailleForm form = new PickBrailleForm(); if (form.ShowDialog() == DialogResult.OK) { int newLen = txtBraille.Text.Length - txtBraille.SelectionLength + form.BrailleText.Length; if (newLen > 3) { MsgBoxHelper.ShowInfo("點字最多只能輸入三方!"); return; } ControlHelper.InputText(txtBraille, form.BrailleText); } }
/// <summary> /// 详情 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void tsbtnInfo_Click(object sender, EventArgs e) { if (dgvStoreList.CurrentRow != null) { ViewStoreInfoModel storeInfo = dgvStoreList.CurrentRow.DataBoundItem as ViewStoreInfoModel; if (storeInfo != null) { ShowStoreInfoPage(4, storeInfo.StoreId); } } else { MsgBoxHelper.MsgErrorShow("请选择要查看的仓库信息!"); return; } }
/// <summary> /// 详情响应 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void tsbtnInfo_Click(object sender, EventArgs e) { if (dgvGoodsList.CurrentRow != null) { ViewGoodsInfoModel goodsInfo = dgvGoodsList.CurrentRow.DataBoundItem as ViewGoodsInfoModel; if (goodsInfo != null) { ShowGoodsInfoPage(4, goodsInfo.GoodsId); } } else { MsgBoxHelper.MsgErrorShow("请选择要查看的商品信息!"); return; } }
private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) { try { var ex = e.ExceptionObject as Exception; if (ex == null) { return; } MsgBoxHelper.Error(ex.Message); } catch (Exception ex) { MsgBoxHelper.Error(ex.Message); } }
private void tsbtnCheck_Click(object sender, EventArgs e) { Action act = () => { if (actType == 1) { MsgBoxHelper.MsgErrorShow("销售单还未保存,不能审核!"); return; } if (MsgBoxHelper.MsgBoxConfirm("销售单审核", "你确定要审核该销售单吗?") == DialogResult.Yes) { List <ViewSaleGoodsInfoModel> listGoods = dgvGoods.DataSource as List <ViewSaleGoodsInfoModel>; //检查库存 string reStr = RequestStar.CheckGoodsCurCount(listGoods, store.StoreId); if (!string.IsNullOrEmpty(reStr)) { string[] arrStock = reStr.Split(';'); string[] noStockArr = arrStock.Where(s => s.Contains("0")).ToArray(); string[] notStockArr = arrStock.Where(s => s.Contains("1")).ToArray(); //库存不足 if (noStockArr.Length == 0 && notStockArr.Length == 0) //所有商品的库存足够 { bool bl = RequestStar.CheckSaleInfo(saleId, uName, store.StoreId); if (bl) { lblCheckState.Text = "已审核"; lblCheckState.ForeColor = Color.Red; SetBtnsEnabled(1);//更新页面按钮的可用 } } else if (noStockArr.Length > 0) { string goodsNames = string.Join(",", noStockArr.Select(s => s.Split('-')[0])); MsgBoxHelper.MsgErrorShow($"当前销售单中:{goodsNames} 的没有库存,不能进行审核!"); return; } else if (notStockArr.Length > 0) { string goodsNames = string.Join(",", notStockArr.Select(s => s.Split('-')[0])); MsgBoxHelper.MsgErrorShow($"当前销售单中:{goodsNames} 的库存不足,不能进行审核!"); return; } } } }; act.TryCatch("审核销售单出现异常!"); }
/// <summary> /// 删除类别信息处理(删除、恢复、移除) /// </summary> /// <param name="isDeleted"></param> /// <param name="st"></param> private void DeleteStoreType(int isDeleted, StoreTypeInfoModel st) { string delTypeName = FormUtility.GetDeleteTypeName(isDeleted); string msgTitle = $"仓库类别{delTypeName}"; if (MsgBoxHelper.MsgBoxConfirm(msgTitle, $"您确定要{delTypeName}该仓库类别?") == DialogResult.Yes) { bool bl = false; switch (isDeleted) { case 1: //删除 //如果该类别添加了仓库,不允许删除 bool hasAddStores = RequestStar.IsAddStores(st.STypeId); if (!hasAddStores) { bl = RequestStar.StoreTypeLogicDelete(st.STypeId); } else { MsgBoxHelper.MsgErrorShow($"该类别:{st.STypeName} 已经添加了仓库,不能删除!"); return; } break; case 0: //恢复 bl = RequestStar.StoreTypeRecover(st.STypeId); break; case 2: //移除 bl = RequestStar.StoreTypeDelete(st.STypeId); break; } string sucType = bl ? "成功" : "失败"; string delMsg = $"仓库类别:{st.STypeName} {delTypeName} {sucType}"; if (bl) { MsgBoxHelper.MsgBoxShow(msgTitle, delMsg); LoadStoreTypeList(); } else { MsgBoxHelper.MsgErrorShow(delMsg); return; } } }
// MARK - 접속하고자 하는 채팅을 더블클릭 했을 때 private void createdServerList_MouseDoubleClick(object sender, MouseEventArgs e) { int index = createdServerList.IndexFromPoint(e.Location); userID = userName.Text; if (userName.Text == "Input User Name" || userName.Text == null) { MsgBoxHelper.Warn("닉네임을 먼저 입력하세요."); userName.Focus(); } else { if (createdServerNameList[index] != involvedServerName) { if (index != ListBox.NoMatches) { txtBox.Clear(); involvedServerName = createdServerNameList[index]; serverName.Text = involvedServerName; if (involvedServerCode != null) { byte[] b = Encoding.UTF8.GetBytes("exitInvolvedServer" + ':' + involvedServerCode + ':' + userID + ':' + index); clientSock.Send(b); } else { byte[] b = Encoding.UTF8.GetBytes("requestServerCode" + ':' + userID + ':' + index); clientSock.Send(b); } AppendText(txtBox, string.Format("채팅방 {0}에 접속하였습니다.", createdServerNameList[index])); sendMsgButton.Enabled = true; } } else { MsgBoxHelper.Warn("이미 접속한 채팅 서버 입니다."); } } }
/// <summary> /// 删除单位信息(删除、恢复、移除) /// </summary> /// <param name="isDeleted"></param> /// <param name="unitInfo"></param> private void DeleteUnitInfo(int isDeleted, ViewUnitInfoModel unitInfo) { string delTypeName = FormUtility.GetDeleteTypeName(isDeleted); string msgTitle = $"单位信息{delTypeName}"; if (MsgBoxHelper.MsgBoxConfirm(msgTitle, $"您确定要{delTypeName}该单位信息?") == DialogResult.Yes) { bool bl = false; switch (isDeleted) { case 1: //删除 //如果单位在使用中,不允许删除 bool isUnitUse = RequestStar.CheckUnitUse(unitInfo.UnitId); if (!isUnitUse) { bl = RequestStar.UnitLogicDelete(unitInfo.UnitId); } else { MsgBoxHelper.MsgErrorShow($"该单位:{unitInfo.UnitName} 在使用中,不能删除!"); return; } break; case 0: //恢复 bl = RequestStar.UnitRecover(unitInfo.UnitId); break; case 2: //移除 bl = RequestStar.UnitDelete(unitInfo.UnitId); break; } string sucType = bl ? "成功" : "失败"; string delMsg = $"单位信息:{unitInfo.UnitName} {delTypeName} {sucType}"; if (bl) { MsgBoxHelper.MsgBoxShow(msgTitle, delMsg); LoadUnitList(); } else { MsgBoxHelper.MsgErrorShow(delMsg); return; } } }