public void OpenInv(string docId, TSDUtils.ActionCode docType) { OpenInv(docId, docType, InventarFormMode.DefaultInventar); }
public void OpenInv(string docId, TSDUtils.ActionCode docType, InventarFormMode mode ) { byte docCloseType = (mode == InventarFormMode.DefaultInventar) ? (byte)TSDUtils.ActionCode.CloseInventar : (byte)TSDUtils.ActionCode.CloseIncome; string textToThrow = (mode == InventarFormMode.DefaultInventar) ? "Инв-ция" : "Накл-я"; ScannedProductsDataSet.ScannedBarcodesRow[] r = FindByDocIdAndDocType(docId, docCloseType); //(byte)TSDUtils.ActionCode.CloseInventar); if (r != null && r.Length > 0) throw new ApplicationException(string.Format("{0} {1} уже просчитана", textToThrow, docId)); //using (System.IO.StreamWriter wr = // new System.IO.StreamWriter( // System.IO.Path.Combine(Program.Default.DatabaseStoragePath, "scannedbarcodes.txt"), true)) { //if (row["FactQuantity"] != System.DBNull.Value // && row.FactQuantity > 0) //{ DoScanEvents = false; try { ScannedProductsDataSet.ScannedBarcodesRow r1 = AddScannedRow(long.Parse(docId), docCloseType//((byte)TSDUtils.ActionCode.CloseInventar) , docId, 0, 0); string s = string.Format("{0}|{1}|{2}|{3}|{4}|{5}|{6}|{7}", docId, docId, docCloseType,//((byte)TSDUtils.ActionCode.CloseInventar), 0, DateTime.Today.ToString("dd.MM.yyyy"), Program.Default.TerminalID, 0, 0 ); byte[] buff = System.Text.Encoding.UTF8.GetBytes(string.Concat(s, "\r\n")); //byte[] buff = System.Text.Encoding.UTF8.GetBytes(string.Concat(s, '\n')); //byte[] buff = new byte[] { 0xD, 0xA }; writer.Write(buff, 0, buff.Length); writer.Flush(); } finally { DoScanEvents = true; } //writer.WriteLine(s); //} } //Program.СurrentInvId = docId; if (mode == InventarFormMode.DefaultInventar) Program.СurrentInvId = docId; else Program.СurrentIncomeId = docId; }
public void CloseInv(string docId, TSDUtils.ActionCode docType, InventarFormMode mode) { byte docCloseType = (mode == InventarFormMode.DefaultInventar) ? (byte)TSDUtils.ActionCode.CloseInventar : (byte)TSDUtils.ActionCode.CloseIncome; ScannedProductsDataSet.ScannedBarcodesRow[] scannedrow = _scannedProducts.ScannedBarcodes.FindByDocIdAndDocType(docId, (byte)docType); if (scannedrow == null || scannedrow.Length == 0) { /*throw new ApplicationException(string.Format("Документ {0} с типом {1} не найден!", docId, docType.ToString()) );*/ } else { for (int i = 0; i < scannedrow.Length; i++) { scannedrow[i].Priority = byte.MaxValue; //WriteDbTxt(scannedrow[i]); } } //using (System.IO.StreamWriter wr = // new System.IO.StreamWriter( // System.IO.Path.Combine(Program.Default.DatabaseStoragePath, "scannedbarcodes.txt"), true)) { //if (row["FactQuantity"] != System.DBNull.Value // && row.FactQuantity > 0) //{ DoScanEvents = false; try { ScannedProductsDataSet.ScannedBarcodesRow r1 = _scannedProducts.ScannedBarcodes.FindByBarcodeDocTypeDocId( long.Parse(docId), docCloseType//((byte)TSDUtils.ActionCode.CloseInventar) , docId); if (r1 != null) r1.Priority = 255; else r1 = AddScannedRow(long.Parse(docId), ((byte)TSDUtils.ActionCode.CloseInventar), docId, 0, 255); string s = string.Format("{0}|{1}|{2}|{3}|{4}|{5}|{6}|{7}", docId, docId, docCloseType,//((byte)TSDUtils.ActionCode.CloseInventar), 0, DateTime.Today.ToString("dd.MM.yyyy"), Program.Default.TerminalID, 255, 0 ); byte[] buff = System.Text.Encoding.UTF8.GetBytes(string.Concat(s, "\r\n")); //byte[] buff = System.Text.Encoding.UTF8.GetBytes(string.Concat(s, '\n')); //byte[] buff = new byte[] { 0xD, 0xA }; writer.Write(buff, 0, buff.Length); writer.Flush(); } finally { DoScanEvents = true; } //writer.WriteLine(s); //} } //текущий открытый просчет теперь пуст if (mode == InventarFormMode.DefaultInventar) Program.СurrentInvId = string.Empty; else Program.СurrentIncomeId = string.Empty; }
public void CloseDoc(string docId, TSDUtils.ActionCode docType, int totalFactQty) { ScannedProductsDataSet.ScannedBarcodesRow[] scannedrow = _scannedProducts.ScannedBarcodes.FindByDocIdAndDocType(docId, (byte)docType); if (scannedrow == null || scannedrow.Length == 0) { /*throw new ApplicationException(string.Format("Документ {0} с типом {1} не найден!", docId, docType.ToString()) );*/ } else { for (int i = 0; i < scannedrow.Length; i++) { scannedrow[i].Priority = byte.MaxValue; //WriteDbTxt(scannedrow[i]); } } //using (System.IO.StreamWriter wr = // new System.IO.StreamWriter( // System.IO.Path.Combine(Program.Default.DatabaseStoragePath, "scannedbarcodes.txt"), true)) { //if (row["FactQuantity"] != System.DBNull.Value // && row.FactQuantity > 0) //{ string s = string.Format("{0}|{1}|{2}|{3}|{4}|{5}|{6}|{7}", docId, docId, ((byte)docType), totalFactQty, DateTime.Today.ToString("dd.MM.yyyy"), Program.Default.TerminalID, 255, 0 ); byte[] buff = System.Text.Encoding.UTF8.GetBytes(string.Concat(s, "\r\n")); //byte[] buff = System.Text.Encoding.UTF8.GetBytes(string.Concat(s, '\n')); //byte[] buff = new byte[] { 0xD, 0xA }; writer.Write(buff, 0, buff.Length); writer.Flush(); //writer.WriteLine(s); //} } //текущий открытый просчет теперь пуст //Program.СurrentInvId = string.Empty; }
/// <summary> /// Подсчет ШК в документах с указанным типом /// </summary> /// <param name="docType">Тип документа</param> /// <param name="totalBk">Возврат всего уникальных ШК</param> /// <param name="total">Возврат всего записей</param> public void CalculateTotalsWOPriority(TSDUtils.ActionCode docType, DateTime date, out int totalBk, out int total) { total = 0; totalBk = 0; if (_scannedProducts.ScannedBarcodes.Rows.Count == 0) { OpenScanned(); } List<long> scannedList = new List<long>(); foreach (ScannedProductsDataSet.ScannedBarcodesRow r in _scannedProducts.ScannedBarcodes) { if (//r.DocId == docId && r.DocType == (byte)docType && //r.Barcode == long.Parse(barcode) r.ScannedDate == date ) { total += r.FactQuantity;//int.Parse(strAr[3]); if (!scannedList.Contains(r.Barcode)) { scannedList.Add(r.Barcode); totalBk += 1; } } } return; #region old action /*using (System.IO.StreamReader wr = new System.IO.StreamReader( System.IO.Path.Combine( Program.Default.DatabaseStoragePath, "scannedbarcodes.txt"), true)) { string s = string.Empty; //List<long> scannedList = // new List<long>(); while ((s = wr.ReadLine()) != null) { string[] strAr = s.Split('|'); if (strAr.Length > 0) { if (strAr[2] == ((byte)docType).ToString()) { if (strAr[4] == date.ToString("dd.MM.yyyy")) { total += 1; if (!scannedList.Contains(long.Parse(strAr[0]))) { scannedList.Add(long.Parse(strAr[0])); totalBk += 1; } } } } } //string.Format("{0}|{1}|{2}|{3}|{4}|{5}|{6}", // row.Barcode, // row.DocId, // row.DocType, // quantity, // (row["ScannedDate"] == System.DBNull.Value) ? // DateTime.Today : row.ScannedDate, // (row["TerminalId"] == System.DBNull.Value) ? // string.Empty : row.TerminalId.ToString(), // row.Priority // ); //wr.WriteLine(s); //} }*/ #endregion /* ScannedProductsDataSet.ScannedBarcodesRow[] scannedrow = _scannedProducts.ScannedBarcodes.FindByDocType( (byte)docType); if (scannedrow == null || scannedrow.Length == 0) { return; } else { total = scannedrow.Length; List<long> scannedList = new List<long>(); for (int i = 0; i < scannedrow.Length; i++) { if (scannedrow[i].ScannedDate == date) { if (!scannedList.Contains(scannedrow[i].Barcode)) { scannedList.Add(scannedrow[i].Barcode); totalBk += 1; } } } }*/ }
/// <summary> /// Подсчет ШК в документах с указанным типом /// </summary> /// <param name="docType">Тип документа</param> /// <param name="totalBk">Возврат всего уникальных ШК</param> /// <param name="total">Возврат всего записей</param> public void CalculateTotalsWOPriority(TSDUtils.ActionCode docType, string docId, string barcode, out int totalBk, out int total) { total = 0; totalBk = 0; if (_scannedProducts.ScannedBarcodes.Rows.Count == 0) { OpenScanned(); } List<long> scannedList = new List<long>(); foreach (ScannedProductsDataSet.ScannedBarcodesRow r in _scannedProducts.ScannedBarcodes) { if (r.DocId == docId && r.DocType == (byte)docType && r.Barcode == long.Parse(barcode)) { total += r.FactQuantity;//int.Parse(strAr[3]); if (!scannedList.Contains(r.Barcode)) { scannedList.Add(r.Barcode); totalBk += 1; } } } return; #region old action if (!System.IO.File.Exists(System.IO.Path.Combine( Program.Default.DatabaseStoragePath, "scannedbarcodes.txt"))) return; /* using (System.IO.StreamReader wr = new System.IO.StreamReader( System.IO.Path.Combine( Program.Default.DatabaseStoragePath, "scannedbarcodes.txt"), true)) { string s = string.Empty; //List<string> scannedList = // new List<string>(); while ((s = wr.ReadLine()) != null) { string[] strAr = s.Split('|'); if (strAr.Length > 0) { if (strAr[2] == ((byte)docType).ToString() && strAr[0] == barcode && strAr[1] == docId) { //if (strAr[4] == date.ToString("dd.MM.yyyy")) //{ total += int.Parse(strAr[3]); if (!scannedList.Contains(strAr[0])) { scannedList.Add(strAr[0]); totalBk += 1; } //} } } } }*/ #endregion }
/// <summary> /// Подсчет ШК в документах с указанным типом /// и Приоритетом = 0 /// </summary> /// <param name="docType">Тип документа</param> /// <param name="totalBk">Возврат всего уникальных ШК</param> /// <param name="total">Возврат всего записей</param> public void CalculateTotals(TSDUtils.ActionCode docType, out int totalBk, out int total) { total = 0; totalBk = 0; if (_scannedProducts.ScannedBarcodes.Rows.Count == 0) { OpenScanned(); } List<long> scannedList = new List<long>(); foreach (ScannedProductsDataSet.ScannedBarcodesRow r in _scannedProducts.ScannedBarcodes) { if (//r.DocId == docId && r.DocType == (byte)docType && //r.Barcode == long.Parse(barcode) r.Priority == 255 ) { total += r.FactQuantity;//int.Parse(strAr[3]); if (!scannedList.Contains(r.Barcode)) { scannedList.Add(r.Barcode); totalBk += 1; } } } return; #region oldaction /*if (!System.IO.File.Exists(System.IO.Path.Combine( Program.Default.DatabaseStoragePath, "scannedbarcodes.txt"))) return; using (System.IO.StreamReader wr = new System.IO.StreamReader( System.IO.Path.Combine( Program.Default.DatabaseStoragePath, "scannedbarcodes.txt"), true)) { string s = string.Empty; //List<long> scannedList = // new List<long>(); List<string> scannedList = new List<string>(); while ((s = wr.ReadLine()) != null) { string[] strAr = s.Split('|'); if (strAr.Length > 0) { if (strAr[2] == ((byte)docType).ToString() && strAr[6] == "255") { //if (strAr[4] == date.ToString("dd.MM.yyyy")) //{ //total += 1; total += int.Parse(strAr[3]); if (!scannedList.Contains(strAr[0])) { scannedList.Add(strAr[0]); totalBk += 1; } //} } } } }*/ #endregion /*ScannedProductsDataSet.ScannedBarcodesRow[] scannedrow = _scannedProducts.ScannedBarcodes.FindByDocTypeAndPriority( (byte)docType, 0); if (scannedrow == null || scannedrow.Length == 0) { return; } else { total = scannedrow.Length; List<long> scannedList = new List<long>(); for (int i = 0; i < scannedrow.Length; i++) { if (!scannedList.Contains(scannedrow[i].Barcode)) { scannedList.Add(scannedrow[i].Barcode); totalBk += 1; } } }*/ }
/// <summary> /// Посчитать общее кол-во ШК в документе /// и кол-во уникальных ШК /// </summary> /// <param name="docId">№ док-та</param> /// <param name="docType">Тип документа</param> /// <param name="totalBk">уникальное кол-во ШК</param> /// <param name="total">Всего записей</param> public void CalculateTotals(string docId, TSDUtils.ActionCode docType, out int totalBk, out int total) { total = 0; totalBk = 0; foreach (ScannedProductsDataSet.ScannedBarcodesRow row in ScannedProducts.ScannedBarcodes) { if (row.DocId == docId && row.DocType == (byte)docType) { total += row.FactQuantity; totalBk++; } } return; #region if (!System.IO.File.Exists(System.IO.Path.Combine( Program.Default.DatabaseStoragePath, "scannedbarcodes.txt"))) return; using (System.IO.StreamReader wr = new System.IO.StreamReader( System.IO.Path.Combine( Program.Default.DatabaseStoragePath, "scannedbarcodes.txt"), true)) { string s = string.Empty; List<string> scannedList = new List<string>(); while ((s = wr.ReadLine()) != null) { string[] strAr = s.Split('|'); if (strAr.Length > 0) { if (strAr[2] == ((byte)docType).ToString() && strAr[1] == docId) { //if (strAr[4] == date.ToString("dd.MM.yyyy")) //{ total += int.Parse(strAr[3]); if (!scannedList.Contains(strAr[0])) { scannedList.Add(strAr[0]); totalBk += 1; } //} } } } } #endregion /*ScannedProductsDataSet.ScannedBarcodesRow [] scannedrow = _scannedProducts.ScannedBarcodes.FindByDocIdAndDocType(docId, (byte)docType); if (scannedrow == null || scannedrow.Length == 0) { return; } else { total = scannedrow.Length; List<long> scannedList = new List<long>(); for (int i = 0; i < scannedrow.Length; i++) { if (!scannedList.Contains(scannedrow[i].Barcode)) { scannedList.Add(scannedrow[i].Barcode); totalBk += scannedrow[i].FactQuantity; } } }*/ }
public void InvokeAction(TSDUtils.ActionCode ac, ProductsDataSet.ProductsTblRow datarow, ProductsDataSet.DocsTblRow docsRow) { if (actionsDict.ContainsKey(ac)) { actionsDict[ac].Invoke(datarow, docsRow); } }