public void PositionsStats(out int positionsCount, out int notSold, out int isSold, out int isReturn, out double soldBetrag) { positionsCount = GParams.Instance.PositionsTable.Rows.Count; var _notSold = GParams.Instance.PositionsTable.Select("SoldAt is null and ReturnedToSupplierAt is null"); notSold = _notSold.Length; var _isSold = GParams.Instance.PositionsTable.Select("SoldAt is not null"); isSold = _isSold.Length; soldBetrag = 0; foreach (var _isSoldRow in _isSold) { if (GParams.ToDouble(_isSoldRow["SoldFor"]).HasValue) { soldBetrag += GParams.ToDouble(_isSoldRow["SoldFor"]) ?? 0; } } var _isReturn = GParams.Instance.PositionsTable.Select("ReturnedToSupplierAt is not null"); isReturn = _isReturn.Length; }
private BizPosition ConvertFromDataRow(DataRow row) { BizPosition _result = null; if (row != null) { _result = new BizPosition(); try { _result.SupplierId = GParams.ToString(row["SupplierId"]); _result.PositionNo = GParams.ToInt32(row["PositionNo"]).Value; _result.PositionNoSpecified = true; _result.Material = GParams.ToString(row["Material"]); _result.Category = GParams.ToString(row["Category"]); _result.Manufacturer = GParams.ToString(row["Manufacturer"]); _result.PriceMin = GParams.ToDouble(row["PriceMin"]); _result.PriceMinSpecified = true; _result.PriceMax = GParams.ToDouble(row["PriceMax"]).Value; _result.PriceMaxSpecified = true; _result.Memo = GParams.ToString(row["Memo"]); } catch (Exception _ex) { _result = null; } } return(_result); }
private void ScreenToBiz(ref BizPosition positionBiz) { positionBiz.PositionNo = GParams.ToInt32(this.m_posNrTb.Text).Value; positionBiz.Material = this.m_posTitelTb.Text; positionBiz.Category = this.m_posCatCb.Text; positionBiz.Manufacturer = this.m_herstellerCb.Text; positionBiz.PriceMax = GParams.ToDouble(this.m_posMaxPriceTb.Text).Value; positionBiz.PriceMin = GParams.ToDouble(this.m_posMinPriceTb.Text); positionBiz.Memo = this.m_posDescTb.Text; }
private void m_supplierNoTb_KeyUp(object sender, KeyEventArgs e) { if (sender == this.m_supplierNoTb && e.KeyCode == Keys.Return) { if (!string.IsNullOrEmpty(this.m_supplierNoTb.Text) && !string.IsNullOrEmpty(this.m_supplierNoTb.Text.Trim()) && GParams.ToInt32(this.m_supplierNoTb.Text).HasValue) { try { this.SetActualSupplier(GParams.Instance.BasarCom.SupplierGet_No(GParams.ToInt32(this.m_supplierNoTb.Text).Value, true)); } catch (Exception _ex) { MessageBox.Show(_ex.Message); } } else { this.Reset(); } } }
private void OnCtrlKeyUp(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Escape) { if (this.ActualToSellPosition != null) { this.m_cancelPositionBtn_Click(sender, e); } else { this.m_clearCellPositonsBtn_Click(sender, e); } } else if (e.KeyCode == Keys.F4 && this.ActualToSellPosition != null) { if (this.m_sellMinPriceBtn.Enabled) { this.OnConfirmSellPosBtn(this.m_sellMinPriceBtn, e); } } else if (e.KeyCode == Keys.F5 && this.ActualToSellPosition != null) { if (this.m_sellMaxPriceBtn.Enabled) { this.OnConfirmSellPosBtn(this.m_sellMaxPriceBtn, e); } } else if (e.KeyCode == Keys.F9 && this.m_confirmSellBtn.Enabled) { this.m_confirmSellBtn_Click(this.m_sellMaxPriceBtn, e); } else if (sender == this.m_positonNoTb && !this.m_positonNoTb.ReadOnly) { this.DeActivateConfirmPosMode(); if (e.KeyCode == Keys.Return) { this.ResetBadMsg(); try { if (!string.IsNullOrEmpty(this.m_positonNoTb.Text) && GParams.ToInt32(this.m_positonNoTb.Text).HasValue) { var _positionNo = GParams.ToInt32(this.m_positonNoTb.Text).Value; if (!this.IsPositionAlreadyInList(_positionNo)) { var _posToSell = GParams.Instance.BasarCom.PositionGet(_positionNo, true); var _isSold = _posToSell != null && _posToSell.SoldAt.HasValue && _posToSell.SoldAtSpecified; if (_posToSell != null && !_isSold) { this.ActivateConfirmPosMode(_posToSell); this.m_positonNoTb.ReadOnly = true; this.SetGoodMsg("Position akzeptiert, Bitte Preis wählen..."); } else if (_posToSell != null && _isSold) { this.SetBadMsg("Position bereits verkauft..."); this.DeActivateConfirmPosMode(); this.m_positonNoTb.Focus(); this.m_positonNoTb.SelectAll(); } else { this.SetBadMsg("Position nicht bekannt"); this.DeActivateConfirmPosMode(); this.m_positonNoTb.Focus(); this.m_positonNoTb.SelectAll(); } } else { this.SetBadMsg("Position bereits in Liste"); this.DeActivateConfirmPosMode(); this.m_positonNoTb.Focus(); this.m_positonNoTb.SelectAll(); } } } catch (Exception _ex) { this.SetBadMsg(_ex.Message); } } } }
private bool HasMinFor_Comunication() { var _result = true; _result = _result && !string.IsNullOrEmpty(this.m_serverIpTb.Text) && !string.IsNullOrEmpty(this.m_serverIpTb.Text.Trim()); _result = _result && !string.IsNullOrEmpty(this.m_serverPortTb.Text) && !string.IsNullOrEmpty(this.m_serverPortTb.Text.Trim()) && GParams.ToInt32(this.m_serverPortTb.Text).HasValue; return(_result); }
private void m_printNotSoldPositionsBtn_Click(object sender, EventArgs e) { try { this.ShowActualSupplierInfos(); if (this.m_notSoldPosLv.Items.Count <= 0) { return; } var _tableInfo = new TablePrintDef(); _tableInfo.AddColumn(new TablePrintDef.ColumnItem("Pos Nr.", 8.50F)); _tableInfo.AddColumn(new TablePrintDef.ColumnItem("Kategorie", 14.50F)); _tableInfo.AddColumn(new TablePrintDef.ColumnItem("Hersteller", 14.50F)); _tableInfo.AddColumn(new TablePrintDef.ColumnItem("Bezeichnung", 40.50F)); _tableInfo.AddColumn(new TablePrintDef.ColumnItem("Regel Preis", 11.00F)); _tableInfo.AddColumn(new TablePrintDef.ColumnItem("Min. Preis", 11.00F)); var _itemsToPrint = new List <ListViewItem>(); var _returndGoodCounter = 0; foreach (ListViewItem _lvItem in this.m_notSoldPosLv.Items) { if (_lvItem is NonSoldPositionLvi && ((NonSoldPositionLvi)_lvItem).DataObj.ReturnedToSupplierAt.HasValue) { _returndGoodCounter++; } else if (_lvItem is SoldPositionLvi && ((SoldPositionLvi)_lvItem).DataObj.ReturnedToSupplierAt.HasValue) { _returndGoodCounter++; } _itemsToPrint.Add(_lvItem); } if (_returndGoodCounter == _itemsToPrint.Count) { MessageBox.Show("Ware wurde bereits zurück gegeben..."); } else if (_returndGoodCounter > 0 && _returndGoodCounter != _itemsToPrint.Count) { MessageBox.Show("Ein Teil der Ware wurde bereits zurück gegeben..."); } if (_itemsToPrint.Count > 0) { _itemsToPrint.Sort(delegate(ListViewItem lv01, ListViewItem lv02) { var _pos01 = GParams.ToInt32(lv01.SubItems[0].Text); var _pos02 = GParams.ToInt32(lv02.SubItems[0].Text); if (_pos01.HasValue && _pos02.HasValue) { if (_pos01.Value > _pos02.Value) { return(1); } else if (_pos01.Value < _pos02.Value) { return(-1); } else { return(0); } } return(string.Compare(lv01.SubItems[0].Text, lv02.SubItems[0].Text)); }); foreach (var _lvItem in _itemsToPrint) { var _notSoldLvItem = _lvItem as NonSoldPositionLvi; if (_notSoldLvItem != null) { var _posNoInfo = new TablePrintDef.FieldDef(_notSoldLvItem.DataObj.PositionNo.ToString()); var _kategorie = new TablePrintDef.FieldDef(_notSoldLvItem.DataObj.Category); var _hersteller = new TablePrintDef.FieldDef(_notSoldLvItem.DataObj.Manufacturer); var _bezeichnung = new TablePrintDef.FieldDef(_notSoldLvItem.DataObj.Material); var _minPreis = new TablePrintDef.FieldDef(_notSoldLvItem.DataObj.PriceMin.ToString()); var _regelPreis = new TablePrintDef.FieldDef(_notSoldLvItem.DataObj.PriceMax.ToString()); _posNoInfo.StringFormat.Alignment = StringAlignment.Center; _regelPreis.StringFormat.Alignment = StringAlignment.Far; _minPreis.StringFormat.Alignment = StringAlignment.Far; _tableInfo.AddLine(_posNoInfo, _kategorie, _hersteller, _bezeichnung, _regelPreis, _minPreis); } else { var _posNoInfo = new TablePrintDef.FieldDef(_lvItem.SubItems[0].Text); var _maxQtyInfo = new TablePrintDef.FieldDef(_lvItem.SubItems[4].Text + " €"); var _minQtyInfo = new TablePrintDef.FieldDef(_lvItem.SubItems[5].Text + " €"); _posNoInfo.StringFormat.Alignment = StringAlignment.Center; _maxQtyInfo.StringFormat.Alignment = StringAlignment.Far; _minQtyInfo.StringFormat.Alignment = StringAlignment.Far; _tableInfo.AddLine(_posNoInfo, new TablePrintDef.FieldDef(_lvItem.SubItems[2].Text), new TablePrintDef.FieldDef(_lvItem.SubItems[3].Text), new TablePrintDef.FieldDef(_lvItem.SubItems[1].Text), _maxQtyInfo, _minQtyInfo); } } //PrintDocErfassung _printDocument = new PrintDocErfassung(_tableInfo); var _printDocument = new PrintDocNotSoldPos(_tableInfo); _printDocument.DefaultPageSettings.Landscape = true; _printDocument.PrinterSettings.DefaultPageSettings.Landscape = true; _printDocument.SellerAdress = new PrintDocNotSoldPos.SellerAdressElem(); _printDocument.SellerAdress.Id = this.m_supplierSelection.ActualSupplier.SupplierNo.ToString(); _printDocument.SellerAdress.Titel = this.m_supplierSelection.ActualSupplier.Salutation; _printDocument.SellerAdress.VName = this.m_supplierSelection.ActualSupplier.FirstName; _printDocument.SellerAdress.NName = this.m_supplierSelection.ActualSupplier.LastName; _printDocument.SellerAdress.Street = this.m_supplierSelection.ActualSupplier.Adress; _printDocument.SellerAdress.Zip = this.m_supplierSelection.ActualSupplier.ZipCode; _printDocument.SellerAdress.Town = this.m_supplierSelection.ActualSupplier.Town; if (GParams.Instance.SystemParameters.PrintPev) { var _printPrevDlg = new PrintPreviewDialog(); var _leiste = _printPrevDlg.Controls.Cast <object>().FirstOrDefault(p => p is ToolStrip) as ToolStrip; if (_leiste != null) { _leiste.Height = 60; _leiste.Items[0].AutoSize = false; _leiste.Items[0].DisplayStyle = ToolStripItemDisplayStyle.ImageAndText; _leiste.Items[0].Size = new Size(80, 60); //_leiste.Items[0].Image = DeVes.Bazaar.Client.Properties.Resources.printer_60x60; } _printPrevDlg.Document = _printDocument; _printPrevDlg.Size = new Size(800, 600); _printPrevDlg.ShowDialog(); } else { var _printerFrm = new PrintDialog(); if (_printerFrm.ShowDialog(this) == DialogResult.OK) { _printDocument.PrinterSettings = _printerFrm.PrinterSettings; _printDocument.Print(); } } } } catch (Exception _ex) { MessageBox.Show(_ex.Message); } this.ShowActualSupplierInfos(); }
private void m_posNrToFindTb_KeyUp(object sender, KeyEventArgs e) { if (sender == this.m_posNrToFindTb && e.KeyCode == Keys.Escape) { this.m_posNrToFindTb.ResetText(); this.ResetBadMsg(); this.ResetSupplier(); this.ResetPositions(); this.m_posNrToFindTb.Focus(); this.m_posNrToFindTb.SelectAll(); } else if (sender == this.m_posNrToFindTb && e.KeyCode == Keys.Return) { e.Handled = true; this.ResetBadMsg(); this.ResetSupplier(); this.ResetPositions(); if (!GParams.ToInt32(this.m_posNrToFindTb.Text).HasValue) { this.SetBadMsg("Fehlerhafte Eingabe"); this.m_posNrToFindTb.Focus(); this.m_posNrToFindTb.SelectAll(); return; } var _positionNo = GParams.ToInt32(this.m_posNrToFindTb.Text).Value; var _posToSell = GParams.Instance.BasarCom.PositionGet(_positionNo, true); if (_posToSell == null) { this.SetBadMsg("Nummer nicht als Position bekannt!"); this.m_posNrToFindTb.Focus(); this.m_posNrToFindTb.SelectAll(); return; } this.PositionsToSceen(_posToSell); SetGoodMsg("Position gefunden..."); var _supplierBiz = GParams.Instance.BasarCom.SupplierGet_ByID(_posToSell.SupplierId); if (_supplierBiz == null) { this.SetBadMsg("Lieferant nicht gefunden!"); this.m_posNrToFindTb.Focus(); this.m_posNrToFindTb.SelectAll(); return; } this.SupplierToSceen(_supplierBiz); SetGoodMsg("Lieferant und Position gefunden..."); this.m_posNrToFindTb.Focus(); this.m_posNrToFindTb.SelectAll(); } }
private void m_printListBtn_Click(object sender, EventArgs e) { if (this.m_matlPosLv.Items.Count <= 0) { return; } var _tableInfo = new TablePrintDef(); _tableInfo.AddColumn(new TablePrintDef.ColumnItem("Pos Nr.", 8.50F)); _tableInfo.AddColumn(new TablePrintDef.ColumnItem("Kategorie", 14.50F)); _tableInfo.AddColumn(new TablePrintDef.ColumnItem("Hersteller", 14.50F)); _tableInfo.AddColumn(new TablePrintDef.ColumnItem("Bezeichnung", 40.50F)); _tableInfo.AddColumn(new TablePrintDef.ColumnItem("Regel Preis", 11.00F)); _tableInfo.AddColumn(new TablePrintDef.ColumnItem("Min. Preis", 11.00F)); var _itemsToPrint = new List <ListViewItem>(); foreach (ListViewItem _lvItem in this.m_matlPosLv.Items) { _itemsToPrint.Add(_lvItem); } _itemsToPrint.Sort(delegate(ListViewItem lv01, ListViewItem lv02) { var _pos01 = GParams.ToInt32(lv01.SubItems[0].Text); var _pos02 = GParams.ToInt32(lv02.SubItems[0].Text); if (_pos01.HasValue && _pos02.HasValue) { if (_pos01.Value > _pos02.Value) { return(1); } else if (_pos01.Value < _pos02.Value) { return(-1); } else { return(0); } } return(string.Compare(lv01.SubItems[0].Text, lv02.SubItems[0].Text)); }); foreach (var _lvItem in _itemsToPrint) { var _posNoInfo = new TablePrintDef.FieldDef(_lvItem.SubItems[0].Text); var _maxQtyInfo = new TablePrintDef.FieldDef(_lvItem.SubItems[4].Text + " €"); var _minQtyInfo = new TablePrintDef.FieldDef(_lvItem.SubItems[5].Text + " €"); _posNoInfo.StringFormat.Alignment = StringAlignment.Center; _maxQtyInfo.StringFormat.Alignment = StringAlignment.Far; _minQtyInfo.StringFormat.Alignment = StringAlignment.Far; _tableInfo.AddLine(_posNoInfo, new TablePrintDef.FieldDef(_lvItem.SubItems[2].Text), new TablePrintDef.FieldDef(_lvItem.SubItems[3].Text), new TablePrintDef.FieldDef(_lvItem.SubItems[1].Text), _maxQtyInfo, _minQtyInfo); } var _printDocument = new PrintDocErfassung(_tableInfo); _printDocument.DefaultPageSettings.Landscape = true; _printDocument.PrinterSettings.DefaultPageSettings.Landscape = true; _printDocument.SellerAdress = new PrintDocErfassung.SellerAdressElem(); _printDocument.SellerAdress.Id = this.m_supplierSelection.ActualSupplier.SupplierNo.ToString(); _printDocument.SellerAdress.Titel = this.m_supplierSelection.ActualSupplier.Salutation; _printDocument.SellerAdress.VName = this.m_supplierSelection.ActualSupplier.FirstName; _printDocument.SellerAdress.NName = this.m_supplierSelection.ActualSupplier.LastName; _printDocument.SellerAdress.Street = this.m_supplierSelection.ActualSupplier.Adress; _printDocument.SellerAdress.Zip = this.m_supplierSelection.ActualSupplier.ZipCode; _printDocument.SellerAdress.Town = this.m_supplierSelection.ActualSupplier.Town; if (GParams.Instance.SystemParameters.PrintPev) { var _printPrevDlg = new PrintPreviewDialog(); _printPrevDlg.Document = _printDocument; _printPrevDlg.ShowDialog(); } else { var _printerFrm = new PrintDialog(); if (_printerFrm.ShowDialog(this) == DialogResult.OK) { _printDocument.PrinterSettings = _printerFrm.PrinterSettings; _printDocument.Print(); } } }
public int DrawTable(Graphics g, RectangleF mainRect, int startByLine) { var _gridLinePen1 = new Pen(Color.Black, 1); var _colToWidth = new Dictionary <int, int>(); #region . columns . var _colRect = GParams.ToRectangle(new RectangleF(mainRect.X, mainRect.Y, 10, this.ColApear.Height)); Brush _colBkBrush = new SolidBrush(this.ColApear.BkColor); Brush _colTextBrush = new SolidBrush(this.ColApear.ForeColor); foreach (var _colValue in this.Columns) { var _isLastCol = this.Columns.IndexOf(_colValue) == this.Columns.Count - 1; if (this.CalcWidth(mainRect.Width, _colValue.Width) <= 0) { continue; } //Widht anpassen _colToWidth[this.Columns.IndexOf(_colValue)] = (int)this.CalcWidth(mainRect.Width, _colValue.Width); _colRect.Width = (int)this.CalcWidth(mainRect.Width, _colValue.Width); if (_isLastCol) { _colRect.Width = (int)(mainRect.Right - (float)_colRect.X); } //Hindergrund zeichnen g.FillRectangle(_colBkBrush, _colRect); //Text var _stringFormat = new StringFormat(); _stringFormat.Alignment = StringAlignment.Near; _stringFormat.LineAlignment = StringAlignment.Center; g.DrawString(_colValue.Text, this.ColApear.Font, _colTextBrush, _colRect, _stringFormat); //Rahmen um den Text g.DrawRectangle(_gridLinePen1, _colRect); ////Sencrechte linie zeichnen //g.DrawLine(_gridLinePen1, new Point((int)_colRect.Right, (int)mainRect.Top), new Point((int)_colRect.Right, (int)mainRect.Bottom)); //Nach rechts erweitern _colRect.X += _colRect.Width; } _colBkBrush.Dispose(); _colTextBrush.Dispose(); #endregion . columns . #region . Zeilen . var _lineRect = GParams.ToRectangle(new RectangleF(mainRect.X, _colRect.Bottom + 2, 50, this.ColApear.Height)); for (; startByLine < this.Lines.Count; startByLine++) { var _line = this.Lines[startByLine]; var _lineIndex = this.Lines.IndexOf(_line); var _biggestHeightOfLine = this.GetBiggestHeightOfLine(g, _lineIndex); if (_biggestHeightOfLine <= 0) { continue; } //Recht zurück auf X=0 setzten _lineRect.X = (int)mainRect.X; //Rechteck auf die höhe anpassen _lineRect.Height = (int)_biggestHeightOfLine; //Points ermitteln var _pointStart1 = new PointF(_lineRect.X + 1, _lineRect.Y + 1); var _pointStart2 = new PointF(_lineRect.Right, _lineRect.Bottom); //Prüfen ob das nächste noch passt if (!mainRect.Contains(_pointStart1) || !mainRect.Contains(_pointStart2)) { break; } //Zeile durchlaufen for (var _colIndex = 0; _colIndex < _line.Count; _colIndex++) { var _field = _line[_colIndex]; var _colItem = this.Columns[_colIndex]; var _isLastCol = this.Columns.Count - 1 == _colIndex; if (!_colToWidth.ContainsKey(_colIndex)) { continue; } //Rechteck auf die Länge anpassen if (_isLastCol) { _lineRect.Width = (int)(mainRect.Right - (float)_lineRect.X); } else { _lineRect.Width = _colToWidth[_colIndex]; } //Hindergrund using (Brush _ftBk = new SolidBrush(_field.BkColor)) { g.FillRectangle(_ftBk, new Rectangle(_lineRect.X + 1, _lineRect.Y + 1, _lineRect.Width - 1, _lineRect.Height - 1)); } //Text zeichnen using (Brush _ftF = new SolidBrush(_field.ForeColor)) { g.DrawString(_field.Text, _field.Font, _ftF, new Rectangle(_lineRect.X + 1, _lineRect.Y, _lineRect.Width - 2, _lineRect.Height), _field.StringFormat); } //Zeilenlinie zeichnen g.DrawLine(_gridLinePen1, new Point((int)_lineRect.X, (int)mainRect.Top), new Point((int)_lineRect.X, (int)_lineRect.Bottom)); g.DrawLine(_gridLinePen1, new Point((int)_lineRect.Right, (int)mainRect.Top), new Point((int)_lineRect.Right, (int)_lineRect.Bottom)); //Um die aktuelle Zeile erhöhen _lineRect.X += _lineRect.Width; } //Zeilenlinie zeichnen g.DrawLine(_gridLinePen1, new Point((int)mainRect.Left + 1, (int)_lineRect.Bottom), new Point((int)_lineRect.Left + 1, (int)_lineRect.Bottom)); //Um die aktuelle Zeile erhöhen _lineRect.Y += _lineRect.Height; } #endregion . Zeilen . _gridLinePen1.Dispose(); return(startByLine); }