[How To]如何使用Wildfish進行ISeries開發—多操作篇

來源:互聯網
上載者:User
            ORDEREntity entity = orderDataSet1.ORDERTable.CreateEntity();
            entity.CUSTOMERNAME = this.txtCustomerName.Text;
            entity.ORDERDATE = DateTime.Now;
            entity.PROCESSDATE = DateTime.Now; //Here I think it will be a nullable date type,but the framework now do not support this feature. 
            entity.PROCESSUSER = "";
            orderDataSet1.ORDERTable.SetEntity(entity);
            ORDERSystem mgrSystem = new ORDERSystem();
            if (!mgrSystem.InsertOrder(orderDataSet1))
            {
                MessageBox.Show("Error occured at inserting order!Please check the log for the problem!");
            }
            else
            {
                MessageBox.Show("Success to insert an order!You may using STRSQL or using navigator to see what inserted!");
            }

1。建立一個Winform 名字是TestMultiTable
2. 添加using
  
using Wildfish.Data.ISeries;
using Wildfish.BusinessFacade.ISeries;
3。畫螢幕
4。編寫Code
插入OrderItem //thus is just a sample,so i do not add lot of validation
            int maxItemIndex = 0;
            for (int i = 0; i < orderDataSet1.ORDERITEMTable.Rows.Count; i++)
            {
                if (maxItemIndex < orderDataSet1.ORDERITEMTable.GetEntity(i).ITEMID)
                {
                    maxItemIndex = orderDataSet1.ORDERITEMTable.GetEntity(i).ITEMID;
                }
            }
            maxItemIndex++; //It will be a new Item
            ORDERITEMEntity entity = orderDataSet1.ORDERITEMTable.CreateEntity();
            entity.ITEMID = maxItemIndex;
            entity.PRICE = Convert.ToDecimal(this.txtPrice.Text);
            entity.PRODUCTNAME = this.txtProductName.Text;
            entity.QUANTITY = Convert.ToInt32(this.txtQuantity.Text);
            orderDataSet1.ORDERITEMTable.SetEntity(entity);

OrderSystem的InsertOrder邏輯            KEYSEQNUpdateObject updObj = new KEYSEQNUpdateObject();
            updObj.Where[KEYSEQNUpdateObject.TYPE_Field].FieldValue = "SEQN";
            updObj.Where[KEYSEQNUpdateObject.CODE_Field].FieldValue = "ORDER";
            updObj.Result[KEYSEQNUpdateObject.DETAIL6_Field].Expression = "DETAIL6+1";

            try
            {
                baseDataAccess.BeginTransaction();
                if (!mgrRule.UpdateData(baseDataAccess, updObj))
                {
                    baseDataAccess.Rollback();
                    return false;
                }
                string orderID = "Order" + updObj.Result[KEYSEQNUpdateObject.DETAIL6_Field].FieldValue;
                ORDEREntity orderEntity = orderDataSet.ORDERTable.GetEntity(0);
                orderEntity.ORDERID = orderID;
                for (int i = 0; i < orderEntity.ORDERITEMEntities.Count; i++)
                {
                    orderEntity.ORDERITEMEntities[i].ORDERID = orderID;
                }
                orderDataSet.SetEntity(orderEntity);
                if (!baseDataAccess.InsertObjectData(orderDataSet))
                {
                    baseDataAccess.Rollback();
                    return false;
                }
                baseDataAccess.Commit();
                return true;
            }
            catch
            {
                baseDataAccess.Rollback();
                return false;
            }

代碼很簡單,我就不細說了,
其實就是,用一個UpdateObject對象產生Key,然後給Order對象的OrderID賦值,然後Insert到資料庫。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.