/// <summary>Gets a <seealso cref="LevelObjectIDUsage"/> from a <seealso cref="GeneralObject"/>'s used Block IDs.</summary> /// <param name="obj">The <seealso cref="GeneralObject"/> whose Block IDs to analyze.</param> public static LevelObjectIDUsage BlockIDsFromObject(GeneralObject obj) { return(IDsFromObject <BlockID, LevelObjectIDUsage>(obj)); }
private bool FillPrecautionsAccordingToChoices2(Panel p, GeneralObject go, ObjectList lines, bool mustSelect, bool checkContradition, string equipment) { bool selected = false; bool normalChecked = false; bool abnormalChecked = false; foreach (UIElement element in p.Children) { if (element is CheckBox) { CheckBox aBox = element as CheckBox; if (aBox.IsChecked.HasValue && aBox.IsChecked.Value) { if (aBox.Content.Equals("无") || aBox.Content.Equals("正常")) { normalChecked = true; } else { abnormalChecked = true; } } if (aBox.IsChecked.HasValue) { selected |= aBox.IsChecked.Value; } } } if (!selected && mustSelect) { MessageBox.Show("请选择" + equipment + "隐患选项!"); return(false); } if (normalChecked && abnormalChecked && checkContradition) { MessageBox.Show("请检查" + equipment + "隐患选项!"); return(false); } foreach (UIElement element in p.Children) { if (element is CheckBox) { CheckBox aBox = element as CheckBox; if (aBox.IsChecked.HasValue && aBox.IsChecked.Value) { if (aBox.Content.Equals("无") || aBox.Content.Equals("正常")) { continue; } GeneralObject line = CreateALine(go); lines.Add(line); line.SetPropertyValue("EQUIPMENT", equipment, true); if (aBox.Content.Equals("腐蚀")) { if (rbErodedSlight.IsChecked.Value) { line.SetPropertyValue("CONTENT", rbErodedSlight.Content, true); } else if (rbErodedSevere.IsChecked.Value) { line.SetPropertyValue("CONTENT", rbErodedSevere.Content, true); } else if (rbErodedModerate.IsChecked.Value) { line.SetPropertyValue("CONTENT", rbErodedModerate.Content, true); } } } } } return(true); }
private void listwh_DataLoaded(object sender, System.ComponentModel.AsyncCompletedEventArgs e) { //产生现在月份 Int32 thisMonth = Int32.Parse(ui_deliverydate.Text.Substring(5, 2)); GeneralObject kbfee = kbfee1.DataContext as GeneralObject; GeneralObject ljql1 = (GeneralObject)(from r in loader.Res where r.Name.Equals("ljql1") select r).First(); GeneralObject ljql2 = (GeneralObject)(from r in loader.Res where r.Name.Equals("ljql2") select r).First(); GeneralObject dbhjtqj1 = (GeneralObject)(from r in loader.Res where r.Name.Equals("dbhjtqj1") select r).First(); GeneralObject dbhjtqj2 = (GeneralObject)(from r in loader.Res where r.Name.Equals("dbhjtqj2") select r).First(); GeneralObject dbhjtqj3 = (GeneralObject)(from r in loader.Res where r.Name.Equals("dbhjtqj3") select r).First(); GeneralObject jtqj1 = (GeneralObject)(from r in loader.Res where r.Name.Equals("jtqj1") select r).First(); GeneralObject jtqj2 = (GeneralObject)(from r in loader.Res where r.Name.Equals("jtqj2") select r).First(); GeneralObject jtqj3 = (GeneralObject)(from r in loader.Res where r.Name.Equals("jtqj3") select r).First(); GeneralObject fmyljql1 = (GeneralObject)(from r in loader.Res where r.Name.Equals("fmyljql1") select r).First(); GeneralObject fmyljql2 = (GeneralObject)(from r in loader.Res where r.Name.Equals("fmyljql2") select r).First(); GeneralObject fmyjtqj1 = (GeneralObject)(from r in loader.Res where r.Name.Equals("fmyjtqj1") select r).First(); GeneralObject fmyjtqj2 = (GeneralObject)(from r in loader.Res where r.Name.Equals("fmyjtqj2") select r).First(); GeneralObject fmyjtqj3 = (GeneralObject)(from r in loader.Res where r.Name.Equals("fmyjtqj3") select r).First(); GeneralObject xiangys = (GeneralObject)(from r in loader.Res where r.Name.Equals("xiangys") select r).First(); //临界气量1 double cs_ljql1 = double.Parse(ljql1.GetPropertyValue("value").ToString()); //临界气量2 double cs_ljql2 = double.Parse(ljql2.GetPropertyValue("value").ToString()); //低保户阶梯气价1 double cs_dbhjtqj1 = double.Parse(dbhjtqj1.GetPropertyValue("value").ToString()); //低保户阶梯气价2 double cs_dbhjtqj2 = double.Parse(dbhjtqj2.GetPropertyValue("value").ToString()); //低保户阶梯气价3 double cs_dbhjtqj3 = double.Parse(dbhjtqj3.GetPropertyValue("value").ToString()); //阶梯气价1 double cs_jtqj1 = double.Parse(jtqj1.GetPropertyValue("value").ToString()); //阶梯气价2 double cs_jtqj2 = double.Parse(jtqj2.GetPropertyValue("value").ToString()); //阶梯气价3 double cs_jtqj3 = double.Parse(jtqj3.GetPropertyValue("value").ToString()); //非民用临界气量1 double cs_fmyljql1 = double.Parse(fmyljql1.GetPropertyValue("value").ToString()); //非民用临界气量2 double cs_fmyljql2 = double.Parse(fmyljql2.GetPropertyValue("value").ToString()); //非民用阶梯气价1 double cs_fmyjtqj1 = double.Parse(fmyjtqj1.GetPropertyValue("value").ToString()); //非民用阶梯气价2 double cs_fmyjtqj2 = double.Parse(fmyjtqj2.GetPropertyValue("value").ToString()); //非民用阶梯气价3 double cs_fmyjtqj3 = double.Parse(fmyjtqj3.GetPropertyValue("value").ToString()); //限购月数 double cs_xiangys = double.Parse(xiangys.GetPropertyValue("value").ToString()); //将预购气量转换成为double string pgas = ui_pregas.Text.ToString(); double pregas = 0; if (pgas != null && !pgas.Equals("")) { pregas = double.Parse(ui_pregas.Text.ToString()); } //周期起始月 double zqqsy = Math.Round((thisMonth / cs_xiangys), 0) * cs_xiangys + 1; //周期截止月 double zqjzy = Math.Round((thisMonth / cs_xiangys), 0) * cs_xiangys + cs_xiangys; // 民用 if (kbfee.GetPropertyValue("f_usertype").ToString().Equals("民用")) { //定义本阶梯够气量 double bjtgql = 0; //IEnumerable<int> scoreQuery =from score in list where thisMonth==getMonth select score; foreach (GeneralObject go in listwh) { //取出交费日期 var f_deliverydate = go.GetPropertyValue("f_deliverydate"); //取出每一条数据的交费月份 Int32 getMonth = Int32.Parse(f_deliverydate.ToString().Substring(5, 2)); if (getMonth >= zqqsy && getMonth <= zqjzy) { if (go.GetPropertyValue("f_pregas").Equals("")) { bjtgql = 0; } else { bjtgql += double.Parse(go.GetPropertyValue("f_pregas").ToString()); } MessageBox.Show("bjtgql是" + bjtgql); } else { bjtgql = 0; } } //如果不是低保户 if (!kbfee.GetPropertyValue("f_dibaohu").ToString().Equals("0")) { //阶梯气价1 if (bjtgql + pregas <= cs_ljql1) { ui_preamount.Text = (cs_jtqj1 * (bjtgql + pregas - bjtgql)).ToString(); } //阶梯气价2 else if (bjtgql + pregas <= cs_ljql2) { ui_preamount.Text = ((cs_jtqj2 * (bjtgql + pregas - cs_ljql1)) + cs_jtqj1 * (cs_ljql2 - (bjtgql + cs_ljql1))).ToString(); } //阶梯气价3 else { ui_preamount.Text = ((cs_jtqj3 * (bjtgql + pregas - cs_ljql2)) + cs_jtqj2 * (bjtgql + cs_ljql2)).ToString(); } } //是低保户 else { //低保户阶梯气价1 if (bjtgql + pregas <= cs_ljql1) { ui_preamount.Text = (cs_dbhjtqj1 * (bjtgql + pregas - bjtgql)).ToString(); } //低保户阶梯气价2 else if (bjtgql + pregas <= cs_ljql2) { ui_preamount.Text = ((cs_dbhjtqj2 * (bjtgql + pregas - cs_ljql1)) + cs_dbhjtqj1 * (cs_ljql2 - (bjtgql + pregas))).ToString(); } //低保户阶梯气价3 else { ui_preamount.Text = ((cs_dbhjtqj3 * (bjtgql + pregas - cs_ljql1)) + cs_dbhjtqj2 * (cs_ljql2 - (bjtgql + pregas))).ToString(); } } } else // 非民用 { //定义本阶梯够气量 double fmybjtgql = 0; //IEnumerable<int> scoreQuery =from score in list where thisMonth==getMonth select score; foreach (GeneralObject go in listwh) { //取出交费日期 var f_deliverydate = go.GetPropertyValue("f_deliverydate"); //取出每一条数据的交费月份 Int32 getMonth = Int32.Parse(f_deliverydate.ToString().Substring(5, 2)); if (getMonth >= zqqsy && getMonth <= zqjzy) { if (go.GetPropertyValue("f_pregas").Equals("")) { fmybjtgql = 0; } else { fmybjtgql += double.Parse(go.GetPropertyValue("f_pregas").ToString()); } MessageBox.Show("fmybjtgql是" + fmybjtgql); } else { fmybjtgql = 0; } //非民用阶梯气价1 if (fmybjtgql + pregas <= cs_fmyljql1) { ui_preamount.Text = (cs_fmyjtqj1 * (fmybjtgql + pregas - fmybjtgql)).ToString(); } //非民用阶梯气价2 else if (fmybjtgql + pregas <= cs_fmyljql2) { ui_preamount.Text = ((cs_fmyjtqj2 * (fmybjtgql + pregas - cs_fmyljql1)) + cs_jtqj1 * (cs_fmyljql2 - (fmybjtgql + pregas))).ToString(); } //非民用阶梯气价3 else { ui_preamount.Text = ((cs_fmyjtqj3 * (fmybjtgql + pregas - cs_fmyljql1)) + cs_jtqj2 * (cs_fmyljql2 - (fmybjtgql + pregas))).ToString(); } } } }
private void PostUITask(GeneralObject go) { if (go.GetPropertyValue("CONDITION").ToString().Equals("正常")) { //供暖方式 ObjectCollection oc = this.Resources["WARM"] as ObjectCollection; bool found = false; foreach (Pair pair in oc) { if (pair.CName.Equals(go.GetPropertyValue("WARM").ToString())) { found = true; WARM.SelectedItem = pair; } } if (!found) { WARM_OTHER.Text = go.GetPropertyValue("WARM").ToString(); WARM.SelectedIndex = oc.Count - 1; } //基表厂家型号 oc = this.Resources["JB_METER_NAME"] as ObjectCollection; found = false; foreach (Pair pair in oc) { if (pair.CName.Equals(go.GetPropertyValue("JB_METER_NAME").ToString())) { JB_METER_NAME.SelectedItem = pair; found = true; } } if (!found) { JB_METER_NAME_OTHER.Text = go.GetPropertyValue("JB_METER_NAME").ToString(); JB_METER_NAME.SelectedIndex = oc.Count - 1; } //IC卡表厂家型号 oc = this.Resources["IC_METER_NAME"] as ObjectCollection; found = false; foreach (Pair pair in oc) { if (pair.CName.Equals(go.GetPropertyValue("IC_METER_NAME").ToString())) { found = true; IC_METER_NAME.SelectedItem = pair; } } if (!found) { IC_METER_NAME_OTHER.Text = go.GetPropertyValue("IC_METER_NAME").ToString(); go.SetPropertyValue("IC_METER_NAME", (oc.ElementAt(oc.Count - 1) as Pair).Code, true, true); IC_METER_NAME.SelectedIndex = oc.Count - 1; } ObjectList lines = go.GetPropertyValue("LINES") as ObjectList; //不存在隐患 if (lines == null) { return; } foreach (GeneralObject line in lines) { String EQUIPMENT = line.GetPropertyValue("EQUIPMENT") as string; String CONTENT = line.GetPropertyValue("CONTENT") as string; if (EQUIPMENT.Equals("安全隐患")) { CheckCheckBox(CONTENT, precautionCheckPane); } else if (EQUIPMENT.Equals("水表")) { CheckCheckBox(CONTENT, MeterDefectsPane); } else if (EQUIPMENT.Equals("立管")) { CheckPlumbingBox(CONTENT, PlumbingDefectsPane); } else if (EQUIPMENT.Equals("阀门表前阀")) { CheckCheckBox(CONTENT, PlumbingMeterValvePane); } else if (EQUIPMENT.Equals("阀门灶前阀")) { CheckCheckBox(CONTENT, PlumbingCookerValvePane); } else if (EQUIPMENT.Equals("阀门自闭阀")) { CheckCheckBox(CONTENT, PlumbingAutomaticValvePane); } else if (EQUIPMENT.Equals("户内管")) { CheckCheckBox(CONTENT, PlumbingPipePane); } else if (EQUIPMENT.Equals("灶具软管")) { CheckCheckBox(CONTENT, CookerPipePane); } else if (EQUIPMENT.Equals("热水器软管")) { CheckCheckBox(CONTENT, BoilerPipePane); } else if (EQUIPMENT.Equals("热水器安全隐患")) { CheckCheckBox(CONTENT, BoilerDefectsPane); } else if (EQUIPMENT.Equals("壁挂锅炉安全隐患")) { CheckCheckBox(CONTENT, WHEDefectsPane); } } //提取用户档案地址 String card_id = go.GetPropertyValue("CARD_ID") as string; if (IsNullOrEmpty(card_id)) { return; } WebClient wc = new WebClient(); wc.DownloadStringCompleted += wc_GetUserProfileCompleted; wc.DownloadStringAsync(new Uri(go.WebClientInfo.BaseAddress + "/one/from T_IC_USERFILE where CARD_ID='" + card_id + "'")); } }
private bool TransformBeforeSave(GeneralObject go) { if (!go.GetPropertyValue("CONDITION").Equals("正常")) { return(true); } //必须输入字段 if (go.GetPropertyValue("CARD_ID").ToString().Length == 0) { MessageBox.Show("卡号不能为空!"); return(false); } if (go.GetPropertyValue("USER_NAME").ToString().Length == 0) { MessageBox.Show("用户名不能为空!"); return(false); } if (go.GetPropertyValue("TELPHONE").ToString().Length == 0) { MessageBox.Show("电话号码不能为空!"); return(false); } if (go.GetPropertyValue("JB_NUMBER").ToString().Length == 0) { MessageBox.Show("基表读数不能为空!"); return(false); } //供暖方式 if (!CheckCombo(go, WARM, WARM_OTHER, "WARM", "请检查供暖方式!")) { return(false); } //基表厂家型号 if (!CheckCombo(go, JB_METER_NAME, JB_METER_NAME_OTHER, "JB_METER_NAME", "请检查基表厂家型号!")) { return(false); } //IC卡表厂家型号 if (!CheckCombo(go, IC_METER_NAME, IC_METER_NAME_OTHER, "IC_METER_NAME", "请检查IC卡表厂家型号!")) { return(false); } if (NEEDS_REPAIR.IsChecked.Value && cmbRepair.SelectedItem == null) { MessageBox.Show("请选择维修人!"); return(false); } if (NEEDS_REPAIR.IsChecked.Value) { go.SetPropertyValue("NEEDS_REPAIR", "是", true); GeneralObject mechanic = cmbRepair.SelectedItem as GeneralObject; go.SetPropertyValue("REPAIRMAN", mechanic.GetPropertyValue("REPAIRMAN"), true); go.SetPropertyValue("REPAIRMAN_ID", mechanic.GetPropertyValue("REPAIRMAN_ID"), true); } else { go.SetPropertyValue("NEEDS_REPAIR", "否", true); go.SetPropertyValue("REPAIRMAN", null, true); go.SetPropertyValue("REPAIRMAN_ID", null, true); } ObjectList lines = new ObjectList(); //水表隐患,必选一个,也可多选 if (!FillPrecautionsAccordingToChoices(MeterDefectsPane, go, lines, true, false, "水表")) { return(false); } go.SetPropertyValue("RQB", RQB.IsChecked.Value?"正常":"不正常", true); //立管隐患 if (!FillPrecautionsAccordingToChoices2(PlumbingDefectsPane, go, lines, true, false, "立管")) { return(false); } go.SetPropertyValue("STANDPIPE", STANDPIPE.IsChecked.Value ? "正常" : "不正常", true); //严密性测试 if (cbRIGIDITYNormal.IsChecked.Value) { go.SetPropertyValue("RIGIDITY", "正常", true); } else { go.SetPropertyValue("RIGIDITY", "不正常", true); } if (cbRIGIDITYLeakage.IsChecked.Value) { go.SetPropertyValue("RIGIDITY", "漏水", true); } //静止压力 if (cbPressureAbnormal.IsChecked.Value && cbPressureNormal.IsChecked.Value) { MessageBox.Show("请检查静止选项!"); return(false); } if (cbPressureNormal.IsChecked.Value) { go.SetPropertyValue("STATIC", "正常", true); } else if (cbPressureAbnormal.IsChecked.Value) { go.SetPropertyValue("STATIC", "不正常", true); } else { go.SetPropertyValue("STATIC", "", true); } //表前阀 if (!FillPrecautionsAccordingToChoices(PlumbingMeterValvePane, go, lines, true, false, "阀门表前阀")) { return(false); } go.SetPropertyValue("TABLE_TAP", TABLE_TAP.IsChecked.Value ? "正常" : "不正常", true); //灶前阀 if (!FillPrecautionsAccordingToChoices(PlumbingCookerValvePane, go, lines, true, true, "阀门灶前阀")) { return(false); } go.SetPropertyValue("COOK_TAP", COOK_TAP.IsChecked.Value ? "正常" : "不正常", true); //自闭阀 if (!FillPrecautionsAccordingToChoices(PlumbingAutomaticValvePane, go, lines, true, true, "阀门自闭阀")) { return(false); } go.SetPropertyValue("CLOSE_TAP", CLOSE_TAP.IsChecked.Value ? "正常" : "不正常", true); //户内管 if (!FillPrecautionsAccordingToChoices(PlumbingPipePane, go, lines, true, true, "户内管")) { return(false); } go.SetPropertyValue("INDOOR", INDOOR.IsChecked.Value ? "正常" : "不正常", true); //漏水 if (cbLEAKAGE_COOKER.IsChecked.Value) { go.SetPropertyValue("LEAKAGE_COOKER", "灶具漏水", true); } else { go.SetPropertyValue("LEAKAGE_COOKER", "", true); } if (cbLEAKAGE_HEATER.IsChecked.Value) { go.SetPropertyValue("LEAKAGE_HEATER", "热水器漏水", true); } else { go.SetPropertyValue("LEAKAGE_HEATER", "", true); } if (cbLEAKAGE_BOILER.IsChecked.Value) { go.SetPropertyValue("LEAKAGE_BOILER", "壁挂炉漏水", true); } else { go.SetPropertyValue("LEAKAGE_BOILER", "", true); } if (cbLEAKAGE_NOTIFIED.IsChecked.Value) { go.SetPropertyValue("LEAKAGE_NOTIFIED", "安检告知", true); } else { go.SetPropertyValue("LEAKAGE_NOTIFIED", "", true); } //灶具软管 if (!FillPrecautionsAccordingToChoices(CookerPipePane, go, lines, false, true, "灶具软管")) { return(false); } go.SetPropertyValue("COOKPIPE_NORMAL", COOKPIPE_NORMAL.IsChecked.Value ? "正常" : "不正常", true); //热水器软管 if (!FillPrecautionsAccordingToChoices(BoilerPipePane, go, lines, false, true, "热水器软管")) { return(false); } go.SetPropertyValue("WATER_PIPE", WATER_PIPE.IsChecked.Value ? "正常" : "不正常", true); //热水器隐患 if (!FillPrecautionsAccordingToChoices(BoilerDefectsPane, go, lines, false, true, "热水器安全隐患")) { return(false); } go.SetPropertyValue("WATER_HIDDEN", WATER_HIDDEN.IsChecked.Value ? "正常" : "不正常", true); //壁挂锅炉安全隐患 if (!FillPrecautionsAccordingToChoices(WHEDefectsPane, go, lines, false, true, "壁挂锅炉安全隐患")) { return(false); } go.SetPropertyValue("WHE_HIDDEN", WHE_HIDDEN.IsChecked.Value ? "正常" : "不正常", true); //安全隐患 if (!FillPrecautionsAccordingToChoices(precautionCheckPane, go, lines, false, false, "安全隐患")) { return(false); } go.SetPropertyValue("LINES", lines, true); return(true); }
public static LevelObjectCollection GetObjects(string objectString) { List <GeneralObject> objects = new List <GeneralObject>(); while (objectString.Length > 0 && objectString[objectString.Length - 1] == ';') { objectString = objectString.Remove(objectString.Length - 1); } if (objectString.Length > 0) { string[][] objectProperties = objectString.Split(';').SplitAsJagged(','); for (int i = 0; i < objectProperties.Length; i++) { try { var objectInfo = objectProperties[i]; var instance = GeneralObject.GetNewObjectInstance(ToInt16(objectInfo[1])); objects.Add(instance); // Get IDs of the selected objects for (int j = 3; j < objectInfo.Length; j += 2) { try { int propertyID = ToInt32(objectInfo[j - 1]); switch (GetPropertyIDAttribute(propertyID)) { case IGenericAttribute <int> _: instance.SetPropertyWithID(propertyID, ToInt32(objectInfo[j])); break; case IGenericAttribute <bool> _: instance.SetPropertyWithID(propertyID, ToBoolean(ToInt32(objectInfo[j]))); break; case IGenericAttribute <double> _: instance.SetPropertyWithID(propertyID, ToDouble(objectInfo[j])); break; case IGenericAttribute <string> _: instance.SetPropertyWithID(propertyID, objectInfo[j]); break; case IGenericAttribute <HSVAdjustment> _: instance.SetPropertyWithID(propertyID, objectInfo[j].ToString()); break; case IGenericAttribute <int[]> _: instance.SetPropertyWithID(propertyID, objectInfo[j].ToString().Split('.').ToInt32Array()); break; case IGenericAttribute <Easing> _: instance.SetPropertyWithID(propertyID, (Easing)ToInt32(objectInfo[j])); break; case IGenericAttribute <InstantCountComparison> _: instance.SetPropertyWithID(propertyID, (InstantCountComparison)ToInt32(objectInfo[j])); break; case IGenericAttribute <PickupItemPickupMode> _: instance.SetPropertyWithID(propertyID, (PickupItemPickupMode)ToInt32(objectInfo[j])); break; case IGenericAttribute <PulseMode> _: instance.SetPropertyWithID(propertyID, (PulseMode)ToInt32(objectInfo[j])); break; case IGenericAttribute <PulseTargetType> _: instance.SetPropertyWithID(propertyID, (PulseTargetType)ToInt32(objectInfo[j])); break; case IGenericAttribute <TargetPosCoordinates> _: instance.SetPropertyWithID(propertyID, (TargetPosCoordinates)ToInt32(objectInfo[j])); break; case IGenericAttribute <TouchToggleMode> _: instance.SetPropertyWithID(propertyID, (TouchToggleMode)ToInt32(objectInfo[j])); break; } } catch (FormatException) // If the property is not just a number; most likely a Start Pos object { // After logging the exceptions in the console, the exception is ignorable } catch (KeyNotFoundException e) { int propertyID = ToInt32(objectInfo[j - 1]); if (propertyID == 36) { continue; } Console.WriteLine(e.Message); } } } catch (InvalidOperationException) { // So far this only happens when attempting to abstractly create a yellow teleportation portal } } objectProperties = null; } return(new LevelObjectCollection(objects)); }
/// <summary> /// 构建四级树节点 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void LoadBuildingAndOthers_Completed(object sender, System.ComponentModel.AsyncCompletedEventArgs e) { list.Completed -= LoadBuildingAndOthers_Completed; if (e.Error != null) { MessageBox.Show("提取数据错误。"); return; } List <TreeViewItem> llist = new List <TreeViewItem>(); List <int> rankList = new List <int>(); for (int i = 0; i < 4; i++) { llist.Add(curItem); rankList.Add(1); } int preLevel = 5; int preRank = 1; TreeViewItem parentItem = curItem; TreeViewItem preItem = curItem; for (int i = 0; i < list.Count; i++) { TreeViewItem item = new TreeViewItem(); GeneralObject go = (list[i] as GeneralObject); item.Header = go.GetPropertyValue("col1").ToString(); item.Tag = list[i]; int level = int.Parse(go.GetPropertyValue("col3").ToString()); int rank = int.Parse(go.GetPropertyValue("col6").ToString()); if (level < preLevel) { parentItem = llist[level]; preRank = rankList[level]; } else if (level == preLevel) { } else { llist[level] = preItem; parentItem = preItem; } if (rank >= preRank) { parentItem.Items.Add(item); rankList[level] = rank; } else { //查找比他大的最小值 int min = 999999; int pos = parentItem.Items.Count; for (int j = 0; j < pos; j++) { GeneralObject go2 = ((parentItem.Items[j] as TreeViewItem).Tag) as GeneralObject; int rank2 = int.Parse(go2.GetPropertyValue("col6").ToString()); if (rank2 > rank) { if (min > rank2) { min = rank2; pos = j; } } } //没找到 if (min == 999999) { parentItem.Items.Add(item); } else { parentItem.Items.Insert(pos, item); } } preItem = item; preLevel = level; preRank = rank; } curItem.IsExpanded = true; }
/// <summary> /// 添加子节点 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BtnAddChild_Click(object sender, RoutedEventArgs e) { if ((EditGrid.DataContext as SearchObject).HasErrors) { MessageBox.Show("请填写名称。"); return; } Indicator.IsBusy = true; //查找是否重复 String newName = (EditGrid.DataContext as SearchObject).GetPropertyValue("AName").ToString(); object remark = (EditGrid.DataContext as SearchObject).GetPropertyValue("Remark"); if (remark == null) { remark = ""; } bool duplicated = false; GeneralObject curGo = curItem.Tag as GeneralObject; int level = 0; if (String.IsNullOrEmpty(curGo.EntityType)) { level = int.Parse(curGo.GetPropertyValue("col3").ToString()) + 1; } if (level == 4) { Indicator.IsBusy = false; MessageBox.Show("房间下不能再添加节点!"); return; } String iid = ""; if (String.IsNullOrEmpty(curGo.EntityType)) { iid = curGo.GetPropertyValue("col0") + "000000"; } else { iid = curGo.GetPropertyValue("id").ToString().PadLeft(6, '0') + "000000"; } ItemCollection ic = curItem.Items; for (int i = 0; i < ic.Count; i++) { GeneralObject item = (ic[i] as TreeViewItem).Tag as GeneralObject; if (item.GetPropertyValue("col1").ToString().Equals(newName)) { duplicated = true; } String tiid = item.GetPropertyValue("col0").ToString(); if (tiid.CompareTo(iid) > 0) { iid = tiid; } } //判断重复 if (duplicated) { Indicator.IsBusy = false; MessageBox.Show("该名称已经存在。"); return; } iid = iid.Substring(0, iid.Length - 6) + (int.Parse(iid.Substring(iid.Length - 6)) + 1).ToString().PadLeft(6, '0'); int rank = 1; object pid = curGo.GetPropertyValue("col0"); if (!String.IsNullOrEmpty(curGo.EntityType)) { pid = curGo.GetPropertyValue("id").ToString(); } if (curItem.Items.Count != 0) { //计算排序号 GeneralObject go = (curItem.Items[curItem.Items.Count - 1] as TreeViewItem).Tag as GeneralObject; rank = int.Parse(go.GetPropertyValue("col6").ToString()) + 1; level = int.Parse(go.GetPropertyValue("col3").ToString()); } arguments = new object[] { iid, newName, remark, rank, level, pid }; //如果是叶子,插入t_gasaddress 并保存到t_design_address if (level == 3) { GeneralObject goAddress = new GeneralObject(); goAddress.EntityType = "t_gasaddress"; goAddress.WebClientInfo = App.Current.Resources["dbclient"] as WebClientInfo; goAddress.SetPropertyValue("f_apartment", newName, false); goAddress.SetPropertyValue("f_cusFloor", curItem.Header, false); goAddress.SetPropertyValue("f_cusDy", curItem.GetParentTreeViewItem().Header, false); goAddress.SetPropertyValue("f_cusDom", curItem.GetParentTreeViewItem().GetParentTreeViewItem().Header, false); TreeViewItem residentialArea = curItem.GetParentTreeViewItem().GetParentTreeViewItem().GetParentTreeViewItem(); goAddress.SetPropertyValue("f_districtname", residentialArea.Header, false); goAddress.SetPropertyValue("f_road", (residentialArea.Tag as GeneralObject).GetPropertyValue("f_road"), false); goAddress.Completed += goAddress_Completed; goAddress.Name = "asd"; goAddress.Save(); } //只保存入t_design_address else { GeneralObject address = new GeneralObject(); address.Name = "address"; address.EntityType = "t_design_address"; address.WebClientInfo = App.Current.Resources["dbclient"] as WebClientInfo; address.SetPropertyValue("iid", arguments[0], false); address.SetPropertyValue("name", arguments[1], false); address.SetPropertyValue("remark", arguments[2], false); address.SetPropertyValue("rank", arguments[3], false); address.SetPropertyValue("level", arguments[4], false); address.SetPropertyValue("pid", arguments[5], false); address.SetPropertyValue("col0", arguments[0], false); address.SetPropertyValue("col1", arguments[1], false); address.SetPropertyValue("col2", arguments[2], false); address.SetPropertyValue("col6", arguments[3].ToString(), false); address.SetPropertyValue("col3", arguments[4].ToString(), false); address.SetPropertyValue("col4", arguments[5], false); address.Completed += address_Completed; address.Save(); } }
private string synchronous(TreeViewItem curItem, string newName) { string sql = ""; GeneralObject go = curItem.Tag as GeneralObject; int level = Int32.Parse(go.GetPropertyValue("col3") + ""); switch (level) { case 0: sql = "update t_gasaddress set f_cusDom='" + newName + "' where f_cusDom='" + curItem.Header + "'"; break; case 1: sql = "update t_gasaddress set f_cusDy='" + newName + "' where f_cusDy='" + curItem.Header + "'"; break; case 2: sql = "update t_gasaddress set f_cusFloor='" + newName + "' where f_cusFloor='" + curItem.Header + "'"; break; case 3: sql = "update t_gasaddress set f_apartment='" + newName + "' where f_apartment='" + curItem.Header + "'"; break; default: break; } TreeViewItem tvi = curItem; for (int i = level; i >= 0; i--) { switch (i) { case 0: //小区 string f_districtname = tvi.GetParentTreeViewItem().Header.ToString(); sql += " and f_districtname='" + f_districtname + "' "; break; case 1: //楼号 string f_cusDom = tvi.GetParentTreeViewItem().Header.ToString(); sql += " and f_cusDom='" + f_cusDom + "' "; break; case 2: //单元 string f_cusDy = tvi.GetParentTreeViewItem().Header.ToString(); sql += " and f_cusDy='" + f_cusDy + "' "; break; case 3: //楼层 string f_cusFloor = tvi.GetParentTreeViewItem().Header.ToString(); sql += " and f_cusFloor='" + f_cusFloor + "' "; break; default: break; } tvi = tvi.GetParentTreeViewItem(); } return(sql); }
private void PostUITask(GeneralObject go) { if (go.GetPropertyValue("CONDITION").ToString().Equals("正常")) { ////供暖方式 //ObjectCollection oc = this.Resources["WARM"] as ObjectCollection; //bool found = false; //foreach (Pair pair in oc) //{ // if (pair.CName.Equals(go.GetPropertyValue("WARM").ToString())) // { // found = true; // WARM.SelectedItem = pair; // } //} //if (!found) //{ // WARM_OTHER.Text = go.GetPropertyValue("WARM").ToString(); // WARM.SelectedIndex = oc.Count - 1; //} ////基表厂家型号 //oc = this.Resources["JB_METER_NAME"] as ObjectCollection; //found = false; //foreach (Pair pair in oc) //{ // if (pair.CName.Equals(go.GetPropertyValue("JB_METER_NAME").ToString())) // { // JB_METER_NAME.SelectedItem = pair; // found = true; // } //} //if (!found) //{ // JB_METER_NAME_OTHER.Text = go.GetPropertyValue("JB_METER_NAME").ToString(); // JB_METER_NAME.SelectedIndex = oc.Count - 1; //} ////IC卡表厂家型号 //oc = this.Resources["IC_METER_NAME"] as ObjectCollection; //found = false; //foreach (Pair pair in oc) //{ // if (pair.CName.Equals(go.GetPropertyValue("IC_METER_NAME").ToString())) // { // found = true; // IC_METER_NAME.SelectedItem = pair; // } //} //if (!found) //{ // IC_METER_NAME_OTHER.Text = go.GetPropertyValue("IC_METER_NAME").ToString(); // go.SetPropertyValue("IC_METER_NAME", (oc.ElementAt(oc.Count - 1) as Pair).Code, true, true); // IC_METER_NAME.SelectedIndex = oc.Count - 1; //} //ObjectList lines = go.GetPropertyValue("LINES") as ObjectList; ////不存在隐患 //if (lines == null) // return; //foreach (GeneralObject line in lines) //{ // String EQUIPMENT = line.GetPropertyValue("EQUIPMENT") as string; // String CONTENT = line.GetPropertyValue("CONTENT") as string; // if (EQUIPMENT.Equals("安全隐患")) // CheckCheckBox(CONTENT, precautionCheckPane); // else if (EQUIPMENT.Equals("燃气表")) // CheckCheckBox(CONTENT, MeterDefectsPane); // else if (EQUIPMENT.Equals("立管")) // CheckPlumbingBox(CONTENT, PlumbingDefectsPane); // else if (EQUIPMENT.Equals("阀门表前阀")) // CheckCheckBox(CONTENT, PlumbingMeterValvePane); // else if (EQUIPMENT.Equals("阀门灶前阀")) // CheckCheckBox(CONTENT, PlumbingCookerValvePane); // else if (EQUIPMENT.Equals("阀门自闭阀")) // CheckCheckBox(CONTENT, PlumbingAutomaticValvePane); // else if (EQUIPMENT.Equals("户内管")) // CheckCheckBox(CONTENT, PlumbingPipePane); // else if (EQUIPMENT.Equals("灶具软管")) // CheckCheckBox(CONTENT, CookerPipePane); // else if (EQUIPMENT.Equals("热水器软管")) // CheckCheckBox(CONTENT, BoilerPipePane); // else if (EQUIPMENT.Equals("热水器安全隐患")) // CheckCheckBox(CONTENT, BoilerDefectsPane); // else if (EQUIPMENT.Equals("壁挂锅炉安全隐患")) // CheckCheckBox(CONTENT, WHEDefectsPane); //} //提取用户档案地址 String user_id = go.GetPropertyValue("f_userid") as string; if (IsNullOrEmpty(user_id)) { return; } WebClient wc = new WebClient(); wc.DownloadStringCompleted += wc_GetUserProfileCompleted; wc.DownloadStringAsync(new Uri(go.WebClientInfo.BaseAddress + "/one/from t_userfiles where f_userid='" + user_id + "'")); } }