private bool InitDataCash() { Datecs _printer = new Datecs(); if (_printer.HasError) { MessageBox.Show("Ошибка принтера :" + _printer.ErrorText); _printer.Close(); return(false); } DataRow[] _dr = this.mDataSet.Cash.Select("NumZ= -1"); if (_dr.Length == 0) { MessageBox.Show("Не найдена строка для Z отчета"); MainForm.Log("Не найдена строка для Z отчета"); _printer.Close(); return(false); } else { _cashRow = _dr[0] as MDataSet.CashRow; } _cashRow.Date = DateTime.Today; _cashRow.BalanceBegin = _printer.printerCashInfo.BalanceBegin; _cashRow.OfIncome = 0; _cashRow.OfExpend = _printer.printerCashInfo.OfExpend; _cashRow.Income = _printer.printerCashInfo.Income; _cashRow.Expend = 0; _cashRow.BalanceEnd = _printer.printerCashInfo.BalanceEnd; DataRow[] _modif = new DataRow[1]; _modif[0] = _cashRow; if (!(this.ParentForm as MainForm).SaveToBaseDirectoryModifed(_modif)) { MainForm.Log("Не обновлена строка Z Отчета"); return(false); } _mainForm.cashBindingSource.Position = _mainForm.cashBindingSource.Find("ID", _cashRow.ID); this.cashBindingSource.DataSource = _mainForm.cashBindingSource.Current; this.cashBindingSource.ResetBindings(true); /* this.cashBindingSource.DataSource = _cashRow; * this.cashBindingSource.ResetBindings(true); */ _printer.Close(); return(true); }
public DialogOfExpend(MDataSet.CashRow cashrow) { InitializeComponent(); _cash = cashrow; this.cashBindingSource.DataSource = _cash; this.cashBindingSource.ResetBindings(true); this.SummEdit.DataBindings.Add(new Binding("EditValue", this, "SummExpend")); }
private bool InitDataCash() { Datecs _printer = new Datecs(); if (_printer.HasError) { MessageBox.Show("Ошибка принтера :" + _printer.ErrorText); _printer.Close(); return false; } DataRow[] _dr = this.mDataSet.Cash.Select("NumZ= -1"); if (_dr.Length == 0) { MessageBox.Show("Не найдена строка для Z отчета"); MainForm.Log("Не найдена строка для Z отчета"); _printer.Close(); return false; } else _cashRow = _dr[0] as MDataSet.CashRow; _cashRow.Date = DateTime.Today; _cashRow.BalanceBegin = _printer.printerCashInfo.BalanceBegin; _cashRow.OfIncome = 0; _cashRow.OfExpend = _printer.printerCashInfo.OfExpend; _cashRow.Income = _printer.printerCashInfo.Income; _cashRow.Expend = 0; _cashRow.BalanceEnd = _printer.printerCashInfo.BalanceEnd; DataRow[] _modif = new DataRow[1]; _modif[0] = _cashRow; if (!(this.ParentForm as MainForm).SaveToBaseDirectoryModifed(_modif)) { MainForm.Log("Не обновлена строка Z Отчета"); return false; } _mainForm.cashBindingSource.Position = _mainForm.cashBindingSource.Find("ID", _cashRow.ID); this.cashBindingSource.DataSource = _mainForm.cashBindingSource.Current; this.cashBindingSource.ResetBindings(true); /* this.cashBindingSource.DataSource = _cashRow; this.cashBindingSource.ResetBindings(true); */ _printer.Close(); return true; }
private void btMariaZReport_Click(object sender, EventArgs e) { Maria301Printer _printer = new Maria301Printer(1); if (_printer.HasError) { MessageBox.Show("Ошибка инициализации принтера "); _printer.Done(); return; } /* если нет строки*/ MDataSet.CashRow _firstRow; DataRow[] dataRowsInTable = this.mDataSet.Cash.Select("NumZ = " + _printer.Info.NumZ.ToString()); if (dataRowsInTable.Length == 0) { dataRowsInTable = this.mDataSet.Cash.Select("NumZ = -1"); if (dataRowsInTable.Length != 0) { _firstRow = (dataRowsInTable[0] as MDataSet.CashRow); _firstRow.NumZ = _printer.Info.NumZ; } else { _firstRow = (this.cashBindingSource.AddNew() as DataRowView).Row as MDataSet.CashRow; _firstRow.NumZ = _printer.Info.NumZ; _firstRow.Date = DateTime.Today; _firstRow.BalanceBegin = _printer.Info.BalanceBegin; _firstRow.BalanceEnd = _printer.Info.BalanceEnd; _firstRow.OfIncome = 0; _firstRow.OfExpend = _printer.Info.OfExpend; _firstRow.Income = _printer.Info.Income; _firstRow.Expend = 0; this.cashBindingSource.EndEdit(); this.cashTableAdapter.Update(_firstRow); } } else { _firstRow = null; } if ((_printer.Info.ifJustZ) & _firstRow != null) { _firstRow.NumZ += 1; DataRow[] _forSave = new DataRow[1]; _forSave[0] = _firstRow; this.SaveToBaseDirectoryModifed(_forSave); _printer.Done(); MessageBox.Show("Z отчет был снят!"); return; } this.cashBindingSource.Position = this.cashBindingSource.Find("NumZ", _printer.Info.NumZ); MDataSet.CashRow _cashRow = (this.cashBindingSource.Current as DataRowView).Row as MDataSet.CashRow; if (_cashRow == null) { MessageBox.Show("Не инициализированна касса!"); return; } int newZ = _printer.Info.NumZ + 1; _cashRow.NumZ = _printer.Info.NumZ; _cashRow.Date = DateTime.Today; _cashRow.BalanceBegin = _printer.Info.BalanceBegin; _cashRow.OfIncome = 0; _cashRow.OfExpend = _printer.Info.OfExpend; _cashRow.Income = _printer.Info.Income; _cashRow.Expend = 0; _cashRow.BalanceEnd = _printer.Info.BalanceEnd; DataRow[] _modif1 = new DataRow[1]; _modif1[0] = _cashRow; if (!this.SaveToBaseDirectoryModifed(_modif1)) { _printer.Done(); return; } if (DialogResult.OK == MessageBox.Show(this, "Поверните ключ в положение Z отчет ", "Печать Z дневного отчета", MessageBoxButtons.OKCancel, MessageBoxIcon.Information)) { _printer.ZReport(); } try { this.cashTableAdapter.ClosePeriod(newZ); this.cashTableAdapter.Fill(this.mDataSet.Cash); this.FillTableNewDocuments(this.mDataSet.InvoiceMaster); } catch (Exception err) { Log("Zreport" + err.Message); MessageBox.Show("Ошибка!!! " + err.Message); } finally { this.cashBindingSource.Position = this.cashBindingSource.Find("NumZ", newZ); } while (_printer.KeyPosition != Maria301Printer.KeyPositions.Work) { MessageBox.Show("Поверните ключ в рабочее положение!", "Печать переодического отчета закончена"); } MessageBox.Show("Остаток в кассе : " + _printer.Info.BalanceEnd.ToString(), "Печать дневного отчета (Z-Отчет)"); _printer.Done(); }
private void btDatecsOfExpend_Click(object sender, EventArgs e) { Datecs _printer = new Datecs(); if (_printer.HasError) { MessageBox.Show("Ошибка принтера :" + _printer.ErrorText); _printer.Close(); return; } this.cashBindingSource.Position = this.cashBindingSource.Find("NumZ", -1); MDataSet.CashRow _cashRow = (this.cashBindingSource.Current as DataRowView).Row as MDataSet.CashRow; if (_cashRow == null) { MessageBox.Show("Не инициализированна касса!"); _printer.Close(); return; } _cashRow.NumZ = _printer.printerCashInfo.NumZ; _cashRow.Date = DateTime.Today; _cashRow.BalanceBegin = _printer.printerCashInfo.BalanceBegin; _cashRow.OfIncome = 0; _cashRow.OfExpend = _printer.printerCashInfo.OfExpend; _cashRow.Income = _printer.printerCashInfo.Income; _cashRow.Expend = 0; _cashRow.BalanceEnd = _printer.printerCashInfo.BalanceEnd; DialogOfExpend _DialogOfExpend = new DialogOfExpend(_cashRow); if (DialogResult.OK == _DialogOfExpend.ShowDialog(this)) { if (!_printer.OfExpend((double)_DialogOfExpend.SummExpend)) { MessageBox.Show("Не удалось изъять сумму !"); _printer.Close(); return; } _cashRow.NumZ = _printer.printerCashInfo.NumZ; _cashRow.Date = DateTime.Today; _cashRow.BalanceBegin = _printer.printerCashInfo.BalanceBegin; _cashRow.OfIncome = 0; _cashRow.OfExpend = _printer.printerCashInfo.OfExpend; _cashRow.Income = _printer.printerCashInfo.Income; _cashRow.Expend = 0; _cashRow.BalanceEnd = _printer.printerCashInfo.BalanceEnd; DataRow[] _modif1 = new DataRow[1]; _modif1[0] = _cashRow; if (!this.SaveToBaseDirectoryModifed(_modif1)) { _printer.Close(); return; } } _printer.Close(); }