private void simpleButton1_Click(object sender, EventArgs e) { string msg = this.textBox1.Text; List <string> pars = new List <string>(); if (this.checkBox1.Checked) { pars.Add(msg); HomePageNetOperation.ManagerCommandOperation(ManagerCommandOperationResult, COMMAND_TYPE.NOTIFYALL, pars); } else { //TODO:判断是否是群发 for (int i = 0; i < this.mainDataTable.Rows.Count; i++) { StructRealTime com = this.onlines[i]; DataRow row = this.mainDataTable.Rows[i]; if (row[TitleList.Check.ToString()].ToString().Equals("True")) { pars.Add(com.Cardnumber); } } if (pars.Count > 0) { pars.Add(msg); HomePageNetOperation.ManagerCommandOperation(ManagerCommandOperationResult, COMMAND_TYPE.NOTIFY, pars); } } }
private void UpdateUserStatus(IList <string> pars) { string comid = pars[0]; //获取需要修改的电脑数据 int index = GetComputerIndex(int.Parse(comid)); StructRealTime com = this.computers[index]; //生成新StructRealTime StructRealTime.Builder newCom = new StructRealTime.Builder(com); //----// 余额,开始时间。已用时。结束时间 newCom.Balance = pars[1]; newCom.Starttime = pars[2]; newCom.Usedtime = pars[3]; newCom.Stoptime = pars[4]; //计算剩余时间 DateTime start = DateTime.Parse(newCom.Starttime); DateTime end = DateTime.Parse(newCom.Stoptime); TimeSpan ts = end.Subtract(start); int dateDiffSecond = ts.Days * 24 * 60 + ts.Hours * 60 + ts.Minutes; newCom.Remaintime = (dateDiffSecond - int.Parse(newCom.Usedtime)) + ""; //修改数组字典数据 this.computers[index] = newCom.Build(); //更新首页数据 UpdateHomePage(index, newCom.Build()); }
private void UserDownComputer(IList <string> pars) { string comid = pars[0]; int index = GetComputerIndex(int.Parse(comid)); //获取需要修改的电脑数据 StructRealTime com = this.computers[index]; //生成新StructRealTime StructRealTime.Builder newCom = new StructRealTime.Builder(com); newCom.Status = ((int)COMPUTERSTATUS.空闲).ToString(); newCom.Name = ""; newCom.Cardnumber = ""; newCom.Usertype = ""; newCom.Billing = ""; newCom.Verify = ""; //----// 余额,余时。开始时间。已用时。结束时间 newCom.Balance = ""; newCom.Starttime = ""; newCom.Usedtime = ""; newCom.Remaintime = ""; newCom.Stoptime = ""; //修改数组字典数据 this.computers[index] = newCom.Build(); //更新首页数据 UpdateHomePage(index, newCom.Build()); //刷新首页状态数量 UpdateStatusNumEvent(); }
public void GetOtherComputers(string code) { List <AreaTypeModel> areas = SysManage.Areas; this.currentComs = new List <StructRealTime>(); this.otherComs = new List <StructRealTime>(); for (int i = 0; i < this.allComputers.Count; i++) { StructRealTime com = this.allComputers[i]; //判断修改的字典 this.changeComDict.TryGetValue(com.Computerid, out com); if (com == null) { com = this.allComputers[i]; } if (com.Area.Equals(code)) { currentComs.Add(com); } else if (areas.Where(area => area.areaId == int.Parse(com.Area)).Count() == 0) //不包含 { otherComs.Add(com); } } }
//点击进行修改 private void ComLabel_Click(object sender, EventArgs e) { StructRealTime com = (StructRealTime)(sender as AreaComView).Tag; ComputerDetailView view = new ComputerDetailView(com); ToolsManage.ShowForm(view, false); }
private void RefreshGridControl() { this.coms = HomePageMessageManage.FilterComputers; this.mainDataTable.Rows.Clear(); for (int i = 0; i < this.coms.Count; i++) { StructRealTime computer = coms[i]; AddNewRow(computer, null); } }
//添加新行 private void AddNewRow(StructRealTime com) { DataRow row = this.mainDataTable.NewRow(); this.mainDataTable.Rows.Add(row); //row[TitleList.Check.ToString()] = ""; row[TitleList.Name.ToString()] = com.Name; row[TitleList.Card.ToString()] = com.Cardnumber; row[TitleList.Ip.ToString()] = com.Ip; row[TitleList.Check.ToString()] = this.checkBox1.Checked; }
//更新电脑显示数据 public void UpdateHomePageData(StructRealTime com) { this.Invoke(new RefreshUIHandle(delegate { int index = HomePageMessageManage.GetComputerIndex(com.Computerid, this.coms); if (index < 0) { return; } this.coms[index] = com; DataRow row = this.mainDataTable.Rows[index]; AddNewRow(com, row); })); }
// 刷新电脑状态(开机。下机。认证) public void UpdateHomePageData(StructRealTime com) { this.Invoke(new RefreshUIHandle(delegate { //获取所对应的电脑 List <StructRealTime> coms = new List <StructRealTime>(); if (areaComsDict.Keys.Contains(com.Area)) { coms = areaComsDict[com.Area]; } else { coms = areaComsDict["-1"]; } //获取电脑所在数组的索引 int comIndex = -1; try { comIndex = coms.Select((StructRealTime tem, int index) => new { tem, index }).Where(a => a.tem.Computerid == com.Computerid).First().index; } catch (Exception exc) { comIndex = -1; } //通过索引获取电脑 if (comIndex < 0) { return; } Control[] res = this.comsBg.Controls.Find(string.Format("name_{0}", com.Computerid), true); if (res.Count() > 0) { coms[comIndex] = com; AreaComView updateComView = res.First() as AreaComView; updateComView.Tag = com; COMPUTERSTATUS status = COMPUTERSTATUS.无; Enum.TryParse <COMPUTERSTATUS>(com.Status, out status); updateComView.ComStatus = status; } //修改过滤数组的值 int comindex = HomePageMessageManage.GetComputerIndex(com.Computerid, this.filterComs); if (comindex < 0) { return; } this.filterComs[comindex] = com; this.comsBg.Refresh(); })); }
//刷新区域电脑 private void RefreshAreaComsPanel() { this.currentComsPanel.Controls.Clear(); for (int i = 0; i < this.areaManage.currentComs.Count; i++) { StructRealTime time = this.areaManage.currentComs[i]; AreaComView view = new AreaComView(); view.Click += Button_Click; view.Title = time.Computer; this.currentComsPanel.Controls.Add(view); view.Tag = i.ToString(); } }
public void UpateHomePageComputerArea() { foreach (StructRealTime change in this.changeComDict.Values) { int index = this.allComputers.FindIndex(com => com.Computerid == change.Computerid); StructRealTime ori = this.allComputers[index]; //修改电脑 if (!ori.Area.Equals(change.Area) || !ori.Computer.Equals(change.Computer)) { this.allComputers[index] = change; } } HomePageMessageManage.UpdateHomePageComputerArea(this.changeComDict.Values.ToList <StructRealTime>(), AREA_SETTING.NONE); this.changeComDict.Clear(); }
private void UpdateUserVerifyStatus(IList <string> pars) { string comid = pars[0]; //获取需要修改的电脑数据 int index = GetComputerIndex(int.Parse(comid)); StructRealTime com = this.computers[index]; //生成新StructRealTime StructRealTime.Builder newCom = new StructRealTime.Builder(com); newCom.Verify = "1"; //修改数组字典数据 this.computers[index] = newCom.Build(); //更新首页数据 UpdateHomePage(index, newCom.Build()); }
private void UpdateHomePage(int index, StructRealTime newcom) { //如果当前在过滤条件下以及电脑状态也在过滤条件下则重新搜索过滤数据 if (IsFilter && this.s_status != COMPUTERSTATUS.无) { //判断是否影响当前搜索 HomePageMessageManage.GetFilterComputers(this.s_status, this.s_areaId, this.s_key); } //否则更新单个电脑状态 else { if (this.UpdateComputerDataEvent != null) { this.UpdateComputerDataEvent(newcom); } } }
//添加新行 private void AddNewRow(StructRealTime computer, DataRow row) { //this.gridView1.RefreshRow if (row == null) { row = this.mainDataTable.NewRow(); this.mainDataTable.Rows.Add(row); } else { int index = this.mainDataTable.Rows.IndexOf(row); this.mainDataTable.Rows.Remove(row); row = this.mainDataTable.NewRow(); this.mainDataTable.Rows.InsertAt(row, index); } row[TitleList.EpNumber.ToString()] = computer.Computer; row[TitleList.Area.ToString()] = SysManage.GetAreaName(computer.Area); COMPUTERSTATUS status = COMPUTERSTATUS.在线; Enum.TryParse <COMPUTERSTATUS>(computer.Status, out status); //TODO:状态需要判断 row[TitleList.State.ToString()] = Enum.GetName(typeof(COMPUTERSTATUS), status); row[TitleList.IdCard.ToString()] = computer.Cardnumber; row[TitleList.CardType.ToString()] = SysManage.GetMemberTypeName(computer.Usertype); row[TitleList.MoneyType.ToString()] = computer.Billing; if (computer.Verify.Equals("")) { row[TitleList.VerifyType.ToString()] = ""; } else { row[TitleList.VerifyType.ToString()] = computer.Verify.Equals("1") ? "已验证" : "未验证"; } row[TitleList.ResMoney.ToString()] = computer.Balance; row[TitleList.ResTime.ToString()] = computer.Remaintime; row[TitleList.BeginTime.ToString()] = computer.Starttime; row[TitleList.UseTime.ToString()] = computer.Usedtime; row[TitleList.EndTime.ToString()] = computer.Stoptime; row[TitleList.MacLoc.ToString()] = computer.Mac; row[TitleList.IpLoc.ToString()] = computer.Ip; }
//监听CustomRowCellEdit private void GridView1_CustomRowCellEdit(object sender, DevExpress.XtraGrid.Views.Grid.CustomRowCellEditEventArgs e) { if (!e.Column.FieldName.Equals(TitleList.Operation.ToString())) { return; } //System.Console.WriteLine("GridView1_CustomDrawCell:" + e.RowHandle); StructRealTime com = this.coms[e.RowHandle]; //是否认证 if (com.Verify.Equals("1")) { e.RepositoryItem = verietyEdit; } else { e.RepositoryItem = normalEdit; } }
/// <summary> /// 设置电脑 /// </summary> public void SetComs(List <StructRealTime> coms, PaintEventHandler paint) { for (int i = 0; i < coms.Count; i++) { StructRealTime com = coms[i]; AreaComView view = new AreaComView(); view.Tag = com; view.Name = string.Format("name_{0}", com.Computerid); view.Title = com.Computer; view.Click += ComLabel_Click; view.Paint += paint; this.flowLayoutPanel1.Controls.Add(view); COMPUTERSTATUS status = COMPUTERSTATUS.无; Enum.TryParse <COMPUTERSTATUS>(com.Status, out status); view.ComStatus = status; } }
private void ButtonEdit_ButtonClick(object sender, ButtonPressedEventArgs e) { int rowhandle = this.gridView1.FocusedRowHandle; StructRealTime computer = coms[rowhandle]; if (computer.Cardnumber.Equals("")) { return; } DataRow row = this.gridView1.GetDataRow(rowhandle); char[] splites = { '_' }; string [] btnparams = ((string)e.Button.Tag).Split(splites); //锁定 if (btnparams[1].Equals("1")) { UserLockView view = new UserLockView(computer.Cardnumber); ToolsManage.ShowForm(view, false); } //强制下机 else if (btnparams[1].Equals("0")) { List <string> cards = new List <string>() { computer.Cardnumber }; HomePageNetOperation.ManagerCommandOperation(ManagerCommandOperationResult, COMMAND_TYPE.TICKOFF, cards); } //验证 else if (btnparams[1].Equals("2")) { List <string> cards = new List <string>() { computer.Cardnumber }; HomePageNetOperation.ManagerCommandOperation(ManagerCommandOperationResult, COMMAND_TYPE.VERIFY, cards); } }
//更新单个电脑区域数据 public void UpdateHomePageArea(StructRealTime com) { this.Invoke(new RefreshUIHandle(delegate { int index = HomePageMessageManage.GetComputerIndex(com.Computerid, this.coms); if (index < 0) { return; } //判断一下区域id和获取的名称是否相同 StructRealTime ori = this.coms[index]; DataRow row = this.mainDataTable.Rows[index]; string areaName = row[TitleList.Area.ToString()] as string; string newAreaName = SysManage.GetAreaName(com.Area); if (com.Area.Equals(ori.Area) && newAreaName.Equals(areaName)) { System.Console.WriteLine("更新的电脑没有改变"); return; } this.coms[index] = com; row[TitleList.Area.ToString()] = newAreaName; })); }
private void UserUpComputer(IList <string> pars) { string comid = pars[0]; //获取需要修改的电脑数据 int index = GetComputerIndex(int.Parse(comid)); StructRealTime com = this.computers[index]; //生成新StructRealTime StructRealTime.Builder newCom = new StructRealTime.Builder(com); newCom.Status = ((int)COMPUTERSTATUS.在线).ToString(); newCom.Name = pars[1]; newCom.Cardnumber = pars[2]; newCom.Usertype = pars[3]; newCom.Billing = pars[4]; newCom.Verify = pars[5]; //----// 余额,余时。开始时间。已用时。结束时间 newCom.Balance = pars[6]; newCom.Starttime = pars[7]; newCom.Usedtime = pars[8]; newCom.Stoptime = pars[9]; //计算剩余时间 DateTime start = DateTime.Parse(newCom.Starttime); DateTime end = DateTime.Parse(newCom.Stoptime); TimeSpan ts = end.Subtract(start); int dateDiffSecond = ts.Days * 24 * 60 + ts.Hours * 60 + ts.Minutes; newCom.Remaintime = (dateDiffSecond - int.Parse(newCom.Usedtime)) + ""; //修改数组字典数据 this.computers[index] = newCom.Build(); //this.computerDict[int.Parse(comid)] = newCom.Build(); //更新首页数据 UpdateHomePage(index, newCom.Build()); //刷新首页状态数量 UpdateStatusNumEvent(); }
public ComputerDetailView(StructRealTime com) { InitializeComponent(); currentCom = com; InitUI(); }
/// <summary> /// 更新电脑区域信息 /// </summary> /// <param name="changes">需要改变的电脑</param> /// <param name="setting">设置的类型</param> public static void UpdateHomePageComputerArea(List <StructRealTime> changes, AREA_SETTING setting) { if (Manage().RefreshAreaComBox != null) { Manage().RefreshAreaComBox(); } if (setting == AREA_SETTING.ADD) { return; } //先不判断是否有过滤 foreach (StructRealTime change in changes) { StructRealTime ori = Manage().computers.Where(com => com.Computerid == change.Computerid).First(); int index = Manage().computers.IndexOf(ori); switch (setting) { //删除;将Area 设为-1,防止之后添加的code与其相同。将自动归入其下 case AREA_SETTING.DELETE: { StructRealTime.Builder newCom = new StructRealTime.Builder(ori); newCom.Area = "0"; Manage().computers[index] = newCom.Build(); if (Manage().UpdateComputerAreaEvent != null && Manage().s_areaId < 0) { Manage().UpdateComputerAreaEvent(newCom.Build()); } } break; //更改名字。不变原数据只做刷新界面 case AREA_SETTING.UPDATE: { if (Manage().UpdateComputerAreaEvent != null) { Manage().UpdateComputerAreaEvent(ori); } } break; //点击完保存 case AREA_SETTING.NONE: { StructRealTime.Builder newCom = new StructRealTime.Builder(ori); newCom.Area = change.Area; Manage().computers[index] = newCom.Build(); if (Manage().UpdateComputerAreaEvent != null && Manage().s_areaId < 0) { Manage().UpdateComputerAreaEvent(newCom.Build()); } } break; default: break; } } //电脑视图 if (Manage().UpdateAreaEvent != null) { Manage().UpdateAreaEvent(); if (Manage().s_areaId >= 0) { //需要更新一下 GetFilterComputers(Manage().s_status, Manage().s_areaId, Manage().s_key); } } //列表视图(直接过滤一遍) else if (Manage().s_areaId >= 0 && setting != AREA_SETTING.UPDATE) { GetFilterComputers(Manage().s_status, Manage().s_areaId, Manage().s_key); } }