private bool EditData()//批量修改 { Hashtable htEdit = new Hashtable(); int r = 0; if (htRow.Count > 0) { for (int k = 0; k < htRow.Count; k++) { r = Convert.ToInt32(htRow[k].ToString()); MSystemFun MSysFun = new MSystemFun(); MSysFun.MODEL_ID = Convert.ToInt32(GvFunClassOne.Rows[r].Cells["MODEL_ID"].Value.ToString()); if (!string.IsNullOrEmpty(GvFunClassOne.Rows[r].Cells["MODEL_NAME"].FormattedValue.ToString())) { MSysFun.MODEL_NAME = GvFunClassOne.Rows[r].Cells["MODEL_NAME"].Value.ToString(); } else { MessageBoxEx.Show("系统名称不能为空", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return(false); } if (!string.IsNullOrEmpty(GvFunClassOne.Rows[r].Cells["MODEL_PLACE"].FormattedValue.ToString())) { MSysFun.MODEL_PLACE = GvFunClassOne.Rows[r].Cells["MODEL_PLACE"].Value.ToString(); } else { MessageBoxEx.Show("窗体对象名称不能为空", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return(false); } if (ExpressionValidat.IsInt(GvFunClassOne.Rows[r].Cells["SORT_FLAG"].FormattedValue.ToString())) { MSysFun.SORT_FLAG = Convert.ToInt32(GvFunClassOne.Rows[r].Cells["SORT_FLAG"].Value.ToString()); } else { MessageBoxEx.Show("排序号必须为数字!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return(false); } if (!string.IsNullOrEmpty(GvFunClassOne.Rows[r].Cells["IMAGE_ADDRESS"].FormattedValue.ToString())) { MSysFun.IMAGE_ADDRESS = GvFunClassOne.Rows[r].Cells["IMAGE_ADDRESS"].Value.ToString(); } htEdit.Add(k, MSysFun); } if (BSysFun.UpdateMore(htEdit) >= 0) { MessageBoxEx.Show("修改成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBoxEx.Show("修改失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } } htRow.Clear(); i = 0; return(true); }
private bool SaveData()//批量保存 { Hashtable ht = new Hashtable(); if (GvFunClassThree.Rows.Count > rowcount - 1) //说明有新增行 { for (int i = rowcount, j = 0; i <= GvFunClassThree.Rows.Count && j < GvFunClassThree.Rows.Count; i++, j++) //从第rowcount个开始保存 { MSystemFun MSysFunChi = new MSystemFun(); MSysFunChi.MODEL_ID = Convert.ToInt32(GvFunClassThree.Rows[i - 1].Cells["MODEL_ID"].Value.ToString()); if (!string.IsNullOrEmpty(GvFunClassThree.Rows[i - 1].Cells["UP_MODEL_NAME"].FormattedValue.ToString())) { MSysFunChi.UP_MODEL_ID = Convert.ToInt32(BSysFun.GetList(" MODEL_NAME='" + GvFunClassThree.Rows[i - 1].Cells["UP_MODEL_NAME"].Value.ToString() + "'").Rows[0]["MODEL_ID"].ToString()); } else { MessageBoxEx.Show("二级模块不能为空", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return(false); } MSysFunChi.MODEL_CLASS = "3"; MSysFunChi.DEL_FLAG = 0; if (ExpressionValidat.IsInt(GvFunClassThree.Rows[i - 1].Cells["SORT_FLAG"].FormattedValue.ToString())) { MSysFunChi.SORT_FLAG = Convert.ToInt32(GvFunClassThree.Rows[i - 1].Cells["SORT_FLAG"].Value.ToString()); } else { MessageBoxEx.Show("排序号必须为整数!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return(false); } MSysFunChi.MODEL_ID = Convert.ToInt32(GvFunClassThree.Rows[i - 1].Cells["MODEL_ID"].Value.ToString()); if (!string.IsNullOrEmpty(GvFunClassThree.Rows[i - 1].Cells["MODEL_NAME"].FormattedValue.ToString())) { MSysFunChi.MODEL_NAME = GvFunClassThree.Rows[i - 1].Cells["MODEL_NAME"].Value.ToString(); } else { MessageBoxEx.Show("三级模块不能为空", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return(false); } if (!string.IsNullOrEmpty(GvFunClassThree.Rows[i - 1].Cells["MODEL_PLACE"].FormattedValue.ToString())) { MSysFunChi.MODEL_PLACE = GvFunClassThree.Rows[i - 1].Cells["MODEL_PLACE"].Value.ToString(); } else { MessageBoxEx.Show("系统对象名称不能为空", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return(false); } ht.Add(j, MSysFunChi); } } if (ht.Count > 0) { if (BSysFun.AddMore(ht) > 0) { MessageBoxEx.Show("添加成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBoxEx.Show("添加失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } } return(true); }