private void dgvAdjustment_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e) { if (e.RowHandle < 0) { return; } ST_StockTransactionDetailDto detailDto = dgcAdjustment.GetFocusedRowForBandedGridView <ST_StockTransactionDetailDto>(); dgcAdjustment.ClearErrorsForBandedGridView(); this._isValid = true; //Set auto value for column No dgcAdjustment.SetRowCellValueForBandedGridView(CommonKey.LineNumber, CommonMethod.ParseString(e.RowHandle + 1)); dgcAdjustment.SetRowCellValueForBandedGridView(CommonKey.BalanceFlag, IsMinus ? CommonData.BalanceFlag.Minus : CommonData.BalanceFlag.Plus); IsValidFocusedRow(detailDto); #region Add new row if focus to last row if (_isValid && dgcAdjustment.IsFocusedLastRowForBandedGridView()) { dgcAdjustment.AddNewRowForBandedGridView(); } #endregion Add new row if focus to last row }
private void IsValidFocusedRow(ST_StockTransactionDetailDto detailDto) { #region Set validate /// <summary> /// Item Code must be fill in ///</summary> if (string.IsNullOrEmpty(detailDto.ItemCode)) { IvsMessage msg = new IvsMessage(CommonConstantMessage.COM_MSG_REQUIRED, bandItemCode.Caption); dgcAdjustment.SetColumnErrorBandedGridView(colItemCode.FieldName, msg.MessageText); _isValid = false; } /// <summary> /// Item Code must be fill in ///</summary> if (string.IsNullOrEmpty(detailDto.QualityStatus)) { IvsMessage msg = new IvsMessage(CommonConstantMessage.COM_MSG_REQUIRED, BandQuality.Caption); dgcAdjustment.SetColumnErrorBandedGridView(colQuality.FieldName, msg.MessageText); _isValid = false; } /// <summary> /// Quantity must be greater than 0 ///</summary> if (detailDto.InputQuantity == null || detailDto.InputQuantity <= 0) { IvsMessage msg = new IvsMessage(CommonConstantMessage.COM_MSG_REQUIRED, bandQty.Caption); dgcAdjustment.SetColumnErrorBandedGridView(colQuatity.FieldName, msg.MessageText); _isValid = false; } /// <summary> /// Item Code must be fill in ///</summary> if (string.IsNullOrEmpty(detailDto.Remark)) { IvsMessage msg = new IvsMessage(CommonConstantMessage.COM_MSG_REQUIRED, bandReason.Caption); dgcAdjustment.SetColumnErrorBandedGridView(colReason.FieldName, msg.MessageText); _isValid = false; } /// <summary> /// ProductLine must be fill in when Type is WIP ///</summary> if (CommonMethod.ParseString(detailDto.ProcessType).Equals(CommonData.ProcessType.WIP) && CommonMethod.IsNullOrEmpty(detailDto.ProductionLine)) { IvsMessage msg = new IvsMessage(CommonConstantMessage.COM_MSG_REQUIRED, BandProductionLine.Caption); dgcAdjustment.SetColumnErrorBandedGridView(colProductionLine.FieldName, msg.MessageText); _isValid = false; } #endregion Set validate }
private void resQuantity_EditValueChanging(object sender, DevExpress.XtraEditors.Controls.ChangingEventArgs e) { ST_StockTransactionDetailDto detailDto = dgcInventory.GetFocusedRow <ST_StockTransactionDetailDto>(); decimal amount = CommonMethod.ParseDecimal(detailDto.UnitPrice) * CommonMethod.ParseDecimal(e.NewValue); dgcInventory.SetRowCellValue(CommonKey.Amount, CommonMethod.ParseString(amount)); dgvInventory.RefreshData(); }
void resQuantity_EditValueChanging(object sender, DevExpress.XtraEditors.Controls.ChangingEventArgs e) { ST_StockTransactionDetailDto detailDto = dgcAdjustment.GetFocusedRowForBandedGridView <ST_StockTransactionDetailDto>(); decimal unitPrice = CommonMethod.ParseDecimal(detailDto.InputUnitPrice); decimal amount = unitPrice * CommonMethod.ParseDecimal(e.NewValue); dgcAdjustment.SetRowCellValueForBandedGridView(CommonKey.InputUnitPrice, CommonMethod.ParseString(unitPrice)); dgcAdjustment.SetRowCellValueForBandedGridView(CommonKey.InputAmount, CommonMethod.ParseString(amount)); }
private void resUnitPrice_EditValueChanging(object sender, DevExpress.XtraEditors.Controls.ChangingEventArgs e) { ST_StockTransactionDetailDto detailDto = dgcInventory.GetFocusedRow <ST_StockTransactionDetailDto>(); decimal amount = CommonMethod.ParseDecimal(detailDto.Quantity) * CommonMethod.ParseDecimal(e.NewValue); dgcInventory.SetRowCellValue(CommonKey.Amount, CommonMethod.ParseString(amount)); //DataRow row = dgvInventory.GetDataRow(dgvInventory.FocusedRowHandle); //decimal quantity = CommonMethod.ParseDecimal(row["Quantity"]); //decimal unitPrice = CommonMethod.ParseDecimal(e.NewValue); //row["Amount"] = unitPrice * quantity; //dgvInventory.RefreshData(); }
private void dgvInventory_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e) { ST_StockTransactionDetailDto detailDto = dgcInventory.GetFocusedRow <ST_StockTransactionDetailDto>(); //Set auto value for column No dgcInventory.SetRowCellValue(CommonKey.LineNumber, CommonMethod.ParseString(e.RowHandle + 1)); #region Set validate dgcInventory.ClearErrors(); /// <summary> /// Item Code must be fill in ///</summary> if (string.IsNullOrEmpty(detailDto.ItemCode)) { IvsMessage msg = new IvsMessage(CommonConstantMessage.COM_MSG_REQUIRED, colItemCode.Caption); dgcInventory.SetColumnError(colItemCode.FieldName, msg.MessageText); return; } /// <summary> /// Quantity must be greater than 0 ///</summary> if (detailDto.Quantity == null || detailDto.Quantity <= 0) { IvsMessage msg = new IvsMessage(CommonConstantMessage.COM_MSG_REQUIRED, colQuantity.Caption); dgcInventory.SetColumnError(colQuantity.FieldName, msg.MessageText); return; } #endregion Set validate #region Add new row if focus to last row if (dgcInventory.IsFocusedLastRow()) { dgcInventory.AddNewRow(); } #endregion Add new row if focus to last row }
protected override void FillData() { if (CommonMethod.IsNullOrEmpty(this.ItemType) && CommonMethod.IsNullOrEmpty(this.DocumentNo)) { base.FillData(); } else { CommonBl commonBl = new CommonBl(); if (!CommonMethod.IsNullOrEmpty(this.ItemType)) { MS_ItemDto itemDto = new MS_ItemDto() { ItemType = this.ItemType, }; commonBl.SelectItemData(itemDto, out dtNewSource); } if (!CommonMethod.IsNullOrEmpty(this.DocumentNo)) { ST_StockTransactionDetailDto stockDetailDto = new ST_StockTransactionDetailDto() { DocumentNumber = this.DocumentNo, }; commonBl.SelectItemDataByDocument(stockDetailDto, out dtNewSource); } if (dtNewSource.Columns.Count > 0) { if (this.HasNull) { dtNewSource.Rows.InsertAt(dtNewSource.NewRow(), 0); } } this.DataSource = dtNewSource; // this.EditValue = CommonData.StringEmpty; this.NullText = CommonData.StringEmpty; } }
//void dgvInventory_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e) //{ // //If exist error on grid // //if (!this.isValid) // //{ // // //Disable Focused to other row // // this.dgvInventory.FocusedRowHandle = this.selectedRowIndex; // // return; // //} //} void dgvInventory_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e) { if (e.RowHandle < 0) { return; } //Set selected row index on grid this.selectedRowIndex = e.RowHandle; dgcInventory.SetRowCellValue(CommonKey.LineNumber, CommonMethod.ParseString(e.RowHandle + 1)); ST_StockTransactionDetailDto detailDto = dgcInventory.GetFocusedRow <ST_StockTransactionDetailDto>(); #region Set validate dgcInventory.ClearErrors(); this.isValid = true; if (!this.ShowSelect || detailDto.Select) { /// <summary> /// TransferType must be fill in ///</summary> if (this.ShowTransferType && CommonMethod.IsNullOrEmpty(detailDto.TransferType)) { IvsMessage msg = new IvsMessage(CommonConstantMessage.COM_MSG_REQUIRED, colTransferType.Caption); dgcInventory.SetColumnError(colTransferType.FieldName, msg.MessageText); isValid = false; } /// <summary> /// Item Code must be fill in ///</summary> if (string.IsNullOrEmpty(detailDto.ItemCode)) { IvsMessage msg = new IvsMessage(CommonConstantMessage.COM_MSG_REQUIRED, colItemCode.Caption); dgcInventory.SetColumnError(colItemCode.FieldName, msg.MessageText); isValid = false; } /// <summary> /// Quantity must be fill in. ///</summary> if (detailDto.InputQuantity == null) { IvsMessage msg = new IvsMessage(CommonConstantMessage.COM_MSG_REQUIRED, colQuantity.Caption); dgcInventory.SetColumnError(colQuantity.FieldName, msg.MessageText); isValid = false; } else { /// <summary> /// Quantity must be greater than 0 ///</summary> if (detailDto.InputQuantity <= 0) { IvsMessage msg = new IvsMessage(CommonConstantMessage.COM_MSG_GREATER_THAN, colQuantity.Caption, 0); dgcInventory.SetColumnError(colQuantity.FieldName, msg.MessageText); isValid = false; } } /// <summary> /// QualityStatus must be fill in ///</summary> if (this.ShowQuanlityStatus && CommonMethod.IsNullOrEmpty(detailDto.QualityStatus)) { IvsMessage msg = new IvsMessage(CommonConstantMessage.COM_MSG_REQUIRED, colQualityStatus.Caption); dgcInventory.SetColumnError(colQualityStatus.FieldName, msg.MessageText); isValid = false; } /// <summary> /// ProductLine must be fill in when Type is WIP ///</summary> if (this.ShowProcessType && CommonMethod.ParseString(detailDto.ProcessType).Equals(CommonData.ProcessType.WIP) && ShowProductionLine && CommonMethod.IsNullOrEmpty(detailDto.ProductionLine)) { IvsMessage msg = new IvsMessage(CommonConstantMessage.COM_MSG_REQUIRED, colPruductionLine.Caption); dgcInventory.SetColumnError(colPruductionLine.FieldName, msg.MessageText); isValid = false; } /// <summary> /// Error reason must be fill in ///</summary> if (this.ShowErrorReason && CommonMethod.IsNullOrEmpty(detailDto.ErrorReason)) { IvsMessage msg = new IvsMessage(CommonConstantMessage.COM_MSG_REQUIRED, colErrorReason.Caption); dgcInventory.SetColumnError(colErrorReason.FieldName, msg.MessageText); isValid = false; } } #endregion Set validate #region Add new row if focus to last row if (this.AllowAddNewRow && isValid && dgcInventory.IsFocusedLastRow()) { dgcInventory.AddNewRow(); } #endregion Add new row if focus to last row }