/// <summary> /// 数据加载 /// </summary> private void LoadData() { try { OsZbPurchaseProjectInfo info = new OsZbPurchaseProjectInfo(); //info.ProjectName = this.projectNo.Text; pageInfo.ParamsSearch = info; //需要这个把 组件的分页信息赋值当前页面全局变量 ObjectUtil.CopyPop(this.kenPage1.pageInfo, ref pageInfo); pageInfo = projectInfoBLL.SelectPage(pageInfo, null, $" PROJECT_NO like '%{this.projectNo.Text}%'", WhereType.SQL); listData = pageInfo.Records; //this.showStrip.Text = string.Format("共{0}页({1}条记录)", pageInfo.CurrentPage, pageInfo.TotalPage); this.listDataGriddView.DataSource = listData; //分页部分 var item = new MyWfControls.dto.PageInfo() { CurrentPage = pageInfo.CurrentPage > 0? pageInfo.CurrentPage:1, CurrentCount = pageInfo.CurrentCount, PageSize = pageInfo.PageSize, TotalPage = pageInfo.TotalPage }; this.kenPage1.pageInfo = item; this.kenPage1.SetShowText(); } catch (Exception ex) { MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void txButton1_Click(object sender, EventArgs e) { try { OsZbPurchaseProjectInfo projectInfo = FormHelp.GetEntityByControls <OsZbPurchaseProjectInfo>(this.groupBox2); osZbPurchaseProjectInfo = osZbPurchaseProjectInfo ?? new OsZbPurchaseProjectInfo(); ObjectUtil.CopyPop(projectInfo, ref osZbPurchaseProjectInfo, "Id"); VerifyMessage verifyMessage = VerifyUtil.Verify(osZbPurchaseProjectInfo); if (!string.IsNullOrWhiteSpace(verifyMessage.ErrorInfo)) { MessageBox.Show(verifyMessage.ErrorInfo, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } else if (!string.IsNullOrWhiteSpace(verifyMessage.PromptInfo)) { MessageBox.Show(verifyMessage.PromptInfo, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } R result = osZbPurchaseProjectInfoBLL.SaveOrUpdate(osZbPurchaseProjectInfo, null, true, null); if (!result.Successful) { MessageBox.Show(result.ResultHint, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } else { MessageBox.Show("操作成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); if (RefeshParentWindow != null) { RefeshParentWindow.Invoke(); } this.Hide(); this.Close(); } } catch (Exception ex) { log.AddLog(ex.Message, null); MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
public FormDemoAdd(OsZbPurchaseProjectInfo osZbPurchaseProjectInfo) { this.osZbPurchaseProjectInfo = osZbPurchaseProjectInfo; InitializeComponent(); }
public void ImportCheck(MessageInfo <OsZbPurchaseProjectInfo> messageInfo) { R result = null; // 表中已存在的数据ID集合 Dictionary <string, string> containDic = new Dictionary <string, string>(); OsZbPurchaseProjectInfo osZbPurchaseProjectInfo = new OsZbPurchaseProjectInfo(); List <OsZbPurchaseProjectInfo> dbLList = projectInfoBLL.SelectList(osZbPurchaseProjectInfo, null, null, WhereType.Columns); foreach (OsZbPurchaseProjectInfo itemInfo in dbLList) { if (!containDic.ContainsKey(itemInfo.ProjectNo + "," + itemInfo.MarkNo)) { containDic.Add(itemInfo.ProjectNo + "," + itemInfo.MarkNo, ""); } } List <OsZbPurchaseProjectInfo> record = messageInfo.Record; if (record == null) { return; } StringBuilder errorSbf = new StringBuilder(); HashSet <string> dbcompare = new HashSet <string>(); // 表中已存在的数据ID集合 Dictionary <string, string> excelDic = new Dictionary <string, string>(); //需要修改的数据 List <OsZbPurchaseProjectInfo> updateList = new List <OsZbPurchaseProjectInfo>(); foreach (OsZbPurchaseProjectInfo itemInfo in record) { //excel 重复性验证 if (!excelDic.ContainsKey(itemInfo.ProjectNo + "," + itemInfo.MarkNo)) { excelDic.Add(itemInfo.ProjectNo + "," + itemInfo.MarkNo, ""); } else { dbcompare.Add("第" + itemInfo.CurExcelIndex + "行,该项目信息在excel中重复\n"); } if (containDic.ContainsKey(itemInfo.ProjectNo + "," + itemInfo.MarkNo)) { updateList.Add(itemInfo); } } foreach (string str in dbcompare) { errorSbf.Append(str); messageInfo.ExistError = true; } errorSbf.Append(messageInfo.ErrorInfo); messageInfo.ErrorInfo = errorSbf.ToString(); if (messageInfo.ExistError) { MessageBox.Show(messageInfo.ErrorInfo, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } record.RemoveAll(it => updateList.Contains(it));//移除集合中匹配项 if (record.Count > 0) { //projectInfoBLL.SaveOrUpdate() result = projectInfoBLL.SaveList(record, null, true, null); //SQLiteLibrary.insertData(sqliteDbLocation, sqliteDbName, SQLiteSqlUtils.CreateInsertSql(record)); } //修改原数据 if (updateList.Count > 0) { result = projectInfoBLL.UpdateList(updateList, null, "ProjectNo,MarkNo,PackName", WhereType.Columns, null); } if (result.Successful) { importForm.SetImportInfo(true, messageInfo.Record.Count + updateList.Count, 0); MessageBox.Show("导入成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); LoadData(); } else { importForm.SetImportInfo(false, 0, messageInfo.Record.Count + updateList.Count); MessageBox.Show("导入失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void btnImportProject_Click(object sender, EventArgs e) { try { int firstIndex = 2; MessageInfo <OsZbPurchaseProjectInfo> messageInfo = ExcelUtil.ReadExcel <OsZbPurchaseProjectInfo>(firstIndex); if (messageInfo.ExistError) { MessageBox.Show(messageInfo.ErrorInfo, "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning); return; } if (messageInfo.Record == null) { return; } // 表中已存在的数据ID集合 Dictionary <string, string> containDic = new Dictionary <string, string>(); OsZbPurchaseProjectInfo osZbPurchaseProjectInfo = new OsZbPurchaseProjectInfo(); List <OsZbPurchaseProjectInfo> dbLList = projectInfoBLL.SelectList(osZbPurchaseProjectInfo, null, null, WhereType.Columns); foreach (OsZbPurchaseProjectInfo itemInfo in dbLList) { if (!containDic.ContainsKey(itemInfo.ProjectNo + "," + itemInfo.MarkNo)) { containDic.Add(itemInfo.ProjectNo + "," + itemInfo.MarkNo, ""); } } List <OsZbPurchaseProjectInfo> record = messageInfo.Record; if (record == null) { return; } StringBuilder errorSbf = new StringBuilder(); HashSet <string> dbcompare = new HashSet <string>(); // 表中已存在的数据ID集合 Dictionary <string, string> excelDic = new Dictionary <string, string>(); //需要修改的数据 List <OsZbPurchaseProjectInfo> updateList = new List <OsZbPurchaseProjectInfo>(); foreach (OsZbPurchaseProjectInfo itemInfo in record) { //excel 重复性验证 if (!excelDic.ContainsKey(itemInfo.ProjectNo + "," + itemInfo.MarkNo)) { excelDic.Add(itemInfo.ProjectNo + "," + itemInfo.MarkNo, ""); } else { dbcompare.Add("第" + itemInfo.CurExcelIndex + "行,该项目信息在excel中重复\n"); } if (containDic.ContainsKey(itemInfo.ProjectNo + "," + itemInfo.MarkNo)) { updateList.Add(itemInfo); } } foreach (string str in dbcompare) { errorSbf.Append(str); messageInfo.ExistError = true; } errorSbf.Append(messageInfo.ErrorInfo); messageInfo.ErrorInfo = errorSbf.ToString(); if (messageInfo.ExistError) { MessageBox.Show(messageInfo.ErrorInfo, "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning); return; } record.RemoveAll(it => updateList.Contains(it));//移除集合中匹配项 if (record.Count > 0) { //projectInfoBLL.SaveOrUpdate() projectInfoBLL.SaveList(record, null, true, null); //SQLiteLibrary.insertData(sqliteDbLocation, sqliteDbName, SQLiteSqlUtils.CreateInsertSql(record)); } //修改原数据 if (updateList.Count > 0) { projectInfoBLL.UpdateList(updateList, null, "projectNo,markNo,packName", WhereType.Columns, null); /*string updateSql = SQLiteSqlUtils.CreateSelectUpdateSql(updateList, new string[] { "businessFileWay", "skillFileWay", "markName" }, new string[] { "projectNo", "markNo", "packName" }); * SQLiteLibrary.insertData(sqliteDbLocation, sqliteDbName, updateSql);*/ } MessageBox.Show("导入成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); LoadData(); } catch (Exception ex) { MessageBox.Show("导入项目文件错误信息:" + ex.Message); } }