// возваращает количество записей в таблице Scan //и кол-во отсканированных препаратов public ScanInfo GetScanInfo(int IdGamma) { ScanInfo scanInfo = null; string countCommand = @" SELECT COUNT(*) FROM scan WHERE qty > 0 AND id_gamma = " + GlobalArea.CurrentEmployee.GammaID.ToString(); string SumQtyCommand = @" SELECT SUM(Qty) FROM scan WHERE id_gamma = " + GlobalArea.CurrentEmployee.GammaID.ToString(); using (SqlCeConnection connect = new SqlCeConnection(Datasource)) { using (SqlCeCommand command = connect.CreateCommand()) { connect.Open(); command.CommandText = countCommand; int count = (int)command.ExecuteScalar(); int sumQty = 0; if (count > 0) { command.CommandText = SumQtyCommand; sumQty = (int)command.ExecuteScalar(); } scanInfo = new ScanInfo() { Count = count, SumQty = sumQty }; } return(scanInfo); } }
public ScanInfo GetScanInfo(int IdGamma) { ScanInfo scanInfo = null; string countCommand = @" SELECT COUNT(*) FROM scan WHERE id_gamma = " + GlobalArea.CurrentEmployee.GammaID.ToString(); string SumQtyCommand = @" SELECT SUM(Qty) FROM scan WHERE id_gamma = " + GlobalArea.CurrentEmployee.GammaID.ToString(); using (var connect = GetConnect()) { connect.Open(); using (var command = connect.CreateCommand()) { command.CommandText = countCommand; command.CommandType = CommandType.Text; var val = command.ExecuteScalar().ToString(); int count = int.Parse(command.ExecuteScalar().ToString()); int sumQty = 0; if (count > 0) { command.CommandText = SumQtyCommand; sumQty = int.Parse(command.ExecuteScalar().ToString()); } scanInfo = new ScanInfo() { Count = count, SumQty = sumQty }; } return(scanInfo); } }
private void RefreshStatusBar() { statusBar1.Text = string.Format("{0} | {1}", ((taskType == TaskType.EDIT_TYPE) ? "Правка..." : "Добавление..."), handyBarcode.ToString()); ScanInfo scanInfo = data.GetScanInfo(0); sbStatistics.Text = string.Format("Препаратов: {0} | Кол-во {1}", scanInfo.Count, scanInfo.SumQty); }