123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 |
- using Newtonsoft.Json;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace LYFZ.Software.MainBusiness.SystemSettings
- {
- public class FrmAttendanceConfig : LYFZ.Software.UI.SystemSettings.FrmAttendanceConfig
- {
- BLL.BLL_ErpSystemConfigure bLL_ErpSystemConfigure = new BLL.BLL_ErpSystemConfigure();
- List<Model.AttenDance.Model_WifiConfig> wifiList = new List<Model.AttenDance.Model_WifiConfig>();
- Model.AttenDance.Model_WifiConfig selectModel = null;
- public FrmAttendanceConfig()
- {
- this.btn_Save.Click += Btn_Save_Click;
- this.btn_Close.Click += Btn_Close_Click;
- this.btn_Reset.Click += Btn_Reset_Click;
- this.dgvWifiList.CellDoubleClick += DgvWifiList_CellContentDoubleClick;
- this.dgvWifiList.CellClick += DgvWifiList_CellClick;
- InitWifiConfigModelList();
- }
- private void DgvWifiList_CellClick(object sender, System.Windows.Forms.DataGridViewCellEventArgs e)
- {
- if (e.ColumnIndex == 3)
- {
- Model.AttenDance.Model_WifiConfig tempMelectModel = wifiList[e.RowIndex];
- if (MessageBoxCustom.Show("是否确定删除"+ tempMelectModel.WifiName+"的配置","消息提示", System.Windows.Forms.MessageBoxButtons.OKCancel)== System.Windows.Forms.DialogResult.OK)
- {
- wifiList.Remove(tempMelectModel);
- bLL_ErpSystemConfigure.SaveConfigureInfo(Model.ConfigItemType.AttenDanceSetInfo, JsonConvert.SerializeObject(wifiList), "考勤Wifi配置信息");
- if(selectModel!=null&& tempMelectModel == selectModel)
- {
- selectModel = null;
- }
- ResetTextBoxValue();
- BindWifiConfigModelList();
- }
-
-
- }
- }
- private void Btn_Reset_Click(object sender, EventArgs e)
- {
- selectModel = null;
- ResetTextBoxValue();
- }
- private void DgvWifiList_CellContentDoubleClick(object sender, System.Windows.Forms.DataGridViewCellEventArgs e)
- {
- if (e.ColumnIndex < 3)
- {
- if (e.RowIndex > -1)
- {
- selectModel = wifiList[e.RowIndex];
- }
- else
- {
- selectModel = null;
- }
- ResetTextBoxValue();
- }
- }
- void ResetTextBoxValue()
- {
- if (selectModel == null)
- {
- tb_Address.Text = "";
- tb_Equipment.Text = "";
- tb_WifiName.Text = "";
- }
- else
- {
- tb_Address.Text = selectModel.WifiAddress;
- tb_Equipment.Text = selectModel.WifiDentify;
- tb_WifiName.Text = selectModel.WifiName;
- }
- }
- private void Btn_Close_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- private void Btn_Save_Click(object sender, EventArgs e)
- {
- if (selectModel == null)
- {
- selectModel = new Model.AttenDance.Model_WifiConfig()
- {
- WifiAddress = tb_Address.Text,
- WifiDentify = tb_Equipment.Text,
- WifiName = tb_WifiName.Text
- };
- wifiList.Add(selectModel);
- }
- else
- {
- selectModel.WifiAddress = tb_Address.Text;
- selectModel.WifiDentify = tb_Equipment.Text;
- selectModel.WifiName = tb_WifiName.Text;
- }
- bLL_ErpSystemConfigure.SaveConfigureInfo(Model.ConfigItemType.AttenDanceSetInfo, JsonConvert.SerializeObject(wifiList),"考勤Wifi配置信息");
- selectModel = null;
- ResetTextBoxValue();
- BindWifiConfigModelList();
- }
- void InitWifiConfigModelList()
- {
- Model.Model_ErpSystemConfigure sysConfigure = bLL_ErpSystemConfigure.GetConfigureInfo(Model.ConfigItemType.AttenDanceSetInfo);
- if (!string.IsNullOrEmpty(sysConfigure.Sconfig_Value))
- {
- wifiList = JsonConvert.DeserializeObject<List<Model.AttenDance.Model_WifiConfig>>(sysConfigure.Sconfig_Value);
- }
- BindWifiConfigModelList();
- }
- void BindWifiConfigModelList()
- {
- this.dgvWifiList.Rows.Clear();
- foreach (Model.AttenDance.Model_WifiConfig model in wifiList)
- {
- System.Windows.Forms.DataGridViewRow dgvRow = new System.Windows.Forms.DataGridViewRow();
- dgvRow.Cells.Add(new System.Windows.Forms.DataGridViewTextBoxCell());
- dgvRow.Cells[0].Value = model.WifiName;
- dgvRow.Cells.Add(new System.Windows.Forms.DataGridViewTextBoxCell());
- dgvRow.Cells[1].Value = model.WifiDentify;
- dgvRow.Cells.Add(new System.Windows.Forms.DataGridViewTextBoxCell());
- dgvRow.Cells[2].Value = model.WifiAddress;
- System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
- dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
- this.dgvWifiList.DefaultCellStyle = dataGridViewCellStyle1;
- dgvRow.Cells.Add(new System.Windows.Forms.DataGridViewLinkCell());
- dgvRow.Cells[3].Value = "删除";
- this.dgvWifiList.Rows.Add(dgvRow);
- }
-
- }
- }
- }
|