public EditorContext() { Postbox = Postbox.InstanceFor(EditorCode); Configuration.ConfigManager.AddEditorConfig(EditorCode, new Configuration.Config { Language = SupportedLanguages.JS, FormattingType = FormattingType.BRACKETS }); TextsToEnter = new List <string>(); CaretView = new CaretView(); TextView = new TextView(CaretView); SelectionView = new SelectionView(TextView); LinesView = new LinesView(); FoldingView = new FoldingView(); EnterTextCommand = new EnterTextCommand(TextView, CaretView, SelectionView); RemoveTextCommand = new RemoveTextCommand(TextView, CaretView, SelectionView); CaretMoveCommand = new CaretMoveCommand(CaretView, TextView); SelectionCommand = new TextSelectionCommand(TextView, SelectionView, CaretView); CaretView.EditorCode = EditorCode; CaretView.Postbox = Postbox; TextView.EditorCode = EditorCode; TextView.Postbox = Postbox; SelectionView.EditorCode = EditorCode; SelectionView.Postbox = Postbox; LinesView.EditorCode = EditorCode; LinesView.Postbox = Postbox; FoldingView.EditorCode = EditorCode; FoldingView.Postbox = Postbox; InitEvents(); ForceDraw(); }
private void LinesView_KeyDown(object sender, KeyEventArgs e) { try { if (e.KeyCode == Keys.Down) { if (LinesView.IsFilterRow(RowHandle)) { LinesView.ShowFilterEditor(Column); } } if (e.Modifiers == Keys.Control && e.KeyCode == Keys.N) { btnNew_ItemClick(null, null); } if (e.KeyCode == Keys.Delete) { btnDelete_ItemClick(null, null); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void InitEvents() { var postbox = Postbox.InstanceFor(EditorCode); postbox.For <LinesRemovedMessage>().Invoke(message => { var linesRemovedMessage = message as LinesRemovedMessage; LinesView.HandleLinesRemove(linesRemovedMessage); FoldingView.HandleLinesRemove(linesRemovedMessage); }) .For <TextRemovedMessage>().Invoke(message => { var textRemovedMessage = message as TextRemovedMessage; LinesView.HandleTextRemove(textRemovedMessage); FoldingView.HandleTextRemove(textRemovedMessage); }) .For <TextAddedMessage>().Invoke(message => { var textAddedMessage = message as TextAddedMessage; LinesView.HandleTextInput(textAddedMessage); FoldingView.HandleTextInput(textAddedMessage); }) .For <FoldClickedMessage>().Invoke(message => { var foldClickedMessage = message as FoldClickedMessage; TextView.HandleTextFolding(foldClickedMessage); LinesView.HandleFolding(foldClickedMessage); CaretView.HandleTextFolding(foldClickedMessage); }); }
private void btnSave_Click(object sender, EventArgs e) { try { if (deLineDate.EditValue == null) { MessageBox.Show("You must Choose Line Date", "Stop", MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } else if (Account.EditValue == null) { MessageBox.Show("You must Choose Account", "Stop", MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } else if (spDebitAmount.Value == 0 && spCreditAmount.Value == 0) { MessageBox.Show("You must Enter Credit Or Debit Amount", "Stop", MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } else if (OffsetAccount.EditValue == null) { MessageBox.Show("You must Choose Offset Account", "Stop", MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } LinesView.AddNewRow(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void LinesView_CustomRowCellEdit(object sender, DevExpress.XtraGrid.Views.Grid.CustomRowCellEditEventArgs e) { try { if (LinesView.IsFilterRow(e.RowHandle)) { e.RepositoryItem = new RepositoryItemTextEdit(); } else { if (e.RowHandle >= 0 && e.Column.AbsoluteIndex == 3) { int PCode; bool IsParsed = int.TryParse(LinesView.GetRowCellValue(e.RowHandle, LinesView.Columns[1]).ToString(), out PCode); if (IsParsed == true) { FillWareHouse(PCode, e.RowHandle); RepositoryItemSearchLookUpEdit re = (RepositoryItemSearchLookUpEdit)repWareHouse.Clone(); e.RepositoryItem = re; } else { // MessageBox.Show("You Must Choose Product Firstly", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void GetTotalCost() { decimal total = 0; for (int i = 1; i < LinesView.RowCount; i++) { total += decimal.Parse(LinesView.GetRowCellValue(i, LinesView.Columns[6]).ToString()); } LinesView.SetRowCellValue(0, LinesView.Columns[4], total / decimal.Parse(LinesView.GetRowCellValue(0, LinesView.Columns[5]).ToString())); }
private void btnNew_ItemClick(object sender, ItemClickEventArgs e) { try { if (IsPosted == false) { LinesView.AddNewRow(); LinesGrid.EmbeddedNavigator.Buttons.DoClick(LinesGrid.EmbeddedNavigator.Buttons.EndEdit); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void btnDelete_ItemClick(object sender, ItemClickEventArgs e) { try { if (LinesView.FocusedRowHandle >= 0) { TransactionLines l = lines.Get(long.Parse(LinesView.GetRowCellValue(LinesView.FocusedRowHandle, LinesView.Columns[0]).ToString())); lines.Delete(l); LinesView.DeleteRow(LinesView.FocusedRowHandle); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void SetupViews() { int editorCode = editorCode = this.GetEditor().GetHashCode(); linesView = new LinesView(); foldingView = new FoldingView(); views.Add(linesView); views.Add(foldingView); Children.Add(linesView); Children.Add(foldingView); linesView.EditorCode = editorCode; linesView.Postbox = postbox; foldingView.EditorCode = editorCode; foldingView.Postbox = postbox; }
private void LinesView_InitNewRow(object sender, DevExpress.XtraGrid.Views.Grid.InitNewRowEventArgs e) { try { if (LinesView.RowCount <= 1) { int OUtCode = int.Parse(output.GetCode().ToString()); LinesView.SetRowCellValue(e.RowHandle, LinesView.Columns[0], "OUT" + OUtCode); LinesView.SetRowCellValue(e.RowHandle, LinesView.Columns[4], "0"); LinesView.SetRowCellValue(e.RowHandle, LinesView.Columns[5], "1"); output.Add(new BOMOutputProduct() { BOMCode = BOMCode, OutputCode = OUtCode, LookUpCode = "OUT" + OUtCode, Cost = 0, Quantity = 1 }); } else { int INGCode = int.Parse(ingred.GetCode().ToString()); LinesView.SetRowCellValue(e.RowHandle, LinesView.Columns[0], "ING" + INGCode); LinesView.SetRowCellValue(e.RowHandle, LinesView.Columns[4], "0"); LinesView.SetRowCellValue(e.RowHandle, LinesView.Columns[5], "1"); ingred.Add(new BOMIngredientsProducts() { BOMCode = BOMCode, IngCode = INGCode, LookUpCode = "ING" + INGCode, OutputCode = long.Parse(LinesView.GetRowCellValue(0, LinesView.Columns[0]).ToString().Substring(3)), Cost = 0, Quantity = 1 }); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void btnDelete_ItemClick(object sender, ItemClickEventArgs e) { try { if (LinesView.RowCount > 0 && LinesView.FocusedRowHandle > 0) { BOMIngredientsProducts BOMIngr = ingred.Get( long.Parse(LinesView.GetRowCellValue(LinesView.FocusedRowHandle, LinesView.Columns[0]).ToString().Substring(3))); ingred.Delete(BOMIngr); LinesView.DeleteRow(LinesView.FocusedRowHandle); GetTotalCost(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void GetTotalLineCost(int rowHandle, int ColumnIndex, decimal Value) { LinesView.SetRowCellValue(rowHandle, LinesView.Columns[6] , Value * decimal.Parse((LinesView.GetRowCellValue(rowHandle, LinesView.Columns[ColumnIndex])).ToString())); }
private void LinesView_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e) { string Code = LinesView.GetRowCellValue(e.RowHandle, LinesView.Columns[0]).ToString(); if (e.RowHandle >= 0) { if (e.RowHandle == 0) { BOMOutputProduct outProduct = output.Get(int.Parse(Code.Substring(3))); switch (e.Column.AbsoluteIndex) { case 1: outProduct.ProductCode = int.Parse(e.Value.ToString()); LinesView.SetRowCellValue(e.RowHandle, LinesView.Columns[2], new ProductManager().Get(int.Parse(e.Value.ToString())).Product_Name); break; case 3: outProduct.WHCode = int.Parse(e.Value.ToString()); e.Column.ColumnEdit = new RepositoryItemTextEdit(); break; case 4: outProduct.Cost = decimal.Parse(e.Value.ToString()); //GetTotalCost(); GetTotalLineCost(e.RowHandle, 5, decimal.Parse(e.Value.ToString())); break; case 5: outProduct.Quantity = decimal.Parse(e.Value.ToString()); GetTotalCost(); GetTotalLineCost(e.RowHandle, 4, decimal.Parse(e.Value.ToString())); break; default: break; } output.Update(outProduct); } else { BOMIngredientsProducts ingProduct = ingred.Get(int.Parse(Code.Substring(3))); switch (e.Column.AbsoluteIndex) { case 1: int PCode = int.Parse(e.Value.ToString()); ingProduct.ProductCode = PCode; DALLayer.Product productMgr = new ProductManager().Get(PCode); decimal? Cost = productMgr.ProductOnHand.Count() > 0?productMgr.ProductOnHand.FirstOrDefault().AvgCost:null; LinesView.SetRowCellValue(e.RowHandle, LinesView.Columns[4], Cost == null?0:Cost); LinesView.SetRowCellValue(e.RowHandle, LinesView.Columns[2], new ProductManager().Get(PCode).Product_Name); break; case 3: ingProduct.WHCode = int.Parse(e.Value.ToString()); e.Column.ColumnEdit = new RepositoryItemTextEdit(); break; case 4: ingProduct.Cost = decimal.Parse(e.Value.ToString()); GetTotalLineCost(e.RowHandle, 5, decimal.Parse(e.Value.ToString())); break; case 5: ingProduct.Quantity = decimal.Parse(e.Value.ToString()); GetTotalLineCost(e.RowHandle, 4, decimal.Parse(e.Value.ToString())); break; case 6: GetTotalCost(); break; default: break; } ingred.Update(ingProduct); } } }
private void LineCountChangedCallback(int obj) { LinesView.SetLinesCount(obj); }