Пример #1
0
        ///
        private int SetOneDetZ(ref PSC_Types.ScDat sD, DataTable dtZVK, DataSet dsZ, DataRow dZ, DataRow dMDoc, ref int nNPP)
        {
            bool
                bFNsi,
                bSomeDateIsSet = false;
            int
                nCondition = 0,
                nIDOriginal,
                nPrzPl = 0,
            //nM = 0,
                nMest = 0;
            string
                sE,
                sKMC = "",
                sEAN = "";

            object[]
            aIt = dZ.ItemArray;
            DataRow
                dr,
                drNewRow = dtZVK.NewRow();
            FRACT
                fEmkZ;

            nIDOriginal        = (int)drNewRow["ID"];
            drNewRow.ItemArray = aIt;
            try
            {
                bFNsi   = false;
                sD.fEmk = 0;
                nMest   = (int)drNewRow["KOLM"];
                sKMC    = (drNewRow["KMC"] is string) ? drNewRow["KMC"].ToString() : "";
                if (sKMC.Length > 0)
                {
                    dr    = xNSI.DT[NSI.NS_MC].dt.Rows.Find(new object[] { sKMC });
                    bFNsi = sD.GetFromNSI(sD.s, dr, ref nPrzPl);
                    if (bFNsi)
                    {
                        drNewRow["KRKMC"] = sD.nKrKMC;
                        drNewRow["SNM"]   = sD.sN;
                    }
                    else
                    {
                        drNewRow["KRKMC"] = 0;
                        drNewRow["SNM"]   = "Неизвестно";
                    }
                }
                if (drNewRow["EAN13"] == System.DBNull.Value)
                {
                    if (bFNsi)
                    {
                        drNewRow["EAN13"] = sEAN = sD.sEAN;
                    }
                }
                else
                {
                    sEAN = (string)drNewRow["EAN13"];
                }
                if ((!bFNsi) && (sEAN.Length > 0))
                {
                    if (xNSI.GetMCDataOnEAN(sEAN, ref sD, false) == true)
                    {
                        drNewRow["KMC"]   = sD.sKMC;
                        drNewRow["KRKMC"] = sD.nKrKMC;
                        drNewRow["SNM"]   = sD.sN;
                    }
                    else
                    {
                        drNewRow["KRKMC"] = 0;
                        drNewRow["SNM"]   = "Неизвестно";
                    }
                }
            }
            catch
            {
                drNewRow["KRKMC"] = 0;
                drNewRow["SNM"]   = "Неизвестно";
                nMest             = 0;

                sE = String.Format("{0} - Загрузка BC={1} EAN={2}",
                                   DateTime.Now.ToString("dd.MM.yy HH:mm:ss - "),
                                   dMDoc["DOCBC"],
                                   sEAN);
                WriteProt(sE);
            }

            //nM = nMest;
            //if (drNewRow["EMK"] == System.DBNull.Value)
            //{
            //    if (nMest > 0)
            //    {
            //        if (sD.fEmk == 0)
            //            sD.fEmk = (FRACT)((int)(((FRACT)drNewRow["KOLE"]) / nMest));
            //        drNewRow["EMK"] = sD.fEmk;
            //    }
            //    else
            //        drNewRow["EMK"] = 0;
            //}

            try
            {
                fEmkZ = (FRACT)drNewRow["EMK"];
            }
            catch
            {
                fEmkZ = 0;
            }

            //if (drMZ["EMK"] == System.DBNull.Value)
            if (fEmkZ <= 0)
            {
                fEmkZ = 0;
                if (nMest > 0)
                {
                    if (sD.fEmk == 0)
                    {
                        sD.fEmk = (FRACT)((int)(((FRACT)drNewRow["KOLE"]) / nMest));
                    }
                    fEmkZ = sD.fEmk;
                }
                drNewRow["EMK"] = fEmkZ;
            }

            drNewRow["READYZ"] = NSI.READINESS.NO;

            if ((drNewRow["SSCC"] is string) && (drNewRow["SSCC"].ToString().Length > 0))
            {// код паллетты внешней задан
                nCondition |= (int)NSI.SPECCOND.SSCC;
            }
            else
            {
                drNewRow["SSCC"] = "";
            }

            if ((drNewRow["SSCCINT"] is string) && (drNewRow["SSCCINT"].ToString().Length > 0))
            {// код паллетты внутренней задан
                nCondition |= (int)NSI.SPECCOND.SSCC_INT;
            }
            else
            {
                drNewRow["SSCCINT"] = "";
            }

            if (drNewRow["NP"] is string)
            {
                if (((string)drNewRow["NP"] == "*") ||
                    ((string)drNewRow["NP"] == "-1"))
                {
                    drNewRow["NP"] = "";
                    nCondition    |= (int)NSI.SPECCOND.DATE_SET_EXACT;
                }
                else
                {
                    if (((string)drNewRow["NP"]).Length > 0)
                    {// партия задана
                        nCondition |= (int)NSI.SPECCOND.PARTY_SET;
                    }
                }
            }
            else
            {
                drNewRow["NP"] = "";
            }

            if (xPars.UseDTGodn)
            {
                try
                {
                    bSomeDateIsSet = DateCond(drNewRow, "DTG", ref nCondition);
                }
                catch
                {
                    drNewRow["DTG"] = null;
                    bSomeDateIsSet  = false;
                }
            }

            if (xPars.UseDTProizv)
            {
                try
                {
                    bSomeDateIsSet |= DateCond(drNewRow, "DVR", ref nCondition);
                }
                catch
                {
                    drNewRow["DVR"] = null;
                }
            }

            /// если партия - *, а даты вообще нет
            if ((!bSomeDateIsSet) && ((nCondition & (int)NSI.SPECCOND.DATE_SET_EXACT) > 0))
            {
                nCondition -= (int)NSI.SPECCOND.DATE_SET_EXACT;
            }

            drNewRow["COND"] = nCondition;

            if (drNewRow["NPP"] is int)
            {
                nNPP = (int)drNewRow["NPP"];
            }
            else
            {
                drNewRow["NPP"] = nNPP;
            }

            try
            {
                nNPP = (int)drNewRow["NPP"];
            }
            catch { }
            drNewRow["NPP"] = nNPP;

            drNewRow["ID"]   = nIDOriginal;
            drNewRow["SYSN"] = dMDoc["SYSN"];

            dtZVK.Rows.Add(drNewRow);
            AddAKMC(dsZ, dZ, drNewRow);
            return(nMest);
        }
Пример #2
0
        /// заполнение DataRow заявки недостающими данными
        private int SetOneDetZ(ref PSC_Types.ScDat sD, DataTable dtZVK, DataRow dZ, DataRow drCurDoc, ref int nNPP)
        {
            bool
           bFNsi,
           bSomeDateIsSet = true;
            int
            //nIDOriginal,
            //nPrzPl = 0,
                nCondition = 0,
                nM         = 0,
                nMest      = 0;
            string
            //sNameFromSrv,
                sKMC = "",
                sEAN = "";

            object[]
            aIt = dZ.ItemArray;
            //DataSet
            //    dsZ;
            DataRow
                dr,
                drMZ = dtZVK.NewRow();

            //nIDOriginal = (int)drMZ["ID"];
            drMZ.ItemArray = aIt;
            try
            {
                bFNsi   = false;
                sD.fEmk = 0;
                nMest   = (int)drMZ["KOLM"];
                sKMC    = (drMZ["KMC"] is string) ? drMZ["KMC"].ToString() : "";
                if (sKMC.Length > 0)
                {
                    dr    = xNSI.DT[NSI.NS_MC].dt.Rows.Find(new object[] { sKMC });
                    bFNsi = sD.GetFromNSI(sD.s, dr, xNSI.DT[NSI.NS_MC].dt, false);
                    if (bFNsi)
                    {
                        drMZ["KRKMC"] = sD.nKrKMC;
                        drMZ["SNM"]   = sD.sN;
                    }
                    else
                    {
                        drMZ["KRKMC"] = 0;
                        drMZ["SNM"]   = "Неизвестно";
                    }
                }
                if (drMZ["EAN13"] == System.DBNull.Value)
                {
                    if (bFNsi)
                    {
                        drMZ["EAN13"] = sEAN = sD.sEAN;
                    }
                    else
                    {
                        drMZ["EAN13"] = "";
                    }
                }
                else
                {
                    sEAN = (string)drMZ["EAN13"];
                }
                if ((!bFNsi) && (sEAN.Length > 0))
                {
                    if (xNSI.GetMCDataOnEAN(sEAN, ref sD, false) == true)
                    {
                        drMZ["KMC"]   = sD.sKMC;
                        drMZ["KRKMC"] = sD.nKrKMC;
                        drMZ["SNM"]   = sD.sN;
                    }
                    else
                    {
                        drMZ["KRKMC"] = 0;
                        drMZ["SNM"]   = "Неизвестно";
                    }
                }
            }
            catch
            {
                drMZ["KRKMC"] = 0;
                drMZ["SNM"]   = "Неизвестно";
                nMest         = 0;
                //if (swProt != null)
                //{
                //    sE = String.Format("{0} - Загрузка BC={1} EAN={2}",
                //    DateTime.Now.ToString("dd.MM.yy HH:mm:ss - "),
                //    dMDoc["DOCBC"],
                //    sEAN);
                //    swProt.WriteLine(sE);
                //}
            }
            if ((dZ["SNM"] is string) && (((string)dZ["SNM"]).Length > 0))
            {
                drMZ["SNM"] = dZ["SNM"];
            }

            nM = nMest;
            if (drMZ["EMK"] == System.DBNull.Value)
            {
                if (nM > 0)
                {
                    if (sD.fEmk == 0)
                    {
                        sD.fEmk = (FRACT)((int)(((FRACT)drMZ["KOLE"]) / nM));
                    }
                    drMZ["EMK"] = sD.fEmk;
                }
                else
                {
                    drMZ["EMK"] = 0;
                }
            }
            drMZ["READYZ"] = NSI.READINESS.NO;

            if ((drMZ["SSCC"] is string) && (drMZ["SSCC"].ToString().Length > 0))
            {// код паллетты внешней задан
                nCondition |= (int)NSI.SPECCOND.SSCC;
            }
            else
            {
                drMZ["SSCC"] = "";
            }

            if ((drMZ["SSCCINT"] is string) && (drMZ["SSCCINT"].ToString().Length > 0))
            {// код паллетты внутренней задан
                nCondition |= (int)NSI.SPECCOND.SSCC_INT;
            }
            else
            {
                drMZ["SSCCINT"] = "";
            }

            if (drMZ["NP"] is string)
            {
                if (((string)drMZ["NP"] == "*") ||
                    ((string)drMZ["NP"] == "-1"))
                {
                    drMZ["NP"]  = "";
                    nCondition |= (int)NSI.SPECCOND.DATE_SET_EXACT;
                }
                else
                {
                    if (((string)drMZ["NP"]).Length > 0)
                    {// партия задана
                        nCondition |= (int)NSI.SPECCOND.PARTY_SET;
                    }
                }
            }
            else
            {
                drMZ["NP"] = "";
            }


            //if (drMZ["DTG"] is string)
            //{
            //    try
            //    {
            //        DateTime dG = DateTime.ParseExact((string)drMZ["DTG"], "yyyyMMdd", null);
            //        if ((dG.Year < 2000) || (dG == DateTime.MinValue))
            //            drMZ["DTG"] = null;
            //    }
            //    catch
            //    {
            //        drMZ["DTG"] = null;
            //    }
            //}

            try
            {
                bSomeDateIsSet = DateCond(drMZ, "DVR", ref nCondition);
            }
            catch
            {
                bSomeDateIsSet = false;
                drMZ["DVR"]    = null;
            }

            // 18.01.18 - годность только в информативных целях
            //try
            //{
            //    bClearParty = bClearParty & DateCond(drMZ, "DTG");
            //}
            //catch
            //{
            //    drMZ["DTG"] = null;
            //}

            if ((!bSomeDateIsSet) && ((nCondition & (int)NSI.SPECCOND.DATE_SET_EXACT) > 0))
            {
                nCondition -= (int)NSI.SPECCOND.DATE_SET_EXACT;
            }

            drMZ["COND"] = nCondition;

            if (drMZ["NPP"] is int)
            {
                nNPP = (int)drMZ["NPP"];
            }
            else
            {
                drMZ["NPP"] = nNPP;
            }

            //drMZ["ID"] = nIDOriginal;
            drMZ["SYSN"] = drCurDoc["SYSN"];
            dtZVK.Rows.Add(drMZ);

            //AddAKMC(dsZ, dZ, drMZ);
            return(nM);
        }