private void lvwUserList_DoubleClick(object sender, EventArgs e) { try { if (this.lvwUserList.SelectedRows.Count <= 0) { MessageBox.Show("请选择要修改的项!"); return; } if (this.lvwUserList.SelectedRows[0].Cells["PositionVoice_ID"].Value.ToString() == "") { MessageBox.Show("请选择要修改的项!"); return; } else { isUpdate = true; string sql = "select * from PositionVoice where PositionVoice_ID='" + this.lvwUserList.SelectedRows[0].Cells["PositionVoice_ID"].Value.ToString() + "'"; PositionVoice pv = PositionVoiceDAL.GetVoice(sql); txtPositionVoice_Count.Text = pv.PositionVoice_Count.ToString(); txtPositionVoice_Remark.Text = pv.PositionVoice_Remark.ToString(); cmbtxtPositionVoice_Type.Text = pv.PositionVoice_PassageState; chkPositionVoice_Position_Id.SelectedValue = int.Parse(pv.PositionVoice_Position_ID.ToString()); combokPositionVoice_State.Text = pv.PositionVoice_State.ToString(); string[] content = pv.PositionVoice_Content.Split(','); chkCarNumber.Checked = false; chkSerialnumber.Checked = false; chkCarType.Checked = false; foreach (var item in content) { if (item == chkCarNumber.Text) { chkCarNumber.Checked = true; } if (item == chkSerialnumber.Text) { chkSerialnumber.Checked = true; } if (item == chkCarType.Text) { chkCarType.Checked = true; } } } btnAdd.Enabled = false; btnUpdate.Enabled = true; } catch { CommonalityEntity.WriteTextLog("VoiceSetForm lvwUserList_DoubleClick()" + "");//记录异常日志 } }
/// <summary> /// 加载 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void QueueForm_Load(object sender, EventArgs e) { combox_LEDShowNumber.SelectedIndex = 1; cmbtongxing.SelectedIndex = 1; lblDoor.Text = SystemClass.PositionName;//当前门岗 tscbxPageSize.SelectedIndex = 2; GetDriveway(); comboxDriveway_SelectionChangeCommitted(sender, e); userContext(); bindcartpe(); where += " and 通行状态='排队中'"; GetGriddataviewLoad(""); string voSql = "Select * from PositionVoice where PositionVoice_State='启动' and PositionVoice_Position_ID=" + SystemClass.PositionID + ""; pv = PositionVoiceDAL.GetVoice(voSql); }
/// <summary> /// 添加一条数据 /// </summary> /// <param name="pLED">LED实体</param> /// <returns>返回执行结果 true or false</returns> public static bool InsertPositionVoice(PositionVoice pv) { bool rbool = false; using (DCCarManagementDataContext dc = new DCCarManagementDataContext()) { try { rbool = LinQBaseDao.InsertOne <PositionVoice>(dc, pv); } catch { rbool = false; } finally { dc.Connection.Close(); } } return(rbool); }
/// <summary> /// 获取语音设置 /// </summary> /// <param name="sql"></param> /// <returns></returns> public static PositionVoice GetVoice(string sql) { DataSet dataset = LinQBaseDao.Query(sql); PositionVoice pv = new PositionVoice(); foreach (DataRow dr in dataset.Tables[0].Rows) { pv.PositionVoice_Content = dr["PositionVoice_Content"].ToString(); pv.PositionVoice_Count = int.Parse(dr["PositionVoice_Count"].ToString()); pv.PositionVoice_ID = int.Parse(dr["PositionVoice_ID"].ToString()); pv.PositionVoice_Operate = dr["PositionVoice_Operate"].ToString(); pv.PositionVoice_Position_ID = int.Parse(dr["PositionVoice_Position_ID"].ToString()); pv.PositionVoice_Remark = dr["PositionVoice_Remark"].ToString(); pv.PositionVoice_State = dr["PositionVoice_State"].ToString(); pv.PositionVoice_Time = Convert.ToDateTime(dr["PositionVoice_Time"].ToString()); //pv.PositionVoice_Type = int.Parse(dr["PositionVoice_Type"].ToString()); } return(pv); }
/// <summary> /// 添加语音设置 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnAdd_Click(object sender, EventArgs e) { try { //if (!ChkContent()) return; //添加数据到数据库 PositionVoice pv = new PositionVoice(); pv.PositionVoice_Position_ID = int.Parse(chkPositionVoice_Position_Id.SelectedValue.ToString()); pv.PositionVoice_Remark = txtPositionVoice_Remark.Text.Trim(); pv.PositionVoice_State = combokPositionVoice_State.Text.ToString(); pv.PositionVoice_PassageState = cmbtxtPositionVoice_Type.Text; if (cmbtxtPositionVoice_Type.Text.Trim() == "欢迎语") { pv.PositionVoice_Content = txtHY.Text; } else { pv.PositionVoice_Count = int.Parse(txtPositionVoice_Count.Text.Trim()); string serialnumber = ""; string carType = ""; string carNumber = ""; if (chkCarNumber.Checked) { carNumber = chkCarNumber.Text.Trim() + ","; } if (chkCarType.Checked) { carType = chkCarType.Text.Trim() + ","; } if (chkSerialnumber.Checked) { serialnumber = chkSerialnumber.Text.Trim() + ","; } string chklists = ""; if (list.Count() > 0) { foreach (var item in list) { chklists += (item.ToString() + ","); } list.Clear(); } string content = carType + carNumber + serialnumber + chklists; pv.PositionVoice_Content = content; } pv.PositionVoice_Operate = CommonalityEntity.USERNAME; pv.PositionVoice_Time = CommonalityEntity.GetServersTime(); if (pv.PositionVoice_State == "启动") { if (ChkPositionVoiceState()) { DialogResult dlgResult = MessageBox.Show("已经存在启动状态的设置,是否替换?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (dlgResult == DialogResult.OK) { //修改条件 Expression <Func <PositionVoice, bool> > fun = n => n.PositionVoice_State == "启动" && n.PositionVoice_Position_ID == int.Parse(chkPositionVoice_Position_Id.SelectedValue.ToString()); //需要修改的内容 Action <PositionVoice> action = p => { p.PositionVoice_State = "暂停"; }; //执行更新 PositionVoiceDAL.UpdatePositionVoice(fun, action); PositionVoiceDAL.InsertPositionVoice(pv); } else { pv.PositionVoice_State = "暂停"; PositionVoiceDAL.InsertPositionVoice(pv); } } else { PositionVoiceDAL.InsertPositionVoice(pv); } } else { PositionVoiceDAL.InsertPositionVoice(pv); } DataTable dt = LinQBaseDao.Query("select PositionVoice_ID,PositionVoice_State from PositionVoice order by PositionVoice_ID desc").Tables[0]; string positionvoice_id = dt.Rows[0][0].ToString(); string positionvoice_state = dt.Rows[0][1].ToString(); if (positionvoice_state == "启动") { CommonalityEntity.WriteLogData("新增", "新增并启用编号为:" + positionvoice_id + "的语音呼叫信息", CommonalityEntity.USERNAME); } else { CommonalityEntity.WriteLogData("新增", "新增编号为:" + positionvoice_id + "的语音呼叫信息", CommonalityEntity.USERNAME); } MessageBox.Show("保存成功!"); } catch { //记录错误日志 CommonalityEntity.WriteTextLog("VoiceSetForm btnAdd_Click()" + ""); } finally { btnSelect_Click(sender, e); // GetGriddataviewLoad("");//绑定列表 Empty(); } }