private void OnPositionDetailUpdate(PositionDetail positionDetail) { this.Dispatcher.Invoke(new Action(delegate { ViewModel.AddDetailItem(positionDetail); })); }
public bool InsertOrUpdate(PositionDetail positionDetail, bool isUpdating = false) { try { OpenConnection(); string query = ""; if (isUpdating) { query = "update PositionDetail set IsPermitted = @IsPermitted " + "where IdEmployeePosition = @IdEmployeePosition and IdPermission = @IdPermission"; } else { query = "insert into PositionDetail (IdEmployeePosition,IdPermission,IsPermitted) " + "values(@IdEmployeePosition,@IdPermission,@IsPermitted)"; } MySqlCommand cmd = new MySqlCommand(query, conn); cmd.Parameters.AddWithValue("@IdEmployeePosition", positionDetail.IdEmployeePosition); cmd.Parameters.AddWithValue("@IdPermission", positionDetail.IdPermission); cmd.Parameters.AddWithValue("@IsPermitted", positionDetail.IsPermitted); return(cmd.ExecuteNonQuery() == 1); } catch (Exception e) { CustomMessageBox.Show(e.Message.ToString(), "Thông báo", MessageBoxButton.OK, MessageBoxImage.Error); return(false); } finally { CloseConnection(); } }
public List <PositionDetail> GetListByPosition(int idPosition) { try { OpenConnection(); string queryStr = String.Format("select * from PositionDetail where idEmployeePosition = {0} " + "order by idPermission", idPosition); MySqlCommand cmd = new MySqlCommand(queryStr, conn); MySqlDataReader dataReader = cmd.ExecuteReader(); DataTable dt = new DataTable(); dt.Load(dataReader); List <PositionDetail> positionDetails = new List <PositionDetail>(); for (int i = 0; i < dt.Rows.Count; i++) { PositionDetail permission = new PositionDetail(int.Parse(dt.Rows[i].ItemArray[0].ToString()), int.Parse(dt.Rows[i].ItemArray[1].ToString()), bool.Parse(dt.Rows[i].ItemArray[2].ToString())); positionDetails.Add(permission); } return(positionDetails); } catch { return(new List <PositionDetail>()); } finally { CloseConnection(); } }
void UpdatePermission(Button btn) { int success = 0; int n = mainWindow.stkPermission.Children.Count; for (int i = 0; i < n; i++) { PermissionControl control = (PermissionControl)(mainWindow.stkPermission.Children[i]); PositionDetail positionDetail = new PositionDetail(selectedPosition, int.Parse(control.txbId.Text), (bool)control.cbIsPermitted.IsChecked); bool tmp = PositionDetailDAL.Instance.InsertOrUpdate(positionDetail, true); success += tmp ? 1 : 0; } mainWindow.stkPermission.Children.Clear(); btn.IsEnabled = false; mainWindow.cbCheckAll.IsChecked = false; mainWindow.cbCheckAll.IsEnabled = false; if (success == n) { CustomMessageBox.Show("Cập nhật phân quyền thành công!", "Thông báo", MessageBoxButton.OK, MessageBoxImage.Asterisk); } else { CustomMessageBox.Show("Cập nhật phân quyền không thành công!", "Thông báo", MessageBoxButton.OK, MessageBoxImage.Error); } }
private async Task LoadData() { this.IsBusy = true; var mth = new PositionDetail() { PositionID = this.ID }; this.Data = await API.ApiClient.Execute(mth); this.NotifyOfPropertyChange(() => this.Data); var mth2 = new EvaluationList() { PositionID = this.ID }; var evs = await API.ApiClient.Execute(mth2); this.Evaluations.AddRange(evs.Select(e => new EvaluationViewModel(e))); this.NotifyOfPropertyChange(() => this.Evaluations); this.HasEvaluations = this.Evaluations.Count > 0; this.NotHaveEvaluations = !this.HasEvaluations; this.NotifyOfPropertyChange(() => this.HasEvaluations); this.NotifyOfPropertyChange(() => this.NotHaveEvaluations); this.IsBusy = false; }
public IHttpActionResult Put(PositionDetail position) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var service = CreatePositionService(); if (!service.UpdatePosition(position)) { return(InternalServerError()); } return(Ok()); }
public bool UpdatePosition(PositionDetail model) { using (var ctx = new ApplicationDbContext()) { var entity = ctx .PositionDbSet .Single(e => e.PositionId == model.PositionId); entity.PositionTitle = model.PositionTitle; entity.DeptId = model.DeptId; entity.IsSupervisor = model.IsSupervisor; entity.IsDirector = model.IsDirector; entity.IsExecutive = model.IsExecutive; return(ctx.SaveChanges() == 1); } }
public ReinstateMachine(PositionDetail oPositionDetail) { InitializeComponent(); _PositionDetail = oPositionDetail; this.txtPositionValue.Text = Convert.ToInt32(_PositionDetail.PostionNumber).ToString(); this.txtMachineValue.Text = _PositionDetail.AssetNumber; txtFloatValue.TextChanged += new TextChangedEventHandler(txtFloatValue_TextChanged); txtFloatValue.Text = string.Format("0{0}00", ExtensionMethods.GetCurrencyDecimalDelimiter()); txtFloatValue.MaxLength = 8; txtFloatValue.Focus(); if (Settings.CD_Not_Use_Hoppers) { GroupBox_2.Visibility = Visibility.Collapsed; txtFloatValue.Visibility = Visibility.Collapsed; spPanel.Height = 300; } }
public static PositionDetail CreatePositionDetail(string positionId, global::System.DateTimeOffset validFrom, global::System.DateTimeOffset validTo, global::System.DateTimeOffset availableForAssignment, decimal fullTimeEquivalent, global::Microsoft.Dynamics.DataEntities.PositionV2 position) { PositionDetail positionDetail = new PositionDetail(); positionDetail.PositionId = positionId; positionDetail.ValidFrom = validFrom; positionDetail.ValidTo = validTo; positionDetail.AvailableForAssignment = availableForAssignment; positionDetail.FullTimeEquivalent = fullTimeEquivalent; if ((position == null)) { throw new global::System.ArgumentNullException("position"); } positionDetail.Position = position; return(positionDetail); }
private async Task LoadData() { this.IsBusy = true; var mth = new PositionDetail() { PositionID = this.ID }; this.Data = await API.ApiClient.Execute(mth); this.NotifyOfPropertyChange(() => this.Data); if (this.Data != null) { this._title = $"{Data.JobTitle} - {Data.CompanyName}"; this.NotifyOfPropertyChange(() => this.Title); } var mth2 = new EvaluationList() { PositionID = this.ID }; var evs = await API.ApiClient.Execute(mth2); this.Evaluations.AddRange(evs.Select(e => new EvaluationViewModel(e))); this.NotifyOfPropertyChange(() => this.Evaluations); this.HasEvaluations = this.Evaluations.Count > 0; this.NotHaveEvaluations = !this.HasEvaluations; this.NotifyOfPropertyChange(() => this.HasEvaluations); this.NotifyOfPropertyChange(() => this.NotHaveEvaluations); this.IsBusy = false; }
public PositionDetail InsertPositions(PositionDetail position) { return(_repo.InsertPositions(position)); }
/// <summary> /// 查询持仓细节,为了区分多账户 dicPositionDetail的key分为account+"_"+symbol(方便账户快速平仓)和symbol(主要是为了统计展示) /// </summary> /// /// <returns></returns> public static PositionDetail GetPositionDetail(string symbol, string accountID = "") { string vtPositionID; if (string.IsNullOrEmpty(accountID)) { vtPositionID = symbol; } else { vtPositionID = accountID + "_" + symbol; } if (dicPositionDetail.Keys.Contains(vtPositionID)) { var detail = dicPositionDetail[vtPositionID]; try { var contract = DicContract[symbol]; detail.exchange = contract.exchange; // 上期所合约 if (contract.exchange == TradeCanstant.exchangeSHFE) { detail.mode = QuanNetCommon.PositionDetail.enumMode.shfe; } // # 检查是否有平今惩罚 //for productID in self.tdPenaltyList: // if str(productID) in contract.symbol: // detail.mode = detail.MODE_TDPENALTY } catch (Exception e) { } return(dicPositionDetail[vtPositionID]); } else { var detail = new PositionDetail(symbol, accountID); dicPositionDetail.TryAdd(vtPositionID, detail); AllPositionDetailData.Add(detail); try { var contract = DicContract[symbol]; detail.exchange = contract.exchange; // 上期所合约 if (contract.exchange == TradeCanstant.exchangeSHFE) { detail.mode = QuanNetCommon.PositionDetail.enumMode.shfe; } // # 检查是否有平今惩罚 //for productID in self.tdPenaltyList: // if str(productID) in contract.symbol: // detail.mode = detail.MODE_TDPENALTY } catch (Exception e) { } return(detail); } }