/// <summary> /// 通行策略按钮单击事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btn_CurrentAdministration_Click(object sender, EventArgs e) { try { List <string> liststring = new List <string>(); DrivewayStrategyForm dsf = new DrivewayStrategyForm(); int count = dgv_Information.SelectedRows.Count; string strCarTypeName = ""; //遍历 for (int i = 0; i < count; i++) { if (dgv_Information.SelectedRows[i].Cells["CarType_ID"].Value != null) { strCarTypeName = dgv_Information.SelectedRows[i].Cells["CarType_Name"].Value == null ? "" : dgv_Information.SelectedRows[i].Cells["CarType_Name"].Value.ToString(); liststring.Add(strCarTypeName); dsf.listCarTypeID.Add(CommonalityEntity.GetInt(dgv_Information.SelectedRows[i].Cells["CarType_ID"].Value.ToString())); } } strCarTypeName = ""; foreach (var tem in liststring.Distinct()) { strCarTypeName += tem + "," + "\r\n"; } dsf.strCarTypeName = strCarTypeName; PublicClass.ShowChildForm(dsf); //mf.ShowChildForm(dsf, this); } catch { CommonalityEntity.WriteTextLog("CarTypeForm.btn_CurrentAdministration_Click()"); } }
/// <summary> /// 修改 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnUpdate_Click(object sender, EventArgs e) { try { if (NullHandleMethod()) { if (intCarTypeID > 0) { OthCarAttribute("", cbxCarAttribute.Text.Trim()); ssy = 0; Expression <Func <CarType, bool> > funCartype = n => n.CarType_ID == intCarTypeID; Action <CarType> action = n => { n.CarType_UserId = CommonalityEntity.GetInt(CommonalityEntity.USERID); n.CarType_Name = txt_CarTypeNmae.Text.Trim(); n.CarType_Content = txt_CarTypeContent.Text.Trim(); n.CarType_State = cob_CarTypeState.Text.Trim(); n.CarType_Property = cbxCarAttribute.Text.Trim(); n.CarType_Remark = txt_CarTypeRemarks.Text.Trim(); n.CarType_Validity = cob_CarTypeEffective.Text.Trim(); n.CarType_ValidityTemporary = cob_CarTypeTemporary.Text.Trim(); n.CarType_OtherProperty = butname.Trim(); if (!string.IsNullOrEmpty(txt_CarTemporaryValue.Text.Trim())) { n.CarType_ValidityValue = CommonalityEntity.GetInt(txt_CarTemporaryValue.Text.Trim()); } if (!string.IsNullOrEmpty(txtInOutTime.Text.Trim())) { n.CarType_InOutTime = CommonalityEntity.GetInt(txtInOutTime.Text.Trim()); } n.CarType_Value = txt_CarTypeValue.Text.Trim(); n.CarType_DriSName = cmbDriSta.Text; n.CarType_BusType = txtBusType.Text.Trim(); }; if ((CarTypeDAL.Update(funCartype, action))) { //查出通行策略ID、通道ID updateDri(cmbDriSta.Text); btn_Empty_Click(btn_Empty, null); //调用清空按钮事件 CommonalityEntity.WriteLogData("修改", "车辆类型:" + txt_CarTypeNmae.Text.Trim(), CommonalityEntity.USERNAME); //添加操作日志 btn_Empty.Text = "清 空"; MessageBox.Show(this, "修改成功"); } } } } catch { CommonalityEntity.WriteTextLog("CarTypeForm.btnUpdate_Click()"); MessageBox.Show(this, "修改失败"); } finally { btn_Save.Enabled = true; btnUpdate.Enabled = false; BingMethod(); } }
/// <summary> ///设置分页控件每页显示的最大条数事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void tscbxPageSize_SelectedIndexChanged(object sender, EventArgs e) { try { pc = new PageControl(); pc.pageSize = CommonalityEntity.GetInt(tscbxPageSize.SelectedItem.ToString()); SelectMethod(); } catch { CommonalityEntity.WriteTextLog("CarTypeForm.tscbxPageSize_SelectedIndexChanged()"); } }
/// <summary> /// 保存事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btn_Save_Click(object sender, EventArgs e) { try { if (NullHandleMethod()) { OthCarAttribute("", cbxCarAttribute.Text.Trim()); ssy = 0; CarType ct = new CarType(); ct.CarType_UserId = CommonalityEntity.GetInt(CommonalityEntity.USERID); ct.CarType_Name = txt_CarTypeNmae.Text.Trim(); ct.CarType_Content = txt_CarTypeContent.Text.Trim(); ct.CarType_State = cob_CarTypeState.Text.Trim(); ct.CarType_Property = cbxCarAttribute.Text.Trim(); ct.CarType_Remark = txt_CarTypeRemarks.Text.Trim(); ct.CarType_Validity = cob_CarTypeEffective.Text.Trim(); ct.CarType_ValidityTemporary = cob_CarTypeTemporary.Text.Trim(); ct.CarType_OtherProperty = butname.Trim(); if (!string.IsNullOrEmpty(txtInOutTime.Text.Trim())) { ct.CarType_InOutTime = CommonalityEntity.GetInt(txtInOutTime.Text.Trim()); } if (!string.IsNullOrEmpty(txt_CarTemporaryValue.Text.Trim())) { ct.CarType_ValidityValue = CommonalityEntity.GetInt(txt_CarTemporaryValue.Text.Trim()); } ct.CarType_Value = txt_CarTypeValue.Text.Trim(); ct.CarType_CreatTime = CommonalityEntity.GetServersTime(); ct.CarType_UserId = CommonalityEntity.USERID; ct.CarType_DriSName = cmbDriSta.Text; ct.CarType_BusType = txtBusType.Text.Trim(); if ((CarTypeDAL.InsertOneQCRecord(ct))) { btn_Empty_Click(btn_Empty, null); //调用清空按钮事件 CommonalityEntity.WriteLogData("新增", "新增车辆类型:" + txt_CarTypeNmae.Text.Trim(), CommonalityEntity.USERNAME); //添加操作日志 MessageBox.Show(this, "添加成功"); } } } catch { CommonalityEntity.WriteTextLog("CarTypeForm.JudgeCarTypeUseMethod()"); MessageBox.Show(this, "添加失败"); } finally { BingMethod(); } }
/// <summary> /// 遍历一级菜单 /// </summary> /// <param name="Menu_ID"></param> private void UpdateSelectRole(int Menu_ID) { foreach (TreeNode tnTemp in tv_MenuInfo.Nodes) { if (tnTemp.Tag != null) { if (CommonalityEntity.GetInt(tnTemp.Tag.ToString()) == Menu_ID) { tnTemp.Checked = true; tnTemp.ExpandAll();//展开所有子节点 } else { UpdateSelectRoleDiGui(tnTemp, Menu_ID); } } } }
/// <summary> ///设置分页控件每页显示的最大条数事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void tscbxPageSize_SelectedIndexChanged(object sender, EventArgs e) { try { pc = new PageControl(); pc.pageSize = CommonalityEntity.GetInt(tscbxPageSize.SelectedItem.ToString()); if (isload) { ThreadPool.QueueUserWorkItem(new WaitCallback(SelectMethod), null); } else { SelectMethod(null); } } catch { CommonalityEntity.WriteTextLog("carInOutSatistics.tscbxPageSize_SelectedIndexChanged()"); } }
/// <summary> /// 双击进入修改 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dgv_Information_DoubleClick(object sender, EventArgs e) { try { if (dgv_Information.SelectedRows.Count > 0) //选中行 { if (dgv_Information.SelectedRows.Count > 1) //判断是否选中多行 { MessageBox.Show("只能选择一行车辆类型信息进行修改", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { btn_Save.Enabled = false; btnUpdate.Enabled = true; btn_Empty.Text = "取消修改"; intCarTypeID = CommonalityEntity.GetInt(dgv_Information.SelectedRows[0].Cells["CarType_ID"].Value.ToString()); txt_CarTypeNmae.Text = strCarTypeName = strCarTypeName = dgv_Information.SelectedRows[0].Cells["CarType_Name"].Value.ToString(); cob_CarTypeEffective.Text = dgv_Information.SelectedRows[0].Cells["CarType_Validity"].Value.ToString(); cob_CarTypeTemporary.Text = dgv_Information.SelectedRows[0].Cells["CarType_ValidityTemporary"].Value.ToString(); txt_CarTemporaryValue.Text = dgv_Information.SelectedRows[0].Cells["CarType_ValidityValue"].Value.ToString(); txt_CarTypeValue.Text = strCarType_Valueold = dgv_Information.SelectedRows[0].Cells["CarType_Value"].Value.ToString(); cob_CarTypeState.Text = dgv_Information.SelectedRows[0].Cells["CarType_State"].Value.ToString(); cbxCarAttribute.Text = dgv_Information.SelectedRows[0].Cells["CarType_Property"].Value.ToString(); txt_CarTypeContent.Text = dgv_Information.SelectedRows[0].Cells["CarType_Content"].Value.ToString(); txt_CarTypeRemarks.Text = dgv_Information.SelectedRows[0].Cells["CarType_Remark"].Value.ToString(); txtInOutTime.Text = dgv_Information.SelectedRows[0].Cells["CarType_InOutTime"].Value.ToString(); cmbDriSta.Text = dgv_Information.SelectedRows[0].Cells["CarType_DriSName"].Value.ToString(); txtBusType.Text = dgv_Information.SelectedRows[0].Cells["CarType_BusType"].Value.ToString(); drisname = cmbDriSta.Text; } } else { MessageBox.Show("请选中行!!!!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch { CommonalityEntity.WriteTextLog("CarTypeForm.btn_Update_Click()"); } }
/// <summary> /// 递归出所有选中的子级 /// </summary> /// <param name="tn"></param> private void addDiGui(TreeNode tn) { try { if (tn != null) { foreach (TreeNode tnTemp in tn.Nodes) { if (tnTemp.Checked == true) { strDriveway_Name += tnTemp.Text + ","; Driveway_IDList.Add(CommonalityEntity.GetInt(tnTemp.Name.ToString()));//存放入子级实际值 } addDiGui(tnTemp); } } } catch { CommonalityEntity.WriteTextLog("ManagementStrategyRecordForm.addDiGui()" + "".ToString()); } }
public void GetSapDate(string strSerialnumber) { string strSql = "select top 1 * from eh_SAPRecord where sap_state='1' and Sap_Serialnumber='" + strSerialnumber + "' and Sap_InCRFLG is null order by Sap_ID desc"; DataSet ds = LinQBaseDao.Query(strSql); if (ds != null) { if (ds.Tables[0].Rows.Count > 0) { eh_SAPRecord sapobj = new eh_SAPRecord(); sapobj.Sap_ID = CommonalityEntity.GetInt(ds.Tables[0].Rows[0]["Sap_ID"]); sapobj.Sap_Identify = ds.Tables[0].Rows[0]["Sap_Identify"].ToString(); sapobj.Sap_InCarNumber = ds.Tables[0].Rows[0]["Sap_InCarNumber"].ToString(); sapobj.Sap_InCarOperate = ds.Tables[0].Rows[0]["Sap_InCarOperate"].ToString(); sapobj.Sap_InCRFLG = ds.Tables[0].Rows[0]["Sap_InCarOperate"].ToString(); sapobj.Sap_InNO = ds.Tables[0].Rows[0]["Sap_InNO"].ToString(); sapobj.Sap_InTime = Convert.ToDateTime(ds.Tables[0].Rows[0]["Sap_InTime"]); sapobj.Sap_OutEMSG = ds.Tables[0].Rows[0]["Sap_OutEMSG"].ToString(); sapobj.Sap_OutETYPE = ds.Tables[0].Rows[0]["Sap_OutETYPE"].ToString(); sapobj.Sap_OutHG = ds.Tables[0].Rows[0]["Sap_OutHG"].ToString(); sapobj.Sap_OutKDATB = Convert.ToDateTime(ds.Tables[0].Rows[0]["Sap_OutKDATB"]); sapobj.Sap_OutKDATE = Convert.ToDateTime(ds.Tables[0].Rows[0]["Sap_OutKDATE"]); sapobj.Sap_OutMAKTX = ds.Tables[0].Rows[0]["Sap_OutMAKTX"].ToString(); sapobj.Sap_OutNAME1C = ds.Tables[0].Rows[0]["Sap_OutNAME1C"].ToString(); sapobj.Sap_OutNAME1P = ds.Tables[0].Rows[0]["Sap_OutNAME1P"].ToString(); sapobj.Sap_OutOFLAG = ds.Tables[0].Rows[0]["Sap_OutOFLAG"].ToString(); sapobj.Sap_OutTELNUMBER = ds.Tables[0].Rows[0]["Sap_OutTELNUMBER"].ToString(); sapobj.Sap_OutXZ = ds.Tables[0].Rows[0]["Sap_OutXZ"].ToString(); sapobj.Sap_Remark = ds.Tables[0].Rows[0]["Sap_Remark"].ToString(); sapobj.Sap_Serialnumber = ds.Tables[0].Rows[0]["Sap_Serialnumber"].ToString(); sapobj.Sap_State = CommonalityEntity.GetInt(ds.Tables[0].Rows[0]["Sap_State"].ToString()); sapobj.Sap_Type = ds.Tables[0].Rows[0]["Sap_Type"].ToString(); } } }
/// <summary> /// 删除事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btn_Delete_Click(object sender, EventArgs e) { try { string strmessagebox = ""; string Operationlog = ""; strCarTypeName = ""; strCarType_ID = ""; alist = new ArrayList(); if (btn_Delete.Enabled) { btn_Delete.Enabled = false; } if (dgv_Information.SelectedRows.Count > 0)//判断是否选中行 { if (MessageBox.Show("删除将会把关联删除,确定要删除吗?", "提示", MessageBoxButtons.YesNo) == DialogResult.Yes) { int count = dgv_Information.SelectedRows.Count; //遍历 for (int i = 0; i < count; i++) { if (dgv_Information.SelectedRows[i].Cells["CarType_ID"].Value != null) { strCarType_ID += dgv_Information.SelectedRows[i].Cells["CarType_ID"].Value.ToString(); strCarTypeName += dgv_Information.SelectedRows[i].Cells["CarType_Name"].Value.ToString(); if (i < count - 1) { strCarType_ID += ","; } alist.Add(CommonalityEntity.GetInt(dgv_Information.SelectedRows[i].Cells["CarType_ID"].Value.ToString())); } if (JudgeCarTypeUseMethod())//判断当前要操作的车辆类型是否正在使用 { DCCarManagementDataContext db = new DCCarManagementDataContext(); // Expression<Func<CarType, bool>> funCarType = n => alist.Contains(n.CarType_ID); Expression <Func <CarType, bool> > funCarType = n => alist.ToArray().Contains(n.CarType_ID); if (LinQBaseDao.ADD_Delete_UpdateMethod <CarType>(db, 2, null, funCarType, null, true, null)) { strmessagebox = "成功删除车辆类型"; Operationlog = String.Format("删除车辆类型:{0}", strCarTypeName); CommonalityEntity.WriteLogData("删除", Operationlog, CommonalityEntity.USERNAME); } else { strmessagebox = "删除车辆类型失败"; } } else { strmessagebox = "该车辆类型正在使用不能删除"; } if (strmessagebox != "") { MessageBox.Show(strmessagebox, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } } } catch (Exception err) { CommonalityEntity.WriteTextLog("CarTypeForm.btn_Delete_Click()"); } finally { btn_Delete.Enabled = true; pc = new PageControl(); SelectMethod();//更新数据 } }
/// <summary> /// 删除双击事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btn_Delete_Click(object sender, EventArgs e) { try { string strmessagebox = ""; listDrivewayStrategy_ID.Clear(); arraylist.Clear(); string strlog = ""; string strDrivewayStrategy_name = ""; if (btn_Delete.Enabled) { btn_Delete.Enabled = false; } if (dgv_Information.SelectedRows.Count > 0)//判断是否选中行 { if (MessageBox.Show("删除,将会把所有关联删除,确定要删除吗?", "提示", MessageBoxButtons.YesNo) == DialogResult.Yes) { int count = dgv_Information.SelectedRows.Count; //遍历 for (int i = 0; i < count; i++) { if (dgv_Information.SelectedRows[i].Cells["DrivewayStrategyRecord_ID"].Value != null)//通行策略ID { listDrivewayStrategy_ID.Add(CommonalityEntity.GetInt(dgv_Information.SelectedRows[i].Cells["DrivewayStrategyRecord_ID"].Value.ToString())); if (dgv_Information.SelectedRows[i].Cells["DrivewayStrategyRecord_Name"].Value != null)//通行策略名称 { strDrivewayStrategy_name += dgv_Information.SelectedRows[i].Cells["DrivewayStrategyRecord_Name"].Value.ToString() + " "; } } } strlog = String.Format("删除通行策略:'{0}'", strDrivewayStrategy_name); Expression <Func <DrivewayStrategyRecord, bool> > funDrivewayStrategy = n => listDrivewayStrategy_ID.Contains(n.DrivewayStrategyRecord_ID); if (DrivewayStrategyRecordDAL.DeleteToMany(funDrivewayStrategy)) { strmessagebox = "成功删除通行策略"; CommonalityEntity.WriteLogData("删除", strlog, CommonalityEntity.USERNAME); } else { strmessagebox = "通行策略删除失败"; } } } else { strmessagebox = "请选择要删除的行"; } if (strmessagebox != "") { MessageBox.Show(strmessagebox, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch { CommonalityEntity.WriteTextLog("DrivewayStrategyRecordForm.btn_Delete_Click()" + "".ToString()); } finally { btn_Delete.Enabled = true; pc = new PageControl(); SelectMethod();//更新数据 } }
private void btnUpdate_Click() { try { arraylist.Clear();//清空动态数组内的成员 add(); int j = 0; bool Menu_Enabled = true; bool Menu_Visible = true; if (!chb_Menu_Visible.Checked) { Menu_Visible = false; } if (!chb_Menu_Enabled.Checked) { Menu_Enabled = false; } if (CommonalityEntity.YesNoBoolRoleUser) { //删除用户权限,只能删除我拥有的,已经配置的权限 if (CommonalityEntity.UserID <= 0) { return; } DataTable dt = LinQBaseDao.Query("select Permissions_ID from View_MenuInfo_P where Menu_Type=1 and Permissions_UserId=" + CommonalityEntity.UserID + "").Tables[0]; string pids = ""; if (dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { pids += dt.Rows[i][0].ToString() + ","; } LinQBaseDao.Query("delete PermissionsInfo where Permissions_ID in (" + pids.TrimEnd(',') + ")"); } for (int i = 0; i < arraylist.Count; i++) { var permissionsInfo = new PermissionsInfo { Permissions_Menu_ID = CommonalityEntity.GetInt(arraylist[i].ToString()), Permissions_Visible = Menu_Visible, Permissions_Enabled = Menu_Enabled, Permissions_Type = 1,//1为winfrom程序菜单 Permissions_UserId = CommonalityEntity.UserID }; if (!PermissionsInfoDAL.InsertOneQCRecord(permissionsInfo))//是否添加失败 { j++; } } } else { //删除用户的所有权限 Expression <Func <PermissionsInfo, bool> > funmenuinfo = n => n.Permissions_Role_Id == CommonalityEntity.RoleID; if (!PermissionsInfoDAL.DeleteToMany(funmenuinfo))//用户权限菜单是否删除失败 { j++; } for (int i = 0; i < arraylist.Count; i++) { var permissionsInfo = new PermissionsInfo { Permissions_Menu_ID = CommonalityEntity.GetInt(arraylist[i].ToString()), //Dictionary_State = DictionaryDAL.GetDictionaryID("启动"), Permissions_Visible = Menu_Visible, Permissions_Enabled = Menu_Enabled, Permissions_Type = 1, Permissions_Role_Id = CommonalityEntity.RoleID }; if (!PermissionsInfoDAL.InsertOneQCRecord(permissionsInfo))//是否添加失败 { j++; } } } if (j == 0) { MessageBox.Show("添加成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); CommonalityEntity.WriteLogData("新增", "新增角色编号为:" + CommonalityEntity.RoleID + "权限的信息", CommonalityEntity.USERNAME); } else { MessageBox.Show("添加失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch { MessageBox.Show("添加失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); CommonalityEntity.WriteTextLog("UserRoleADD.btnUpdate_Click()"); } finally { this.Close(); } try { arraylist.Clear();//清空动态数组内的成员 add(); CommonalityEntity.arraylist = arraylist; } catch { CommonalityEntity.WriteTextLog("UserRoleADD.btnUpdate_Click()"); } finally { this.Close(); } }
/// <summary> /// “搜 索” 的单击事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSearch_Click(object sender, EventArgs e) { #region 注释 try { int i = 0; string str = ""; //得到查询的条件 string name = this.txtLog_Name.Text.Trim(); string beginTime = this.txtbeginTime.Text.Trim(); string endTime = this.txtendTime.Text.Trim(); string begin = beginTime + " 00:00:00"; string end = endTime + "23:59:59 "; expr = PredicateExtensionses.True <View_LogInfo_Dictionary>(); if (name != "")//操作人 { expr = expr.And(n => SqlMethods.Like(n.Log_Name, "%" + txtLog_Name.Text.Trim() + "%")); i++; } if (beginTime != "")//开始时间 { expr = expr.And(n => n.Log_Time >= CommonalityEntity.GetDateTime(begin)); i++; } if (endTime != "")//结束时间 { expr = expr.And(n => n.Log_Time <= CommonalityEntity.GetDateTime(end)); i++; } if (beginTime != "" && endTime != "") { if (CommonalityEntity.GetDateTime(beginTime) > CommonalityEntity.GetDateTime(endTime)) { MessageBox.Show("查询开始时间不能大于结束时间!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtbeginTime.Text = ""; txtendTime.Text = ""; return; } } if (this.comboxType.SelectedValue != null) { int stateID = Converter.ToInt(comboxType.SelectedValue.ToString()); if (stateID > 0) { Dictionary dicEntity = comboxType.SelectedItem as Dictionary; if (dicEntity.Dictionary_Value == "全部") { expr = n => n.Log_ID != null; } else { expr = expr.And(n => n.Log_Type == CommonalityEntity.GetInt(comboxType.SelectedValue.ToString())); } } i++; } if (i == 0) { expr = n => n.Log_ID != null; } } catch { CommonalityEntity.WriteTextLog("CommonalityEntity.btnSearch()"); } finally { page = new PageControl(); LogInfoLoad(""); LoadData(); } #endregion if (btnSearch.Enabled) { btnSearch.Enabled = false; GetLogInfoSeach(); LogInfoDAL.AddLoginfo("查询", "检测项目查询", CommonalityEntity.USERNAME);//操作日志 btnSearch.Enabled = true; } }