public RemoveFinishForm(ProductsDataSet.ProductsTblRow datarow, ProductsDataSet.DocsTblRow docsRow)
            :this()
        {
            _datarow = datarow;
            _docsRow = docsRow;

        }
        //TSDUtils.CustomEncodingClass CustomEncodingClass MyEncoder = new CustomEncodingClass();
        public DataLoaderClass()
        {
            
            productsDataSet1 = new ProductsDataSet();
            productAdapter = new TSDServer.ProductsDataSetTableAdapters.ProductsTblTableAdapter(productsDataSet1);
            docsAdapter = new TSDServer.ProductsDataSetTableAdapters.DocsTblTableAdapter(productsDataSet1);
            scannedDs = new TSDServer.ScannedProductsDataSet();
            scannedTA = new TSDServer.ScannedProductsDataSetTableAdapters.ScannedBarcodesTableAdapter(scannedDs);
            SetFormats();
            sendmail = Program.sendmail;


           // mEvt.Set();
            

        }
Exemple #3
0
        public void RepriceActionProc(ProductsDataSet.ProductsTblRow datarow, ProductsDataSet.DocsTblRow docsRow)
        {
            

             ScannedProductsDataSet.ScannedBarcodesRow r =
                _scannedProducts.ScannedBarcodes.FindByBarcodeDocTypeDocId(datarow.Barcode, docsRow.DocType, docsRow.DocId);
             if (r != null)
             {
                 
                 try
                 {
                     PlayVibroAsyncAction(docsRow);
                     PlaySoundAsyncAction(docsRow);
                     //PrintLabelAsync(datarow, docsRow);
                     uint shablonCode = TSDUtils.ActionCodeDescription.ActionDescription.GetShablon(docsRow.DocType, (uint)docsRow.LabelCode);
                     if (PrintLabel(datarow, docsRow, shablonCode))
                     {
                         r.FactQuantity += 1;
                         
                     }
                     else
                     {
                         PlayVibroAsync((byte)TSDUtils.ActionCode.NotFound);
                         PlaySoundAsync((byte)TSDUtils.ActionCode.NotFound);
                     }

                 }
                 finally
                 {
                     if (OnActionCompleted != null)
                         OnActionCompleted(docsRow, r);
                 }
             } 
            

            ////System.Threading.Thread.Sleep(1000);
            //ScannedProductsDataSet.ScannedBarcodesRow r = _scannedProducts.ScannedBarcodes.UpdateQuantity(
            //docsRow.Barcode, docsRow.DocType, 1);
            //        if (r != null)
            //        {
            //            TSDUtils.ActionCode ac = (TSDUtils.ActionCode)docsRow.DocType;

            //            //this.actionLabel.Text = TSDUtils.ActionCodeDescription.ActionDescription[ac];
            //            if (OnActionCompleted != null)
            //                OnActionCompleted(docsRow, r);
            //        }

        }
Exemple #4
0
 public void NoActionProc(ProductsDataSet.ProductsTblRow datarow, ProductsDataSet.DocsTblRow docsRow)
 {
     PlayVibro((byte)TSDUtils.ActionCode.NotFound);
     PlaySound((byte)TSDUtils.ActionCode.NotFound);
     //PlayVibroAsyncAction(docsRow);
     //PlaySoundAsyncAction(docsRow);
     
     //System.Threading.Thread.Sleep(1000);
 }
Exemple #5
0
        private byte[] ReplaceAttr(byte[] bArray, ProductsDataSet.ProductsTblRow productsRow, ProductsDataSet.DocsTblRow docsRow)
        {
            string attrString = string.Empty;
             List<byte> tempList = new List<byte>();
            List<byte> outArray = new List<byte>();
            for (int i = 0; i < bArray.Length; i++)
            {
                if (i < bArray.Length + 2 &&
                    bArray[i] == Convert.ToByte('<') &&
                    bArray[i + 1] == Convert.ToByte('<') &&
                    bArray[i + 2] == Convert.ToByte('<'))
                {
                    while (i < bArray.Length &&
                    bArray[i] != Convert.ToByte('>') &&
                    bArray[i - 1] != Convert.ToByte('>') &&
                    bArray[i - 2] != Convert.ToByte('>')

                        )
                    {
                        tempList.Add(bArray[i]);
                        i++;
                    }
                    Byte[] bArrTmp = new byte[tempList.Count];

                    tempList.CopyTo(bArrTmp);
                    tempList.Clear();
                    string atrName = TSDUtils.CustomEncodingClass.Encoding.GetString(bArrTmp).Replace("<", "");
                    System.Data.DataRow datarow = null;
                    if (atrName.IndexOf("GOODS") >= 0 ||
                        atrName.IndexOf("DOCS") >= 0 ||
                        atrName.IndexOf("SCAN") >= 0)
                    {
                        if (atrName.IndexOf("GOODS") >= 0)
                        {
                            attrString = "GOODS_ATTRIBUTE_";
                            datarow = productsRow;
                        }
                        else
                            if (atrName.IndexOf("DOCS") >= 0)
                            {
                                attrString = "DOCS_ATTRIBUTE_";
                                datarow = docsRow;
                            }
                            else
                                if (atrName.IndexOf("SCAN") >= 0)
                                {
                                    attrString = "SCAN_ATTRIBUTE_";
                                    datarow = 
                                        _scannedProducts.ScannedBarcodes.FindByBarcodeDocTypeDocId(
                                        productsRow.Barcode, docsRow.DocType, docsRow.DocId); 
                                }
                        string atrCode = atrName.Replace(attrString, "");
                        int colId = -1;

                        //try
                        //{
                        colId = int.Parse(atrCode) - 1;
                        if (colId >= datarow.Table.Columns.Count)
                            continue;
                        bArrTmp = GetAttrValue(datarow[colId], datarow.Table.Columns[colId].DataType);
                    }
                    else
                    {
                        if (atrName.IndexOf("SYSTEMDATE") >= 0)
                        {
                            bArrTmp = GetAttrValue(DateTime.Today, typeof(DateTime));
                        }
                    }
                        //atrName = "Test";
                        /*if (datarow.Table.Columns[colId].DataType == typeof(string) ||
                            datarow.Table.Columns[colId].DataType == typeof(long) ||
                            datarow.Table.Columns[colId].DataType == typeof(int) ||
                            datarow.Table.Columns[colId].DataType == typeof(byte))
                        {
                            bArrTmp = TSDUtils.CustomEncodingClass.Encoding.GetBytes(
                                datarow[colId].ToString());
                        }
                        else
                            if (datarow.Table.Columns[colId].DataType == typeof(DateTime))
                            {
                                bArrTmp = TSDUtils.CustomEncodingClass.Encoding.GetBytes(
                                    ((DateTime)datarow[colId]).ToShortDateString());
                            }
                            else
                                if (datarow.Table.Columns[colId].DataType == typeof(Single))
                                {
                                    bArrTmp = TSDUtils.CustomEncodingClass.Encoding.GetBytes(
                                        ((Single)datarow[colId]).ToString("######.00"));
                                }
                                else
                                bArrTmp =TSDUtils.CustomEncodingClass.Encoding.GetBytes(
                                    datarow[colId].ToString());
                    */
                    //}
                    //catch
                    //{
                    //}



                    outArray.AddRange(bArrTmp);
                    i += 2;//skip 2 >>
                }
                else
                {
                    outArray.Add(bArray[i]);
                }
            }
            return outArray.ToArray();
        }
