コード例 #1
0
        protected override void EnterField(int fn)
        {
            Field  f = (Field)fields[fn];
            string s = f.ToString();

            try
            {
                switch (fn)
                {
                case 1: did = int.Parse(s);
                    FetchDistrict(ref s);
                    break;

                case 2: cid = int.Parse(s);
                    FetchCustFromId(ref s);
                    DoDisplay(ref s);
                    SetCurField(85);
                    break;

                case 5: clast = s;
                    FetchCustFromLast(ref s);
                    DoDisplay(ref s);
                    break;
                }
            }
            catch (Exception ex)
            {
                s = ex.Message;
                Form1.RecordResponse(ex, fid, tid);
                Form1.wconflicts++;
            }
            SetCurField(curField);
            status.Text = s;
            Invalidate(true);
        }
コード例 #2
0
        void Carrier(int carid)
        {
            int done = 0, skipped = 0;
            var tr = db.BeginTransaction(System.Data.IsolationLevel.Serializable);

            tid = ++Form1._tid;
            try
            {
                for (int d = 1; d <= 10; d++)
                {
                    if (Schedule(d, carid, tr))
                    {
                        done++;
                    }
                    else
                    {
                        skipped++;
                    }
                }
                tr.Commit();
            } catch (Exception ex)
            {
                Form1.RecordResponse(ex, fid, tid);
            }
        }
コード例 #3
0
        public bool DoCommit(ref string mess)
        {
            bool done = false;

            try
            {
                for (int j = 0; j < ol_cnt; j++)
                {
                    OrderLine a = ols[j];
                    s_quantity = a.s_quantity - a.ol_quantity;
                    if (s_quantity < 10)
                    {
                        s_quantity += 91;
                    }
                    var cmd = db.CreateCommand();
                    cmd.Transaction = tr;
                    cmd.CommandText = "update STOCK set S_QUANTITY=" + s_quantity + " where S_I_ID=" + a.oliid + " and S_W_ID=" + a.ol_supply_w_id;
                    Form1.RecordRequest(cmd, fid, tid);
                    cmd.ExecuteNonQuery();
                    cmd.CommandText = "insert into ORDER_LINE(OL_O_ID,OL_D_ID,OL_W_ID,OL_NUMBER,OL_I_ID,OL_SUPPLY_W_ID,OL_QUANTITY,OL_AMOUNT)values(" +
                                      o_id + "," + did + "," + wid + "," + (j + 1) + "," + a.oliid + "," + a.ol_supply_w_id + "," + a.ol_quantity + "," + a.ol_amount + ")";
                    Form1.RecordRequest(cmd, fid, tid);
                    cmd.ExecuteNonQuery();
                }
                mess = "OKAY";
                int rbk = util.random(1, 100);
                if (rbk == 1)
                {
                    tr.Rollback();
                    tr   = null;
                    done = true;
                }
                else
                {
                    tr.Commit();
                    Form1.commits++;
                    tr = null;
                }
                // Phase 3 display the results
                Set(130, "OKAY");
                done = true;
            }
            catch (Exception ex)
            {
                Set(130, ex.Message);
                Form1.RecordResponse(ex, fid, tid);
                tr.Rollback();
                Form1.wconflicts++;
            }
            return(done);
        }
コード例 #4
0
 bool ExecNQ(string sql)
 {
     try
     {
         var cmd = db.CreateCommand();
         cmd.Transaction = tr;
         cmd.CommandText = sql;
         Form1.RecordRequest(cmd, fid, tid);
         cmd.ExecuteNonQuery();
         return(false);
     }
     catch (Exception ex)
     {
         Form1.RecordResponse(ex, fid, tid);
         Form1.wconflicts++;
     }
     return(true);
 }
コード例 #5
0
        protected override void EnterField(int fn)
        {
            Field  f = (Field)fields[fn];
            string s = f.ToString();

            try
            {
                switch (fn)
                {
                case 1: carid = int.Parse(s);
                    DoCarrier(ref s);
                    break;
                }
            }
            catch (Exception ex)
            {
                Form1.RecordResponse(ex, fid, tid);
                Form1.wconflicts++;
            }
            SetCurField(curField);
            status.Text = s;
            Invalidate(true);
        }
コード例 #6
0
        protected override void EnterField(int fn)
        {
            Field  f = (Field)fields[fn];
            string s = f.ToString();
            int    ol;

            try
            {
                if (fn < 10)
                {
                    switch (fn)
                    {
                    case 1: did = int.Parse(s);
                        FetchDistrict(ref s);
                        break;

                    case 2: cid = int.Parse(s);
                        FetchCustomer(ref s);
                        break;

                    case 7: ol_cnt = int.Parse(s);
                        DoOLCount(ref s);
                        for (int j = 0; j < ol_cnt; j++)
                        {
                            ols[j] = new OrderLine();
                        }
                        break;
                    }
                }
                else
                {
                    ol = (fn - 10) / 8;
                    fn = (fn - 10) % 8;
                    OrderLine o = ols[ol];
                    switch (fn)
                    {
                    case 0: o.ol_supply_w_id = int.Parse(s);
                        break;

                    case 1: o.oliid = int.Parse(s);
                        FetchItemData(ol, ref s);
                        break;

                    case 3: o.ol_quantity = int.Parse(s);
                        DoOLQuantity(ol, ref s);
                        if (ol == ol_cnt - 1)
                        {
                            DoTotal();
                        }
                        break;
                    }
                }
                status.Text = s;
            }
            catch (Exception ex) {
                status.Text = ex.Message;
                Form1.RecordResponse(ex, fid, tid);
                tr.Rollback();
                Form1.wconflicts++;
            }
            Invalidate(true);
        }
コード例 #7
0
        public void Single()
        {
            PutBlanks();
            did = util.random(1, 10);
            if (FetchDistrict())
            {
                goto bad;
            }
            cdid  = did;
            cid   = -1;
            clast = "";

/*			if (activewh>1)
 *                      {
 *                              int x = util.random(1,100);
 *                              if (x>85)
 *                              {
 *                                      cdid = util.random(1,10);
 *                                      cwid = util.random(1,activewh,wid);
 *                              }
 *                      } */
            int y = util.random(1, 100);

            if (y <= 60)           // select by random last name
            {
                clast = enc.GetString(util.NextLast(9999));
            }
            else
            {
                cid = util.NURandCID();
            }
            c_amount = decimal.Parse(util.NextNString(1, 500000, 2).ToString());
            bool   done = false;
            string mess = "";

            while (!done && count++ < 1000)
            {
                tr  = db.BeginTransaction(System.Data.IsolationLevel.Serializable);
                tid = ++Form1._tid;
                try
                {
                    if (cid < 0)
                    {
                        FetchCustFromLast(ref mess);
                    }
                    else
                    {
                        FetchCustFromId(ref mess);
                    }
                    DoPayment(ref mess);
                    Invalidate(true);
                    tr.Commit();
                    done = true;
                }
                catch (Exception ex)
                {
                    Form1.RecordResponse(ex, fid, tid);
                    Form1.wconflicts++;
                }
            }
            return;

            bad :;
        }