Esempio n. 1
0
        public void BeginInit2()
        {
            DataTable  table = new DataTable("table");
            DataView   dv    = new DataView();
            DataColumn col1  = new DataColumn("col1");
            DataColumn col2  = new DataColumn("col2");

            dvInitialized = false;

            dv.Initialized += new EventHandler(OnDataViewInitialized);

            dv.BeginInit();
            table.BeginInit();
            table.Columns.AddRange(new DataColumn[] { col1, col2 });

            dv.Table = table;
            AssertNull("#1", dv.Table);
            dv.EndInit();

            dv.Initialized -= new EventHandler(OnDataViewInitialized);

            AssertEquals("#2", table, dv.Table);
            AssertEquals("#3", 0, table.Columns.Count);

            table.EndInit();
            AssertEquals("#4", 2, table.Columns.Count);
            AssertEquals("DataViewInitialized #5", dvInitialized, true);
        }
Esempio n. 2
0
        public void BeginInit2()
        {
            DataTable  table = new DataTable("table");
            DataView   dv    = new DataView();
            DataColumn col1  = new DataColumn("col1");
            DataColumn col2  = new DataColumn("col2");

            _dvInitialized = false;

            dv.Initialized += new EventHandler(OnDataViewInitialized);

            dv.BeginInit();
            table.BeginInit();
            table.Columns.AddRange(new DataColumn[] { col1, col2 });

            dv.Table = table;
            Assert.Null(dv.Table);
            dv.EndInit();

            Assert.Null(dv.Table);
            Assert.Equal(0, table.Columns.Count);

            table.EndInit();

            dv.Initialized -= new EventHandler(OnDataViewInitialized); // this should not be unregistered before table.EndInit().

            Assert.Equal(2, table.Columns.Count);
            Assert.Equal(table, dv.Table);
            Assert.True(_dvInitialized);
        }
Esempio n. 3
0
        public void BeginInit()
        {
            DataTable  table = new DataTable("table");
            DataView   dv    = new DataView();
            DataColumn col1  = new DataColumn("col1");
            DataColumn col2  = new DataColumn("col2");

            dv.BeginInit();
            table.BeginInit();
            table.Columns.AddRange(new DataColumn[] { col1, col2 });

            dv.Table = table;
            AssertNull("#1", dv.Table);
            dv.EndInit();

            AssertEquals("#2", table, dv.Table);
            AssertEquals("#3", 0, table.Columns.Count);

            table.EndInit();
            AssertEquals("#4", 2, table.Columns.Count);
        }
Esempio n. 4
0
        public void BeginInit()
        {
            DataTable  table = new DataTable("table");
            DataView   dv    = new DataView();
            DataColumn col1  = new DataColumn("col1");
            DataColumn col2  = new DataColumn("col2");

            dv.BeginInit();
            table.BeginInit();
            table.Columns.AddRange(new DataColumn[] { col1, col2 });

            dv.Table = table;
            Assert.Null(dv.Table);
            dv.EndInit();

            Assert.Null(dv.Table);
            Assert.Equal(0, table.Columns.Count);

            table.EndInit();
            Assert.Equal(table, dv.Table);
            Assert.Equal(2, table.Columns.Count);
        }
Esempio n. 5
0
        public void BeginInit()
        {
            DataTable  table = new DataTable("table");
            DataView   dv    = new DataView();
            DataColumn col1  = new DataColumn("col1");
            DataColumn col2  = new DataColumn("col2");

            dv.BeginInit();
            table.BeginInit();
            table.Columns.AddRange(new DataColumn[] { col1, col2 });

            dv.Table = table;
            Assert.IsNull(dv.Table, "#1");
            dv.EndInit();

            Assert.IsNull(dv.Table, "#2");              // still.
            Assert.AreEqual(0, table.Columns.Count, "#3");

            table.EndInit();
            Assert.AreEqual(table, dv.Table, "#4");
            Assert.AreEqual(2, table.Columns.Count, "#5");
        }
Esempio n. 6
0
        public void BeginInit2()
        {
            DataTable table = new DataTable("table");
            DataView dv = new DataView();
            DataColumn col1 = new DataColumn("col1");
            DataColumn col2 = new DataColumn("col2");

            _dvInitialized = false;

            dv.Initialized += new EventHandler(OnDataViewInitialized);

            dv.BeginInit();
            table.BeginInit();
            table.Columns.AddRange(new DataColumn[] { col1, col2 });

            dv.Table = table;
            Assert.Null(dv.Table);
            dv.EndInit();

            Assert.Null(dv.Table);
            Assert.Equal(0, table.Columns.Count);

            table.EndInit();

            dv.Initialized -= new EventHandler(OnDataViewInitialized); // this should not be unregistered before table.EndInit().

            Assert.Equal(2, table.Columns.Count);
            Assert.Equal(table, dv.Table);
            Assert.Equal(true, _dvInitialized);
        }
