📄 frm-computemodify.cs
字号:
DGViewResult.CurrentCell = DGViewResult.Rows[i].Cells[j];
btnModify.Enabled = false;
return;
}
if(MyCls.IsInteger(DGViewResult.CurrentCell.Value.ToString()))
{
MessageBox.Show("请输入大于0的正整数","错误",MessageBoxButtons.OK,MessageBoxIcon.Error);
DGViewResult.CurrentCell = DGViewResult.Rows[i].Cells[j];
btnModify.Enabled = false;
return;
}
}
break;
case 3://MAC
{
if (!MyCls.CheckString(DGViewResult.CurrentCell.Value.ToString(), 25))
{
DGViewResult.CurrentCell = DGViewResult.Rows[i].Cells[j];
btnModify.Enabled = false;
return;
}
}
break;
case 4://端口
{
if (!MyCls.CheckString(DGViewResult.CurrentCell.Value.ToString(), 10))
{
DGViewResult.CurrentCell = DGViewResult.Rows[i].Cells[j];
btnModify.Enabled = false;
return;
}
}
break;
case 5://计算机型号
{
if (!MyCls.CheckString(DGViewResult.CurrentCell.Value.ToString(), 25))
{
DGViewResult.CurrentCell = DGViewResult.Rows[i].Cells[j];
btnModify.Enabled = false;
return;
}
}
break;
case 6://部门
{
if (!MyCls.CheckString(DGViewResult.CurrentCell.Value.ToString(), 30))
{
DGViewResult.CurrentCell = DGViewResult.Rows[i].Cells[j];
btnModify.Enabled = false;
return;
}
}
break;
case 7://负责人
{
if (!MyCls.CheckString(DGViewResult.CurrentCell.Value.ToString(), 10))
{
DGViewResult.CurrentCell = DGViewResult.Rows[i].Cells[j];
btnModify.Enabled = false;
return;
}
}
break;
case 8://是否绑定
{
if(!(DGViewResult.CurrentCell.Value.ToString()=="Y" || DGViewResult.CurrentCell.Value.ToString() == "N"))
{
DGViewResult.CurrentCell = DGViewResult.Rows[i].Cells[j];
btnModify.Enabled = false;
MessageBox.Show("请输入:Y或N!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
break;
case 9://备注
{
if (!MyCls.CheckString(DGViewResult.CurrentCell.Value.ToString(), 100))
{
DGViewResult.CurrentCell = DGViewResult.Rows[i].Cells[j];
btnModify.Enabled = false;
return;
}
}
break;
}
DataRow DR = myds.Tables["t_computer_ip"].Rows[i];
DR.BeginEdit();
DR[j] = DGViewResult.CurrentCell.Value.ToString();
DR.EndEdit();
btnModify.Enabled = true;
}
//删除
private void btnDelete_Click(object sender, EventArgs e)
{
string strReturn = MessageBox.Show("确实要删除此记录吗?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information).ToString();
if (strReturn == "OK")
{
int i = DGViewResult.CurrentRow.Index;
DataRow DR = myds.Tables["t_computer_ip"].Rows[i];
DR.BeginEdit();
DR.Delete();
DR.EndEdit();
bool blFlag = MyCls.DataSetUpdateByDataSet(myds, "t_computer_ip");
if (blFlag)
{
MessageBox.Show("删除成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
if (myds.Tables[0].Rows.Count <= 0)
{
btnDelete.Enabled = false;
btnModify.Enabled = false;
}
}
else
{
MessageBox.Show("删除失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
}
//查询方式改变时
private void txtFindType_SelectedIndexChanged(object sender, EventArgs e)
{
switch (txtFindType.SelectedItem.ToString())
{
case "负责人所在部门":
{
txtModel.DataSource = null;
MyCls.GetDataToComboBox("select distinct name from t_department", txtParam, "t_department", "name", "name");
txtModel.Enabled = false;
}
break;
case "IP":
{
txtModel.Enabled = true;
txtModel.DataSource = null;
MyCls.GetDataToComboBox("select distinct network from t_switch where network<>''", txtModel, "t_switch", "network", "network");
}
break;
case "交换机端口":
{
txtModel.Enabled = true;
txtModel.DataSource = null;
MyCls.GetDataToComboBox("select distinct scope from t_switch where scope<>''", txtModel, "t_switch", "scope", "scope");
}
break;
case "负责人":
{
txtModel.Enabled = true;
txtModel.DataSource = null;
MyCls.GetDataToComboBox("select distinct name from t_department", txtModel, "t_department", "name", "name");
}
break;
default:
{
//查询参数
txtParam.DataSource = null;
txtParam.Items.Clear();
//中间条件
txtModel.DataSource = null;
txtModel.Items.Clear();
txtModel.Enabled = false;
}
break;
}
}
////查询的中间条件发生改变时
private void txtModel_SelectedValueChanged(object sender, EventArgs e)
{
StringBuilder strSql = new StringBuilder("Select distinct ");
switch (txtFindType.SelectedItem.ToString())
{
case "IP":
{
strSql.Append("ip from t_computer_ip where network ='");
strSql.Append(txtModel.Text.Trim());
strSql.Append("'");
txtParam.DataSource = null;
MyCls.GetDataToComboBox(strSql.ToString(), txtParam, "t_computer_ip", "ip", "ip");
}
break;
case "交换机端口":
{
strSql.Append("port from t_computer_ip where scope ='");
strSql.Append(txtModel.Text.Trim());
strSql.Append("'");
txtParam.DataSource = null;
MyCls.GetDataToComboBox(strSql.ToString(), txtParam, "t_computer_ip", "port", "port");
}
break;
case "负责人":
{
strSql.Append("charge from t_computer_ip where department ='");
strSql.Append(txtModel.Text.Trim());
strSql.Append("'");
txtParam.DataSource = null;
MyCls.GetDataToComboBox(strSql.ToString(), txtParam, "t_computer_ip", "charge", "charge");
}
break;
default:
{
txtParam.DataSource = null;
txtParam.Items.Clear();
}
break;
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -