private void saveButton_Click(object sender, RoutedEventArgs e) { ui_handBusy.IsBusy = true; string json = "["; BaseObjectList list = daninfos.ItemsSource as BaseObjectList; List <GeneralObject> removed = new List <GeneralObject>(); //对于每一条记录 foreach (GeneralObject go in list) { // 抄表记录里的上期指数 var lastinputnum = go.GetPropertyValue("lastinputgasnum"); // 本次抄表指数 var lastrecord = go.GetPropertyValue("lastrecord"); //卡表剩余水量 var f_leftgas = go.GetPropertyValue("f_leftgas"); // 本次指数为空,这条不上传 if (lastrecord == null) { continue; } // 本期指数小于上期指数,不上传 if (double.Parse(lastrecord.ToString()) < double.Parse(lastinputnum.ToString())) { continue; } // 从列表中去除 removed.Add(go); //已经有项目,加逗号区分 if (json != "[") { json += ','; } //产生要发送后台的JSON串 json += ("{userid:" + go.GetPropertyValue("f_userid") + ",lastreading:" + lastinputnum + ",reading:" + lastrecord + ",leftgas:" + f_leftgas + ",meterstate:" + meterstate + "}"); } json += "]"; foreach (GeneralObject go in removed) { list.Remove(go); } //将产生的json串送后台服务进行处理 WebClientInfo wci = Application.Current.Resources["server"] as WebClientInfo; string uri = wci.BaseAddress + "/handcharge/record/batch/" + ui_handdate.SelectedDate + "/" + ui_sgnetwork.Text + "/" + ui_sgoperator.Text + "/" + chaobiaoriqi.SelectedDate + "/" + meter.SelectedValue.ToString() + "?uuid=" + System.Guid.NewGuid().ToString(); WebClient client = new WebClient(); client.UploadStringCompleted += client_UploadStringCompleted; client.UploadStringAsync(new Uri(uri), json); }
private static void OnEmptyRowTypeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { ItemsControl c = (ItemsControl)d; //不要空行,直接返回 if (e.NewValue == null) { return; } BaseObjectList list = (BaseObjectList)c.ItemsSource; //如果还没有设置ItemsSource,监听ItemsSource改变事件,在ItemsSource有值时进行设置 if (list == null) { c.Watch("ItemsSource", OnItemSourceChanged); return; } //设置过有空行,不重复设置 if (list.HasEmptyRow) { return; } list.EntityType = (string)e.NewValue; list.HasEmptyRow = true; }
public override void Invoke() { char[] c = new char[] { ';' }; string[] str = ReturnName.Split(c); BaseObjectList ol = (BaseObjectList)SaveObj.GetPropertyValue(ListName); foreach (GeneralObject item in ol) { for (int i = 0; i < str.Length; i++) { string value = str[i]; string[] split = new string[] { "=>" }; string[] objs = value.Split(split, StringSplitOptions.RemoveEmptyEntries); //获得稽查结果 object result = item.GetPropertyValue(objs[0]); if (result == null) { continue; } //获得用户档案 GeneralObject user = (GeneralObject)item.GetPropertyValue(UserName); //给用户档案设置稽查结果 user.SetPropertyValue(objs[1], result, true); } } SaveObj.Save(); }
/// <summary> /// React on the event that a view has been closed /// </summary> /// <param name="sender">The view that has been closed.</param> /// <param name="e">The event's arguments.</param> public void OnViewClosed(IView sender, EventArgs e) { try { if (sender != null && this.viewCollection.Contains(sender)) { // the view belongs to this document! this.viewCollection.Remove(sender); this.viewControllerList.Remove(sender.ViewController); if (this.viewCollection.Count == 0) { // the last view has been closed // let this document and all associated data vanish sender.Close(); System.Diagnostics.Debug.Assert(this.viewControllerList.Count == 0, "No Views in the List"); this.viewCollection = null; this.viewControllerList = null; AppContext.DocumentList.Remove(this); AppContext.ViewClosed -= this.OnViewClosed; this.docContent = null; this.docObjects = null; this.selectedObjects = null; this.docName = string.Empty; this.fileName = string.Empty; GC.Collect(); // this a justifiable use of GC.Collect() since the last view of an document is closed and rather big amounts of data being freed. } } } catch (Exception ex) { Util.ReportException(ex); } }
static void Items_Loaded(object sender, RoutedEventArgs e) { FrameworkElement ui = (FrameworkElement)sender; ui.Loaded -= Items_Loaded; BaseObjectList bol = (BaseObjectList)GetItems(ui); bol.Init(ui); }
/// <summary> /// Insert the representation of all objects contained in the document /// into the view (via this viewcontroller). /// </summary> public virtual void InsertAllObjects() { BaseObjectList objects = this.document.BaseObjects; foreach (BaseObject baseObject in objects) { this.InsertRepresentation(baseObject); } }
/// <summary> /// Initializes a new instance of the <see cref="Document"/> class /// </summary> /// <remarks> /// Creates a new document. /// </remarks> public Document() { this.docObjects = new BaseObjectList(); this.viewCollection = new ViewCollection(); this.viewControllerList = new ViewControllerList(); this.selectedObjects = new BaseObjectList(); this.docName = string.Empty; this.fileName = string.Empty; this.docGuid = Guid.NewGuid(); AppContext.ViewClosed += this.OnViewClosed; }
public static void Add_(object list, object go) { if (!(list is BaseObjectList) || !(go is GeneralObject)) { throw new Exception("只能把GeneralObject放进BasicObjectList中"); } BaseObjectList l = list as BaseObjectList; GeneralObject o = go as GeneralObject; l.Add(o); }
private void saveButton_Click(object sender, RoutedEventArgs e) { ui_handBusy.IsBusy = true; BaseObjectList list = daninfos.ItemsSource as BaseObjectList; List <GeneralObject> removed = new List <GeneralObject>(); //对于每一条记录 foreach (GeneralObject go in list) { //表具编号 var userid = go.GetPropertyValue("f_userid"); //抄表id var id = go.GetPropertyValue("id"); // 抄表记录里的上期指数 var lastinputnum = go.GetPropertyValue("lastinputgasnum"); // 本次抄表指数 var lastrecord = go.GetPropertyValue("lastrecord"); // 抄表记录里的阶梯类型 var stairType = go.GetPropertyValue("f_stairtype"); // 用水量 var oughtamount = go.GetPropertyValue("oughtamount"); // 本次指数为空,这条不上传 if (lastrecord == null) { continue; } // 本期指数小于上期指数,不上传 if (double.Parse(lastrecord.ToString()) < double.Parse(lastinputnum.ToString())) { MessageBox.Show("表" + userid + "本期指数异常,请核查"); continue; } removed.Add(go); string sql = "update t_handplan set lastrecord=" + lastrecord + ",f_state= '" + "待审核" + "',oughtamount= " + oughtamount + " where id=" + id; HQLAction action = new HQLAction(); action.HQL = sql; action.WebClientInfo = Application.Current.Resources["dbclient"] as WebClientInfo; action.Name = "t_handplan"; action.Completed += action_Completed; action.Invoke(); } foreach (GeneralObject go in removed) { list.Remove(go); } }
/// <summary> /// Add the given <paramref name="baseObject"/> to the selection list and tell the /// view controllers to redraw it. /// </summary> /// <param name="baseObject"><see cref="BaseObject"/> to select.</param> /// <param name="deselectCurrent"><see langword="bool"/> indicating if the existing /// selection is to be cancelled.</param> public void SelectObject(BaseObject baseObject, bool deselectCurrent) { if (baseObject == null) { throw new ArgumentNullException("baseObject"); } var selectees = new BaseObjectList { baseObject }; this.SelectObjects(selectees, deselectCurrent); }
// 清除界面上的数据 private void Clear() { // 清除交费内容 GeneralObject kbfee = (GeneralObject)(from r in loader.Res where r.Name.Equals("kbfee") select r).First(); kbfee.New(); // 清除欠费信息 BaseObjectList list = dataGrid1.ItemsSource as BaseObjectList; list.Clear(); // 当前选中用户为空 userfiles.SelectedItem = null; }
//获取对象在某个列表中的位置 public static int Pos(object go, object list) { if (go == null) { throw new NullReferenceException(); } if (!(go is GeneralObject && list is BaseObjectList)) { throw new Exception("Pos函数只能用于获取GeneralObject在BasicObjectList中的位置"); } GeneralObject ngo = (GeneralObject)go; BaseObjectList nlist = (BaseObjectList)list; int ret = nlist.IndexOf(go); return(ret); }
private void saveButton_Click(object sender, RoutedEventArgs e) { ui_handBusy.IsBusy = true; BaseObjectList list = daninfos.ItemsSource as BaseObjectList; ObjectList data = new ObjectList(); //参数对象 GeneralObject param = FrameworkElementExtension.FindResource(this.saveButton, "param") as GeneralObject; //对于每一条记录 foreach (GeneralObject go in list) { //表状态 var meterstate = meter.SelectedValue; // 抄表记录里的上期指数 var lastinputnum = go.GetPropertyValue("lastinputgasnum"); // 本次抄表指数 var lastrecord = go.GetPropertyValue("lastrecord"); // 本次指数为空,这条不上传 if (lastrecord == null) { continue; } // 本期指数小于上期指数,不上传 if (double.Parse(lastrecord.ToString()) < double.Parse(lastinputnum.ToString())) { continue; } go.CopyDataFrom(param); data.Add(go); } if (data.Count == 0) { return; } //将产生的json串送后台服务进行处理 WebClientInfo wci = Application.Current.Resources["server"] as WebClientInfo; string uri = wci.BaseAddress + "/handcharge/record/payfeeforhand?uuid=" + System.Guid.NewGuid().ToString(); WebClient client = new WebClient(); client.UploadStringCompleted += client_UploadStringCompleted; client.UploadStringAsync(new Uri(uri), data.ToJson().ToString()); }
//监听ItemsSource发生的变换 private static void OnItemSourceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { ItemsControl c = (ItemsControl)d; if (c.ItemsSource == null) { return; } BaseObjectList list = (BaseObjectList)c.ItemsSource; //设置过有空行,不重复设置 if (list.HasEmptyRow) { return; } list.EntityType = GetEmptyRowType(c); list.HasEmptyRow = true; }
private void allSend_Click(object sender, RoutedEventArgs e) { BaseObjectList list = daninfos.ItemsSource as BaseObjectList; //对于每一条记录 foreach (GeneralObject go in list) { // id String smsId = go.GetPropertyValue("id").ToString(); String sql = "update t_sms set f_state='未发' where id=" + smsId + ""; HQLAction action = new HQLAction(); action.Name = "abc"; action.HQL = sql; action.WebClientInfo = Application.Current.Resources["dbclient"] as WebClientInfo; action.Invoke(); } }
private void allSend_Click(object sender, RoutedEventArgs e) { BaseObjectList list = daninfos.ItemsSource as BaseObjectList; String content = f_content.Text.ToString(); String templateName = templatename.SelectedValue.ToString(); //对于每一条记录 foreach (GeneralObject go in list) { // id String username = go.GetPropertyValue("f_username").ToString(); String f_phone = go.GetPropertyValue("f_phone").ToString(); WebClientInfo wci = (WebClientInfo)Application.Current.Resources["smsserver"]; string str = wci.BaseAddress + "/send/" + username + "/" + f_phone + "/" + content + "/" + templateName; Uri uri = new Uri(str); WebClient client = new WebClient(); client.DownloadStringAsync(uri); } }
//通过树状结构子属性名把列表转换成通用对象列表 public static BaseObjectList ToList(object list, string childPropertyName) { //只有枚举对象才可以转换成通用对象 if (!(list is IEnumerable)) { throw new Exception("非枚举对象无法转换成对象列表:"); } BaseObjectList result = new ObjectList(); foreach (GeneralObject go in (IEnumerable)list) { BaseObjectList bol = (BaseObjectList)go.GetPropertyValue(childPropertyName); if (bol != null) { foreach (GeneralObject cgo in bol) { result.Add(cgo); } } } return(result); }
static void dg_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { DataGrid grid = (DataGrid)sender; //获取点击列标题 var u = from element in VisualTreeHelper.FindElementsInHostCoordinates(e.GetPosition(null), grid) where element is DataGridColumnHeader select element; if (u.Count() == 1) { e.Handled = true; DataGridColumnHeader header = (DataGridColumnHeader)u.Single(); string headername = header.Content.ToString(); //将获得的标题名传给模型处理 BaseObjectList list = (BaseObjectList)grid.ItemsSource; list.ChangeSortName(headername); } else { e.Handled = false; } }
public static void SetItems(FrameworkElement ui, BaseObjectList value) { ui.SetValue(ItemsProperty, value); }
/// <summary> /// Load and convert the file specified by <paramref name="fileName"/> to the format specified by <paramref name="targetExt"/> /// and/or create a bitmap of the file. The bitmap format is defined by <paramref name="bitmapExt"/>. The result will be stored /// in the directory given by <paramref name="targetDir"/>. /// </summary> /// <param name="fileName">The full qualified filename of the file to process.</param> /// <param name="targetDir">The directory where the results should be stored.</param> /// <param name="targetExt">The target format to which to convert the given file. If empty, no conversion takes place.</param> /// <param name="bitmapExt">If not empty a bitmap of the type specified by this extension is created from the files (image) content.</param> /// <param name="bitmapDir">Specifies an additional directory where a copy of the bitmap (if any) should be created.</param> /// <returns>A <see cref="bool"/> value indicating the success of the operation.</returns> public bool BatchProcess(string fileName, string targetDir, string targetExt, string bitmapExt, string bitmapDir) { if (string.IsNullOrEmpty(fileName) || !File.Exists(fileName)) { return(false); } // load the file... try { // identify the loader on the basis of the extension... string extension = Path.GetExtension(fileName); ISpecFileLoader loader = AppContext.SpecFileLoaders.FindSupportingLoader(extension); if (loader == null) { return(false); } // find the matching image writer IImagingWriter imageWriter = null; if (!string.IsNullOrEmpty(targetExt)) { foreach (var candidate in AppContext.ImagingWriters) { if (candidate != null) { bool found = false; foreach (FileTypeDescriptor fileType in candidate.SupportedFileTypes) { if (fileType != null && fileType.IncludesExtension(targetExt)) { found = true; break; } } if (found) { imageWriter = candidate; break; } } } } // find the matching bitmap writer IBitmapWriter bitmapWriter = null; if (!string.IsNullOrEmpty(bitmapExt)) { foreach (IBitmapWriter candidate in AppContext.BitmapWriters) { if (candidate != null) { bool found = false; foreach (FileTypeDescriptor fileType in candidate.SupportedFileTypes) { if (fileType != null && fileType.IncludesExtension(bitmapExt)) { found = true; break; } } if (found) { bitmapWriter = candidate as BitmapWriter; break; } } } } if (imageWriter == null && bitmapWriter == null) { // no appropriate writers found for requested operation return(false); } // let the loader load ISpecFileContent specFileContent = loader.Load(fileName); if (specFileContent == null) { return(false); } BaseObjectList baseObjects = specFileContent.GetContent(); if (baseObjects == null) { return(false); } string outDir = (!string.IsNullOrEmpty(targetDir) && Directory.Exists(targetDir)) ? targetDir : Path.GetDirectoryName(fileName); string filename = Path.GetFileNameWithoutExtension(fileName); // loop over the images an process foreach (BaseObject baseObject in baseObjects) { var imaging = baseObject as Imaging; if (imaging == null) { continue; } // perform image conversion if requested... if (imageWriter != null) { // compose filename string targetFile = filename + " - " + imaging.Name; targetFile = Util.SubstitueInvalidPathChars(targetFile, '-'); targetFile = targetFile.Replace('.', '_'); targetFile = Path.Combine(outDir, targetFile + targetExt); imageWriter.Write(imaging, targetFile, false); } // create a bitmap if required if (bitmapWriter != null) { BitmapSourceList bitmaps = imaging.GetBitmaps(); if (bitmaps != null && bitmaps.Count > 0) { System.Windows.Media.Imaging.BitmapSource bitmap = bitmaps[0]; if (bitmap != null) { // compose filename string bitmapFileName = filename + " - " + imaging.Name; bitmapFileName = Util.SubstitueInvalidPathChars(bitmapFileName, '-'); bitmapFileName = bitmapFileName.Replace('.', '_'); string bitmapFilePath = Path.Combine(outDir, bitmapFileName + bitmapExt); bitmapWriter.Write(bitmap, bitmapFilePath, false); if (!string.IsNullOrEmpty(bitmapDir) && Directory.Exists(bitmapDir)) { bitmapFilePath = Path.Combine(bitmapDir, bitmapFileName + bitmapExt); bitmapWriter.Write(bitmap, bitmapFilePath, false); } } } } } } catch (Exception e) { Util.ReportException(e); return(false); } return(true); }
public MyList(BaseObjectList list) { _list = list; list.PropertyChanged += list_PropertyChanged; }
public int IndexOf(BaseObjectList list) { return list.IndexOf(this); }
void userfiles_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e) { kbsellgasbusy.IsBusy = false; busy.IsBusy = false; if (e.Error != null) { MessageBox.Show("未找到用户的表具信息,请去表具建档!"); return; } //把数据转换成JSON JsonObject item = JsonValue.Parse(e.Result) as JsonObject; //把用户数据写到交费界面上 ui_username.Text = (string)item["f_username"]; ui_usertype.Text = (String)item["f_usertype"]; ui_districtname.Text = (String)item["f_districtname"]; ui_gasproperties.Text = (String)item["f_gasproperties"]; ui_stairpricetype.Text = (String)item["f_stairtype"]; // zhye.Text = item["f_zhye"].ToString(); ui_address.Text = (String)item["f_address"]; //ui_gaspricetype.Text = (String)item["f_gaspricetype"]; ui_userid.Text = item["infoid"].ToString(); //zhe.Text=item["f_zherownum"].ToString(); //ui_dibaohu.IsChecked = item["f_dibaohu"].ToString().Equals("1"); //ui_userstate.Text = (String)item["f_userstate"]; // ui_paytype.Text = (String)item["f_payment"]; // ui_gasprice.Text = item["f_gasprice"].ToString(); //把欠费数据插入到欠费表中 BaseObjectList list = dataGrid1.ItemsSource as BaseObjectList; if (list != null) { list.Clear(); } // 当前正在处理的表号 String currentId = ""; // 总的上期指数 decimal lastnum = 0; // 总气量 decimal gasSum = 0; // 总气费 decimal feeSum = 0; //总的滞纳金 decimal zhinajinAll = 0; //余额 decimal f_zhye = decimal.Parse(item["f_zhye"].ToString()); JsonArray bills = item["f_hands"] as JsonArray; foreach (JsonObject json in bills) { GeneralObject go = new GeneralObject(); go.EntityType = "t_handplan"; //默认选中 go.IsChecked = true; //上期指数 decimal lastinputgasnum = (decimal)json["lastinputgasnum"]; go.SetPropertyValue("lastinputgasnum", lastinputgasnum, false); string f_userid = (string)json["f_userid"]; go.SetPropertyValue("f_userid", f_userid, false); // 如果表号变了 if (!f_userid.Equals(currentId)) { currentId = f_userid; lastnum += lastinputgasnum; } //计算总金额 decimal oughtfee = (decimal)json["oughtfee"]; go.SetPropertyValue("oughtfee", oughtfee, false); feeSum += oughtfee; // 计算总气量 decimal oughtamount = (decimal)json["oughtamount"]; gasSum += oughtamount; go.SetPropertyValue("oughtamount", oughtamount, false); //计算总滞纳金 decimal f_zhinajin = (decimal)json["f_zhinajin"]; zhinajinAll += f_zhinajin; go.SetPropertyValue("f_zhinajin", f_zhinajin, false); int id = Int32.Parse(json["id"] + ""); go.SetPropertyValue("id", id, false); go.SetPropertyValue("lastinputdate", DateTime.Parse(json["lastinputdate"]), false); go.SetPropertyValue("lastrecord", (decimal)json["lastrecord"], false); go.SetPropertyValue("f_endjfdate", DateTime.Parse(json["f_endjfdate"]), false); go.SetPropertyValue("f_zhinajintianshu", (int)json["days"], false); go.SetPropertyValue("f_network", (string)json["f_network"], false); go.SetPropertyValue("f_operator", (string)json["f_operator"], false); go.SetPropertyValue("f_inputdate", DateTime.Parse(json["f_inputdate"]), false); go.SetPropertyValue("f_userid", (string)json["f_userid"], false); go.SetPropertyValue("f_stair1amount", (decimal)json["f_stair1amount"], false); go.SetPropertyValue("f_stair1price", (decimal)json["f_stair1price"], false); go.SetPropertyValue("f_stair1fee", (decimal)json["f_stair1fee"], false); go.SetPropertyValue("f_stair2amount", (decimal)json["f_stair2amount"], false); go.SetPropertyValue("f_stair2price", (decimal)json["f_stair2price"], false); go.SetPropertyValue("f_stair2fee", (decimal)json["f_stair2fee"], false); go.SetPropertyValue("f_stair3amount", (decimal)json["f_stair3amount"], false); go.SetPropertyValue("f_stair3price", (decimal)json["f_stair3price"], false); go.SetPropertyValue("f_stair3fee", (decimal)json["f_stair3fee"], false); list.Add(go); } }
//设置列表属性,设置时,将监听其IsModified属性改变事件 private void SetCollectionProperty(string key, BaseObjectList ol) { //如果有默认对象,且要设置的列表为空,采用默认对象的复制结果 var p = (from ps in PropertySetters where ps.PropertyName == key select ps).FirstOrDefault(); if (p != null && p.DefaultObject != null && (ol == null || ol.Count == 0)) { //复制默认对象到新对象 ObjectList go = p.DefaultObject as ObjectList; ObjectList ngo = new ObjectList(); ngo.CopyFrom(go); ol = ngo; } SetPropertyValue(key, ol, true); ol.Watch("IsModified", ol_PropertyChanged); }
protected override void OnKeyDown(KeyEventArgs e) { //配置单元格索引 string inputIndex = CustomDataGrid.GetInputIndex(this); //是否跳行 bool isNextRow = true; //当前索引行 int nextIndex = this.CurrentColumn.DisplayIndex; if (e.Key.Equals(Key.Tab) || e.Key.Equals(Key.Enter)) { e.Handled = true; int currentRow = this.SelectedIndex; BaseObjectList ol = (BaseObjectList)this.ItemsSource; if (currentRow < ol.Size - 1) { e.Handled = true; if (ol[currentRow + 1] != null) { //默认跳转 if (inputIndex == null) { GeneralObject go = ol[currentRow + 1]; this.SelectedIndex = currentRow + 1; DataGridColumn fe = this.Columns[this.CurrentColumn.DisplayIndex]; this.CurrentColumn = fe; this.ScrollIntoView(go, fe); FrameworkElement c = (FrameworkElement)this.CurrentColumn.GetCellContent(go); c.GetType().GetMethod("Focus").Invoke(c, null); } //计算是否跳转下一行何列位置 else { string[] ins = inputIndex.Split(new char[] { '|' }); for (int i = 0; i < ins.Length; i++) { int w = int.Parse(ins[i]); if (w == this.CurrentColumn.DisplayIndex) { //当期索引== 配置的结束索引,下一行,第一个索引 if (i == ins.Length - 1) { isNextRow = true; nextIndex = int.Parse(ins[0]); break; } //当期那索引==配置的索引未结束,下一个索引 else { isNextRow = false; nextIndex = int.Parse(ins[i + 1]); break; } } } GeneralObject go = ol[currentRow]; if (isNextRow) { go = ol[currentRow + 1]; this.SelectedIndex = currentRow + 1; } DataGridColumn fe = this.Columns[nextIndex]; this.CurrentColumn = fe; this.ScrollIntoView(go, fe); FrameworkElement c = (FrameworkElement)this.CurrentColumn.GetCellContent(go); c.GetType().GetMethod("Focus").Invoke(c, null); } } } } else { base.OnKeyDown(e); } }
void userfiles_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e) { kbsellgasbusy.IsBusy = false; busy.IsBusy = false; if (e.Error != null) { MessageBox.Show("未找到用户的表具信息,请去表具建档!"); return; } //把数据转换成JSON JsonObject item = JsonValue.Parse(e.Result) as JsonObject; //把用户数据写到交费界面上 ui_username.Text = (string)item["f_username"]; ui_usertype.Text = (String)item["f_usertype"]; ui_districtname.Text = (String)item["f_districtname"]; ui_gasproperties.Text = (String)item["f_gasproperties"]; ui_stairpricetype.Text = (String)item["f_stairtype"]; zhye.Text = item["f_zhye"].ToString(); ui_address.Text = (String)item["f_address"]; //ui_gaspricetype.Text = (String)item["f_gaspricetype"]; ui_userid.Text = item["infoid"].ToString(); ui_dibaohu.IsChecked = item["f_dibaohu"].ToString().Equals("1"); ui_userstate.Text = (String)item["f_userstate"]; ui_paytype.Text = (String)item["f_payment"]; // ui_gasprice.Text = item["f_gasprice"].ToString(); //把欠费数据插入到欠费表中 BaseObjectList list = dataGrid1.ItemsSource as BaseObjectList; if (list != null) { list.Clear(); } // 当前正在处理的表号 String currentId = ""; // 总的上期指数 decimal lastnum = 0; // 总气量 decimal gasSum = 0; // 总气费 decimal feeSum = 0; // 总附加费用 decimal extrafeeSum = 0; // 总基本用水金额 decimal f_feeSum = 0; //总的违约金 decimal zhinajinAll = 0; //余额 decimal f_zhye = decimal.Parse(item["f_zhye"].ToString()); JsonArray bills = item["f_hands"] as JsonArray; foreach (JsonObject json in bills) { GeneralObject go = new GeneralObject(); go.EntityType = "t_handplan"; //默认选中 go.IsChecked = true; //上期指数 decimal lastinputgasnum = (decimal)json["lastinputgasnum"]; go.SetPropertyValue("lastinputgasnum", lastinputgasnum, false); string f_userid = (string)json["f_userid"]; go.SetPropertyValue("f_userid", f_userid, false); // 如果表号变了 if (!f_userid.Equals(currentId)) { currentId = f_userid; lastnum += lastinputgasnum; } //计算总金额 decimal fee = (decimal)json["f_fee"]; go.SetPropertyValue("f_fee", fee, false); feeSum += fee; //计算总附加费用 decimal fujiafee = (decimal)json["extrazjfee"]; go.SetPropertyValue("extrazjfee", fujiafee, false); extrafeeSum += fujiafee; //计算总基本用水金额 decimal shuifee = (decimal)json["oughtfee"]; go.SetPropertyValue("oughtfee", shuifee, false); f_feeSum += shuifee; // 计算总气量 decimal oughtamount = (decimal)json["oughtamount"]; gasSum += oughtamount; go.SetPropertyValue("oughtamount", oughtamount, false); //计算总违约金 decimal f_zhinajin = (decimal)json["f_zhinajin"]; zhinajinAll += f_zhinajin; go.SetPropertyValue("f_zhinajin", f_zhinajin, false); go.SetPropertyValue("lastinputdate", DateTime.Parse(json["lastinputdate"]), false); go.SetPropertyValue("lastrecord", (decimal)json["lastrecord"], false); go.SetPropertyValue("f_endjfdate", DateTime.Parse(json["f_endjfdate"]), false); go.SetPropertyValue("f_zhinajintianshu", (int)json["days"], false); go.SetPropertyValue("f_network", (string)json["f_network"], false); go.SetPropertyValue("f_operator", (string)json["f_operator"], false); go.SetPropertyValue("f_inputdate", DateTime.Parse(json["f_inputdate"]), false); go.SetPropertyValue("f_userid", (string)json["f_userid"], false); go.SetPropertyValue("jianshuiliang", (string)json["jianshuiliang"], false); go.SetPropertyValue("f_stair1amount", (decimal)json["f_stair1amount"], false); go.SetPropertyValue("f_stair1price", (decimal)json["f_stair1price"], false); go.SetPropertyValue("f_stair1fee", (decimal)json["f_stair1fee"], false); go.SetPropertyValue("f_stair2amount", (decimal)json["f_stair2amount"], false); go.SetPropertyValue("f_stair2price", (decimal)json["f_stair2price"], false); go.SetPropertyValue("f_stair2fee", (decimal)json["f_stair2fee"], false); go.SetPropertyValue("f_stair3amount", (decimal)json["f_stair3amount"], false); go.SetPropertyValue("f_stair3price", (decimal)json["f_stair3price"], false); go.SetPropertyValue("f_stair3fee", (decimal)json["f_stair3fee"], false); go.SetPropertyValue("f_stair4amount", (decimal)json["f_stair4amount"], false); go.SetPropertyValue("f_stair4price", (decimal)json["f_stair4price"], false); go.SetPropertyValue("f_stair4fee", (decimal)json["f_stair4fee"], false); list.Add(go); } // 计算出来的总气量等放到用户界面上 ui_pregas.Text = gasSum.ToString("0.#"); //总气量 ui_lastinputgasnum.Text = lastnum.ToString("0.#"); //总上期底数 ui_lastrecord.Text = (lastnum + gasSum).ToString("0.#"); //总本期底数 ui_zhinajin.Text = zhinajinAll.ToString("0.##"); //总违约金 ui_linshizhinajin.Text = zhinajinAll.ToString("0.##"); //违约金 decimal f_totalcost = feeSum - f_zhye + zhinajinAll > 0 ? feeSum - f_zhye + zhinajinAll : 0; ui_totalcost.Text = f_totalcost.ToString("0.##");//应缴金额 decimal f_benqizhye = (decimal)(f_zhye - feeSum - zhinajinAll > 0 ? f_zhye - feeSum - zhinajinAll : 0); ui_benqizhye.Text = f_benqizhye.ToString("0.##"); //本期结余 shoukuan.Text = f_totalcost.ToString("0.##"); ui_preamount.Text = f_feeSum.ToString("0.##"); //总基本水费金额 ui_extrafee.Text = extrafeeSum.ToString("0.##"); //总附加费用金额 }
/// <summary> /// Add the given <paramref name="baseObjects"/> to the selection list and tell the /// view controllers to redraw it. /// </summary> /// <param name="baseObjects"><see cref="BaseObjectList"/> holding the objects to /// select.</param> /// <param name="deselectCurrent"><see langword="bool"/> indicating if the existing /// selection is to be cancelled.</param> public void SelectObjects(BaseObjectList baseObjects, bool deselectCurrent) { var objectsToDeselect = new BaseObjectList(); var objectsToSelect = new BaseObjectList(); if (baseObjects == null) { throw new ArgumentNullException("baseObjects"); } if (deselectCurrent) { foreach (BaseObject selectedObject in this.selectedObjects) { selectedObject.IsSelected = false; objectsToDeselect.Add(selectedObject); } this.selectedObjects.Clear(); } if (this.selectedObjects.Count == 0) { foreach (BaseObject baseObject in baseObjects) { baseObject.IsSelected = true; this.selectedObjects.Add(baseObject); objectsToSelect.Add(baseObject); } } else { foreach (BaseObject baseObject in baseObjects) { if (this.selectedObjects.Contains(baseObject)) { this.selectedObjects.Remove(baseObject); baseObject.IsSelected = false; objectsToDeselect.Add(baseObject); } else { this.selectedObjects.Add(baseObject); baseObject.IsSelected = true; objectsToSelect.Add(baseObject); } } } foreach (BaseObject deselectee in objectsToDeselect) { foreach (ViewController viewCtrl in this.viewControllerList) { deselectee.Deselect(viewCtrl); } } foreach (BaseObject selectee in objectsToSelect) { foreach (ViewController viewCtrl in this.viewControllerList) { selectee.Select(viewCtrl); } } }