예제 #1
0
        }  // WhatUNeed

        private bool RefreshRowSum()
        {
            string TextQuery =
                "select " +
                "sum(DocCC.$КонтрольНабора.Сумма ) as Sum, " +
                "count(*) Amount " +
                "from " +
                "DT$КонтрольНабора as DocCC (nolock) " +
                "where " +
                "DocCC.iddoc in (:Docs ) " +
                "and DocCC.$КонтрольНабора.Дата5 = :EmptyDate " +
                "and DocCC.$КонтрольНабора.Корректировка = 0 " +
                "and DocCC.$КонтрольНабора.Количество > 0 ";

            TextQuery = TextQuery.Replace(":Docs", Helper.ListToStringWithQuotes(DocsSet));
            QuerySetParam(ref TextQuery, "EmptyDate", GetVoidDate());
            DataTable DT;

            if (!ExecuteWithRead(TextQuery, out DT))
            {
                return(false);
            }
            if (DT.Rows.Count > 0)
            {
                DocSet.Sum = (decimal)DT.Rows[0]["Sum"];
                AllSetsRow = (int)DT.Rows[0]["Amount"];
            }
            else
            {
                DocSet.Sum = 0;
                AllSetsRow = 0;
            }
            return(true);
        }
예제 #2
0
        } // RefreshAMT()

        public bool RefreshCCRP()
        {
            RefreshRowSum();

            string TextQuery =
                "select " +
                "DocCC.lineno_ as Number, " +
                "Goods.$Спр.Товары.ИнвКод as InvCode, " +
                "DocCC.$КонтрольНабора.Сумма as Sum, " +
                "DocCC.$КонтрольНабора.Количество as Count, " +
                "Sections.descr as Adress " +
                "from " +
                "DT$КонтрольНабора as DocCC (nolock) " +
                "LEFT JOIN DH$КонтрольНабора as DocCCHead (nolock) " +
                "ON DocCCHead.iddoc = DocCC.iddoc " +
                "LEFT JOIN $Спр.Товары as Goods (nolock) " +
                "ON Goods.id = DocCC.$КонтрольНабора.Товар " +
                "LEFT JOIN $Спр.Секции as Sections (nolock) " +
                "ON Sections.id = DocCC.$КонтрольНабора.Адрес0 " +
                "where " +
                "DocCC.iddoc in ( :Docs) " +
                "and DocCC.$КонтрольНабора.Дата5 = :EmptyDate " +
                "and DocCC.$КонтрольНабора.Корректировка = 0 " +
                "and DocCC.$КонтрольНабора.Количество > 0 " +
                "order by " +
                "DocCCHead.$КонтрольНабора.Сектор , Sections.$Спр.Секции.Маршрут , Number";

            TextQuery = TextQuery.Replace(":Docs", Helper.ListToStringWithQuotes(DocsSet));
            QuerySetParam(ref TextQuery, "EmptyDate", GetVoidDate());
            if (!ExecuteWithRead(TextQuery, out CCRP))
            {
                return(false);
            }
            return(true);
        } // RefreshCCRP
예제 #3
0
        private bool ToModeSetCompleteAfrerBox(RefSection Adress)
        {
            EmpbtyBox = false;
            string TextQuery = "select iddoc from DH$КонтрольНабора where iddoc in (:Docs) and $КонтрольНабора.Коробка = :box";

            TextQuery = TextQuery.Replace(":Docs", Helper.ListToStringWithQuotes(DocsSet));
            if (Adress == null)
            {
                EmpbtyBox = true;
                QuerySetParam(ref TextQuery, "box", GetVoidID());
            }
            else
            {
                QuerySetParam(ref TextQuery, "box", Adress.ID);
            }
            DataTable DT;

            if (!ExecuteWithRead(TextQuery, out DT))
            {
                return(false);
            }
            if (DT.Rows.Count == 0)
            {
                FExcStr = "Сборочный с такой коробкой не найдет!";
                return(false);
            }
            if (!LoadDocSet(DT.Rows[0]["iddoc"].ToString()))
            {
                return(false);
            }

            RepeatCountBox = false;
            BoxOk          = false;
            DocSet.Boxes   = 0;
            TextQuery      =
                "Select " +
                "count(*) as boxes " +
                "from $Спр.МестаПогрузки (nolock) " +
                "where $Спр.МестаПогрузки.КонтрольНабора = :iddoc";
            QuerySetParam(ref TextQuery, "iddoc", DocSet.ID);
            DT.Clear();
            if (ExecuteWithRead(TextQuery, out DT))
            {
                if (DT.Rows.Count > 0)
                {
                    DocSet.Boxes = (int)DT.Rows[0]["boxes"];
                }
            }

            TextQuery =
                "Select " +
                "ISNULL(RefSection.$Спр.Секции.МаксКорешков , 0) as MaxStub " +
                "from DH$КонтрольНабора as DocCC (nolock) " +
                "left join $Спр.Секции as RefSection (nolock) " +
                " on DocCC.$КонтрольНабора.Сектор = RefSection.id " +
                "where DocCC.iddoc = :iddoc";
            QuerySetParam(ref TextQuery, "iddoc", DocSet.ID);
            DT.Clear();
            if (!ExecuteWithRead(TextQuery, out DT))
            {
                return(false);
            }
            DocSet.MaxStub = (int)(decimal)DT.Rows[0]["MaxStub"];

            BoxForSet = Adress;
            if (Employer.SelfControl)
            {
                TextQuery =
                    "select top 1 iddoc " +
                    "from DT$КонтрольНабора as DocT (nolock) " +
                    "where " +
                    "iddoc = :iddoc " +
                    "and DocT.$КонтрольНабора.Состояние0 = 2 " +
                    "and DocT.$КонтрольНабора.Контроль <= 0 " +
                    "and DocT.$КонтрольНабора.СостояниеКорр = 0 " +
                    "and DocT.$КонтрольНабора.Количество > 0 ";
                QuerySetParam(ref TextQuery, "iddoc", DocSet.ID);
                DT.Clear();
                if (!ExecuteWithRead(TextQuery, out DT))
                {
                    return(false);
                }
                if (DT.Rows.Count > 0)
                {
                    //Включен самоконтроль и осталось что-то "поконтролить"
                    return(ToModeSetSelfControl());
                }
            }
            return(true);
        } // ToModeSetCompleteAfterBox
