private StockTemplate SaveTemplateToDB(StockTemplate stockTemplate, TempChangeType type) { switch (type) { case TempChangeType.New: { var template = _templateBLL.CreateTemplate(stockTemplate); stockTemplate.TemplateId = template.TemplateId; } break; case TempChangeType.Update: { int tempid = _templateBLL.UpdateTemplate(stockTemplate); if (tempid > 0) { stockTemplate.TemplateId = tempid; } else { MessageDialog.Error(this, msgModifyFail); } } break; default: break; } return(stockTemplate); }
private async void metroButton1_Click(object sender, EventArgs e) { if (ViewValidateInputs()) { var productQty = await _productService.GetProductQty(cmbProduct.SelectedValue.ToString()); if (productQty < Convert.ToInt32(txtQty.Text)) { MessageDialog.Error($"out of stock. we don't have {txtQty.Text} qty in our stock"); return; } var amount = Convert.ToInt32(txtQty.Text) * Convert.ToInt32(txtUnitPrice.Text); metroGrid1.Rows.Add(cmbProduct.Text, txtQty.Text, txtUnitPrice.Text, amount, cmbCustomer.Text); _saleProduct.Add(new Models.ProductSale { CustomerId = cmbCustomer.SelectedValue.ToString(), ProductId = cmbProduct.SelectedValue.ToString(), Qty = txtQty.Text, UnitPrice = txtUnitPrice.Text, Amount = amount.ToString() }); _totalAmount += amount; _noOfItems += Convert.ToInt32(txtQty.Text); txtNoOfItems.Text = $@"No Of Items : {_noOfItems}"; txtTotalAmount.Text = $@"Total Amount : {_totalAmount}"; } }
private async void metroButton2_Click(object sender, EventArgs e) { IsBusy = true; var response = await _productPurchaseService.SaveAsync(_purchaseProduct, _noOfItems, _totalAmount); if (response) { MessageDialog.Information("Saved SuccessFully."); } else { MessageDialog.Error("Something went wrong."); } IsBusy = false; }
public void Execute() { WorkbookContext workbookContext = App.Context.GetActiveWorkbookContext(); var testContext = new TestContextImpl(workbookContext); testContext.Compile(workbookContext.TestCases); if (0 == testContext.TestSequence.CompileErrorCount) { MessageDialog.Info(Properties.Resources.SyntaxCheckSuccess); } else { MessageDialog.Error(Properties.Resources.SyntaxCheckFailed, testContext.TestSequence.CompileErrorCount); } }
private async void metroButton1_Click(object sender, EventArgs e) { IsBusy = true; metroButton1.Enabled = false; var id = metroComboBox1.SelectedValue as string; var results = await _permissionsManger.OnSaveAsync(id); if (results) { MessageDialog.Information("Saved SuccessFully"); } else { MessageDialog.Error("Something went wrong."); } metroButton1.Enabled = true; IsBusy = false; }
private void ButtonContainer_ButtonClick(object sender, EventArgs e) { if (!(sender is Button)) { return; } Button button = sender as Button; switch (button.Name) { case "Refresh": { try { waitDialog.Show(this); QueryQuote(); } catch (Exception ex) { MessageDialog.Error(this, ex.Message); } finally { waitDialog.Close(); } this.monitorGridView.Invalidate(); this.securityGridView.Invalidate(); } break; case "GiveOrder": { GiveOrder(); } break; default: break; } }
public async Task <DataTable> Authenticate(Login model) { var moduleQuery = $"SELECT * FROM ps_us_userpermissions inner join ps_us_users on ps_us_userpermissions.userId = ps_us_users.userId right join ps_ap_appmenu on ps_ap_appmenu.menuId=ps_us_userpermissions.menuId where ps_us_users.userId='{model.UserId}'and ps_ap_appmenu.moduleId='0' and ps_ap_appmenu.active='1';"; var userQuery = $"select (name),(roleId),(active) from ps_us_users where userId='{model.UserId}' and password = '******'"; var login = await _dbContext.FindAsync(userQuery); if (login.Rows.Count == 0) { MessageDialog.Error("Invalid username/password."); return(null); } var isActive = Convert.ToBoolean(login.Rows[0].ItemArray[2]); if (!isActive) { MessageDialog.Error("Your account is deactivated by admin. kindly contact your administration."); return(null); } Session.AddItem("CURRENT_USER_ID", model.UserId); return(await _dbContext.GetAllAsync(moduleQuery)); }
private bool ImportFromExcel(ImportType importType) { OpenFileDialog fileDialog = new OpenFileDialog(); fileDialog.Filter = "(*.xls)|*.xls|(*.xlsx)|*.xlsx"; if (fileDialog.ShowDialog() != System.Windows.Forms.DialogResult.OK) { return(false); } else { string extension = Path.GetExtension(fileDialog.FileName); List <string> list = new List <string>() { ".xls", ".xlsx" }; if (!list.Contains(extension)) { MessageDialog.Warn(this, msgImportInvalidFileType); return(false); } var sheetConfig = ConfigManager.Instance.GetImportConfig().GetSheet("stocktemplate"); var cellRanges = ConfigManager.Instance.GetImportConfig().GetColumnHeader(sheetConfig.Columns); Dictionary <string, DataColumnHeader> colHeadMap = new Dictionary <string, DataColumnHeader>(); foreach (var column in cellRanges) { colHeadMap.Add(column.Name, column); } int sheetIndex = 0; var table = ExcelUtil.GetSheetData(fileDialog.FileName, sheetIndex, colHeadMap); if (table == null || table.ColumnIndex == null || table.Rows == null) { MessageDialog.Error(this, msgImportLoadFail); return(false); } List <TemplateStock> stockList = null; try { stockList = ExcelToGrid(table); } catch (Exception e) { string msg = string.Format("Fail to convert excel data to table, message: {0}", e.Message); logger.Error(msg); } if (stockList == null || stockList.Count == 0) { MessageDialog.Error(this, msgImportLoadFail); return(false); } switch (importType) { case ImportType.Replace: { _spotDataSource.Clear(); foreach (var stock in stockList) { _spotDataSource.Add(stock); } } break; case ImportType.Append: { //List<TemplateStock> appendList = new List<TemplateStock>(); List <TemplateStock> duplicatedList = new List <TemplateStock>(); foreach (var sp in _spotDataSource) { int index = stockList.FindIndex(p => p.SecuCode.Equals(sp.SecuCode)); if (index >= 0) { duplicatedList.Add(stockList[index]); stockList.RemoveAt(index); } } foreach (var nitem in stockList) { _spotDataSource.Add(nitem); } } break; default: break; } } return(true); }
public void RunLoginProcedure(RequireSessionLoginWorker worker) { using (var wd = new YetAnotherWaitingDialog()) { var vccount = 0; IVerifyCodeRecognizeResult vcResult = null; wd.WorkCallback = worker.DoLogin; worker.StateChanged += (ss, se) => { wd.SetState(worker.State.ToExecutionState(), worker.Message); }; worker.VerifyCodeError += (x, y) => { if (vcResult != null && VerifyCodeRecognizeServiceLoader.VerifyCodeRecognizeEngine != null) { VerifyCodeRecognizeServiceLoader.VerifyCodeRecognizeEngine.MarkResult(vcResult, false); vcResult = null; } }; worker.RequireEnterVerifyCode += (ss, ee) => { wd.Invoke(() => { if (vccount > 5 && ProgramConfiguration.Instance.AutoEnterLoginVcCode) { MessageDialog.Information("亲,验证码自动识别失败超过限制,自动识别已经关闭,请手动输入验证码。"); } //var vcform = new UI.Dialogs.RequireVcCode //{ // Session = ee.Session, // EnableAutoVc = vccount < 6 && ProgramConfiguration.Instance.AutoEnterLoginVcCode, // AutoVcCount = vccount //}; //if (vcform.ShowDialog(OwnerForm) == DialogResult.OK) //{ // vcResult = vcform.VcResult; // vccount = vcform.AutoVcCount; // ee.VerifyCode = vcform.Code; // if (vcResult != null) // { // //report // ApiEvents.OnAutoVc(null, new GeneralEventArgs<AutoVcLog>(new AutoVcLog() // { // Account12306 = worker.UserName, // TypeID = 0, // TodayUsed = AutoVcBaseLimition.GetVcUsed() // })); // } //} var vc = new TouchClickVcSimpleForm(ee.Session) { RandCodeType = RandCodeType.SjRand, EnableAutoVc = vccount < 6 && ProgramConfiguration.Instance.AutoEnterLoginVcCode }; if (vc.ShowDialog(OwnerForm) == DialogResult.OK) { ee.VerifyCode = vc.Code; vcResult = vc.AutoVcResult; if (vcResult != null) { vccount++; } } }); vccount++; }; wd.ShowDialog(OwnerForm); if (EnableFallback && worker.Session == null && (string.IsNullOrEmpty(worker.Message) || worker.Message.IndexOf("密码输入错误") != -1)) { //返回 using (var logindlg = new Login() { PreSelectUser = worker.UserName }) { logindlg.ShowDialog(OwnerForm); } } else if (worker.State == OpearationState.Blocked && !worker.Message.IsNullOrEmpty()) { MessageDialog.Error(OwnerForm, "尝试登录的时候遇到了问题:\n\n" + worker.Message); } else if (wd.Exception != null) { MessageDialog.Error(OwnerForm, "尝试登录的时候遇到了问题:\n\n" + wd.Exception.ToString()); } if (worker.Session != null && worker.LoginConflict) { MessageDialog.Information(OwnerForm, "此次登录检测到会话冲突,如果您此时还在其它的软件或浏览器上登录此账号,它们将会被12306无情地注销掉。\n\n世界就是这样的残酷,多坑点身份证注册几个账号吧……"); } } }