Esempio n. 1
0
        public Item InsertNewItem(int index)
        {
            this.DisableUpdate();   // 防止闪动。彻底解决问题。2009/10/13 

            try
            {

                this.tableLayoutPanel_content.RowCount += 1;
                this.tableLayoutPanel_content.RowStyles.Insert(index + 1, new System.Windows.Forms.RowStyle());

                Item item = new Item(this);

                item.InsertToTable(this.tableLayoutPanel_content, index);

                this.Items.Insert(index, item);

                if (this.GetDefaultRecord != null)
                {
                    GetDefaultRecordEventArgs e = new GetDefaultRecordEventArgs();
                    this.GetDefaultRecord(this, e);

                    string strDefaultRecord = e.Xml;

                    if (String.IsNullOrEmpty(strDefaultRecord) == true)
                        goto END1;

                    string strError = "";
                    // 根据缺省XML订购记录填充必要的字段
                    int nRet = SetDefaultRecord(item,
                        strDefaultRecord,
                        true,
                        out strError);
                    if (nRet == -1)
                        throw new Exception(strError);
                }
            END1:

                item.State = ItemState.New;

                return item;
            }
            finally
            {
                this.EnableUpdate();
            }
        }
Esempio n. 2
0
        public Item InsertNewItem(int index, string strDefaultRecord = "")
        {
            this.DisableUpdate();   // 防止闪动。彻底解决问题。2009/10/13 
            try
            {
                this.tableLayoutPanel_content.RowCount += 1;
                this.tableLayoutPanel_content.RowStyles.Insert(index + 1, new System.Windows.Forms.RowStyle());

                Item item = new Item(this);

                item.InsertToTable(this.tableLayoutPanel_content, index);

                this.Items.Insert(index, item);

                if (string.IsNullOrEmpty(strDefaultRecord) == true)
                    strDefaultRecord = this.GetDefaultXml();

                if (String.IsNullOrEmpty(strDefaultRecord) == false)
                {
                    string strError = "";
                    // 根据缺省XML订购记录填充必要的字段
                    int nRet = SetDefaultRecord(item,
                        strDefaultRecord,
                        true,
                        out strError);
                    if (nRet == -1)
                        throw new Exception("装载订购记录缺省值时出错: " + strError);
                }

                item.State = ItemState.New;
                return item;
            }
            finally
            {
                this.EnableUpdate();
            }
        }