예제 #1
0
        /// <summary>
        /// 修改焦点对象
        /// </summary>
        public void UpdateObject()
        {
            //获取焦点对象
            Substation_Info obj = FocusedObject;

            if (obj == null)
            {
                return;
            }
            if (obj.S4 == "no")
            {
                MessageBox.Show("此行不能修改!"); return;
            }
            //创建对象的一个副本
            Substation_Info objCopy = new Substation_Info();

            DataConverter.CopyTo <Substation_Info>(obj, objCopy);

            //执行修改操作
            using (FrmSubstation_InfoDialog dlg = new FrmSubstation_InfoDialog())
            {
                dlg.SetVisible();
                dlg.IsSelect            = isselect;
                dlg.Type                = types1;
                dlg.Flag                = flags1;
                dlg.ctrlSubstation_Info = this;
                dlg.ProjectID           = projectid;
                dlg.Object              = objCopy;      //绑定副本
                if (dlg.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
            }

            //用副本更新焦点对象
            DataConverter.CopyTo <Substation_Info>(objCopy, obj);
            this.bandedGridView1.BeginUpdate();
            CalcTotal();
            //刷新表格
            //gridControl.RefreshDataSource();
            this.bandedGridView1.EndUpdate();
        }
예제 #2
0
        /// <summary>
        /// 添加对象
        /// </summary>
        public void AddObject()
        {
            //检查对象链表是否已经加载
            //if (ObjectList == null)
            //{
            //    return;
            //}
            //新建对象
            Substation_Info obj = new Substation_Info();

            obj.Flag       = flags1;
            obj.CreateDate = DateTime.Now;
            //obj.L1 = 100;
            //obj.L2 = 100;
            //obj.L3 = 100;

            //执行添加操作
            using (FrmSubstation_InfoDialog dlg = new FrmSubstation_InfoDialog())
            {
                dlg.SetVisible();
                dlg.Type = types1;
                dlg.Flag = flags1;
                dlg.ctrlSubstation_Info = this;
                dlg.ProjectID           = projectid;
                dlg.IsCreate            = true;         //设置新建标志
                dlg.Object = obj;
                if (dlg.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
            }
            this.bandedGridView1.BeginUpdate();
            CalcTotal();
            //CalcTotal(" order by convert(int,L1) desc,AreaName desc,S4,CreateDate,convert(int,S5) ");
            this.bandedGridView1.EndUpdate();
            //将新对象加入到链表中
            //ObjectList.Add(obj);

            ////刷新表格,并将焦点行定位到新对象上。
            //gridControl.RefreshDataSource();
            //GridHelper.FocuseRow(this.bandedGridView1, obj);
        }