예제 #1
0
        private void GetInfoFromDB()
        {
            msSQLTransport = new MSSQLTransport();
            var regex = new Regex(@"[\d*]{1,}");

            var cBIN = entryOrder.clientBIN.Replace(" ", "");

            cBIN = regex.Match(cBIN).ToString();
            entryOrder.clientBIN = cBIN;

            dataSet = msSQLTransport.Execute("select a.* from altair.dbo.companiesView a where a.bin='" + entryOrder.clientBIN + "'");

            if (dataSet == null || dataSet.Tables.Count <= 0)
            {
                return;
            }

            entryOrder.clientFullName = dataSet.Tables[0].Rows[0].Field <string>("fullName");
            entryOrder.clientAddress  = dataSet.Tables[0].Rows[0].Field <string>("addrJur");
            entryOrder.clientPhones   = dataSet.Tables[0].Rows[0].Field <string>("phones");
            entryOrder.clientBankIIK  = dataSet.Tables[0].Rows[0].Field <string>("iik");
            entryOrder.clientBankBIK  = dataSet.Tables[0].Rows[0].Field <string>("bik");

            dataSet = msSQLTransport.Execute("select a.* from altair.dbo.banksView a where a.bik='" + entryOrder.clientBankBIK + "'");

            if (dataSet == null || dataSet.Tables.Count <= 0)
            {
                return;
            }

            entryOrder.clientBankName = dataSet.Tables[0].Rows[0].Field <string>("bankName");
        }