예제 #4
0
        //BASE METHOD's
        private bool ToModeSet(string AdressID, string iddoc)
        {
            foreach (string id in DocsSet)
            {
                if (!LockDoc(id))
                {
                    return(false);
                }
            }

            string TextQuery =
                "DECLARE @curdate DateTime; " +
                "SELECT @curdate = DATEADD(DAY, 1 - DAY(curdate), curdate) FROM _1ssystem (nolock); " +
                "select top 1 " +
                "DocCC.$КонтрольНабора.Товар as ID, " +
                "DocCC.lineno_ as LINENO_, " +
                "Goods.descr as ItemName, " +
                "Goods.$Спр.Товары.ИнвКод as InvCode, " +
                "Goods.$Спр.Товары.КоличествоДеталей as Details, " +
                "DocCC.$КонтрольНабора.Количество as Count, " +
                "DocCC.$КонтрольНабора.Адрес0 as Adress, " +
                "DocCC.$КонтрольНабора.Цена as Price, " +
                "Sections.descr as AdressName, " +
                "ISNULL(AOT.Balance, 0) as Balance, " +
                //Реквизиты документа
                "DocCC.iddoc as IDDOC, " +
                "journForBill.docno as DocNo, " +
                "CONVERT(char(8), CAST(LEFT(journForBill.date_time_iddoc, 8) as datetime), 4) as DateDoc, " +
                "journForBill.iddoc as Bill, " +
                "DocCCHead.$КонтрольНабора.КолСтрок as Rows, " +
                "Sector.descr as Sector, " +
                "DocCCHead.$КонтрольНабора.Сумма as Sum, " +
                "DocCCHead.$КонтрольНабора.НомерЛиста as Number, " +
                "DocCCHead.$КонтрольНабора.ФлагСамовывоза as SelfRemovel, " +
                "Clients.descr as Client, " +
                "Bill.$Счет.ТипНакладной as TypeNakl, " +
                "isnull(DocCCHead.$КонтрольНабора.Коробка , :EmptyID) as BoxID, " +
                "AdressBox.descr as Box " +
                "from " +
                "DT$КонтрольНабора as DocCC (nolock) " +
                "LEFT JOIN DH$КонтрольНабора as DocCCHead (nolock) " +
                "ON DocCCHead.iddoc = DocCC.iddoc " +
                "LEFT JOIN $Спр.Товары as Goods (nolock) " +
                "ON Goods.id = DocCC.$КонтрольНабора.Товар " +
                "LEFT JOIN $Спр.Секции as Sections (nolock) " +
                "ON Sections.id = DocCC.$КонтрольНабора.Адрес0 " +
                "LEFT JOIN ( " +
                "select " +
                "RegAOT.$Рег.АдресОстаткиТоваров.Товар as item, " +
                "RegAOT.$Рег.АдресОстаткиТоваров.Адрес as adress, " +
                "sum(RegAOT.$Рег.АдресОстаткиТоваров.Количество ) as balance " +
                "from " +
                "RG$Рег.АдресОстаткиТоваров as RegAOT (nolock) " +
                "where " +
                "period = @curdate " +
                "and $Рег.АдресОстаткиТоваров.Склад = :Warehouse " +
                "and $Рег.АдресОстаткиТоваров.Состояние = 2 " +
                "group by RegAOT.$Рег.АдресОстаткиТоваров.Товар , RegAOT.$Рег.АдресОстаткиТоваров.Адрес " +
                ") as AOT " +
                "ON AOT.item = DocCC.$КонтрольНабора.Товар and AOT.adress = DocCC.$КонтрольНабора.Адрес0 " +
                "LEFT JOIN DH$КонтрольРасходной as DocCB (nolock) " +
                "ON DocCB.iddoc = DocCCHead.$КонтрольНабора.ДокументОснование " +
                "LEFT JOIN DH$Счет as Bill (nolock) " +
                "ON Bill.iddoc = DocCB.$КонтрольРасходной.ДокументОснование " +
                "LEFT JOIN _1sjourn as journForBill (nolock) " +
                "ON journForBill.iddoc = Bill.iddoc " +
                "LEFT JOIN $Спр.Секции as Sector (nolock) " +
                "ON Sector.id = DocCCHead.$КонтрольНабора.Сектор " +
                "LEFT JOIN $Спр.Клиенты as Clients (nolock) " +
                "ON Bill.$Счет.Клиент = Clients.id " +
                "LEFT JOIN $Спр.Секции as AdressBox (nolock) " +
                "ON AdressBox.id = DocCCHead.$КонтрольНабора.Коробка " +
                "where " +
                "DocCC.iddoc in (:Docs) " +
                "and DocCC.$КонтрольНабора.Дата5 = :EmptyDate " +
                "and DocCC.$КонтрольНабора.Корректировка = 0 " +
                "and DocCC.$КонтрольНабора.Количество > 0 " +
                (AdressID == null ? "" : "and DocCC.$КонтрольНабора.Адрес0 = :Adress ") +
                (iddoc == null ? "" : "and DocCC.iddoc = :iddoc ") +
                "order by " +
                "DocCCHead.$КонтрольНабора.Сектор , Sections.$Спр.Секции.Маршрут , LINENO_";

            DataTable DT;

            TextQuery = TextQuery.Replace(":Docs", Helper.ListToStringWithQuotes(DocsSet));
            QuerySetParam(ref TextQuery, "EmptyDate", GetVoidDate());
            QuerySetParam(ref TextQuery, "Warehouse", Const.MainWarehouse);
            if (iddoc != null)
            {
                QuerySetParam(ref TextQuery, "iddoc", iddoc);
            }
            if (AdressID != null)
            {
                QuerySetParam(ref TextQuery, "Adress", AdressID);
            }
            if (!ExecuteWithRead(TextQuery, out DT))
            {
                return(false);
            }

            if (DT.Rows.Count == 0)
            {
                if (AdressID == null)
                {
                    return(ToModeSetComplete());
                }
                else
                {
                    //Это попытка перепрыгнуть
                    FExcStr = "Нет такого адреса в сборочном!";
                    return(false);
                }
            }

            RefreshRowSum();    //Подтянем циферки

            CCItem            = new StructItemSet();
            CCItem.ID         = DT.Rows[0]["id"].ToString();
            CCItem.InvCode    = DT.Rows[0]["InvCode"].ToString();
            CCItem.Name       = DT.Rows[0]["ItemName"].ToString();
            CCItem.Price      = (decimal)DT.Rows[0]["Price"];
            CCItem.Count      = (int)(decimal)DT.Rows[0]["Count"];
            CCItem.CountFact  = (int)(decimal)DT.Rows[0]["Count"];
            CCItem.AdressID   = DT.Rows[0]["Adress"].ToString();
            CCItem.AdressName = DT.Rows[0]["AdressName"].ToString();
            CCItem.CurrLine   = (short)DT.Rows[0]["LINENO_"];
            CCItem.Balance    = (int)(decimal)DT.Rows[0]["Balance"];
            CCItem.Details    = (int)(decimal)DT.Rows[0]["Details"];

            if (!MultiplesOKEI2(ref CCItem))
            {
                return(false);
            }

            DocSet                 = new StrictDoc();
            DocSet.ID              = DT.Rows[0]["IDDOC"].ToString();
            DocSet.SelfRemovel     = (int)(decimal)DT.Rows[0]["SelfRemovel"];
            DocSet.View            = (DocSet.SelfRemovel == 1 ? "(C) " : "") + DT.Rows[0]["Sector"].ToString().Trim() + "-" + DT.Rows[0]["Number"].ToString() + " Заявка " + DT.Rows[0]["DocNo"].ToString() + " (" + DT.Rows[0]["DateDoc"].ToString() + ")";
            DocSet.Rows            = (int)(decimal)DT.Rows[0]["Rows"];
            DocSet.FromWarehouseID = DT.Rows[0]["Bill"].ToString();
            DocSet.Client          = DT.Rows[0]["Client"].ToString().Trim();
            DocSet.Sum             = (decimal)DT.Rows[0]["Sum"];
            DocSet.Special         = (int)(decimal)DT.Rows[0]["TypeNakl"] == 2 ? true : false;
            DocSet.Box             = DT.Rows[0]["Box"].ToString();
            DocSet.BoxID           = DT.Rows[0]["BoxID"].ToString();

            CurrentAction = ActionSet.ScanAdress;
            FExcStr       = WhatUNeed();
            FCurrentMode  = Mode.Set;
            return(true);
        } // ToModeSet