Esempio n. 7
0
        public void BeginInit()
        {
            DataTable table = new DataTable("table");
            DataView dv = new DataView();
            DataColumn col1 = new DataColumn("col1");
            DataColumn col2 = new DataColumn("col2");

            dv.BeginInit();
            table.BeginInit();
            table.Columns.AddRange(new DataColumn[] { col1, col2 });

            dv.Table = table;
            Assert.Null(dv.Table);
            dv.EndInit();

            Assert.Null(dv.Table);
            Assert.Equal(0, table.Columns.Count);

            table.EndInit();
            Assert.Equal(table, dv.Table);
            Assert.Equal(2, table.Columns.Count);
        }
Esempio n. 8
0
        /// контроль всего документа на соответствие заявке
        private int ControlDocZVK(DataRow drD, List <string> lstProt, string s1Pallet)
        {
            bool
                bGood_KMC,
                bIsKMPL;
            int
                i = 0,
                nM,
                iStart,
                iCur,
                iCurSaved,
                iTMax, iZMax,
                nDokState = AppC.RC_OK,
                nM_KMC,
                nBad_NPP,
                nRet;
            string
                s1,
                s2,
                sOldKMC,
                sKMC,
                sFlt;
            FRACT
                fE,
                fE_KMC,
                fV = 0;
            object
                xProt;

            DataRow
                drC;
            DataView
                dv,
                dvZ, dvT;
            RowObj
                xR;

            //TimeSpan tsDiff;
            //int t1 = Environment.TickCount, t2, t3, td1, td2, tc = 0, tc1 = 0, tc2 = 0;
            //t2 = t1;

            if (drD == null)
            {
                drD = xCDoc.drCurRow;
            }

            bIsKMPL = (xCDoc.xDocP.TypOper == AppC.TYPOP_KMPL) ? true : false;

            string sRf = String.Format("(SYSN={0})", drD["SYSN"]);

            PSC_Types.ScDat sc = new PSC_Types.ScDat(new BarcodeScannerEventArgs(BCId.Code128, ""));
            lstProt.Add(HeadLineCtrl(drD));

            // пока что результат контроля неизвестен
            drD["DIFF"] = NSI.DOCCTRL.UNKNOWN;

            // вся продукция из заявки по документу
            dvZ = new DataView(xNSI.DT[NSI.BD_DIND].dt, sRf, "KMC", DataViewRowState.CurrentRows);

            iZMax = dvZ.Count;
            if (iZMax <= 0)
            {
                nDokState = AppC.RC_CANCEL;
                lstProt.Add("*** Заявка отсутствует! ***");
            }
            else
            {
                bZVKPresent = true;
            }

            /// вся продукция из ТТН по документу
            //dvT = new DataView(xNSI.DT[NSI.BD_DOUTD].dt, sRf, "KMC,EMK DESC", DataViewRowState.CurrentRows);

            if (s1Pallet.Length > 0)
            {
                sRf = String.Format("{0} AND (SSCC='{1}')", sRf, s1Pallet);
            }

            dvT   = new DataView(xNSI.DT[NSI.BD_DOUTD].dt, sRf, "KMC,EMK DESC", DataViewRowState.CurrentRows);
            iTMax = dvT.Count;
            if (iTMax <= 0)
            {
                nDokState = AppC.RC_CANCEL;
                lstProt.Add("*** ТТН отсутствует! ***");
            }
            dvZ.BeginInit();
            dvT.BeginInit();

            if (nDokState == AppC.RC_OK)
            {
                foreach (DataRowView dr in dvZ)
                {// сброс всех статусов
                    dr["READYZ"] = NSI.READINESS.NO;
                }
                foreach (DataRowView dr in dvT)
                {// сброс всех назначений строк
                    dr["DEST"]    = NSI.DESTINPROD.UNKNOWN;
                    dr["NPP_ZVK"] = -1;
                }


                lstProt.Add("<->----- ТТН ------<->");

                sOldKMC = "";
                fE_KMC  = 0;
                nM_KMC  = 0;
                while (i < iTMax)
                {
                    if ((int)dvT[i]["DEST"] != (int)NSI.DESTINPROD.UNKNOWN)
                    {// строка накладной уже обработана
                        i++;
                        continue;
                    }

                    drC = dvT[i].Row;
                    // что за объект в строке?
                    xR = new RowObj(drC);

                    if (xR.AllFlags == (int)AppC.OBJ_IN_DROW.OBJ_NONE)
                    {
                        lstProt.Add("Нет продукции/SSCC");
                        i++;
                        continue;
                    }
                    if (!xR.IsEAN)
                    {// один из SSCC
                        sFlt = "";
                        if (xR.IsSSCCINT)
                        {
                            sFlt += String.Format("AND(SSCCINT='{0}')", xR.sSSCCINT);
                        }
                        if (xR.IsSSCC)
                        {
                            sFlt += String.Format("AND(SSCC='{0}')", xR.sSSCC);
                        }

                        DataView dvZSC = new DataView(xNSI.DT[NSI.BD_DIND].dt, sRf + sFlt, "SSCC,SSCCINT",
                                                      DataViewRowState.CurrentRows);
                        if (dvZSC.Count > 0)
                        {
                            dvZSC[0].Row["READYZ"] = NSI.READINESS.FULL_READY;
                        }
                        else
                        {// SSCC не найден
                            lstProt.Add(String.Format("Подд.{0} {1}:нет заявки", xR.sSSCCINT, xR.sSSCC));
                        }
                        i++;
                        continue;
                    }

                    sc.sEAN   = (string)drC["EAN13"];
                    sc.sKMC   = (string)drC["KMC"];
                    sc.nKrKMC = (int)drC["KRKMC"];

                    sc.bVes = ((int)(drC["SRP"]) > 0) ? true : false;

                    sc.fEmk     = (FRACT)drC["EMK"];
                    sc.nParty   = (string)drC["NP"];
                    sc.dDataIzg = DateTime.ParseExact((string)drC["DVR"], "yyyyMMdd", null);
                    //sc.nTara = (string)drC["KRKT"];
                    sc.nTara = (string)drC["KTARA"];

                    sc.nRecSrc = (int)NSI.SRCDET.CR4CTRL;

                    //td1 = Environment.TickCount;

                    iStart = dvZ.Find(sc.sKMC);
                    //iStart = dvZ.Find(sc.sKMC);
                    if (iStart != -1)
                    {
                        nRet = EvalZVKMest(ref sc, dvZ, iStart, iZMax);
                    }
                    //nRet = LookAtZVK(ref sc, dvZ, iStart, iZMax);
                    else
                    {
                        nRet = AppC.RC_NOEAN;
                    }

                    //tc += (Environment.TickCount - td1);

                    iCur = -1;
                    if (nRet == AppC.RC_OK)
                    {// есть или единички или такая емкость
                     //td1 = Environment.TickCount;

                        if ((bIsKMPL) || true)
                        {
                            sc.nMest  = (int)drC["KOLM"];
                            sc.fVsego = (FRACT)drC["KOLE"];
                            EvalZVKStateNew(ref sc, drC);

                            if (sOldKMC != sc.sKMC)
                            {// смена кода
                                iCurSaved = i;

                                //EvalEnteredKol(dvT, i, ref sc, sc.sKMC, sc.fEmk, out nM, out fV, true);

                                iCur = i;

                                //nRet = EvalDiffZVK(ref sc, dvZ, dvT, lstProt, iStart, iZMax, ref iCur, iTMax, nM, fV);

                                //if (nDokState != AppC.RC_CANCEL)
                                //{
                                //    if (nRet != AppC.RC_OK)
                                //        nDokState = nRet;
                                //}
                                sOldKMC = sc.sKMC;
                            }
                        }
                        else
                        {
                            EvalEnteredKol(dvT, i, ref sc, sc.sKMC, sc.fEmk, out nM, out fV, true);

                            //td2 = Environment.TickCount;
                            //tc1 += (td2 - td1);

                            iCur = i;
                            nRet = EvalDiffZVK(ref sc, dvZ, dvT, lstProt, iStart, iZMax, ref iCur, iTMax, nM, fV);

                            //tc2 += (Environment.TickCount - td2);

                            if (nDokState != AppC.RC_CANCEL)
                            {
                                if (nRet != AppC.RC_OK)
                                {
                                    nDokState = nRet;
                                }
                            }
                        }
                    }
                    else
                    {
                        switch (nRet)
                        {
                        case AppC.RC_NOEAN:
                            // код отсутствует
                            s1    = "";
                            xProt = "";
                            fE    = -100;
                            break;

                        case AppC.RC_NOEANEMK:
                            // емкость отсутствует
                            s1    = "емк.";
                            xProt = sc.fEmk;
                            fE    = sc.fEmk;
                            break;

                        case AppC.RC_BADPARTY:
                            // нет партии
                            s1    = "парт.";
                            xProt = sc.nParty;
                            fE    = sc.fEmk;
                            break;

                        default:
                            s1    = String.Format("емк={0}", sc.fEmk);
                            xProt = String.Format("парт-{0}", sc.nParty);
                            fE    = sc.fEmk;
                            break;
                        }
                        nDokState = AppC.RC_CANCEL;

                        lstProt.Add(String.Format("_{0} {1} {2}:нет заявки", sc.nKrKMC, s1, xProt));
                        iCur = SetTTNState(dvT, ref sc, fE, NSI.DESTINPROD.USER, i, iTMax);
                    }
                    if (iCur != -1)
                    {
                        i = iCur;
                    }

                    i++;
                }


                if (s1Pallet.Length > 0)
                {
                    return(nDokState);
                }


                //t2 = Environment.TickCount;

                lstProt.Add("<->---- Заявка ----<->");
                sOldKMC   = "";
                fE_KMC    = 0;
                nM_KMC    = 0;
                bGood_KMC = true;
                nBad_NPP  = 0;
                for (i = 0; i < dvZ.Count; i++)
                {
                    drC  = dvZ[i].Row;
                    xR   = new RowObj(drC);
                    sKMC = (string)drC["KMC"];

                    if (sOldKMC != sKMC)
                    {// смена кода
                        if (nBad_NPP > 1)
                        {
                            Total4KMC(dvZ[i - 1].Row, sOldKMC, true, true, lstProt, nM_KMC, fE_KMC);
                        }
                        sOldKMC   = sKMC;
                        fE_KMC    = 0;
                        nM_KMC    = 0;
                        bGood_KMC = true;
                        nBad_NPP  = 0;
                    }

                    try
                    {
                        if (xR.IsEAN)
                        {
                            if ((FRACT)drC["EMK"] > 0)
                            {
                                nM_KMC += (int)(drC["KOLM"]);
                            }
                            else
                            {
                                fE_KMC += (FRACT)(drC["KOLE"]);
                            }

                            if ((NSI.READINESS)drC["READYZ"] != NSI.READINESS.FULL_READY)
                            {
                                nDokState = AppC.RC_CANCEL;
                                bGood_KMC = false;
                                nBad_NPP++;
                                Total4KMC(drC, sKMC, xR.IsEAN, false, lstProt, (int)(drC["KOLM"]), (FRACT)(drC["KOLE"]));
                            }
                        }
                        else
                        {
                            if (xR.IsSSCCINT || xR.IsSSCC)
                            {
                                if ((NSI.READINESS)drC["READYZ"] != NSI.READINESS.FULL_READY)
                                {
                                    lstProt.Add(String.Format("Подд.{0} {1}:нет ввода", xR.sSSCCINT, xR.sSSCC));
                                }
                            }
                        }
                    }
                    catch
                    {
                    }
                }
                if (i > 0)
                {
                    if (nBad_NPP > 1)
                    {
                        i--;
                        drC = dvZ[i].Row;
                        xR  = new RowObj(drC);
                        //sKMC = (string)drC["KMC"];
                        Total4KMC(drC, sOldKMC, xR.IsEAN, true, lstProt, nM_KMC, fE_KMC);
                    }
                }
            }

            if (nDokState == AppC.RC_CANCEL)
            {
                drD["DIFF"] = NSI.DOCCTRL.ERRS;
                lstProt.Add("!!!===! ОШИБКИ Контроля !===!!!");
            }
            else if (nDokState == AppC.RC_WARN)
            {
                drD["DIFF"] = NSI.DOCCTRL.WARNS;
                lstProt.Add("== Результат - Предупреждения ==");
            }
            else if (nDokState == AppC.RC_OK)
            {
                drD["DIFF"] = NSI.DOCCTRL.OK;
                lstProt.Add("=== Результат - нет ошибОК ===");
            }

            dvT.EndInit();
            dvZ.EndInit();

            //t3 = Environment.TickCount;
            //tsDiff = new TimeSpan(0, 0, 0, 0, t3 - t1);

            //lstProt.Add(String.Format("Всего - {0}, заявка - {1}, ZVK-{2}, TTN-{3}, Diff-{4}",
            //    tsDiff.TotalSeconds,
            //    new TimeSpan(0, 0, 0, 0, t3 - t2).TotalSeconds,
            //    new TimeSpan(0, 0, 0, 0, tc).TotalSeconds,
            //    new TimeSpan(0, 0, 0, 0, tc1).TotalSeconds,
            //    new TimeSpan(0, 0, 0, 0, tc2).TotalSeconds));
            //MessageBox.Show(new TimeSpan(0, 0, 0, 0, tss).TotalSeconds.ToString());
            return(nDokState);
        }