Ejemplo n.º 1
0
        //private void GvFunClassThree_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
        //{
        //    switch (GvFunClassThree.Columns[e.ColumnIndex].Name)
        //    {

        //        case "UP_MODEL_NAME":
        //            if (String.IsNullOrEmpty(e.FormattedValue.ToString()))
        //            {
        //                MessageBoxEx.Show("请选择上级模块!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
        //                e.Cancel = true;
        //            }
        //            break;

        //        case "MODEL_NAME":
        //            if (String.IsNullOrEmpty(e.FormattedValue.ToString()))
        //            {
        //                MessageBoxEx.Show("三级模块名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
        //                e.Cancel = true;
        //            }
        //            break;

        //        case "MODEL_PLACE":
        //            if (String.IsNullOrEmpty(e.FormattedValue.ToString()))
        //            {
        //                MessageBoxEx.Show("窗体对象名称不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
        //                e.Cancel = true;
        //            }
        //            break;
        //        case "SORT_FLAG":
        //            if (!ExpressionValidat.IsNumeric(e.FormattedValue.ToString()))
        //            {
        //                MessageBoxEx.Show("排序号必须为数字!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
        //            }
        //            break;
        //    }

        //}

        private void GvFunClassThree_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            DataGridView gv = (DataGridView)sender;

            if (gv.Columns[e.ColumnIndex].Name == "Operate")
            {
                if (e.RowIndex < rowcount - 1)
                {
                    if (DialogResult.OK == MessageBoxEx.Show(" 确认要删除" + gv.Rows[e.RowIndex].Cells["MODEL_NAME"].Value + "吗", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk))
                    {
                        if (BSysFun.Delete(" where MODEL_ID='" + gv.Rows[e.RowIndex].Cells["MODEL_ID"].Value.ToString() + "'") >= 0)
                        {
                            MessageBoxEx.Show("删除成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            GetClassThreeModel();//刷新表格
                        }
                        else
                        {
                            MessageBoxEx.Show("删除失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                }
                else
                {
                    if (!gv.Rows[e.RowIndex].IsNewRow)
                    {
                        gv.Rows.RemoveAt(e.RowIndex);
                    }
                }
            }

            if (gv.Columns[e.ColumnIndex].Name == "Edit")//修改历史数据
            {
                SetDataGridViewRowEditModel(e.RowIndex);
                gv.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.DarkGray;
                htRow.Add(i++, e.RowIndex.ToString());
            }
        }
Ejemplo n.º 2
0
        private void GvFunClassTwo_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            DataGridView gv = (DataGridView)sender;

            if (gv.Columns[e.ColumnIndex].Name == "Operate")
            {
                if (e.RowIndex < rowcount - 1)
                {
                    if (DialogResult.OK == MessageBoxEx.Show(" 将删除该模块下的所有子模块,确认要删除" + gv.Rows[e.RowIndex].Cells["MODEL_NAME"].Value + "吗", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk))
                    {
                        if (BSysFun.Delete("  where model_id in( select model_id from SYSTEM_FUNCTION start with MODEL_ID=" + Convert.ToInt32(gv.Rows[e.RowIndex].Cells["MODEL_ID"].Value.ToString()) + " connect by prior model_id=up_model_id )") >= 0)
                        {
                            MessageBoxEx.Show("删除成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            GetClassTwoModel();//刷新表格
                        }
                        else
                        {
                            MessageBoxEx.Show("删除失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                }
                else
                {
                    if (!gv.Rows[e.RowIndex].IsNewRow)
                    {
                        gv.Rows.RemoveAt(e.RowIndex);
                    }
                }
            }

            if (gv.Columns[e.ColumnIndex].Name == "Edit")//修改历史数据
            {
                SetDataGridViewRowEditModel(e.RowIndex);
                gv.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.DarkGray;
                htRow.Add(i++, e.RowIndex.ToString());
            }
        }