private void EditSatellite() { var num = txtNumber.Value.Trim(); var t = SatelliteInstance.Find(f => f.id == ParseInt(Utility.Decrypt(hidID.Value))); if (null != t) { var old = SatelliteInstance.Find(f => f.CardNo.Equals(num)); if (null != old && old.id != t.id) { ShowNotification("./satellite_manage.aspx", "Cannot edit the satellite object: The number has exist.", false); } else { SatelliteInstance.Update(f => f.id == t.id, act => { act.CardNo = num; }); SaveHistory(new TB_AccountHistory() { ActionId = ActionInstance.Find(f => f.Name.Equals("EditSat")).id, ObjectA = SatelliteInstance.ToString(t) }); ShowNotification("./satellite_manage.aspx", "You saved the satellite information."); } } else { ShowNotification("./satellite_manage.aspx", "Cannot edit the satellite object: no record exist.", false); } }
private void ShowEdit() { var t = SatelliteInstance.Find(f => f.id == ParseInt(Utility.Decrypt(hidID.Value))); if (null != t) { txtNumber.Value = t.CardNo; btSave.Text = "Save"; } else { ShowNotification("./satellite_manage.aspx", "Error: Cannot edit null object of <a>Satellite Item</a>.", false); } }
protected void btSave_Click(object sender, EventArgs e) { // 保存新的铱星模块号码 var number = txtQueryNumber.Value.Trim(); var len = number.Length; if (len != 6 && len != 15) { ShowNotification("/iridium_model_register.aspx", "Your input is not a Iridium IMEI number.", false); } else { var pre = number.Substring(0, 3); if (pre != "306" && pre != "300") { ShowNotification("/iridium_model_register.aspx", "Your input is not a Iridium IMEI number.", false); } else { var obj = SatelliteInstance.Find(f => f.CardNo.Equals(number)); if (null != obj) { ShowNotification("/iridium_model_register.aspx", "There have a SAME satellite IMEI number exist.", false); } else { var old = SatelliteInstance.FindList <TB_Satellite>(f => f.PcbNumber.Contains("Satellite"), "PcbNumber", true).FirstOrDefault(); var newNumber = "Satellite"; var num = 0; if (null != old) { var tmp = old.PcbNumber.ToLower().Replace("satellite", ""); num = int.Parse(tmp); } newNumber = string.Format("{0}{1:0000}", newNumber, num + 1); var n = SatelliteInstance.GetObject(); n.CardNo = number; n.PcbNumber = newNumber; SatelliteInstance.Add(n); ShowSatellites(); } } } }
private void NewSatellite() { var num = txtNumber.Value.Trim(); var t = SatelliteInstance.Find(f => f.CardNo.Equals(num)); if (null != t) { ShowNotification("./satellite_manage.aspx", "Error: A old one has the same card number <a>" + num + "</a>.", false); return; } else { var obj = SatelliteInstance.GetObject(); obj.CardNo = num; SatelliteInstance.Add(obj); SaveHistory(new TB_AccountHistory() { ActionId = ActionInstance.Find(f => f.Name.Equals("AddSat")).id, ObjectA = SatelliteInstance.ToString(obj) }); ShowNotification("./satellite_manage.aspx", "You add a new satellite object."); } }
protected void btBoundSatellite_Click(object sender, EventArgs e) { var value = hidBoundSatellite.Value.Trim(); if (string.IsNullOrEmpty(value)) { return; } // 为终端绑定卫星模块 var index = value.IndexOf(','); if (index < 0) { // 没有,分割的是解绑卫星模块 UnboundSatellite(); return; } var tid = value.Substring(0, index); var gid = value.Substring(index + 1); gid = Utility.Decrypt(gid); var t = TerminalInstance.Find(f => f.id == int.Parse(tid)); if (null == t) { ShowNotification("./terminal_list.aspx", "Bound fail: Terminal not exists.", false); } else { if (t.Satellite != (int?)null) { ShowNotification("./terminal_list.aspx", "Terminal \"" + t.Number + "\" has bound Satellite: " + t.TB_Satellite.CardNo, false); } else { var g = SatelliteInstance.Find(f => f.id == int.Parse(gid)); if (null == g) { ShowNotification("./terminal_list.aspx", "No Satellite info exists.", false); } else { if (g.Bound == true) { var gt = TerminalInstance.Find(f => f.TB_Satellite.id == g.id); ShowNotification("./terminal_list.aspx", "Satellite \"" + g.CardNo + "\" has bound on Terminal: " + gt.Number, false); } else { TerminalInstance.Update(f => f.id == t.id, act => { act.Satellite = g.id; }); t = TerminalInstance.Find(f => f.id == t.id); SatelliteInstance.Update(f => f.id == g.id, act => { act.Bound = true; }); // 发送绑定卫星模块的命令 SendDD02Command(true, t); // 保存绑定卫星模块的历史记录 SaveHistory(new TB_AccountHistory() { ActionId = ActionInstance.Find(f => f.Name.Equals("BindSat")).id, ObjectA = TerminalInstance.ToString(t) }); //ShowTerminals(); ShowNotification("./terminal_list.aspx", "Terminal \"" + t.Number + "\" bound Satellite \"" + g.CardNo + "\" OK!"); } } } } }