Exemple #6
0
        public void PrintLabelAsync(ProductsDataSet.ProductsTblRow datarow, ProductsDataSet.DocsTblRow docRow)
        {
            PrintLabelParam prm = new PrintLabelParam();
            prm.datarow = datarow;
            prm.docRow = docRow;

            System.Threading.ThreadPool.QueueUserWorkItem(
               new System.Threading.WaitCallback(PrintLabel), prm);
        }
 public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedTableSchema(global::System.Xml.Schema.XmlSchemaSet xs) {
     global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType();
     global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence();
     ProductsDataSet ds = new ProductsDataSet();
     global::System.Xml.Schema.XmlSchemaAny any1 = new global::System.Xml.Schema.XmlSchemaAny();
     any1.Namespace = "http://www.w3.org/2001/XMLSchema";
     any1.MinOccurs = new decimal(0);
     any1.MaxOccurs = decimal.MaxValue;
     any1.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax;
     sequence.Items.Add(any1);
     global::System.Xml.Schema.XmlSchemaAny any2 = new global::System.Xml.Schema.XmlSchemaAny();
     any2.Namespace = "urn:schemas-microsoft-com:xml-diffgram-v1";
     any2.MinOccurs = new decimal(1);
     any2.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax;
     sequence.Items.Add(any2);
     global::System.Xml.Schema.XmlSchemaAttribute attribute1 = new global::System.Xml.Schema.XmlSchemaAttribute();
     attribute1.Name = "namespace";
     attribute1.FixedValue = ds.Namespace;
     type.Attributes.Add(attribute1);
     global::System.Xml.Schema.XmlSchemaAttribute attribute2 = new global::System.Xml.Schema.XmlSchemaAttribute();
     attribute2.Name = "tableTypeName";
     attribute2.FixedValue = "DocsTblDataTable";
     type.Attributes.Add(attribute2);
     type.Particle = sequence;
     global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable();
     if (xs.Contains(dsSchema.TargetNamespace)) {
         global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream();
         global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream();
         try {
             global::System.Xml.Schema.XmlSchema schema = null;
             dsSchema.Write(s1);
             for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext(); ) {
                 schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current));
                 s2.SetLength(0);
                 schema.Write(s2);
                 if ((s1.Length == s2.Length)) {
                     s1.Position = 0;
                     s2.Position = 0;
                     for (; ((s1.Position != s1.Length) 
                                 && (s1.ReadByte() == s2.ReadByte())); ) {
                         ;
                     }
                     if ((s1.Position == s1.Length)) {
                         return type;
                     }
                 }
             }
         }
         finally {
             if ((s1 != null)) {
                 s1.Close();
             }
             if ((s2 != null)) {
                 s2.Close();
             }
         }
     }
     xs.Add(dsSchema);
     return type;
 }
        private void DoAction(ProductsDataSet.ProductsTblRow row)
        {
            if (_mEvt.WaitOne(5000, false) == false)
            {
                this.Close();
            }
            try
            {

                //tmr.Change(System.Threading.Timeout.Infinite, System.Threading.Timeout.Infinite);

                label5.Text = "";
                label6.Text = "";
                label7.Text = "";
                label8.Text = "";
                label9.Text = "";
                label20.Text = "";
                label21.Text = "";
                //label17.Text = "";
                actionLabel.Text = "";
                navCodeTB.Text = "";
                currentProductRow = row;

                if (row != null)
                {
                    label17.Text = row.Barcode.ToString("0000000000000");
                    if (row.ProductName.Length > 15)
                    {
                        label5.Text = row.ProductName.Substring(0, 15);
                        label6.Text = row.ProductName.Substring(15);
                    }
                    else
                        label5.Text = row.ProductName;
                    navCodeTB.Text = row.NavCode;

                    label7.Text = (row["NewPrice"] == System.DBNull.Value ||
                        row["NewPrice"] == null) ? string.Empty : row.NewPrice.ToString("######.00");
                    label8.Text = (row["OldPrice"] == System.DBNull.Value ||
                        row["OldPrice"] == null) ? string.Empty : row.OldPrice.ToString("######.00");
                    if (label8.Text != label7.Text)
                        label7.Font = boldFont;
                    else
                        label7.Font = normalFont;


                    label9.Text = (row["Article"] == System.DBNull.Value ||
                        row["Article"] == null) ? string.Empty : row.Article;
                    switch (_mode)
                    {
                        case WorkMode.ProductsScan:
                            {
                                #region prod
                                ProductsDataSet.DocsTblRow[] docRows =
                           ActionsClass.Action.GetDataByNavCode(row.NavCode);
                                actionDict.Clear();
                                currentdocRows = docRows;

                                if (docRows != null)
                                {

                                    foreach (ProductsDataSet.DocsTblRow docRow in docRows)
                                    {
                                        ScannedProductsDataSet.ScannedBarcodesRow scannedRow =
                                            ActionsClass.Action.AddScannedRow(
                                            row.Barcode,
                                            docRow.DocType,
                                            docRow.DocId,
                                            docRow.Quantity,
                                            docRow.Priority);
                                        /*_scannedProducts.ScannedBarcodes.FindByBarcodeDocTypeDocId(
                                        row.Barcode,
                                        docRow.DocType,
                                        docRow.DocId);
                                    if (scannedRow == null)
                                    {
                                        scannedRow =
                                            _scannedProducts.ScannedBarcodes.NewScannedBarcodesRow();
                                        scannedRow.Barcode = row.Barcode;
                                        scannedRow.DocId = docRow.DocId;
                                        scannedRow.DocType = docRow.DocType;
                                        scannedRow.PlanQuanity = docRow.Quantity;
                                        scannedRow.Priority = docRow.Priority;
                                        scannedRow.ScannedDate = DateTime.Today;
                                        scannedRow.TerminalId = Program.TerminalId;
                                        _scannedProducts.ScannedBarcodes.AddScannedBarcodesRow(scannedRow);
                                    }*/
                                        byte actionCodes = docRow.DocType;
                                        if (!actionDict.ContainsKey(actionCodes))
                                            actionDict.Add(actionCodes, docRow);
                                    }
                                    foreach (byte acode in actionDict.Keys)
                                    {
                                        ActionsClass.Action.InvokeAction((TSDUtils.ActionCode)acode, row, actionDict[acode]);
                                        //this.Refresh();
                                    }
                                }
                                else
                                {
                                    ActionsClass.Action.InvokeAction(TSDUtils.ActionCode.DocNotFound, row, null);
                                }
                                break;
#endregion
                            }
                        case WorkMode.InventarScan:
                            {
                                #region inv
                                if (_invMode == InventarMode.DontUseReturns)
                                {
                                    inventRow.NavCode = row.NavCode;
                                    ActionsClass.Action.InvokeAction(TSDUtils.ActionCode.InventoryGlobal,
                                        row,
                                        inventRow
                                        );
                                }
                                else
                                {
                                    ProductsDataSet.DocsTblRow[] arrofdocs = ActionsClass.Action.GetDataByNavCodeAndType(
                                        row.NavCode,
                                        (byte)TSDUtils.ActionCode.Returns);

                                    if (arrofdocs != null &&
                                        arrofdocs.Length > 0)
                                    {
                                        ActionsClass.Action.PlaySoundAsync((byte)TSDUtils.ActionCode.ReturnInInventory);
                                        ActionsClass.Action.PlayVibroAsync((byte)TSDUtils.ActionCode.ReturnInInventory);

                                        string str = string.Format("{0}-{1}-{2}",
                                            arrofdocs[0].DocId,
                                            arrofdocs[0].Text2,
                                            arrofdocs[0].Text1);



                                        DialogResult dr = DialogFrm.ShowMessage(
                                          row.NavCode + " " + row.ProductName
                                        , "Этот товар участвует в возврате"
                                        , str
                                        , "Режим инвентаризации");
                                    }
                                    else
                                    {
                                        inventRow.NavCode = row.NavCode;
                                        ActionsClass.Action.InvokeAction(TSDUtils.ActionCode.InventoryGlobal,
                                            row,
                                            inventRow
                                            );
                                    }

                                }
                                break;
                                //this.Refresh();
                                //ActionsClass.Action.InventoryGlobalActionProc(
                                //    row,
                                //    inventRow);
#endregion
                            }
                        case WorkMode.BoxScan:
                            {
                                #region box
                                try
                                {
                                    ProductsDataSet.DocsTblRow docRow =
                                        ActionsClass.Action.GetDataByNavcodeDocIdAndType(row.NavCode,
                                            inventRow.DocId,
                                            (byte)TSDUtils.ActionCode.BoxWProducts
                                        );
                                    if (docRow != null)
                                    {
                                        /*
                                         * ScannedProductsDataSet.ScannedBarcodesRow srows
                                            = ActionsClass.Action.FindByBarcodeDocTypeDocId(row.Barcode.ToString(),
                                            (byte)TSDUtils.ActionCode.BoxWProducts,
                                            inventRow.DocId
                                            );*/

                                        ScannedProductsDataSet.ScannedBarcodesRow[] rowsS
                                            = ActionsClass.Action.FindByDocIdAndDocType(inventRow.DocId,
                                            (byte)TSDUtils.ActionCode.BoxWProducts);

                                        int fQty = 0;
                                        for (int i = 0; i < rowsS.Length; i++)
                                        {
                                            if (rowsS[i].Barcode == currentProductRow.Barcode)
                                                fQty += rowsS[i].FactQuantity;
                                        }

                                        if (rowsS.Length > 0)
                                        {
                                            if (docRow.Quantity < (fQty + quantityKoeff))
                                            {
                                                ActionsClass.Action.PlaySoundAsync((byte)TSDUtils.ActionCode.AlreadyAccepted);
                                                ActionsClass.Action.PlayVibroAsync((byte)TSDUtils.ActionCode.AlreadyAccepted);


                                                //using (DialogForm dlgfrm =
                                                //new DialogForm(
                                                DialogResult dr = DialogFrm.ShowMessage(
                                            string.Format("Товар уже принят {0} из {1}",
                                            fQty,
                                            docRow.Quantity)
                                            , string.Format("Принять еще {0} шт", quantityKoeff)//string.Format("Посчитано: {0} кодов", totalBk)
                                            , row.ProductName
                                            , "Прием товара");//)
                                                // {
                                                if (dr == DialogResult.Yes)
                                                {
                                                    //inventRow.NavCode = row.NavCode;
                                                    ActionsClass.Action.BoxWProductsActionProc(
                                                        row,
                                                        docRow,
                                                        quantityKoeff
                                                        );
                                                    return;//приняли
                                                }
                                                else //не хотим принимать
                                                    return;
                                                //}
                                            }
                                        }
                                        //если не сработали условия - то принимаем
                                        //inventRow.NavCode = row.NavCode;
                                        ActionsClass.Action.BoxWProductsActionProc(
                                                             row,
                                                             docRow,
                                                             quantityKoeff
                                                             );
                                        /*ActionsClass.Action.InvokeAction(TSDUtils.ActionCode.BoxWProducts,
                                            row,
                                            docRow
                                            );*/


                                    }
                                    else
                                    {
                                        ActionsClass.Action.PlaySoundAsync((byte)TSDUtils.ActionCode.StrangeBox);
                                        ActionsClass.Action.PlayVibroAsync((byte)TSDUtils.ActionCode.StrangeBox);

                                        //using (DialogForm dlgfrm =
                                        //new DialogForm(
                                        DialogResult dr = DialogFrm.ShowMessage(
                                            "Товар не входит в короб!"
                                            , string.Format("Принять этот товар {0}", row.Barcode)//string.Format("Посчитано: {0} кодов", totalBk)
                                            , row.ProductName
                                            , "Прием товара");//)
                                        //{
                                        if (dr == DialogResult.Yes)
                                        {
                                            inventRow.NavCode = row.NavCode;
                                            ActionsClass.Action.BoxWProductsActionProc(
                                                        row,
                                                        inventRow,
                                                        quantityKoeff
                                                        );
                                            return;
                                        }
                                        //}

                                    }
                                }
                                finally
                                {
                                    quantityLabel.Visible = false;
                                    quantityKoeff = 1;
                                }
                                break;
#endregion
                            }
                        case WorkMode.SimpleIncome:
                            {
                                #region income
                                inventRow.NavCode = row.NavCode;

                                if (row.AcceptDefect == 0)
                                {
                                    /*
2. Нужно изменить функционирование кнопки "5 - накладные".
Сначала там вопрос насчет "поданных на возврат" - оставляем как есть.
Изменения в самом просчете товара.
* Если поле 11 у товара = 1, то оставляем "как есть"
* Если поле 11 у товара = 0, то где-то ярко пишем "БРАК"
при этом посчет товара не меняется, формируетс один файл на накладную, как и сейчас.
                                     */
                                    if (row["ProductName"] == System.DBNull.Value)
                                        label6.Text = "Нет названия";
                                    else
                                        if (row.ProductName.Length <30)
                                            label6.Text = row.ProductName;
                                        else
                                            label6.Text = row.ProductName.Substring(0, 30);

                                    label5.Text = "      БРАК     ";
                                    label5.BackColor = Color.Red;


                                }
                                else
                                {

                                    //label5.BackColor = System.Drawing.Color.PaleGreen;
                                    if (_invMode == InventarMode.UseReturns)
                                        label5.BackColor = System.Drawing.Color.Turquoise;
                                    else
                                        label5.BackColor = System.Drawing.Color.PaleGreen;

                                    

                                    if (row.ProductName.Length > 15)
                                    {
                                        label5.Text = row.ProductName.Substring(0, 15);
                                        label6.Text = row.ProductName.Substring(15);
                                    }
                                    else
                                        label5.Text = row.ProductName;
                                }


                                if (_invMode == InventarMode.DontUseReturns)
                                {
                                    //inventRow.NavCode = row.NavCode;
                                    ActionsClass.Action.InvokeAction(TSDUtils.ActionCode.SimpleIncome,
                                        row,
                                        inventRow
                                        );
                                }
                                else
                                {
                                    ProductsDataSet.DocsTblRow[] arrofdocs = ActionsClass.Action.GetDataByNavCodeAndType(
                                        row.NavCode,
                                        (byte)TSDUtils.ActionCode.Returns);

                                    if (arrofdocs != null &&
                                        arrofdocs.Length > 0)
                                    {
                                        ActionsClass.Action.PlaySoundAsync((byte)TSDUtils.ActionCode.ReturnInInventory);
                                        ActionsClass.Action.PlayVibroAsync((byte)TSDUtils.ActionCode.ReturnInInventory);

                                        string str = string.Format("{0}-{1}-{2}",
                                            arrofdocs[0].DocId,
                                            arrofdocs[0].Text2,
                                            arrofdocs[0].Text1);



                                        DialogResult dr = DialogFrm.ShowMessage(
                                          row.NavCode + " " + row.ProductName
                                        , "Этот товар участвует в возврате"
                                        , str
                                        , "Режим накладных");
                                    }
                                    else
                                    {
                                        //inventRow.NavCode = row.NavCode;
                                        ActionsClass.Action.InvokeAction(TSDUtils.ActionCode.SimpleIncome,
                                            row,
                                            inventRow
                                            );
                                    }
                                }
                                #endregion
                                break;
                            }
                        case WorkMode.ReturnBoxWProducts:
                            {
                                #region box
                                try
                                {
                                //ProductsDataSet.DocsTblRow docRow =
                                //    ActionsClass.Action.GetActualBoxReturnsDocRow();

                                    //if (docRow != null)
                                    //{
                                        /*
                                         * ScannedProductsDataSet.ScannedBarcodesRow srows
                                            = ActionsClass.Action.FindByBarcodeDocTypeDocId(row.Barcode.ToString(),
                                            (byte)TSDUtils.ActionCode.BoxWProducts,
                                            inventRow.DocId
                                            );*/

                                        //ScannedProductsDataSet.ScannedBarcodesRow[] rowsS
                                        //    = ActionsClass.Action.FindByDocIdAndDocType(inventRow.DocId,
                                        //    (byte)TSDUtils.ActionCode.BoxWProducts);

                                        //int fQty = 0;
                                        //for (int i = 0; i < rowsS.Length; i++)
                                        //{
                                        //    if (rowsS[i].Barcode == currentProductRow.Barcode)
                                        //        fQty += rowsS[i].FactQuantity;
                                        //}

                                        //if (rowsS.Length > 0)
                                        //{
                                        //    if (docRow.Quantity < (fQty + quantityKoeff))
                                        //    {
                                        //        ActionsClass.Action.PlaySoundAsync((byte)TSDUtils.ActionCode.AlreadyAccepted);
                                        //        ActionsClass.Action.PlayVibroAsync((byte)TSDUtils.ActionCode.AlreadyAccepted);


                                        //        //using (DialogForm dlgfrm =
                                        //        //new DialogForm(
                                        //        DialogResult dr = DialogFrm.ShowMessage(
                                        //    string.Format("Товар уже принят {0} из {1}",
                                        //    fQty,
                                        //    docRow.Quantity)
                                        //    , string.Format("Принять еще {0} шт", quantityKoeff)//string.Format("Посчитано: {0} кодов", totalBk)
                                        //    , row.ProductName
                                        //    , "Прием товара");//)
                                        //        // {
                                        //        if (dr == DialogResult.Yes)
                                        //        {
                                        //            //inventRow.NavCode = row.NavCode;
                                        //            ActionsClass.Action.BoxWProductsActionProc(
                                        //                row,
                                        //                docRow,
                                        //                quantityKoeff
                                        //                );
                                        //            return;//приняли
                                        //        }
                                        //        else //не хотим принимать
                                        //            return;
                                        //        //}
                                        //    }
                                        //}
                                        //если не сработали условия - то принимаем
                                        //inventRow.NavCode = row.NavCode;
                                    ActionsClass.Action.ReturnBoxWProductsActionProc(
                                                             row,
                                                             inventRow
                                                             );
                                        /*ActionsClass.Action.InvokeAction(TSDUtils.ActionCode.BoxWProducts,
                                            row,
                                            docRow
                                            );*/


                                    //}
                                    //else
                                    //{
                                    //    ActionsClass.Action.PlaySoundAsync((byte)TSDUtils.ActionCode.StrangeBox);
                                    //    ActionsClass.Action.PlayVibroAsync((byte)TSDUtils.ActionCode.StrangeBox);

                                    //    //using (DialogForm dlgfrm =
                                    //    //new DialogForm(
                                    //    DialogResult dr = DialogFrm.ShowMessage(
                                    //        "Товар не входит в короб!"
                                    //        , string.Format("Принять этот товар {0}", row.Barcode)//string.Format("Посчитано: {0} кодов", totalBk)
                                    //        , row.ProductName
                                    //        , "Прием товара");//)
                                    //    //{
                                    //    if (dr == DialogResult.Yes)
                                    //    {
                                    //        inventRow.NavCode = row.NavCode;
                                    //        ActionsClass.Action.BoxWProductsActionProc(
                                    //                    row,
                                    //                    inventRow,
                                    //                    quantityKoeff
                                    //                    );
                                    //        return;
                                    //    }
                                    //    //}

                                    //}
                                //}
                                finally
                                {
                                    //quantityLabel.Visible = false;
                                    //quantityKoeff = 1;
                                }
                                break;
                                #endregion
                            }
                            
                        default:
                            {
                                currentdocRows = null;
                                currentProductRow = null;
                                ActionsClass.Action.InvokeAction(TSDUtils.ActionCode.NotFound, null, null);
                                label5.Text = "...Действие ";
                                label6.Text = "  не определено ...";
                                label17.Text = "";
                                break;
                            }
                    }
#region old code
                    /*if (_mode == WorkMode.ProductsScan)
                    {
                        ProductsDataSet.DocsTblRow[] docRows =
                            ActionsClass.Action.GetDataByNavCode(row.NavCode);
                        actionDict.Clear();
                        currentdocRows = docRows;

                        if (docRows != null)
                        {

                            foreach (ProductsDataSet.DocsTblRow docRow in docRows)
                            {
                                ScannedProductsDataSet.ScannedBarcodesRow scannedRow =
                                    ActionsClass.Action.AddScannedRow(
                                    row.Barcode,
                                    docRow.DocType,
                                    docRow.DocId,
                                    docRow.Quantity,
                                    docRow.Priority);
                            //    _scannedProducts.ScannedBarcodes.FindByBarcodeDocTypeDocId(
                            //    row.Barcode,
                            //    docRow.DocType,
                            //    docRow.DocId);
                            //if (scannedRow == null)
                            //{
                            //    scannedRow =
                            //        _scannedProducts.ScannedBarcodes.NewScannedBarcodesRow();
                            //    scannedRow.Barcode = row.Barcode;
                            //    scannedRow.DocId = docRow.DocId;
                            //    scannedRow.DocType = docRow.DocType;
                            //    scannedRow.PlanQuanity = docRow.Quantity;
                            //    scannedRow.Priority = docRow.Priority;
                            //    scannedRow.ScannedDate = DateTime.Today;
                            //    scannedRow.TerminalId = Program.TerminalId;
                            //    _scannedProducts.ScannedBarcodes.AddScannedBarcodesRow(scannedRow);
                            //}
                     
                                byte actionCodes = docRow.DocType;
                                if (!actionDict.ContainsKey(actionCodes))
                                    actionDict.Add(actionCodes, docRow);
                            }
                            foreach (byte acode in actionDict.Keys)
                            {
                                ActionsClass.Action.InvokeAction((TSDUtils.ActionCode)acode, row, actionDict[acode]);
                                //this.Refresh();
                            }
                        }
                        else
                        {
                            ActionsClass.Action.InvokeAction(TSDUtils.ActionCode.DocNotFound, row, null);
                        }
                    }
                    else
                    {
                        if (_mode == WorkMode.SimpleIncome)
                        {
                            inventRow.NavCode = row.NavCode;
                            ActionsClass.Action.InvokeAction(TSDUtils.ActionCode.SimpleIncome,
                                row,
                                inventRow
                                );
                        }
                        if (_mode == WorkMode.InventarScan)
                        {
                            if (_invMode == InventarMode.DontUseReturns)
                            {
                                inventRow.NavCode = row.NavCode;
                                ActionsClass.Action.InvokeAction(TSDUtils.ActionCode.InventoryGlobal,
                                    row,
                                    inventRow
                                    );
                            }
                            else
                            {
                                ProductsDataSet.DocsTblRow[] arrofdocs = ActionsClass.Action.GetDataByNavCodeAndType(
                                    row.NavCode,
                                    (byte)TSDUtils.ActionCode.Returns);

                                if (arrofdocs != null &&
                                    arrofdocs.Length > 0)
                                {
                                    ActionsClass.Action.PlaySoundAsync((byte)TSDUtils.ActionCode.ReturnInInventory);
                                    ActionsClass.Action.PlayVibroAsync((byte)TSDUtils.ActionCode.ReturnInInventory);

                                    string str = string.Format("{0}-{1}-{2}",
                                        arrofdocs[0].DocId,
                                        arrofdocs[0].Text2,
                                        arrofdocs[0].Text1);



                                    DialogResult dr = DialogFrm.ShowMessage(
                                      row.NavCode + " " + row.ProductName
                                    , "Этот товар участвует в возврате"
                                    , str
                                    , "Режим инвентаризации");
                                }
                                else
                                {
                                    inventRow.NavCode = row.NavCode;
                                    ActionsClass.Action.InvokeAction(TSDUtils.ActionCode.InventoryGlobal,
                                        row,
                                        inventRow
                                        );
                                }

                            }

                            //this.Refresh();
                            //ActionsClass.Action.InventoryGlobalActionProc(
                            //    row,
                            //    inventRow);


                        }
                        else
                        {//BoxScan
                            //_mode == WorkMode.BoxScan
                            try
                            {
                                ProductsDataSet.DocsTblRow docRow =
                                    ActionsClass.Action.GetDataByNavcodeDocIdAndType(row.NavCode,
                                        inventRow.DocId,
                                        (byte)TSDUtils.ActionCode.BoxWProducts
                                    );
                                if (docRow != null)
                                {
                                    //
                                    //  ScannedProductsDataSet.ScannedBarcodesRow srows
                                    //    = ActionsClass.Action.FindByBarcodeDocTypeDocId(row.Barcode.ToString(),
                                    //    (byte)TSDUtils.ActionCode.BoxWProducts,
                                    //    inventRow.DocId
                                    //    );

                                    ScannedProductsDataSet.ScannedBarcodesRow[] rowsS
                                        = ActionsClass.Action.FindByDocIdAndDocType(inventRow.DocId,
                                        (byte)TSDUtils.ActionCode.BoxWProducts);

                                    int fQty = 0;
                                    for (int i = 0; i < rowsS.Length; i++)
                                    {
                                        if (rowsS[i].Barcode == currentProductRow.Barcode)
                                            fQty += rowsS[i].FactQuantity;
                                    }

                                    if (rowsS.Length > 0)
                                    {
                                        if (docRow.Quantity < (fQty + quantityKoeff))
                                        {
                                            ActionsClass.Action.PlaySoundAsync((byte)TSDUtils.ActionCode.AlreadyAccepted);
                                            ActionsClass.Action.PlayVibroAsync((byte)TSDUtils.ActionCode.AlreadyAccepted);


                                            //using (DialogForm dlgfrm =
                                            //new DialogForm(
                                            DialogResult dr = DialogFrm.ShowMessage(
                                        string.Format("Товар уже принят {0} из {1}",
                                        fQty,
                                        docRow.Quantity)
                                        , string.Format("Принять еще {0} шт", quantityKoeff)//string.Format("Посчитано: {0} кодов", totalBk)
                                        , row.ProductName
                                        , "Прием товара");//)
                                            // {
                                            if (dr == DialogResult.Yes)
                                            {
                                                //inventRow.NavCode = row.NavCode;
                                                ActionsClass.Action.BoxWProductsActionProc(
                                                    row,
                                                    docRow,
                                                    quantityKoeff
                                                    );
                                                return;//приняли
                                            }
                                            else //не хотим принимать
                                                return;
                                            //}
                                        }
                                    }
                                    //если не сработали условия - то принимаем
                                    //inventRow.NavCode = row.NavCode;
                                    ActionsClass.Action.BoxWProductsActionProc(
                                                         row,
                                                         docRow,
                                                         quantityKoeff
                                                         );
                                    //ActionsClass.Action.InvokeAction(TSDUtils.ActionCode.BoxWProducts,
                                    //    row,
                                    //    docRow
                                    //    );


                                }
                                else
                                {
                                    ActionsClass.Action.PlaySoundAsync((byte)TSDUtils.ActionCode.StrangeBox);
                                    ActionsClass.Action.PlayVibroAsync((byte)TSDUtils.ActionCode.StrangeBox);

                                    //using (DialogForm dlgfrm =
                                    //new DialogForm(
                                    DialogResult dr = DialogFrm.ShowMessage(
                                        "Товар не входит в короб!"
                                        , string.Format("Принять этот товар {0}", row.Barcode)//string.Format("Посчитано: {0} кодов", totalBk)
                                        , row.ProductName
                                        , "Прием товара");//)
                                    //{
                                    if (dr == DialogResult.Yes)
                                    {
                                        inventRow.NavCode = row.NavCode;
                                        ActionsClass.Action.BoxWProductsActionProc(
                                                    row,
                                                    inventRow,
                                                    quantityKoeff
                                                    );
                                        return;
                                    }
                                    //}

                                }
                            }
                            finally
                            {
                                quantityLabel.Visible = false;
                                quantityKoeff = 1;
                            }
                            //this.Refresh();

                        }
                        
                    }*/

#endregion 

                }
                else
                {
                    currentdocRows = null;
                    currentProductRow = null;
                    ActionsClass.Action.InvokeAction(TSDUtils.ActionCode.NotFound, null, null);
                    label5.Text = "...Товар не ";
                    label6.Text = "   найден...";
                    label17.Text = "";
                    //NativeClass.Play("ding.wav");
                }
            }
            finally
            {
                navCodeTB.SelectAll();
                this.Refresh();
            }
        }
Exemple #9
0
 public void InvokeAction(TSDUtils.ActionCode ac, ProductsDataSet.ProductsTblRow datarow, ProductsDataSet.DocsTblRow docsRow)
 {
     if (actionsDict.ContainsKey(ac))
     {
         actionsDict[ac].Invoke(datarow, docsRow);
     }
             
 }
Exemple #10
0
 public void PlayVibroAsyncAction(ProductsDataSet.DocsTblRow docsRow)
 {
     //System.Threading.Thread.Sleep(1000);
     ActionsClass.Action.PlayVibroAsync(docsRow.VibroCode);
 }
Exemple #11
0
 public void DocNotFoundActionProc(ProductsDataSet.ProductsTblRow datarow, ProductsDataSet.DocsTblRow docsRow)
 {
     PlayVibroAsync((byte)TSDUtils.ActionCode.DocNotFound);
     PlaySoundAsync((byte)TSDUtils.ActionCode.DocNotFound);
 }
Exemple #12
0
        public void BoxWProductsActionProc(ProductsDataSet.ProductsTblRow datarow, ProductsDataSet.DocsTblRow docsRow, int quantityFoef)
        {
            //ScannedProductsDataSet.ScannedBarcodesRow[] r =
            //    _scannedProducts.ScannedBarcodes.FindByBarcodeAndDocType(datarow.Barcode, docsRow.DocType);
            ScannedProductsDataSet.ScannedBarcodesRow scannedRow = null;
            //for (int i = 0; i < quantityFoef; i++)
            //{
                scannedRow = ActionsClass.Action.AddScannedRow(
                                   datarow.Barcode,
                                   docsRow.DocType,
                                   docsRow.DocId,
                                   docsRow.Quantity,
                                   0);

                //if (scannedRow == null)
                //{
                //    return 
                //    //r = new ScannedProductsDataSet.ScannedBarcodesRow[1];
                //    //r[0] = scannedRow;
                //}

                //for (int i = 0; i < r.Length; i++)
                //{

                scannedRow.FactQuantity += quantityFoef;
            //}
            PlayVibroAsyncAction(docsRow);
            PlaySoundAsyncAction(docsRow);
            //PrintLabelAsync(datarow, docsRow);
            if (OnActionCompleted != null)
                OnActionCompleted(docsRow, scannedRow);
            //break;


            //}
        }
Exemple #13
0
        public void ReturnBoxWProductsActionProc(ProductsDataSet.ProductsTblRow datarow, ProductsDataSet.DocsTblRow docsRow)
        {
            //ScannedProductsDataSet.ScannedBarcodesRow[] r =
            //    _scannedProducts.ScannedBarcodes.FindByBarcodeAndDocType(datarow.Barcode, docsRow.DocType);
            ScannedProductsDataSet.ScannedBarcodesRow scannedRow =
                               ActionsClass.Action.AddScannedRow(
                               datarow.Barcode,
                               ((byte)TSDUtils.ActionCode.ReturnBoxWProducts),
                               docsRow.DocId,
                               docsRow.Quantity,
                               docsRow.Priority);


            PlayVibroAsyncAction(docsRow);
            PlaySoundAsyncAction(docsRow);
            scannedRow.FactQuantity += 1;
            //PrintLabelAsync(datarow, docsRow);
            if (OnActionCompleted != null)
                OnActionCompleted(docsRow, scannedRow);
            //break;


            //}
        }
Exemple #14
0
        public void RemoveActionProc(ProductsDataSet.ProductsTblRow datarow, ProductsDataSet.DocsTblRow docsRow)
        {
            ScannedProductsDataSet.ScannedBarcodesRow[] r =
                _scannedProducts.ScannedBarcodes.FindByBarcodeAndDocType(datarow.Barcode, docsRow.DocType);
            if (r != null)
            {
                for (int i = 0; i < r.Length; i++)
                {
                    if (r[i].FactQuantity < r[i].PlanQuanity)
                    {
                        //r[i].FactQuantity += 1;
                        try
                        {
                            PlayVibroAsyncAction(docsRow);
                            PlaySoundAsyncAction(docsRow);
                            /*PrintLabelAsync(datarow, docsRow);
                            r[i].FactQuantity += 1;
                            */
                            uint shablonCode = TSDUtils.ActionCodeDescription.ActionDescription.GetShablon(docsRow.DocType, (uint)docsRow.LabelCode);
                            if (PrintLabel(datarow, docsRow, shablonCode))

                            //if (PrintLabel(datarow, docsRow, docsRow.LabelCode))
                            {
                                r[i].FactQuantity += 1;
                                //PlayVibroAsyncAction(docsRow);
                                //PlaySoundAsyncAction(docsRow);
                            }
                            else
                            {
                                PlayVibroAsync((byte)TSDUtils.ActionCode.NotFound);
                                PlaySoundAsync((byte)TSDUtils.ActionCode.NotFound);
                            }


                            if (r[i].FactQuantity == r[i].PlanQuanity)
                            {

                                using (RemoveFinishForm frm = new RemoveFinishForm(datarow, docsRow))
                                {
                                    frm.ShowDialog();

                                }
                            }
                        }
                        finally
                        {
                            if (OnActionCompleted != null)
                                OnActionCompleted(docsRow, r[i]);
                        }
                        break;
                    }
                    
                }
                //this.actionLabel.Text = TSDUtils.ActionCodeDescription.ActionDescription[ac];
 

            }
            /*ScannedProductsDataSet.ScannedBarcodesRow r = _scannedProducts.ScannedBarcodes.UpdateQuantity(
            docsRow.Barcode, docsRow.DocType, 1);
            if (r != null)
            {
                //TSDUtils.ActionCode ac = (TSDUtils.ActionCode)docsRow.DocType;

                if (r.FactQuantity == r.PlanQuanity)
                {
                    using (RemoveFinishForm frm = new RemoveFinishForm())
                    {
                        frm.ShowDialog();
                    }
                }
                //this.actionLabel.Text = TSDUtils.ActionCodeDescription.ActionDescription[ac];
                if (OnActionCompleted != null)
                    OnActionCompleted(docsRow, r);
            }*/

        }
Exemple #15
0
        public void ReturnActionProc(ProductsDataSet.ProductsTblRow datarow, ProductsDataSet.DocsTblRow docsRow)
        {
            ScannedProductsDataSet.ScannedBarcodesRow[] r =
                _scannedProducts.ScannedBarcodes.FindByBarcodeAndDocType(datarow.Barcode, docsRow.DocType);
            if (r != null)
            {
                for (int i = 0; i < r.Length; i++)
                {
                    
                    try
                    {
                       
                        PlayVibroAsyncAction(docsRow);
                        PlaySoundAsyncAction(docsRow);
                         /*PrintLabelAsync(datarow, docsRow);
                        r[i].FactQuantity += 1;
                         */
                        uint shablonCode = TSDUtils.ActionCodeDescription.ActionDescription.GetShablon(docsRow.DocType, (uint)docsRow.LabelCode);
                        if (PrintLabel(datarow, docsRow, shablonCode))
                        //if (PrintLabel(datarow, docsRow, docsRow.LabelCode))
                        {
                            r[i].FactQuantity += 1;
                            //PlayVibroAsyncAction(docsRow);
                            //PlaySoundAsyncAction(docsRow);
                        }
                        else
                        {
                            PlayVibroAsync((byte)TSDUtils.ActionCode.NotFound);
                            PlaySoundAsync((byte)TSDUtils.ActionCode.NotFound);
                        }

                    }
                    finally
                    {
                        if (OnActionCompleted != null)
                            OnActionCompleted(docsRow, r[i]);
                    }

                    /*if (r[i].FactQuantity < r[i].PlanQuanity)
                    {
                        r[i].FactQuantity += 1;
                        PlayVibroAsyncAction(docsRow);
                        PlaySoundAsyncAction(docsRow);
                        PrintLabelAsync(datarow, docsRow);
                        if (r[i].FactQuantity == r[i].PlanQuanity)
                        {

                            using (RemoveFinishForm frm = new RemoveFinishForm(datarow,docsRow))
                            {
                                frm.ShowDialog();
                                
                            }

                        }
                        if (OnActionCompleted != null)
                            OnActionCompleted(docsRow, r[i]);
                        break;
                    }
                    */
                }
            }
            System.Threading.Thread.Sleep(1000);
        }
        void Action_OnActionCompleted(ProductsDataSet.DocsTblRow docsRow, ScannedProductsDataSet.ScannedBarcodesRow scannedRow)
        {
            if (this.InvokeRequired)
            {
                ActionsClass.ActionCompleted del =
                    new ActionsClass.ActionCompleted(Action_OnActionCompleted);
                this.Invoke(del,
                    docsRow,
                    scannedRow);
            }
            else
            {
                this.label18.Text = "";
                currentDocRow = docsRow;
                this.actionLabel.Text = TSDUtils.ActionCodeDescription.ActionDescription[docsRow.DocType];

                label20.Text = (scannedRow["PlanQuanity"] == System.DBNull.Value ||
                                scannedRow["PlanQuanity"] == null) ? string.Empty : scannedRow.PlanQuanity.ToString();

                label21.Text = (scannedRow["FactQuantity"] == System.DBNull.Value ||
                                scannedRow["FactQuantity"] == null) ? string.Empty : scannedRow.FactQuantity.ToString();



                if (docsRow.DocType == (byte)TSDUtils.ActionCode.BoxWProducts)
                {
                    //label21.Text = (scannedRow["FactQuantity"] == System.DBNull.Value ||
                    //            scannedRow["FactQuantity"] == null) ? string.Empty : scannedRow.FactQuantity.ToString();

                    ScannedProductsDataSet.ScannedBarcodesRow[] rowsS
                           = ActionsClass.Action.FindByDocIdAndDocType(scannedRow.DocId,
                           scannedRow.DocType);
                    int fQty = 0;
                    for (int i = 0; i < rowsS.Length; i++)
                    {
                        if (rowsS[i].Barcode == currentProductRow.Barcode)
                            fQty += rowsS[i].FactQuantity;
                    }

                    label21.Text = fQty.ToString();

                    if (fQty == scannedRow.PlanQuanity)
                    {


                        ProductsDataSet.DocsTblRow[] docsRows =
                            ActionsClass.Action.GetDataByDocIdAndType(scannedRow.DocId,
                            scannedRow.DocType);

                        int pQuantity = 0;
                        int fQuantity = 0;
                        for (int i = 0; i < docsRows.Length; i++)
                            pQuantity += docsRows[i].Quantity;

                        for (int i = 0; i < rowsS.Length; i++)
                            fQuantity += rowsS[i].FactQuantity;
                        if (pQuantity == fQuantity)
                        {
                            //907218|3001011908672|7|1|8|2011-09-03|7|7|7|907218|002355438|03.09.2011
                            ProductsDataSet.DocsTblRow[] docsNaklRows =
                                ActionsClass.Action.GetDataByDocIdAndType(scannedRow.DocId,
                                (byte)TSDUtils.ActionCode.IncomeBox);


                            //using (DialogForm dlgfrm =
                            //    new DialogForm(
                            DialogResult dr = DialogFrm.ShowMessage(
                                    "Короб по накладной"
                                    , docsNaklRows[0].Text2
                                    , "принят полностью!"
                                    , "Прием товара/nПо нажатию ЭНТЕР ВЫЙТИ в меню");//)
                            ActionsClass.Action.PlaySound(250);
                            //{
                            if (dr == DialogResult.Yes)
                            {
                                //inventRow.NavCode = row.NavCode;
                                //ActionsClass.Action.InvokeAction(TSDUtils.ActionCode.BoxWProducts,
                                //    row,
                                //    inventRow
                                //    );
                            }
                            this.navCodeTB.Text = "";
                            //}
                        }
                    }
                }

                this.Refresh();
            }
        }
Exemple #17
0
        public void ChangeQtyPosition(
            ProductsDataSet.DocsTblRow docsRow,
            ScannedProductsDataSet.ScannedBarcodesRow scannedRow,
            int diffQty)
        {
            //ScannedProductsDataSet.ScannedBarcodesRow[] r =
            //_scannedProducts.ScannedBarcodes.FindByBarcodeAndDocType(datarow.Barcode, docsRow.DocType);



            //if (scannedRow != null && //existing row
            //    scannedRow.Priority == 0 //not closed
            //    && scannedRow["FactQuantity"] != System.DBNull.Value
            //    && scannedRow.FactQuantity > 0 //scanned already
            //    && Program.СurrentInvId != string.Empty
            //    )
            //{
            //DoScanEvents = false;
            scannedRow.FactQuantity = scannedRow.FactQuantity + diffQty;

            if (OnActionCompleted != null && docsRow != null)
                OnActionCompleted(docsRow, scannedRow);

            return;
            #region old action
            if (diffQty < 0)
            {
                //scannedRow.FactQuantity = 1;
                for (int i = diffQty; i < 0; i++)
                {
                    
                    scannedRow.FactQuantity -= 1;
                    //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}",
                                    scannedRow.Barcode,
                                    scannedRow.DocId,
                                    scannedRow.DocType,
                                    -1,
                                    (scannedRow["ScannedDate"] == System.DBNull.Value) ?
                                      DateTime.Today.AddHours(_timeShift).ToString("dd.MM.yyyy")
                                      : scannedRow.ScannedDate.AddHours(_timeShift).ToString("dd.MM.yyyy"),

                                    (scannedRow["TerminalId"] == System.DBNull.Value) ?
                                       string.Empty : scannedRow.TerminalId.ToString(),
                                    scannedRow.Priority,
                                    scannedRow.PlanQuanity
                                    );
                        //writer.WriteLine(s);
                        //byte[] buff = System.Text.Encoding.UTF8.GetBytes(string.Concat(s, '\n'));
                        byte[] buff = System.Text.Encoding.UTF8.GetBytes(string.Concat(s, "\r\n"));

                        writer.Write(buff, 0, buff.Length);
                        writer.Flush();
                    }

                }
            }
            else
            {
                if (diffQty > 0)
                {
                    for (int i = 0; i < diffQty; i++)
                    {
                        scannedRow.FactQuantity += 1;
                        //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}",
                                        scannedRow.Barcode,
                                        scannedRow.DocId,
                                        scannedRow.DocType,
                                        1,
                                        (scannedRow["ScannedDate"] == System.DBNull.Value) ?
                                          DateTime.Today.AddHours(_timeShift).ToString("dd.MM.yyyy")
                                          : scannedRow.ScannedDate.AddHours(_timeShift).ToString("dd.MM.yyyy"),

                                        (scannedRow["TerminalId"] == System.DBNull.Value) ?
                                           string.Empty : scannedRow.TerminalId.ToString(),
                                        scannedRow.Priority,
                                        scannedRow.PlanQuanity
                                        );
                            //writer.WriteLine(s);
                            byte[] buff = System.Text.Encoding.UTF8.GetBytes(string.Concat(s, "\r\n"));
                            //byte[] buff = System.Text.Encoding.UTF8.GetBytes(string.Concat(s, '\n'));
                            writer.Write(buff, 0, buff.Length);
                            writer.Flush();
                        }
                    }
                }
            }
            #endregion

            //DoScanEvents = true;
            //if (OnActionCompleted != null && docsRow != null)
            //    OnActionCompleted(docsRow, scannedRow);
            
            //}

            //}
        }
 public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(global::System.Xml.Schema.XmlSchemaSet xs) {
     ProductsDataSet ds = new ProductsDataSet();
     global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType();
     global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence();
     global::System.Xml.Schema.XmlSchemaAny any = new global::System.Xml.Schema.XmlSchemaAny();
     any.Namespace = ds.Namespace;
     sequence.Items.Add(any);
     type.Particle = sequence;
     global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable();
     if (xs.Contains(dsSchema.TargetNamespace)) {
         global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream();
         global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream();
         try {
             global::System.Xml.Schema.XmlSchema schema = null;
             dsSchema.Write(s1);
             for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext(); ) {
                 schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current));
                 s2.SetLength(0);
                 schema.Write(s2);
                 if ((s1.Length == s2.Length)) {
                     s1.Position = 0;
                     s2.Position = 0;
                     for (; ((s1.Position != s1.Length) 
                                 && (s1.ReadByte() == s2.ReadByte())); ) {
                         ;
                     }
                     if ((s1.Position == s1.Length)) {
                         return type;
                     }
                 }
             }
         }
         finally {
             if ((s1 != null)) {
                 s1.Close();
             }
             if ((s2 != null)) {
                 s2.Close();
             }
         }
     }
     xs.Add(dsSchema);
     return type;
 }
