public HomeView() { InitializeComponent(); //bgWorker.DoWork += InputDateToDatabase; myself_col = TransExpV2 <DataGridTemplateColumn, DataGridTemplateColumn> .Trans(table_datagrid.Columns[1] as DataGridTemplateColumn); index_col = TransExpV2 <DataGridTemplateColumn, DataGridTemplateColumn> .Trans(table_datagrid.Columns[0] as DataGridTemplateColumn); input_state_col = TransExpV2 <DataGridTemplateColumn, DataGridTemplateColumn> .Trans(table_datagrid.Columns[2] as DataGridTemplateColumn); table_datagrid.Columns.RemoveAt(1); list.Clear(); table_datagrid.ItemsSource = list; //cmb_fielditem.IsEnabled = false; //DataGridTemplateColumn col = new DataGridTemplateColumn(); //col.Header = ""; //col.Width = 0; //Setter setter = new Setter(DataGridColumnHeader.HorizontalContentAlignmentProperty, System.Windows.HorizontalAlignment.Center); //Style style = new Style(); //style.Setters.Add(setter); //col.HeaderStyle = style; //table_datagrid.Columns.Insert(0,col); //Sheet数量 //workbook.NumberOfSheets; }
private void InsertColumn(int index, String header, String width) { DataGridTemplateColumn col = null; if (StringUtil.isBlank(width)) { return; } if ("*".Equals(width)) { col = TransExpV2 <DataGridTemplateColumn, DataGridTemplateColumn> .Trans(myself_col); } else { col = new DataGridTemplateColumn(); try { int width_value = Int32.Parse(width); col.Width = width_value; } catch { col.Width = 60; } } col.Header = header; Setter setter = new Setter(DataGridColumnHeader.HorizontalContentAlignmentProperty, System.Windows.HorizontalAlignment.Center); Style style = new Style(); style.Setters.Add(setter); col.HeaderStyle = style; table_datagrid.Columns.Insert(index, col); }
//根据效果的名称获取一个深度克隆的效果信息 public EffectInfo GetDepthCloneEffectByName(string effectCode) { EffectInfo effectInfo = TransExpV2 <EffectInfo, EffectInfo> .Trans(effectSysItem.effectInfoMap[effectCode]); //初始化效果 effectSysItem.EffectActionReady(effectInfo); if (effectInfo.preEffectList != null) { //实例化每一个前置后置效果 foreach (string preEffectCode in effectInfo.preEffectList) { EffectInfo preEffectInfo = TransExpV2 <EffectInfo, EffectInfo> .Trans(effectSysItem.effectInfoMap[preEffectCode]); effectSysItem.EffectActionReady(preEffectInfo); effectInfo.preEffectEntryList.Add(preEffectInfo); } } if (effectInfo.postEffectList != null) { //实例化每一个前置后置效果 foreach (string postEffectCode in effectInfo.postEffectList) { EffectInfo postEffectInfo = TransExpV2 <EffectInfo, EffectInfo> .Trans(effectSysItem.effectInfoMap[postEffectCode]); effectSysItem.EffectActionReady(postEffectInfo); effectInfo.postEffectEntryList.Add(postEffectInfo); } } return(effectInfo); }
private void ModifyShippingBill(object obj) { if (SelectedShippingBill == null) { return; } ShippingBillModifyView edit = new ShippingBillModifyView(); var totalAmountBeforeModify = SelectedShippingBill.TotalAmount; var cloneData = TransExpV2 <ShippingBillModel, ShippingBillModel> .Trans(SelectedShippingBill); (edit.DataContext as ShippingBillModifyViewModel).WithParam(cloneData, (type, shippingBill) => { edit.Close(); if (type == 1) { // 重新加载主表 _shippingService.UpdateShipingBill(shippingBill); // 重新分摊 _shippingService.UpdateShipingBillEntry(shippingBill); SelectedShippingBill.BillDate = shippingBill.BillDate; SelectedShippingBill.ChaiLvFei = shippingBill.ChaiLvFei; SelectedShippingBill.Demander = shippingBill.Demander; SelectedShippingBill.GuoLuFei = shippingBill.GuoLuFei; SelectedShippingBill.LogisticsBillNo = shippingBill.LogisticsBillNo; SelectedShippingBill.LogisticsCompanyName = shippingBill.LogisticsCompanyName; SelectedShippingBill.LogisticsType = shippingBill.LogisticsType; SelectedShippingBill.Note = shippingBill.Note; SelectedShippingBill.OtherCosts = shippingBill.OtherCosts; SelectedShippingBill.TotalAmount = shippingBill.TotalAmount; SelectedShippingBill.WeiXiuFei = shippingBill.WeiXiuFei; SelectedShippingBill.YouFei = shippingBill.YouFei; SelectedShippingBill.YunShuFei = shippingBill.YunShuFei; SelectedShippingBill.GuoNeiDuanFeiYong = shippingBill.GuoNeiDuanFeiYong; SelectedShippingBill.GuoJiDuanFeiYong = shippingBill.GuoJiDuanFeiYong; SelectedShippingBill.YunShuDuanFeiYong = shippingBill.YunShuDuanFeiYong; SelectedShippingBill.TotalAmount = shippingBill.TotalAmount; SelectedShippingBill.TotalQuantity = shippingBill.TotalQuantity; SelectedShippingBill.SystemApportionedAmount = shippingBill.SystemApportionedAmount; SelectedShippingBill.SystemApportionedQuantity = shippingBill.SystemApportionedQuantity; SelectedShippingBill.Driver = shippingBill.Driver; SelectedShippingBill.Supercargo = shippingBill.Supercargo; // 重新加载明细 _shippingService.UpdateShipingBillEntry(shippingBill); GetAllShippingBillEntriesById(shippingBill.Id); _commonService.WriteActionLog(new ActionOperationLogModel { ActionName = "ModifyShippingBill", ActionDesc = "修改托运单", UserId = user.ID, MainMenuId = 7, PKId = shippingBill.Id, HostName = _hostName }); } }); edit.ShowDialog(); }
public static IList <T> DeepCloneList <T>(this IList <T> tList) where T : class { IList <T> listNew = new List <T>(); foreach (var item in tList) { listNew.Add(TransExpV2 <T, T> .Trans(item)); } return(listNew); }
private void UpdateShippingBillEntry(object obj) { if (SelectedShippingBill == null) { return; } if (SelectedShippingBillEntry != null) { ShippingBillEntryModifyView edit = new ShippingBillEntryModifyView(); var quantityBeforeModify = SelectedShippingBillEntry.Quantity; var amountBeforeModify = SelectedShippingBillEntry.Amount; var cloneData = TransExpV2 <ShippingBillEntryModel, ShippingBillEntryModel> .Trans(SelectedShippingBillEntry); (edit.DataContext as ShippingBillEntryModifyViewModel).WithParam(cloneData, (type, entry) => { edit.Close(); if (type == 1) { //系统单据只能修改类型Id和备注 if (entry.IsSystem) { _shippingService.UpdateShippingBillEntry2(entry); SelectedShippingBillEntry.GoodsType = entry.GoodsType; SelectedShippingBillEntry.Note = entry.Note; } else { // 前端显示 float qtyDiff = entry.Quantity - quantityBeforeModify; float amountDiff = entry.Amount - amountBeforeModify; SelectedShippingBill.TotalQuantity += qtyDiff; SelectedShippingBill.TotalAmount += amountDiff; if (entry.GoodsType == 1 || entry.GoodsType == 3) { SelectedShippingBill.SystemApportionedQuantity += qtyDiff; } else { SelectedShippingBill.UnApportionedAmount += amountDiff; } //分摊明细金额,更新数据 _shippingService.UpdateShipingBillEntry(entry); _shippingService.UpdateShipingBillEntry(SelectedShippingBill); // 更新主表 _shippingService.UpdateShipingBill2(SelectedShippingBill); // 重新加载明细 GetAllShippingBillEntriesById(entry.MainId); } } }); edit.ShowDialog(); } }
private void ModifyConsignmentBillEntry(object obj) { if (SelectedConsignmentBill == null) { return; } if (SelectedConsignmentBillEntry == null) { return; } if (!SelectedConsignmentBillEntry.IsSystem) { MessageBox.Show("手动新增的数据无法修改,请先【删除】然后【新增】"); return; } string ownerName = _consignmentService.GetConsignmentBillLockOwner(SelectedConsignmentBill.BillNo, SelectedConsignmentBill.UserId); if (string.IsNullOrEmpty(ownerName)) { if (SelectedConsignmentBillEntry.IsChecked) { float currencyQuatityBeforeModify = selectedConsignmentBillEntry.ECurrencyQuantity; var cloneData = TransExpV2 <ConsignmentBillEntryModel, ConsignmentBillEntryModel> .Trans(SelectedConsignmentBillEntry); ConsignmentBillEntryModifyView edit = new ConsignmentBillEntryModifyView(); (edit.DataContext as ConsignmentBillEntryModifyViewModel).WithParam(cloneData, (type, entry) => { edit.Close(); if (type == 1) { if (currencyQuatityBeforeModify != entry.ECurrencyQuantity) { SelectedConsignmentBillEntry.ECurrencyQuantity = entry.ECurrencyQuantity; _consignmentService.UpdateConsignmentBillEntry(entry); // 修改主表界面和后台 SelectedConsignmentBill.CurrencyQuantity += entry.ECurrencyQuantity - currencyQuatityBeforeModify; _consignmentService.UpdateConsignmentBill(SelectedConsignmentBill); } } }); edit.ShowDialog(); } } else { MessageBox.Show($"该记录正在被【{ownerName}】使用,请选择其他数据"); } }
private void CopyConsignmentBillEntry(object obj) { if (SelectedConsignmentBill == null) { return; } string ownerName = _consignmentService.GetConsignmentBillLockOwner(SelectedConsignmentBill.BillNo, SelectedConsignmentBill.UserId); if (string.IsNullOrEmpty(ownerName)) { if (SelectedConsignmentBillEntry == null) { return; } ConsignmentBillEntryCopyView add = new ConsignmentBillEntryCopyView(); var cloneData = TransExpV2 <ConsignmentBillEntryModel, ConsignmentBillEntryModel> .Trans(SelectedConsignmentBillEntry); cloneData.IsChecked = true; cloneData.EntryId = ConsignmentBillEntries.Max(m => m.EntryId) + 1; cloneData.IsSystem = false; cloneData.ECurrencyQuantity = 0; (add.DataContext as ConsignmentBillEntryCopyViewModel).WithParam(cloneData, (type, entry) => { add.Close(); if (type == 1) { // 修改字表界面和后台 int id = _consignmentService.AddConsignmentBillEntry(entry, user.ID); entry.ETotalQuantity = entry.ECurrencyQuantity; entry.EUndoQuantity = entry.ECurrencyQuantity; entry.Id = id; ConsignmentBillEntries.Add(entry); // 修改主表界面和后台 SelectedConsignmentBill.CurrencyQuantity += entry.ECurrencyQuantity; SelectedConsignmentBill.UndoQuantity += entry.ECurrencyQuantity; SelectedConsignmentBill.TotalQuantity += entry.ECurrencyQuantity; _consignmentService.UpdateConsignmentBill(SelectedConsignmentBill); } }); add.ShowDialog(); } else { MessageBox.Show($"该记录正在被【{ownerName}】使用,请选择其他数据"); } }
public void EffectActionReady(EffectInfo effect) { if (effect.operationalTarget != null) { effect.operationalTarget.selectTargetList = new List <TargetSet>(); foreach (string targetSetCode in effect.operationalTarget.selectTarget) { TargetSet targetSetDto = TransExpV2 <TargetSet, TargetSet> .Trans(targetSetMap[targetSetCode]); targetSetDto.CleanEffectTargetSetList(); effect.operationalTarget.selectTargetList.Add(targetSetDto); } } }
public List <Aduit> GetAuditEntries() { SPSite site = new SPSite("http://sp2016"); SPAudit audit = site.Audit; SPAuditEntryCollection collection = audit.GetEntries(); List <Aduit> Data = new List <Aduit>(); foreach (SPAuditEntry i in collection) { Data.Add(TransExpV2 <SPAuditEntry, Aduit> .Trans(i)); } return(Data); }
private void AddColumn(String header, String width, Int32 i) { DataGridTemplateColumn col = null; if (StringUtil.isBlank(width)) { return; } if ("*".Equals(width)) { col = TransExpV2 <DataGridTemplateColumn, DataGridTemplateColumn> .Trans(myself_col); } else { col = new DataGridTemplateColumn(); try { int width_value = Int32.Parse(width); col.Width = width_value; } catch { col.Width = 60; } } col.Header = header; StringBuilder CellTemp = new StringBuilder(); CellTemp.Append("<DataTemplate "); CellTemp.Append("xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' "); CellTemp.Append("xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml' "); CellTemp.Append("xmlns:local = 'clr-namespace:ExcelToDatabase.Views.Home'>"); CellTemp.Append("<TextBlock "); CellTemp.Append("HorizontalAlignment='Left' "); CellTemp.Append("Text='{ Binding _" + i + "}'"); CellTemp.Append("></TextBlock>"); CellTemp.Append("</DataTemplate>"); col.CellTemplate = (DataTemplate)XamlReader.Load(new MemoryStream(Encoding.ASCII.GetBytes(CellTemp.ToString()))); Setter setter = new Setter(DataGridColumnHeader.HorizontalContentAlignmentProperty, System.Windows.HorizontalAlignment.Center); Style style = new Style(); style.Setters.Add(setter); col.HeaderStyle = style; col.DisplayIndex = table_datagrid.Columns.Count(); table_datagrid.Columns.Add(col); }
/// <summary> /// 修改学生信息 /// <para>作 者:Huang GaoLiang </para> /// <para>创建时间: 2019-03-14 </para> /// </summary> /// <param name="studentId">学生编号</param> /// <param name="request">修改输入参数</param> /// <returns>返回修改结果受影响的行数</returns> /// <exception> /// 异常ID:1,系统不存在该学生 /// </exception> public static void Modify(long studentId, StudentRegisterRequest request) { TblCstStudentContactRepository contactRepository = new TblCstStudentContactRepository(); TblCstStudentRepository studentRepository = new TblCstStudentRepository(); // 1、根据编号查询学生信息 TblCstStudent rawStudent = studentRepository.GetCstStudentId(studentId); //原学生信息 if (rawStudent == null) { throw new BussinessException((byte)ModelType.Customer, 1); } List <TblCstStudentContact> rawContacts = contactRepository.GetByStudentId(studentId); //原学生联系人 TblCstStudent newStudent = TransExpV2 <TblCstStudent, TblCstStudent> .Trans(rawStudent); //新学生 // 2、验证 Verification(studentId, request.StudentName, request.LinkMobile); // 3、学生信息和学生联系人信息 List <TblCstStudentContact> newContacts = GetStudentContact(newStudent.StudentId, JsonConvert.SerializeObject(request.ContactPerson)); SetStudentInfo(request, newStudent); //4、数据存储操作 studentRepository.Update(newStudent); //更新学生信息 contactRepository.DeleteByStudentId(new List <long> { newStudent.StudentId }); //删除原来的学生联系人 contactRepository.Add(newContacts); //添加学生联系人 // 5、推送学生至档案库 StudentRequest s = GetStudentToAC(rawStudent); new ACService().StudentInfoToArtLibrary(s); // 6、记录操作日志 AddOperationLog(rawStudent, newStudent, request); // 7、将手机号信息推送至家校互联账户 StudentPublish(rawStudent, newStudent, rawContacts, newContacts); }
private async void ReadExcelData(String @path) { if (StringUtil.isBlank(@path)) { AyMessageBox.ShowError("文件路径不正确!"); btn_readFileData.IsEnabled = true; btn_selectFile.IsEnabled = true; return; } try { fileStream = new FileStream(@path, FileMode.Open, FileAccess.Read); } catch (Exception ex) { AyMessageBox.ShowError(ex.ToString()); btn_readFileData.IsEnabled = true; btn_selectFile.IsEnabled = true; return; } if (fileStream.CanRead) { String houzhui = fileStream.Name.Substring(fileStream.Name.LastIndexOf(".") + 1, fileStream.Name.Length - fileStream.Name.LastIndexOf(".") - 1); if ("xls".Equals(houzhui)) { workbook = new HSSFWorkbook(fileStream); } else if ("xlsx".Equals(houzhui)) { workbook = new XSSFWorkbook(fileStream); } } else { AyMessageBox.ShowError("文件读取失败!"); workbook = null; return; } sheet = workbook.GetSheetAt(0); if (sheet == null) { return; } table_datagrid.Columns.Clear(); DataGridTemplateColumn index_col_val = TransExpV2 <DataGridTemplateColumn, DataGridTemplateColumn> .Trans(index_col); DataGridTemplateColumn input_state_col_val = TransExpV2 <DataGridTemplateColumn, DataGridTemplateColumn> .Trans(input_state_col); index_col_val.DisplayIndex = 0; table_datagrid.Columns.Add(index_col_val); //获取总行数 rowCount = sheet.PhysicalNumberOfRows; int i, j; if (rowCount > 0) { //根据第一行,获取总列数 titleRow = sheet.GetRow(0); colCount = titleRow.PhysicalNumberOfCells; //初始化字段名称和表格标题名称的数组大小 fieldArray = new String[colCount]; headerArray = new String[colCount]; for (i = 0; i < colCount; i++) { String titleString = titleRow.GetCell(i).StringCellValue; if (StringUtil.isNotBlank(titleString)) { String[] titleStringSplitArr = titleString.Replace(" ", "").Split(new Char[] { '(', ')', ',', ':', '[', ']', '(', ')', ',', ':', '【', '】' }, StringSplitOptions.RemoveEmptyEntries); if (titleStringSplitArr != null) { if (titleStringSplitArr.Count() == 3) { headerArray[i] = titleStringSplitArr[1]; fieldArray[i] = titleStringSplitArr[2]; if ("*".Equals(titleStringSplitArr[0])) { AddColumn(headerArray[i], "*", i + 1); } else { AddColumn(headerArray[i], titleStringSplitArr[0], i + 1); } } else if (titleStringSplitArr.Count() == 2) { headerArray[i] = titleStringSplitArr[0]; fieldArray[i] = titleStringSplitArr[1]; AddColumn(headerArray[i], "200", i + 1); } else if (titleStringSplitArr.Count() == 1) { fieldArray[i] = titleStringSplitArr[0]; AddColumn(fieldArray[i], "200", i + 1); } else { AyMessageBox.ShowError("标题和字段信息初始化错误!"); } } } } } //填充数据 AyTime.setTimeout(1, () => { try { btn_inputDataToDatabase.IsEnabled = false; cb_empty.IsEnabled = false; cb_re.IsEnabled = false; cmb_fielditem.IsEnabled = false; cmb_fielditem.SelectedIndex = -1; cmb_fielditem.Text = ""; cmb_fielditem.Items.Clear(); list.Clear(); for (i = 1; i < rowCount; i++) { RowViewItem rowItem = new RowViewItem(); rowItem._number = i.ToString(); IRow rowData = sheet.GetRow(i); for (j = 0; j < colCount; j++) { String value = rowData.GetCell(j).ToString(); SetValue(ref rowItem, j + 1, value); } rowItem._state = "尚未导入"; list.Add(rowItem); } } catch (Exception ex) { btn_inputDataToDatabase.IsEnabled = false; cb_empty.IsEnabled = false; cb_re.IsEnabled = false; cmb_fielditem.IsEnabled = false; cmb_fielditem.SelectedIndex = -1; cmb_fielditem.Text = ""; cmb_fielditem.Items.Clear(); AyMessageBox.ShowError("数据填充时发生错误:" + ex.ToString()); } finally { if (!readTableNames) { if (list.Count > 0) { if (cmb_tables.IsEnabled) { btn_inputDataToDatabase.IsEnabled = true; } } } btn_selectFile.IsEnabled = true; btn_readFileData.IsEnabled = true; } cb_empty.IsEnabled = true; cb_re.IsEnabled = true; cmb_fielditem.IsEnabled = true; int f_count = fieldArray.Count(); int h_count = headerArray.Count(); cmb_fielditem.Items.Add(new ComboBoxItem()); for (i = 0; i < f_count && i < h_count; i++) { ComboBoxItem cbi = new ComboBoxItem(); cbi.Content = headerArray[i]; cbi.Uid = fieldArray[i]; cmb_fielditem.Items.Add(cbi); } }); input_state_col_val.DisplayIndex = table_datagrid.Columns.Count(); table_datagrid.Columns.Add(input_state_col_val); reFlag = false; emptyFlag = false; cb_re.IsChecked = false; cb_empty.IsChecked = false; cmb_fielditem.SelectedIndex = -1; cmb_fielditem.Text = ""; //添加行数据 //table_datagrid. GC.Collect(); }
//根据目标对象的名称获取一个深度克隆的目标对象信息 public TargetSet GetDepthCloneTargetSetByName(string targetSetCode) { return(TransExpV2 <TargetSet, TargetSet> .Trans(effectSysItem.targetSetMap[targetSetCode])); }
/// <summary> /// Copy Propertys and Fileds /// 拷贝属性和公共字段 /// </summary> /// <typeparam name="T"> </typeparam> /// <param name="source"></param> /// <param name="target"></param> public static T1 CopyToAll <T, T1>(this T source) where T : class { return(TransExpV2 <T, T1> .Trans(source)); }
public static T DeepCloneObject <T>(this T t) where T : class { return(TransExpV2 <T, T> .Trans(t)); }