private void btn_Add_Click(object sender, EventArgs e) { string authorizeendtime = ""; string vehicleid = ""; if (SelectVehicleGrid.SelectedRows.Count <= 0) { MessageBox.Show("请选择要添加到设备的人员"); return; } if (SelectVehicleGrid.SelectedRows != null) { if (MessageBox.Show("确定要将车辆" + SelectVehicleGrid.SelectedRows[0].Cells[1].Value.ToString() + "添加到设备" + lab_DeviceName.Text + "的权限中吗?", "添加权限", MessageBoxButtons.YesNo) == DialogResult.No) { return; } if (SelectVehicleGrid.SelectedRows[0].Cells[1].Value.ToString() == "临时车辆") { MessageBox.Show("临时车辆必须设定权限时间"); AuthorizeTimeForm _form = new AuthorizeTimeForm(); if (_form.ShowDialog() == DialogResult.OK) { authorizeendtime = _form.Selecttime.ToString(); } else { return; } } vehicleid = SelectVehicleGrid.SelectedRows[0].Cells[0].Value.ToString(); } DAL.DAL_Authorize authorizedal = new DAL.DAL_Authorize(); if (authorizedal.InsertVehicleAuthrize(vehicleid, this.deviceid, authorizeendtime)) { MessageBox.Show("添加权限成功!"); GetDeviceAuthrizeList(""); } else { MessageBox.Show("添加权限失败!"); } }
private void btn_AddAuthrize_Click(object sender, EventArgs e) { if (AuthrizeCanGive.SelectedRows != null) { if (MessageBox.Show("你确定要为车辆" + lab_vehiclenum.Text + "添加设备:" + AuthrizeCanGive.SelectedRows[0].Cells[1].Value + "的权限吗?", "添加权限", MessageBoxButtons.YesNo) == DialogResult.Yes) { string authorizeendtime = ""; if (vehicletype == "临时车辆") { MessageBox.Show("临时用户必须设定权限时间"); AuthorizeTimeForm _form = new AuthorizeTimeForm(); if (_form.ShowDialog() == DialogResult.OK) { authorizeendtime = _form.Selecttime.ToString(); } else { return; } } else { authorizeendtime = ""; } DAL.DAL_Authorize authorizedal = new DAL.DAL_Authorize(); if (authorizedal.InsertVehicleAuthrize(this.vehicleid, AuthrizeCanGive.SelectedRows[0].Cells[0].Value.ToString(), authorizeendtime)) { MessageBox.Show("添加成功"); GetVehicleAuthrize(); } else { MessageBox.Show("添加失败"); } } } }