Exemple #19
0
 /// <summary>
 /// Печать этикетки. На вход - строка данных и код действия
 /// Код этикетки определяется динамически на основе поля в строке данных и кода действия.
 /// </summary>
 /// <param name="datarow">Строка с данными</param>
 /// <param name="code">Код действия</param>
 public void PrintLabel(ProductsDataSet.ProductsTblRow datarow, ProductsDataSet.DocsTblRow docRow)
 {
     uint shablonCode = TSDUtils.ActionCodeDescription.ActionDescription.GetShablon(docRow.DocType, (uint)docRow.LabelCode);
     PrintLabel(datarow,docRow,shablonCode);
 }
Exemple #20
0
        //public ViewDocsForm(ProductsDataSet.ProductsTblRow productRow):this()
        //{
        //    this.panel2.SuspendLayout();
        //    this.SuspendLayout();
        //    _productRow = productRow;
        //    StringBuilder sb = new StringBuilder();
        //    sb.AppendFormat(System.Globalization.CultureInfo.CurrentCulture,
        //        "Код: {0} \nШтрихкод: {1} \nНазвание: {2}",
        //        _productRow.NavCode,
        //        _productRow.Barcode,
        //        _productRow.ProductName);
        //    this.label.Text = sb.ToString();

        //    Label l = new Label();
        //    l.Size = new System.Drawing.Size(231, 90);
        //    l.Name = string.Format("label{0}", 0);
        //    l.Left = 0;
        //    l.Top = 0;
        //    l.Text = "По данному товару \nнет никаких документов, \nнажмите желтую кнопку \nеще раз для выхода";
        //    l.BackColor = System.Drawing.Color.PaleGreen;
            
        //    this.panel2.Controls.Add(l);
        //    this.panel1.ResumeLayout(false);
        //    this.ResumeLayout();
        //}
        public ViewDocsForm(ProductsDataSet.ProductsTblRow productRow,
            ProductsDataSet.DocsTblRow[] docsRows,
            ScannedProductsDataSet scannedProducts):this()
        {
            this.panel2.SuspendLayout();
            this.SuspendLayout();

            _productRow = productRow;
            _scannedProducts = scannedProducts;
            _docsRows = docsRows;
            //this.listBox1.KeyDown += new KeyEventHandler(listBox1_KeyDown);
            this.Load += new EventHandler(ViewDocsForm_Load);
            int docCounter = 0;
            //this.Paint += new PaintEventHandler(ViewDocsForm_Paint);
            if (_productRow != null)
            {
                StringBuilder sb = new StringBuilder();
                sb.AppendFormat(System.Globalization.CultureInfo.CurrentCulture,
                    "Код: {0} \nШтрихкод: {1} \nНазвание: {2}",
                    _productRow.NavCode,
                    _productRow.Barcode,
                    _productRow.ProductName);
                this.label.Text = sb.ToString();

                if (_docsRows != null && _docsRows.Length > 0)
                {
                    foreach (ProductsDataSet.DocsTblRow doc in _docsRows)
                    {

                        ScannedProductsDataSet.ScannedBarcodesRow srow =
                        _scannedProducts
                                .ScannedBarcodes
                                .FindByBarcodeDocTypeDocId(_productRow.Barcode,
                                                            doc.DocType,
                                                            doc.DocId);

                        DocumentClass d = new DocumentClass();
                        d.DocDate = doc.DocumentDate;
                        d.DocId = doc.DocId;
                        d.DocType = doc.DocType;
                        d.Text1 = doc.Text1;
                        d.Text2 = doc.Text2;
                        d.Text3 = doc.Text3;

                        d.PlanQuantity = doc.Quantity;
                        if (srow != null &&
                            srow["FactQuantity"] != System.DBNull.Value)
                            d.FactQuantity = srow.FactQuantity;
                        else
                            d.FactQuantity = 0;



                        Label l = new Label();
                        l.Size = new System.Drawing.Size(231, 60);
                        l.Name = string.Format("label{0}", documents.Count);
                        l.Left = 0;
                        l.Top = documents.Count * 60;
                        l.Text = d.ToString();
                        l.BackColor = System.Drawing.Color.PaleGreen;
                        l.TextAlign = ContentAlignment.TopCenter;
                        documents.Add(d);
                        this.panel2.Controls.Add(l);
                        selectedItem = 0;
                        docCounter++;

                    }
                }
               else
                {
                    Label l = new Label();
                    l.Size = new System.Drawing.Size(231, 60);
                    l.Name = string.Format("label{0}", 0);
                    l.Left = 0;
                    l.Top = 0;
                    l.Text = "По данному товару \nнет никаких документов";
                    l.BackColor = System.Drawing.Color.PaleGreen;
                    l.TextAlign = ContentAlignment.TopCenter;
                    this.panel2.Controls.Add(l);
                    docCounter++;
                }
                Label l1 = new Label();
                l1.Size = new System.Drawing.Size(231, 30);
                l1.Name = string.Format("label{0}", docCounter + 1);
                l1.Left = 0;
                l1.Top = (docCounter * 60);
                l1.Text = "Нажмите желтую кнопку или Clr-Fn\nеще раз для выхода";
                l1.BackColor = System.Drawing.Color.PaleGreen;
                l1.TextAlign = ContentAlignment.TopCenter;
                this.panel2.Controls.Add(l1);

            }

            this.panel1.ResumeLayout(false);
            this.ResumeLayout();
        }
Exemple #21
0
        public bool PrintLabel(ProductsDataSet.ProductsTblRow datarow,  ProductsDataSet.DocsTblRow docRow, uint shablonCode)
        {
            int counter = 0;
            try
            {
                tryagain:
                if (btPrint.mEvt.WaitOne(Program.Default.WaitPrintTimeDefault, false) == false)
                {
                    counter++;
                    btPrint.SetStatusEvent("Ожидание очереди печати {0} попытка...",counter);
                    if (counter < 5)
                        goto tryagain;
                }

                string fileContent = string.Empty;
                int fileLength = 0;
                byte[] bArray = null;
                //uint shablonCode = TSDUtils.ActionCodeDescription.ActionDescription.GetShablon(docRow.DocType, (uint)docRow.LabelCode);
                if (labelCollection.ContainsKey(shablonCode))
                {
                    bArray = labelCollection[shablonCode];
                    fileLength = bArray.Length;
                    fileContent = TSDUtils.CustomEncodingClass.Encoding.GetString(bArray);
                }
                else
                {
                    string labelName = System.IO.Path.Combine(Program.StartupPath, string.Format("LABEL_{0}.DEF", shablonCode));
                    if (System.IO.File.Exists(labelName))
                    {
                        using (System.IO.FileStream fs = System.IO.File.OpenRead(labelName))
                        {
                            fileLength = (int)fs.Length;
                            bArray = new byte[fileLength];
                            fs.Read(bArray, 0, fileLength);
                            fs.Close();
                        }
                        labelCollection.Add(shablonCode, bArray);
                    }

                }
                //no print shablon - error
                if (bArray == null)
                    return false;

                fileContent = TSDUtils.CustomEncodingClass.Encoding.GetString(bArray);
                //btPrint.SetStatusEvent(fileContent);
                int i = fileContent.IndexOf("MAGICSTRING");
                if (i >= 0)
                {
                    string s1 = fileContent.Substring(0, i);
                    byte[] bArray2 = ReplaceAttr(TSDUtils.CustomEncodingClass.Encoding.GetBytes(s1), datarow, docRow);
                    //fileContent = TSDUtils.CustomEncodingClass.Encoding.GetString(bArray2);
                    //btPrint.SetStatusEvent(s1);
                    //return;
                    bool result1 = Print(bArray2);

                    string s2 = fileContent.Substring(i + "MAGICSTRING".Length+2);
                    byte[] bArray3 = ReplaceAttr(TSDUtils.CustomEncodingClass.Encoding.GetBytes(s2), datarow, docRow);
                    //fileContent = TSDUtils.CustomEncodingClass.Encoding.GetString(bArray2);
                    //btPrint.SetStatusEvent(s2);
                    //return;

                    bool result2 = Print(bArray3);
                    bArray2 = null;
                    bArray3 = null;
                    return result1 & result2;

                }
                else
                {


                    byte[] bArray2 = ReplaceAttr(bArray, datarow, docRow);
                    //fileContent = TSDUtils.CustomEncodingClass.Encoding.GetString(bArray2);
                    //btPrint.SetStatusEvent(fileContent);
                    //return;
                    bool result2 = Print(bArray2);
                    return result2;
                }
                /*
                try
                {
                    if (btPrint.Connected)
                    {
                        btPrint.Print(bArray2);
                        return true; //success print
                    }
                    else
                    {

                        btPrint.ConnToPrinter(Program.Settings.TypedSettings[0].BTPrinterAddress);
                        if (btPrint.Connected)
                        {
                            btPrint.Print(bArray2);
                            return true; //success print
                        }

                    }
                }
                catch
                {
                    btPrint.SetErrorEvent("Ошибка связи BlueTooth. Ждите 5 сек...");
                    //BTPrintClass.PrintClass.Reconnect();
                    System.Threading.Thread.Sleep(5000);
                    //btPrint.ConnToPrinter(Program.Settings.TypedSettings[0].BTPrinterAddress);
                    btPrint.Print(bArray2);
                    return true; //success print
                }*/
            }
            catch (BTConnectionFailedException)
            {
                try
                {
                    using (BTConnectionErrorForm frm =
                            new BTConnectionErrorForm())
                    {
                        if (frm.ShowDialog() == System.Windows.Forms.DialogResult.Yes)
                        {
                            BTPrintClass.PrintClass.Reconnect();
                            PrintLabel(datarow, docRow, shablonCode);
                            return true; //success print
                        }

                    }
                }
                catch (Exception err) 
                { 
                    BTPrintClass.PrintClass.SetErrorEvent(err.ToString());
                    BTPrintClass.PrintClass.SetErrorEvent("Ошибка! Отключите принтер и подключите заново");
                    return false;
                }
            }
            catch (Exception err)
            {
                BTPrintClass.PrintClass.SetErrorEvent(err.ToString());
                BTPrintClass.PrintClass.SetErrorEvent("Отключите принтер и подключите заново");
                return false;
            }
            return false;

        }