예제 #2
0
        private void AddRecord()
        {
            msSQLTransport = new MSSQLTransport();
            var regex = new Regex(@"[\d*]{1,}");

            string req = "", loc = "";
            var    cBIN = JournalC01CompanyInfo.bin.Replace(" ", "");
            long   bankId;

            cBIN = regex.Match(cBIN).ToString();

            if (!string.IsNullOrEmpty(cBIN))
            {
                dataSet = msSQLTransport.Execute("select top 1 a.* from altair.dbo.companiesView a where a.bin like '%" + cBIN + "%'");
            }

            if (dataSet != null && dataSet.Tables.Count > 0 && dataSet.Tables[0].Rows.Count > 0)
            {
                loc    = dataSet.Tables[0].Rows[0].Field <string>("addrJur");
                bankId = dataSet.Tables[0].Rows[0].Field <long>("bankId");
                req    = "БИН " + cBIN + "\n";
                req   += "БИК " + dataSet.Tables[0].Rows[0].Field <string>("bik") + "\n";
                req   += "Кбе " + dataSet.Tables[0].Rows[0].Field <string>("kbe") + "\n";
                req   += "ИИК " + dataSet.Tables[0].Rows[0].Field <string>("iik") + "\n";

                dataSet = msSQLTransport.Execute("select a.* from altair.dbo.banksView a where a.id='" + bankId + "'");
                if (dataSet != null && dataSet.Tables.Count > 0)
                {
                    req += "Банк " + dataSet.Tables[0].Rows[0].Field <string>("bankName") + "\n";
                }
            }
            else
            {
                req = "Данных в базе не обнаружено";
            }

            WaitingListTable.Add(new WaitingListTable {
                company  = "Код клиента: " + SupplierCode + "\n" + SupplierName + "\n Код брокера: " + BrokerCode + "\n" + BrokerName,
                bankReq  = req,
                location = loc
            });
        }
        // Get from db lefted pieces of info
        private int GetFromDB()
        {
            var regex = new Regex(@"[\d*]{1,}");

            var cBIN = invoice.buyerBIN;

            cBIN = Regex.Replace(cBIN, @"[\s]", " ");

            var itmp = 0;

            while (cBIN.IndexOf(" ") != -1)
            {
                itmp = cBIN.IndexOf(" ");
                cBIN = cBIN.Remove(cBIN.IndexOf(" "), 1);
            }

            cBIN             = regex.Match(cBIN).ToString();
            invoice.buyerBIN = cBIN;

            // Get info about buyer from company
            dataSet = msSQLTransport.Execute("select a.* from altair.dbo.companiesView a where a.bin like'%" + invoice.buyerBIN + "%'");

            if (dataSet == null || dataSet.Tables.Count <= 0 || string.IsNullOrEmpty(invoice.buyerBIN))
            {
                return(0);
            }

            invoice.buyerName    = dataSet.Tables[0].Rows[0].Field <string>("fullName");
            invoice.buyerIIK     = dataSet.Tables[0].Rows[0].Field <string>("iik");
            invoice.buyerAddress = dataSet.Tables[0].Rows[0].Field <string>("addrJur");

            var id = dataSet.Tables[0].Rows[0].Field <long>("id").ToString();

            // Get info about broker and supplier from company
            dataSet = msSQLTransport.Execute("select a.* from altair.dbo.companiesView a where a.bin='" + invoice.brokerBIN + "'");

            if (dataSet == null || dataSet.Tables.Count <= 0)
            {
                return(0);
            }

            invoice.brokerName      = dataSet.Tables[0].Rows[0].Field <string>("fullName");
            invoice.supplierName    = invoice.brokerName;
            invoice.supplierAddress = dataSet.Tables[0].Rows[0].Field <string>("addrJur");
            invoice.supplierBIN     = invoice.brokerBIN;
            invoice.brokerIIK       = dataSet.Tables[0].Rows[0].Field <string>("iik");
            invoice.brokerKbe       = dataSet.Tables[0].Rows[0].Field <string>("kbe");
            invoice.brokerBIK       = dataSet.Tables[0].Rows[0].Field <string>("bik");

            // Broker bank name from banks
            dataSet = msSQLTransport.Execute("select a.* from altair.dbo.banksView a where a.bik='" + invoice.brokerBIK + "'");

            if (dataSet == null || dataSet.Tables.Count <= 0)
            {
                return(0);
            }

            invoice.brokerBankName = dataSet.Tables[0].Rows[0].Field <string>("bankName");

            // Contract data from contracts
            dataSet = msSQLTransport.Execute("select a.* from altair.dbo.contractsView a where a.clientId='" + id + "' and a.brokerid='" + invoice.brokerId + "'");

            if (dataSet == null || dataSet.Tables.Count <= 0)
            {
                return(0);
            }

            var lRow = dataSet.Tables[0].Rows.Count - 1;

            invoice.contractNumber = dataSet.Tables[0].Rows[lRow].Field <string>("contractNum");
            invoice.contractId     = dataSet.Tables[0].Rows[lRow].Field <string>("id1c");
            invoice.contractDate   = dataSet.Tables[0].Rows[lRow].Field <DateTime>("contractDate").ToString("dd.MM.yyyy");

            id = dataSet.Tables[0].Rows[lRow].Field <long>("id").ToString();

            // Tarif data from contracts
            dataSet = msSQLTransport.Execute("select a.* from altair.dbo.tarifView a where a.contractId='" + id + "'");

            if (dataSet == null || dataSet.Tables.Count <= 0)
            {
                return(0);
            }

            var     sum = Convert.ToDecimal(invoice.invoiceSum);
            decimal percent = 0, bord = 0;
            var     exchangeName = "";

            foreach (DataRow item in dataSet.Tables[0].Rows)
            {
                if (sum > bord && sum < item.Field <decimal>("bord"))
                {
                    break;
                }

                bord         = item.Field <decimal>("bord");
                percent      = item.Field <decimal>("percent1");
                exchangeName = item.Field <string>("exchangeName");

                var sPercent = "0";

                if (exchangeName.Equals("Астана"))
                {
                    if (InputBoxService.InputBox("Тарифная сетка", "Введите процент:", ref sPercent) == DialogResult.OK)
                    {
                        percent = Convert.ToDecimal(sPercent);
                    }

                    break;
                }
            }

            sum = sum / 100 * percent;

            if (Convert.ToDecimal(invoice.invoiceSum) < 1000000)
            {
                invoice.invoiceBrokerSum = "500";
            }
            else
            {
                invoice.invoiceBrokerSum = "5000";
            }

            invoice.invoiceSum = sum.ToString();

            return(1);
        }