Example #1
0
 //添加地区
 private void barButtonItem1_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
 {
     FrmAddPN frm = new FrmAddPN();
     frm.SetFrmName = "添加地区";
     frm.SetLabelName = "地区名称";
     if (frm.ShowDialog() == DialogResult.OK)
     {
         Ps_Table_GDP data = new Ps_Table_GDP();
         data.ID += "|" + ProjectID;
         data.ParentID = "0";
         data.ProjectID = ProjectID;
         data.SortID = OperTable.GetGDPMaxSort()+1;
         data.Area = frm.ParentName;
         Common.Services.BaseService.Create<Ps_Table_GDP>(data);
     }
     InitGrid2();
 }
Example #2
0
 private void barButtonItem8_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
 {
     if (this.gridView2.FocusedRowHandle > -1)
     {
         IList<string> filedList = new List<string>();
         IList<string> capList = new List<string>();
         for (int i = 0; i < gridView1.Columns.Count; i++)
         {
             capList.Add(gridView1.Columns[i].Caption);
             filedList.Add(gridView1.Columns[i].FieldName);
         }
         OpenFileDialog op = new OpenFileDialog();
         op.Filter = "Excel文件(*.xls)|*.xls";
         if (op.ShowDialog() == DialogResult.OK)
         {
             try
             {
                 DataTable table = OperTable.GetExcel(op.FileName, filedList, capList);
                 for (int i = 0; i < table.Rows.Count; i++)
                 {
                     if (table.Rows[i][0].ToString().IndexOf("合计") > 0 || table.Rows[i][1].ToString().IndexOf("合计") > 0)
                         continue;
                     Ps_Table_GDP area = new Ps_Table_GDP();
                     area.ID += "|" + ProjectID;
                     area.SortID = OperTable.GetGDPMaxSort()+1;
                     area.ParentID = this.gridView2.GetRowCellValue(this.gridView2.FocusedRowHandle, "ID").ToString();
                     area.ProjectID = ProjectID;
                     foreach (DataColumn col in table.Columns)
                     {
                         if(col.ColumnName=="Yearf")
                             area.GetType().GetProperty(col.ColumnName).SetValue(area, int.Parse(table.Rows[i][col].ToString()), null);
                         else
                             area.GetType().GetProperty(col.ColumnName).SetValue(area, double.Parse(table.Rows[i][col].ToString()), null);
                     }
                     Common.Services.BaseService.Create<Ps_Table_GDP>(area);
                 }
             }
             catch { }
             InitGrid1();
         }
     }
     else
         MessageBox.Show("没有选择地区(如果没有请添加一个)","导入EXCEL",MessageBoxButtons.OK);
 }
Example #3
0
 private void btnOK_Click(object sender, EventArgs e)
 {
     if (SaveRecord())
     {
         if (checkEdit1.Checked)
         {
             area.InitGrid1();
             _obj = new Ps_Table_GDP();
             IList<Ps_Table_GDP> list1 = new List<Ps_Table_GDP>();
             list1.Add(_obj);
             this.vGridControl.DataSource = list1;
         }
         else
         {
             DialogResult = DialogResult.OK;
         }
     }
 }
Example #4
0
        private void barButtonItem4_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (this.gridView2.FocusedRowHandle >= 0)
            {
                FrmAddGDP frm = new FrmAddGDP();
                frm.Area = this;
                frm.Text = "添加记录";
                frm.IsCreate = true;

                frm.ProjectID = ProjectID;
                frm.ParentID = this.gridView2.GetRowCellValue(this.gridView2.FocusedRowHandle, "ID").ToString();
                Ps_Table_GDP obj = new Ps_Table_GDP();
                frm.Object = obj;
                if (frm.ShowDialog() == DialogResult.OK)
                {
                    frm.Close();
                    InitGrid1();
                }
            }
            else
            {
                MessageBox.Show("请先选择一个地区", "添加", MessageBoxButtons.OK);
            }
        }
Example #5
0
        protected bool SaveRecord()
        {
            try
            {
                _obj.GDPper = Math.Round((_obj.Population == 0.0 ? 0.0 : 10000 * _obj.GDP / _obj.Population),2);
                if (IsCreate)
                {
                    //Ps_Table_GDP pg = new Ps_Table_GDP();
                    //pg.ID = _obj.ID;
                    //pg.GDP = _obj.GDP;
                    //pg.Population = _obj.Population;
                    //pg.Yearf = _obj.Yearf;
                    //pg.GDPrate = _obj.GDPrate;
                        _obj.ID += "|" + projectid;
                        _obj.ParentID = parentid;
                        _obj.ProjectID = projectid;
                        _obj.SortID = OperTable.GetGDPMaxSort() + 1;
                        IList<Ps_Table_GDP> list = Common.Services.BaseService.GetList<Ps_Table_GDP>("SelectPs_Table_GDPByConn", " ProjectID='" + _obj.ProjectID + "' and ParentID='" + _obj.ParentID + "' and Yearf='" + _obj.Yearf + "'");
                        if (list.Count>0)
                        {
                            MessageBox.Show("��������ݲ��ܹ��ظ���");
                            _obj = new Ps_Table_GDP();
                            IList<Ps_Table_GDP> list1 = new List<Ps_Table_GDP>();
                            list1.Add(_obj);
                            this.vGridControl.DataSource = list1;
                            return false;
                        }
                        Services.BaseService.Create<Ps_Table_GDP>(_obj);

                }
                else
                {
                    IList<Ps_Table_GDP> list = Common.Services.BaseService.GetList<Ps_Table_GDP>("SelectPs_Table_GDPByConn", " ProjectID='" +_obj.ProjectID + "' and ParentID='" +_obj.ParentID+ "' and Yearf='" +_obj.Yearf + "'");
                     foreach (Ps_Table_GDP pg in list)
                    {
                         if (pg.ID!=_obj.ID)
                         {
                             MessageBox.Show("�Ѿ����ڴ������ݣ��������޸ģ�");
                             return false;
                         }
                    }

                    Services.BaseService.Update<Ps_Table_GDP>(_obj);
                }
            }
            catch (Exception exc)
            {
                Debug.Fail(exc.Message);
                HandleException.TryCatch(exc);
                return false ;
            }

            //�����ѳɹ�
            return true;
        }