public InventarForm(InventarFormMode mode):this() { _currentMode = mode; }
public string FindOpenInventar(InventarFormMode mode) { /*ScannedProductsDataSet.ScannedBarcodesRow[] scannedrow = _scannedProducts.ScannedBarcodes.FindByDocTypeAndPriority( (byte)TSDUtils.ActionCode.InventoryGlobal, 0);//openInventar; if (scannedrow != null && scannedrow.Length != 0) { return scannedrow[0].DocId; } else {*/ //DoScanEvents = false; //try //{ // if (!System.IO.File.Exists(DatabaseFile)) //System.IO.Path.Combine(Program.Default.DatabaseStoragePath,"scannedbarcodes.txt"))) // return string.Empty; byte docCloseType = (mode == InventarFormMode.DefaultInventar) ? (byte)TSDUtils.ActionCode.CloseInventar : (byte)TSDUtils.ActionCode.CloseIncome; if (_scannedProducts.ScannedBarcodes.Rows.Count == 0) OpenScanned(); List<long> openedDocs = new List<long>(); foreach (ScannedProductsDataSet.ScannedBarcodesRow r in _scannedProducts.ScannedBarcodes) { if (//r.DocId == docId && r.DocType == docCloseType//((byte)TSDUtils.ActionCode.CloseInventar) //&&r.Priority == 255 //r.Barcode == long.Parse(barcode) //r.ScannedDate == date ) { if (r.Priority == 255) { if (openedDocs.Contains(r.Barcode)) { openedDocs.Remove(r.Barcode); //return false; } } else openedDocs.Add(r.Barcode); /* if (r.DocType == ((byte)TSDUtils.ActionCode.CloseInventar) && r.Priority == 0 && r.DocId == docId) openedDocs.Add(r.Barcode); * */ } } if (openedDocs.Count > 0) return openedDocs[0].ToString(); else return string.Empty; /* using (System.IO.FileStream fs = new System.IO.FileStream(DatabaseFile, System.IO.FileMode.Open, System.IO.FileAccess.ReadWrite, System.IO.FileShare.ReadWrite)) { byte[] arrayOfBytes = new byte[fs.Length]; if (fs.Length == 0) return string.Empty; fs.Read(arrayOfBytes, 0, arrayOfBytes.Length); string allFile = System.Text.Encoding.UTF8.GetString(arrayOfBytes, 0, arrayOfBytes.Length); string[] allLinesOfFile = allFile.Split('\n'); foreach (string s in allLinesOfFile) { if (String.IsNullOrEmpty(s)) continue; try { string[] strAr = s.Split('|'); if (strAr.Length > 0) { if (strAr[0].StartsWith("660")) { if (strAr[2] == ((byte)TSDUtils.ActionCode.CloseInventar).ToString() && strAr[6] == "255") { if (openedDocs.Contains(strAr[0])) { openedDocs.Remove(strAr[0]); } } if (strAr[2] == ((byte)TSDUtils.ActionCode.CloseInventar).ToString() && strAr[6] == "0") openedDocs.Add(strAr[0]); } } } catch (FormatException fexc) { BTPrintClass.PrintClass.SetErrorEvent(fexc.ToString() + "\n" + s); } } */ //} #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; // while ((s = wr.ReadLine()) != null) // { // try // { // string[] strAr = s.Split('|'); // if (strAr.Length > 0) // { // /* // ScannedProductsDataSet.ScannedBarcodesRow scannedRow = // ActionsClass.Action.AddScannedRow( // long.Parse(strAr[0]), // byte.Parse(strAr[2]), // strAr[1], // int.Parse(strAr[3]), // byte.Parse(strAr[6])); // scannedRow.FactQuantity += int.Parse(strAr[3]); // */ // //string openedDocId=string.Empty; // if (strAr[0].StartsWith("660")) // { // //if (scannedRow == null) // //{ // // return // // //r = new ScannedProductsDataSet.ScannedBarcodesRow[1]; // // //r[0] = scannedRow; // //} // //for (int i = 0; i < r.Length; i++) // //{ // if (strAr[2] == ((byte)TSDUtils.ActionCode.CloseInventar).ToString() && // strAr[6] == "255") // { // if (openedDocs.Contains(strAr[0])) // { // openedDocs.Remove(strAr[0]); // } // } // if (strAr[2] == ((byte)TSDUtils.ActionCode.CloseInventar).ToString() && // strAr[6] == "0") // openedDocs.Add(strAr[0]); // //openedDocId = strAr[0]; // //return strAr[0]; // } // } // } // catch (FormatException fexc) // { // BTPrintClass.PrintClass.SetErrorEvent(fexc.ToString() + "\n" + s); // } // } // if (openedDocs.Count > 0) // return openedDocs[0]; // else // return string.Empty; //if (row["FactQuantity"] != System.DBNull.Value // && row.FactQuantity > 0) //{ //string s = // string.Format("{0}|{1}|{2}|{3}|{4}|{5}|{6}", // docId, // docId, // docType, // 0, // DateTime.Today, // Program.Default.TerminalID, // 255 // ); // string s = //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); //} //} //return string.Empty; //} #endregion //} //finally //{ //DoScanEvents = true; //} }
public bool CheckInv(string docId, InventarFormMode mode) { byte docType = (mode == InventarFormMode.DefaultInventar)? (byte)TSDUtils.ActionCode.CloseInventar: (byte)TSDUtils.ActionCode.CloseIncome; if (_scannedProducts.ScannedBarcodes.Rows.Count == 0) { OpenScanned(); } List<long> openedDocs = new List<long>(); foreach (ScannedProductsDataSet.ScannedBarcodesRow r in _scannedProducts.ScannedBarcodes) { if (r.DocId == docId && r.DocType == docType//((byte)TSDUtils.ActionCode.CloseInventar) //&&r.Priority == 255 //r.Barcode == long.Parse(barcode) //r.ScannedDate == date ) { if (r.Priority == 255) { if (openedDocs.Contains(r.Barcode)) { openedDocs.Remove(r.Barcode); return false; } } else openedDocs.Add(r.Barcode); /* if (r.DocType == ((byte)TSDUtils.ActionCode.CloseInventar) && r.Priority == 0 && r.DocId == docId) openedDocs.Add(r.Barcode); * */ } } if (openedDocs.Count > 0) return true; else return false; #region old action /* if (!System.IO.File.Exists(System.IO.Path.Combine( Program.Default.DatabaseStoragePath, "scannedbarcodes.txt"))) return false; List<String> openedDocs = new List<string>(); //найти все открытые и закрытые инв-ции using (System.IO.StreamReader wr = new System.IO.StreamReader( System.IO.Path.Combine( Program.Default.DatabaseStoragePath, "scannedbarcodes.txt"), true)) { string s = string.Empty; while ((s = wr.ReadLine()) != null) { string[] strAr = s.Split('|'); //string openedDocId=string.Empty; if (strAr.Length > 0) { if (strAr[2] == ((byte)TSDUtils.ActionCode.CloseInventar).ToString() && strAr[6] == "255" && strAr[1] == docId) { if (openedDocs.Contains(strAr[0])) { openedDocs.Remove(strAr[0]); return false; } } if (strAr[2] == ((byte)TSDUtils.ActionCode.CloseInventar).ToString() && strAr[6] == "0" && strAr[1] == docId) openedDocs.Add(strAr[0]); //openedDocId = strAr[0]; //return strAr[0]; } } if (openedDocs.Count > 0) return true; else return false; } */ #endregion }
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; }