private void DeleteDevData()
??{
???int deleteNum=0;
???//删除选中的某一行或多行记录,调用DataGrid的IsSelected(i)函数,如果函数返回结果为true,则表示该行被选中
???ArrayList arrList = new ArrayList();
???for(int i=0;i
???{???
????if(dtg_BasicDataInfo.IsSelected(i)==true)
????{?
?????F_WR_Public.VO_DevSpec vo_DevSpec_Delete = new F_WR_Public.VO_DevSpec();
?????//表中第11列保存的是设备类型的主键,但没有显示在表中。
?????vo_DevSpec_Delete.devSpecID = Int64.Parse(DevSpec.Rows[i][10].ToString());
?????arrList.Add(vo_DevSpec_Delete);
?????deleteNum++;
????}
???}
???if (deleteNum !=0)
???{
????if (MessageBox.Show ("你确定要删除这些数据吗?", "删除数据",
?????MessageBoxButtons.YesNo, MessageBoxIcon.Question)== DialogResult.Yes)
????{
?????F_WR_Public.F_WR_Public f_WR_Public = new F_WR_Public.F_WR_Public();?????
?????F_WR_Public.VO_DevSpec[] arrVO_DevSpec_Delete = new F_WR_Public.VO_DevSpec[deleteNum];
?????IEnumerator ienum = arrList.GetEnumerator();
?????int deleteIndex=0;
?????while(ienum.MoveNext())
?????{
??????arrVO_DevSpec_Delete[deleteIndex] = (F_WR_Public.VO_DevSpec)ienum.Current;
??????arrVO_DevSpec_Delete[deleteIndex].col=Int64.MaxValue;
??????arrVO_DevSpec_Delete[deleteIndex].devTypeID=Int64.MaxValue;
??????arrVO_DevSpec_Delete[deleteIndex].num=Int64.MaxValue;
??????arrVO_DevSpec_Delete[deleteIndex].row=Int64.MaxValue;
??????deleteIndex++;
?????}
?????f_WR_Public.removeDevSpec(arrVO_DevSpec_Delete);
?????MessageBox.Show ("删除成功!", "删除数据",MessageBoxButtons.OK, MessageBoxIcon.Information);
????}
????else
????{
?????return;
????}
???}
???else
???{
????MessageBox.Show ("未选中所要删除的数据!", "删除数据", MessageBoxButtons.OK, MessageBoxIcon.Warning);
???}
??}
?
private void QueryDevSpec()
??{
???try
???{
????DevSpec.Clear();
????F_WR_Public.F_WR_Public f_WR_Public = new F_WR_Public.F_WR_Public();
????F_WR_Public.VO_DevSpec vo_DevSpec = new F_WR_Public.VO_DevSpec();
????vo_DevSpec.col=Int64.MaxValue;
????vo_DevSpec.devSpecID=Int64.MaxValue;
????vo_DevSpec.devTypeID=Int64.Parse(cbo_DevType.SelectedValue.ToString());
????vo_DevSpec.num=Int64.MaxValue;
????vo_DevSpec.row=Int64.MaxValue;
????F_WR_Public.VO_DevSpec[] arrVO_DevSpec=f_WR_Public.queryDevSpec(vo_DevSpec);
????if(arrVO_DevSpec!=null)
????{
?????for(int i=0;i?????{
??????F_WR_Public.VO_DevSpec vo_DevSpec_Result = arrVO_DevSpec[i];
??????DataRow myRow;
??????myRow = DevSpec.NewRow();
??????myRow["设备大类"] =DIC_DevSpec[vo_DevSpec_Result.devTypeID].displayMember.ToString();
??????myRow["规格类型"] = vo_DevSpec_Result.specType;
??????myRow["生产厂家"] = vo_DevSpec_Result.manufacturer;
??????myRow["长"] = vo_DevSpec_Result.@long;
??????myRow["宽"] = vo_DevSpec_Result.width;
??????myRow["高"] = vo_DevSpec_Result.high;
??????if ( vo_DevSpec_Result.num != Int64.MaxValue)
??????{
???????myRow["数量"] = vo_DevSpec_Result.num;
??????}
??????else
???????myRow["数量"] ="";
??????if ( vo_DevSpec_Result.row != Int64.MaxValue)
??????{
???????myRow["行"] = vo_DevSpec_Result.row;
??????}
??????else
???????myRow["行"] = "";
??????if ( vo_DevSpec_Result.col != Int64.MaxValue)
??????{
???????myRow["列"] = vo_DevSpec_Result.col;
??????}
??????else
???????myRow["列"] = "";;
??????
??????myRow["排列方式"] = vo_DevSpec_Result.disposeType;
??????myRow["设备型号"] = vo_DevSpec_Result.devSpecID;
??????DevSpec.Rows.Add(myRow);
?????}
?????DevSpec.AcceptChanges();
?????//设置dtg_BasicDataInfo的DataMember为DevSpec
?????dtg_BasicDataInfo.DataMember = DevSpec.ToString();
?????dtg_BasicDataInfo.DataSource=dataSet1;
?????DevTableStyle.MappingName="DevSpec";
?????rowCounts=arrVO_DevSpec.Length;
????}
????else
????{
?????rowCounts=0;
????}
????dtg_BasicDataInfo.ReadOnly = true;
???}
???catch(Exception ee)
???{
????
????MessageBox.Show (ee.ToString(), "Error",
?????MessageBoxButtons.OK, MessageBoxIcon.Information);
???}
??}
?
?private void SaveDevData()
??? {
???try
???{
????F_WR_Public.F_WR_Public f_WR_Public = new F_WR_Public.F_WR_Public();
????//如果某行的状态为Added,则表示该行的数据是新增加的
????DataRow[] dataRowAdd = DevSpec.Select(null,null,DataViewRowState.Added);
????int mCount= dataRowAdd.Length;
????if (mCount != 0)
????{
?????F_WR_Public.VO_DevSpec[] arrVO_DevSpec_Add = new F_WR_Public.VO_DevSpec[mCount];
?????for(int i=0;i
?????{
??????F_WR_Public.VO_DevSpec vo_DevSpec = new F_WR_Public.VO_DevSpec();
??????vo_DevSpec.col=Int64.MaxValue;
??????vo_DevSpec.num=Int64.MaxValue;
??????vo_DevSpec.row=Int64.MaxValue;
??????vo_DevSpec.devTypeID =Int64.Parse(cbo_DevType.SelectedValue.ToString());
??????vo_DevSpec.specType=dataRowAdd[i][1].ToString();
??????vo_DevSpec.manufacturer=dataRowAdd[i][2].ToString();
??????vo_DevSpec.@long=dataRowAdd[i][3].ToString();
??????vo_DevSpec.width=dataRowAdd[i][4].ToString();
??????vo_DevSpec.high=dataRowAdd[i][5].ToString();
??????if(!dataRowAdd[i][6].ToString().Equals(""))
??????{
???????vo_DevSpec.num= Int64.Parse(dataRowAdd[i][6].ToString());
??????}
??????if(!dataRowAdd[i][7].ToString().Equals(""))
??????{
???????vo_DevSpec.row= Int64.Parse(dataRowAdd[i][7].ToString());
??????}
??????if(!dataRowAdd[i][8].ToString().Equals(""))
??????{
???????vo_DevSpec.col= Int64.Parse(dataRowAdd[i][8].ToString());
??????}
??????vo_DevSpec.disposeType=dataRowAdd[i][9].ToString();
??????vo_DevSpec.devSpecID=Int64.MaxValue;
????????
????????
??????arrVO_DevSpec_Add[i] = vo_DevSpec;
?????}
?????f_WR_Public.addDevSpec(arrVO_DevSpec_Add);
?????MessageBox.Show ("增加成功!", "增加数据",MessageBoxButtons.OK, MessageBoxIcon.Information);
????}
????//如果某行的状态为ModifiedCurrent,则表示该行的数据被修改过
????DataRow[] dataRowModify = DevSpec.Select(null,null,DataViewRowState.ModifiedCurrent);
????int intDataRowModify = dataRowModify.Length;
????if (intDataRowModify != 0)
????{
?????F_WR_Public.VO_DevSpec[] arrVO_DevSpec_Modify = new F_WR_Public.VO_DevSpec[intDataRowModify];
?????for(int i=0;i
?????{
??????F_WR_Public.VO_DevSpec vo_DevSpec = new F_WR_Public.VO_DevSpec();
??????//表中第11列保存的是设备类型的主键,但没有显示在表中。
??????vo_DevSpec.devSpecID= Int64.Parse(dataRowModify[i][10].ToString());
??????//
??????vo_DevSpec.col=Int64.MaxValue;
??????vo_DevSpec.num=Int64.MaxValue;
??????vo_DevSpec.row=Int64.MaxValue;
??????vo_DevSpec.specType=dataRowModify[i][1].ToString();
??????vo_DevSpec.manufacturer=dataRowModify[i][2].ToString();
??????vo_DevSpec.@long=dataRowModify[i][3].ToString();
??????vo_DevSpec.width=dataRowModify[i][4].ToString();
??????vo_DevSpec.high=dataRowModify[i][5].ToString();
??????if(!dataRowModify[i][6].ToString().Equals(""))
??????{
???????vo_DevSpec.num= Int64.Parse(dataRowModify[i][6].ToString());
??????}
??????if(!dataRowModify[i][7].ToString().Equals(""))
??????{
???????vo_DevSpec.row= Int64.Parse(dataRowModify[i][7].ToString());
??????}
??????if(!dataRowModify[i][8].ToString().Equals(""))
??????{
???????vo_DevSpec.col= Int64.Parse(dataRowModify[i][8].ToString());
??????}
??????vo_DevSpec.disposeType=dataRowModify[i][9].ToString();
??????arrVO_DevSpec_Modify[i] = vo_DevSpec;
?????}
???????
?????f_WR_Public.modifyDevSpec(arrVO_DevSpec_Modify);
?????MessageBox.Show ("保存成功!", "保存数据",MessageBoxButtons.OK, MessageBoxIcon.Information);
????}
????DevSpec.AcceptChanges();
???}
???catch(Exception ee)
???{
????MessageBox.Show (ee.ToString(), "Error",MessageBoxButtons.OK, MessageBoxIcon.Information);
???}
??? }
?
?
private void QueryIfSaveDevData()
??{
???/*该函数查询Dev表中是否有未保存的数据,如果有,则询问是否保存,
??? * 如果用户回答需要保存,则调用SaveDevData过程保存数据,如果回答否,
??? * 则调用查询过程QueryDevSpec刷新页面*/
???DataRow[] dataRowAdd1 = DevSpec.Select(null,null,DataViewRowState.Added);
???int mAddCount1= dataRowAdd1.Length;
???DataRow[] dataRowModify1 = DevSpec.Select(null,null,DataViewRowState.ModifiedCurrent);
???int mModifyCount1=dataRowModify1.Length;
???if (mAddCount1!=0 || mModifyCount1 !=0)
???{
????if (MessageBox.Show ("有编辑过的数据未保存,需要保存吗?", "提示",
?????MessageBoxButtons.YesNo, MessageBoxIcon.Question)== DialogResult.Yes)
?????SaveDevData();
????else
?????QueryDevSpec();
???}
??}
?