Esempio n. 1
0
        private void InsertLineData1()
        {
            if (ctrlPowerEachTotalList1.FocusedObject == null)
            {
                MsgBox.Show("û����Ŀ���ڣ��޷����룡");
                return;
            }

            string UID = "";
            try
            {
                TreeListNode tln = this.ctrlPowerEachTotal1.ZHJ.FocusedNode;
                UID = tln["UID"].ToString();
            }
            catch
            { }

            string a = "";
            try
            {

                DataTable dts = new DataTable();
                OpenFileDialog op = new OpenFileDialog();
                op.Filter = "Excel�ļ�(*.xls)|*.xls";
                if (op.ShowDialog() == DialogResult.OK)
                {
                    dts = GetExcel(op.FileName);
                    for (int i = 0; i < dts.Rows.Count; i++)
                    {
                        if (dts.Rows[i][0].ToString() != "")
                        {
                            PowerEachTotal li = new PowerEachTotal();
                            //PowerEachTotalList li1 = (PowerEachTotalList)Itop.Client.Common.Services.BaseService.GetObject("SelectPowerEachTotalListList", "");
                            object obj = Services.BaseService.GetObject("SelectPowerEachTotalList1", "");

                            li.PowerLineUID = ctrlPowerEachTotal1.LineUID;
                            li.Remark = ctrlPowerEachTotal1.LineName;
                            li.StuffName = dts.Rows[i][0].ToString();
                            li.Lengths = dts.Rows[i][1].ToString();
                            li.LCount = dts.Rows[i][2].ToString();
                            li.Total = dts.Rows[i][3].ToString();
                            li.Volume = dts.Rows[i][4].ToString();
                            li.Type = dts.Rows[i][5].ToString();
                            li.IsSum = Convert.ToDouble(dts.Rows[i][6].ToString());
                            li.ItSum = Convert.ToDouble(dts.Rows[i][7].ToString());
                            li.ParentID = UID;

                            Services.BaseService.Create<PowerEachTotal>(li);

                        }

            }

            this.ctrlPowerEachTotal1.RefreshData();
            }
            }
            catch { MsgBox.Show("�����ʽ����ȷ��"); }
        }
        /// <summary>
        /// ɾ���������
        /// </summary>
        public void DeleteObject()
        {
            //��ȡ�������
            PowerEachTotalList obj = FocusedObject;
            if (obj == null)
            {
                return;
            }

            PowerEachTotal pt = new PowerEachTotal();
            pt.PowerLineUID = obj.UID;

            IList<PowerEachTotal> li = Services.BaseService.GetList<PowerEachTotal>("SelectPowerEachTotalList", pt);
            if (li.Count > 0)
            {
                MsgBox.Show("�÷��������л��ܱ��¼���޷�ɾ��");
                return;
            }

            //����ȷ��
            if (MsgBox.ShowYesNo(Strings.SubmitDelete) != DialogResult.Yes)
            {
                return;
            }

            //ִ��ɾ������
            try
            {
                Services.BaseService.Delete<PowerEachTotalList>(obj);
            }
            catch (Exception exc)
            {
                Debug.Fail(exc.Message);
                HandleException.TryCatch(exc);
                return;
            }

            this.gridView.BeginUpdate();
            //��ס��ǰ����������
            int iOldHandle = this.gridView.FocusedRowHandle;
            //��������ɾ��
            ObjectList.Remove(obj);
            //ˢ�±��
            gridControl.RefreshDataSource();
            //�����µĽ���������
            GridHelper.FocuseRowAfterDelete(this.gridView, iOldHandle);
            this.gridView.EndUpdate();
        }
Esempio n. 3
0
        /// <summary>
        /// ˢ�±���е�����
        /// </summary>
        /// <returns>ture:�ɹ�  false:ʧ��</returns>
        public bool RefreshData()
        {
            try
            {
                PowerEachTotal pet = new PowerEachTotal();
                pet.PowerLineUID = lineuid;
                list.Clear();
                dataTable = new DataTable();
                list = Services.BaseService.GetList<PowerEachTotal>("SelectPowerEachTotalList", pet);
                dataTable = DataConverter.ToDataTable((IList)list, typeof(PowerEachTotal));
                this.treeList1.DataSource = dataTable;
                this.treeList1.ExpandAll();

                treeList1.MoveFirst();
            }
            catch (Exception exc)
            {
                Debug.Fail(exc.Message);
                HandleException.TryCatch(exc);
                return false;
            }

            return true;
        }
Esempio n. 4
0
        /// <summary>
        /// ��Ӷ���
        /// </summary>
        public void AddObject()
        {
            int count = 0;
            string parentid = "";
            if (treeList1.FocusedNode != null)
            {
                parentid = treeList1.FocusedNode["ParentID"].ToString();
            }

            object objs = Services.BaseService.GetObject("SelectPowerEachTotalBySortID", parentid);
            if (objs != null)
                count = (int)objs;

            //PowerEachTotal obj = new PowerEachTotal();
            //obj.SortID = count + 1;
            //obj.ParentID = parentid;
            //obj.PowerLineUID = lineuid;

            FormTypeTitle frm = new FormTypeTitle();
            frm.Text = "������Ŀ";

            if (frm.ShowDialog() == DialogResult.OK)
            {
                PowerEachTotal obj = new PowerEachTotal();
                obj.UID = Guid.NewGuid().ToString();
                obj.SortID = count + 1;
                obj.ParentID = parentid;
                obj.PowerLineUID = lineuid;
                obj.StuffName = frm.TypeTitle;

                try
                {
                    Services.BaseService.Create<PowerEachTotal>(obj);
                    dataTable.Rows.Add(DataConverter.ObjectToRow(obj, dataTable.NewRow()));
                    //psp_Type.ID = (int)Common.Services.BaseService.Create("InsertPowerTypes", psp_Type);
                    //dataTable.Rows.Add(Itop.Common.DataConverter.ObjectToRow(psp_Type, dataTable.NewRow()));
                }
                catch (Exception ex)
                {
                    MsgBox.Show("������Ŀ�����" + ex.Message);
                }
            }

            //using (FrmPowerEachTotalDialog dlg = new FrmPowerEachTotalDialog())
            //{
            //    dlg.IsCreate = true;    //�����½���־
            //    dlg.Object = obj;
            //    if (dlg.ShowDialog() != DialogResult.OK)
            //    {
            //        return;
            //    }
            //}

            //dataTable.Rows.Add(DataConverter.ObjectToRow(obj, dataTable.NewRow()));
        }
Esempio n. 5
0
        public void InsertData()
        {
            int count = 0;
            string parentid = "";
            if (treeList1.FocusedNode == null)
                return;

            if (treeList1.FocusedNode != null)
            {
                parentid = treeList1.FocusedNode["ParentID"].ToString();
                count = int.Parse(treeList1.FocusedNode["SortID"].ToString());
            }

            //object objs = Services.BaseService.GetObject("SelectPowerProjectBySortID", parentid);
            //if (objs != null)
            //    count = (int)objs;

            PowerEachTotal obj = new PowerEachTotal();
            obj.SortID = count;
            obj.ParentID = parentid;
            obj.PowerLineUID = lineuid;

            using (FrmPowerEachTotalDialog dlg = new FrmPowerEachTotalDialog())
            {
                dlg.IsCreate = true;    //�����½���־
                dlg.Object = obj;
                dlg.IsInsert = true;
                if (dlg.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
            }
            dataTable.Rows.Add(DataConverter.ObjectToRow(obj, dataTable.NewRow()));
            this.treeList1.DataSource = dataTable;
        }