Esempio n. 1
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);
        }
Esempio n. 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);
     }
 }
Esempio n. 3
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();
        }