private void ProblemTraceForm_Load(object sender, EventArgs e) { string defaultProjectCode = UserInfo.GetInstence().DefaultProjectCode; using (BugTraceEntities entiy = new BugTraceEntities(EntityContextHelper.GetEntityConnString())) { //var project = entiy.PPM_ProjectInfo.Where(p => p.ProjectCode == defaultProjectCode).FirstOrDefault(); //if (project != null) //{ // if (!string.IsNullOrWhiteSpace(project.UsedCustom)) // { // string projectUse = project.UsedCustom.Replace(",", ",");//实施客户 // foreach (var item in projectUse.Split(',')) // { // this.cbxProjectUse.Items.Add(item); // } // } //} var query = (from c in entiy.PPM_ProjectTeam join d in entiy.SYS_User on c.TeamMember equals d.UserCode where c.ProjectCode == defaultProjectCode && c.Status == 1 select new { UserCode = c.TeamMember, UserName = d.UserName }).ToList(); List <KeyValuePair <string, string> > kvp = new List <KeyValuePair <string, string> >(); List <KeyValuePair <string, string> > kvp2 = new List <KeyValuePair <string, string> >(); foreach (var item in query) { kvp.Add(new KeyValuePair <string, string>(item.UserCode, item.UserName)); kvp2.Add(new KeyValuePair <string, string>(item.UserCode, item.UserName)); } this.cbxFindPerson.DataSource = kvp; this.cbxFindPerson.DisplayMember = "value"; this.cbxFindPerson.ValueMember = "key"; this.cbxDealPerson.DisplayMember = "value"; this.cbxDealPerson.ValueMember = "key"; this.cbxDealPerson.DataSource = kvp2; } }
private void btnExportExcel_Click(object sender, EventArgs e) { if (folderBrowserDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK) { string strFolder = folderBrowserDialog1.SelectedPath; using (BugTraceEntities context = new BugTraceEntities(EntityContextHelper.GetEntityConnString())) { string selProject = cbxCommonProject.Text; if (string.IsNullOrWhiteSpace(selProject)) { return; } string defaultProjectCode = cbxCommonProject.SelectedValue.ToString(); //string defaultProjectCode = UserInfo.GetInstence().DefaultProjectCode; SqlParameter[] sqlparams = new SqlParameter[1]; sqlparams[0] = new SqlParameter("@DefaultProjectCode", SqlDbType.VarChar, 50); sqlparams[0].Value = string.IsNullOrWhiteSpace(defaultProjectCode) ? "" : defaultProjectCode; string sql = @" SELECT a.Unit,a.Activity,a.Task,a.BudgetWorkload,CONVERT(varchar(100), a.BudgetBeginDate, 23), CONVERT(varchar(100), a.BudgetEndDate, 23),a.RealWorkload, CONVERT(varchar(100), a.RealBeginDate, 23),CONVERT(varchar(100), a.RealEndDate, 23), CONVERT(varchar(100), a.TestPassDate, 23),a.DispatchStatus,a.Status,a.DealPerson,a.TestPerson ,a.DiffAnalyze FROM dbo.V_ProjectPlan a WHERE a.ProjectCode=@DefaultProjectCode ORDER BY a.BusinessCode"; DataTable dtbl = context.Database.SqlQueryForDataTatable(sql, sqlparams); using (OpenXmlHelper ox = new OpenXmlHelper()) { ox.RowIndex = new int[] { 4 }; var fileTemplatePath = System.Environment.CurrentDirectory + "\\Template\\ProjectPlanTemplate.xlsx"; var filePath = strFolder + "\\ProjectPlan.xlsx"; if (File.Exists(filePath)) { File.Delete(filePath); } DataSet ds = new DataSet(); ds.Tables.Add(dtbl); ox.ExcelExport(ds, filePath, fileTemplatePath); } MessageBox.Show("导出excel成功!"); } } }
private void btnDelete_Click(object sender, EventArgs e) { if (MessageBox.Show("您确定要删除吗?", "提示:", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk) == DialogResult.OK) { var key = dataGridViewExt1.CurrentRow.Cells["ID"].Value; if (key == null) { MessageBox.Show("请先选择一行数据"); } else { this.SelectedID = Int32.Parse(key.ToString()); using (BugTraceEntities context = new BugTraceEntities(EntityContextHelper.GetEntityConnString())) { //var problemTraceList = context.PPM_ProblemTrace.Where(p => p.ProjectPlanID == this.SelectedID); //if (problemTraceList != null && problemTraceList.Count() > 0) //{ // MessageBox.Show("任务已经下发,不能删除"); // return; //} var projectPlan = context.PPM_ProjectPlan.Where(p => p.ID == this.SelectedID).FirstOrDefault(); if (projectPlan != null) { projectPlan.DeleteFlag = 1;//删除标识 projectPlan.UpdatePerson = UserInfo.GetInstence().UserCode; projectPlan.UpdateDate = DateTime.Now; var problemTraceList = context.PPM_ProblemTrace.Where(p => p.ProjectPlanID == this.SelectedID); foreach (var problemTrace in problemTraceList) { problemTrace.DeleteFlag = 1;//删除标识 problemTrace.UpdatePerson = UserInfo.GetInstence().UserCode; problemTrace.UpdateDate = DateTime.Now; } context.SaveChanges(); MessageBox.Show("删除成功!"); _loacateIndex = false; this.DataBind(); } } } } }
private void btnSaveBusinessCode_Click(object sender, EventArgs e) { using (BugTraceEntities context = new BugTraceEntities(EntityContextHelper.GetEntityConnString())) { foreach (DataGridViewRow row in this.dataGridViewExt1.Rows) { if (row.Tag == null || row.Tag.ToString() != "Changed") { continue; } int id = Convert.ToInt32(row.Cells["ID"].Value); string bCode = row.Cells["BusinessCode"].Value.ToString(); var projectPlan = context.PPM_ProjectPlan.Where(p => p.ID == id).FirstOrDefault(); projectPlan.BusinessCode = bCode; } context.SaveChanges(); } MessageBox.Show("保存业务编码成功!"); _loacateIndex = true; this.DataBind(); }
/// <summary> /// 数据绑定 /// </summary> private void PageDataBind() { using (BugTraceEntities zEntity = new BugTraceEntities(EntityContextHelper.GetEntityConnString())) { IQueryable <SCM_SaleOrder> query = from c in zEntity.SCM_SaleOrder select c; if (!string.IsNullOrWhiteSpace(this.txtCustomName.Text)) { query = query.Where(p => p.CustomName.Contains(this.txtCustomName.Text)); } if (!string.IsNullOrWhiteSpace(this.cbxPayStatus.Text)) { query = query.Where(p => p.PayStatus == this.cbxPayStatus.Text); } int pageSize = Int32.Parse(cbxPageSize.Text); int pageNum = Int32.Parse(txtPageNum.Text); var saleOrderList = query.OrderBy(p => p.ID).Skip(pageSize * (pageNum - 1)).Take(pageSize).ToList(); this.dgvSaleOrder.DataSource = saleOrderList; var totalRecordCount = query.Count(); this.lblPageInfo.Text = "总共" + totalRecordCount + "条记录,每页"; this.lblPageTotal.Text = Math.Ceiling(Convert.ToDecimal(totalRecordCount) / pageSize) + "页"; } }
private void btnTestPublish_Click(object sender, EventArgs e) { if (MessageBox.Show("您确定已经测试发版了吗?", "提示:", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk) == DialogResult.Yes) { using (BugTraceEntities context = new BugTraceEntities(EntityContextHelper.GetEntityConnString())) { var problem = context.PPM_ProblemTrace.Where(p => p.Status == "已提交未审核" || p.Status == "完成" || p.Status == "发版关闭"); foreach (var item in problem) { item.TestFlag = 1; } string defaultProjectCode = UserInfo.GetInstence().DefaultProjectCode; var project = context.PPM_ProjectInfo.Where(p => p.ProjectCode == defaultProjectCode).FirstOrDefault(); if (project != null) { project.TestPublishDate = DateTime.Now; } context.SaveChanges(); this.lblTestPublish.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); MessageBox.Show("保存成功!"); this.SearchClick(); } } }
private void ProjectPlanForm_Activated(object sender, EventArgs e) { ProjectPlanList listForm = FormSingle.GetForm(typeof(ProjectPlanList)) as ProjectPlanList; this._projectPlanID = listForm.SelectedID; this._isCopy = listForm.IsCopy; if (_projectPlanID == -1) { this.cbxUnit.Text = ""; this.txtActivity.Text = ""; this.txtTask.Text = ""; this.txtBudgetWorkload.Text = ""; this.dtBudgetBeginDate.Text = ""; this.dtBudgetEndDate.Text = ""; this.cbxResource.Text = ""; this.txtBusinessCode.Text = ""; this.txtDiffAnalyze.Text = ""; } else { using (BugTraceEntities context = new BugTraceEntities(EntityContextHelper.GetEntityConnString())) { var projectPlanList = context.Set <PPM_ProjectPlan>().Where(p => p.ID == _projectPlanID); if (projectPlanList != null && projectPlanList.Count() > 0) { var projectPlan = projectPlanList.FirstOrDefault(); this.cbxUnit.Text = projectPlan.Unit; this.txtActivity.Text = projectPlan.Activity; this.txtTask.Text = projectPlan.Task; this.txtBudgetWorkload.Text = projectPlan.BudgetWorkload.ToString(); if (projectPlan.BudgetBeginDate != null) { this.dtBudgetBeginDate.ValueX = projectPlan.BudgetBeginDate; } else { this.dtBudgetBeginDate.ValueX = null; } if (projectPlan.BudgetEndDate != null) { this.dtBudgetEndDate.ValueX = projectPlan.BudgetEndDate; } else { this.dtBudgetEndDate.ValueX = null; } this.cbxResource.Text = projectPlan.ResourceName; this.txtBusinessCode.Text = projectPlan.BusinessCode; this.cbxPlanType.Text = projectPlan.PlanType; this.txtDiffAnalyze.Text = projectPlan.DiffAnalyze; if (projectPlan.HideFlag == 0) { this.rdoDisplay.Checked = true; this.rdoHide.Checked = false; } else { this.rdoDisplay.Checked = false; this.rdoHide.Checked = true; } } } } }
private void btnSave_Click(object sender, EventArgs e) { #region 验证 if (!CheckNumber(this.txtBudgetWorkload.Text)) { MessageBox.Show("预算工作量必须是数值类型", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); this.txtBudgetWorkload.Focus(); return; } if (string.IsNullOrWhiteSpace(cbxPlanType.Text)) { MessageBox.Show("任务类型不能为空", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); this.cbxPlanType.Focus(); return; } #endregion using (BugTraceEntities zEntity = new BugTraceEntities(EntityContextHelper.GetEntityConnString())) { PPM_ProjectPlan projectPlan; if (this._projectPlanID == -1 || this._isCopy) { projectPlan = new PPM_ProjectPlan(); } else { projectPlan = zEntity.PPM_ProjectPlan.Where(p => p.ID == this._projectPlanID).FirstOrDefault(); } projectPlan.Unit = this.cbxUnit.Text; projectPlan.Activity = this.txtActivity.Text; projectPlan.Task = this.txtTask.Text; projectPlan.BudgetWorkload = Convert.ToDecimal(this.txtBudgetWorkload.Text); if (!string.IsNullOrWhiteSpace(this.dtBudgetBeginDate.Text)) { projectPlan.BudgetBeginDate = Convert.ToDateTime(this.dtBudgetBeginDate.Text); } else { projectPlan.BudgetBeginDate = null; } if (!string.IsNullOrWhiteSpace(this.dtBudgetEndDate.Text)) { projectPlan.BudgetEndDate = Convert.ToDateTime(this.dtBudgetEndDate.Text); } else { projectPlan.BudgetEndDate = null; } if (!string.IsNullOrWhiteSpace(this.cbxResource.Text)) { projectPlan.ResourceCode = this.cbxResource.SelectedValue.ToString(); projectPlan.ResourceName = this.cbxResource.Text; } if (this._projectPlanID == -1 || this._isCopy) { projectPlan.CreateDate = DateTime.Now; projectPlan.CreatePerson = UserInfo.GetInstence().UserCode; projectPlan.DeleteFlag = 0; projectPlan.Status = "未开始"; zEntity.PPM_ProjectPlan.Add(projectPlan); } else { var problemTrace = zEntity.PPM_ProblemTrace.Where(p => p.ProjectPlanID == projectPlan.ID).FirstOrDefault(); if (problemTrace != null && problemTrace.Status == "未开始") { problemTrace.Module = projectPlan.Activity; problemTrace.Problem = projectPlan.Task; problemTrace.FindPerson = UserInfo.GetInstence().UserName; problemTrace.FindPersonCode = UserInfo.GetInstence().UserCode; //problemTrace.FindDate = DateTime.Now; problemTrace.DealPerson = projectPlan.ResourceName; problemTrace.DealPersonCode = projectPlan.ResourceCode; problemTrace.UpdateDate = DateTime.Now; problemTrace.UpdatePerson = UserInfo.GetInstence().UserCode; problemTrace.ProblemType = projectPlan.PlanType; } } projectPlan.UpdateDate = DateTime.Now; projectPlan.UpdatePerson = UserInfo.GetInstence().UserCode; projectPlan.ProjectCode = UserInfo.GetInstence().DefaultProjectCode; projectPlan.BusinessCode = this.txtBusinessCode.Text; projectPlan.PlanType = cbxPlanType.Text; if (this.rdoDisplay.Checked && !this.rdoHide.Checked) { projectPlan.HideFlag = 0; } else { projectPlan.HideFlag = 1; } projectPlan.DiffAnalyze = this.txtDiffAnalyze.Text; zEntity.SaveChanges(); } MessageBox.Show("保存成功!"); this.Close(); var projectPlanList = FormSingle.GetForm(typeof(ProjectPlanList)) as ProjectPlanList; projectPlanList.SearchClick(); }
private void CreateProjectForm_Load(object sender, EventArgs e) { if (this.Tag != null && this.Tag.ToString() != null && this.Tag.ToString() == "Add") { this.Text = "新增项目"; _formFlag = "Add"; } else { this.Text = "编辑项目"; _formFlag = "Edit"; } using (BugTraceEntities context = new BugTraceEntities(EntityContextHelper.GetEntityConnString())) { var query = (from c in context.SYS_User select new { UserCode = c.UserCode, UserName = c.UserName }).ToList(); List <KeyValuePair <string, string> > kvp = new List <KeyValuePair <string, string> >(); List <KeyValuePair <string, string> > kvpTeam = new List <KeyValuePair <string, string> >(); List <KeyValuePair <string, string> > kvpLeader = new List <KeyValuePair <string, string> >(); foreach (var item in query) { kvp.Add(new KeyValuePair <string, string>(item.UserCode, item.UserName)); kvpTeam.Add(new KeyValuePair <string, string>(item.UserCode, item.UserName)); kvpLeader.Add(new KeyValuePair <string, string>(item.UserCode, item.UserName)); } this.cbxProjectManager.DataSource = kvp; this.cbxProjectManager.DisplayMember = "value"; this.cbxProjectManager.ValueMember = "key"; cbxProjectManager.Text = ""; this.cbxProjectTeam.DataSource = kvpTeam; this.cbxProjectTeam.DisplayMember = "value"; this.cbxProjectTeam.ValueMember = "key"; cbxProjectTeam.Text = ""; this.cbxProjectLeader.DataSource = kvpLeader; this.cbxProjectLeader.DisplayMember = "value"; this.cbxProjectLeader.ValueMember = "key"; cbxProjectLeader.Text = ""; if (this._formFlag == "Edit") { this.lblSelectProject.Visible = true; this.cbxSelectProject.Visible = true; var projectList = from c in context.PPM_ProjectInfo group c by new { ProjectCode = c.ProjectCode, ProjectName = c.ProjectName } into g select new { g.Key.ProjectCode, g.Key.ProjectName, BeginDate = g.Max(p => p.BeginDate) }; List <KeyValuePair <string, string> > kvpProject = new List <KeyValuePair <string, string> >(); foreach (var item in projectList.OrderByDescending(p => p.BeginDate)) { kvpProject.Add(new KeyValuePair <string, string>(item.ProjectCode, item.ProjectName)); } this.cbxSelectProject.DisplayMember = "value"; this.cbxSelectProject.ValueMember = "key"; this.cbxSelectProject.DataSource = kvpProject; this.txtProjectCode.Enabled = false; //this.cbxSelectProject.SelectedText = ""; //cbxSelectProject.Text = ""; } } }
private void ProblemTraceForm_Activated(object sender, EventArgs e) { int rowID = FormArgument.ProblemTraceID; if (rowID != -1) { using (BugTraceEntities zEntity = new BugTraceEntities(EntityContextHelper.GetEntityConnString())) { //var problemList = zEntity.PPM_ProblemTrace.Where(p => p.ID == rowID); var problemList = (from c in zEntity.PPM_ProblemTrace join d in zEntity.SYS_User on c.AttachmentCreateBy equals d.UserCode into g where c.ID == rowID from item in g.DefaultIfEmpty() select new { c.ID, c.Module, c.ProjectUse, c.FindPersonCode, c.Problem, c.DealPersonCode, c.BeginDealDate, c.EndDealDate, c.Solution, c.Status, c.ProblemType, c.AttachmentUniqueID, c.AttachmentName, c.AttachmentCreateBy, c.PPM_ProblemTraceImage, c.AttachmentCreateDate, AttachmentCreateByName = item.UserName, c.IsRepeat }).DefaultIfEmpty(); var problemTrace = problemList.FirstOrDefault(); this._problemTraceID = problemTrace.ID; this.txtModule.Text = problemTrace.Module; //this.cbxProjectUse.Text = problemTrace.ProjectUse; if (problemTrace.BeginDealDate != null) { this.dtBeginDealDate.ValueX = problemTrace.BeginDealDate; } else { this.dtBeginDealDate.ValueX = null; } this.cbxFindPerson.SelectedValue = problemTrace.FindPersonCode; this.txtProblem.Text = problemTrace.Problem; this.cbxDealPerson.SelectedValue = problemTrace.DealPersonCode; //this.dtEndDealDate.Text = problemTrace.EndDealDate.ToString(); if (problemTrace.EndDealDate != null) { this.dtEndDealDate.ValueX = problemTrace.EndDealDate; } else { this.dtEndDealDate.ValueX = null; } this.txtSolution.Text = problemTrace.Solution; this.cbxStatus.Text = problemTrace.Status; this.cbxProblemType.Text = problemTrace.ProblemType; this._attachmentUniqueID = problemTrace.AttachmentUniqueID; this._oldFileName = problemTrace.AttachmentUniqueID + problemTrace.AttachmentName; this.linkAttachment.Text = problemTrace.AttachmentName; if (!string.IsNullOrWhiteSpace(problemTrace.AttachmentCreateByName)) { this.lblAttachmentCreateBy.Text = "(上传人:" + problemTrace.AttachmentCreateByName + ",上传时间:" + (problemTrace.AttachmentCreateDate == null?"未记录":problemTrace.AttachmentCreateDate.Value.ToString("yyyy-MM-dd HH:mm:ss")) + ")"; } else { this.lblAttachmentCreateBy.Text = ""; } this.cbxIsRepeat.Text = problemTrace.IsRepeat; flowLayoutPanel1.Controls.Clear(); foreach (var item in problemTrace.PPM_ProblemTraceImage.OrderBy(p => p.SerialNo)) { genarateImageList(item.ID, ByteToImage(item.ImageFile)); } } } else { UserInfo userInfo = UserInfo.GetInstence(); this._problemTraceID = rowID; this.txtModule.Text = ""; this.cbxFindPerson.SelectedValue = userInfo.UserCode; //this.cbxProjectUse.Text = ""; this.dtBeginDealDate.Text = ""; this.txtProblem.Text = ""; this.cbxDealPerson.Text = ""; this.dtEndDealDate.Text = ""; this.txtSolution.Text = ""; this.cbxStatus.Text = "未开始"; this._attachmentUniqueID = ""; this._oldFileName = ""; this.linkAttachment.Text = ""; this.lblAttachmentCreateBy.Text = ""; this.cbxIsRepeat.Text = ""; flowLayoutPanel1.Controls.Clear(); } }
private void downloadFile(object obj) { List <KeyValuePair <string, string> > map = obj as List <KeyValuePair <string, string> >; int BufferLen = 4096; string folder = map.Where(p => p.Key == "folder").FirstOrDefault().Value; string fileName = map.Where(p => p.Key == "fileName").FirstOrDefault().Value; string uniqueID = map.Where(p => p.Key == "uniqueID").FirstOrDefault().Value; string serverFilePath = "\\UploadFile\\PPM_ProblemTrace\\" + uniqueID + fileName; string fileServiceUrl = string.Empty; using (BugTraceEntities zentity = new BugTraceEntities(EntityContextHelper.GetEntityConnString())) { var currVersion = zentity.SYS_Version.Where(p => p.IsDefault == 1).FirstOrDefault(); fileServiceUrl = currVersion.FileServiceUrlPort; } Stream sourceStream = null; try { EndpointAddress address = new EndpointAddress("http://" + fileServiceUrl + "/JAJ.WinServer/FileService"); FileTransferSvc.FileServiceClient _client = new FileTransferSvc.FileServiceClient("BasicHttpBinding_IFileService", address); sourceStream = _client.DowndloadFile(serverFilePath); } catch (Exception ex) { MyLog.LogError("文件下载失败!", ex); this.Invoke(new MethodInvoker(() => { try { wait.Close(); } catch { } MessageBox.Show("文件下载失败!"); })); return; } FileStream targetStream = null; if (!sourceStream.CanRead) { MyLog.LogError("下载异常", new Exception("Invalid Stream!")); throw new Exception("Invalid Stream!"); } string filePath = Path.Combine(folder, fileName); using (targetStream = new FileStream(filePath, FileMode.Create, FileAccess.Write, FileShare.None)) { byte[] buffer = new byte[BufferLen]; int count = 0; while ((count = sourceStream.Read(buffer, 0, BufferLen)) > 0) { targetStream.Write(buffer, 0, count); } targetStream.Close(); sourceStream.Close(); } this.Invoke(new MethodInvoker(() => { try { wait.Close(); } catch { } MessageBox.Show("下载成功!"); })); }
private void SaveProblemTrace(bool hasUpload) { PPM_ProblemTrace problemTrace; using (BugTraceEntities zEntity = new BugTraceEntities(EntityContextHelper.GetEntityConnString())) { UserInfo currUser = UserInfo.GetInstence(); if (this._problemTraceID == -1) { problemTrace = new PPM_ProblemTrace(); } else { problemTrace = zEntity.PPM_ProblemTrace.Where(p => p.ID == this._problemTraceID).FirstOrDefault(); } problemTrace.ProjectCode = currUser.DefaultProjectCode; problemTrace.Module = this.txtModule.Text; problemTrace.FindPersonCode = this.cbxFindPerson.SelectedValue.ToString(); problemTrace.FindPerson = this.cbxFindPerson.Text; problemTrace.Problem = this.txtProblem.Text; problemTrace.DealPersonCode = this.cbxDealPerson.SelectedValue.ToString(); problemTrace.DealPerson = this.cbxDealPerson.Text; //problemTrace.ProjectUse = this.cbxProjectUse.Text; if (!string.IsNullOrWhiteSpace(this.dtBeginDealDate.Text)) { problemTrace.BeginDealDate = Convert.ToDateTime(this.dtBeginDealDate.Text); } else { problemTrace.BeginDealDate = null; } if (!string.IsNullOrWhiteSpace(this.dtEndDealDate.Text)) { problemTrace.EndDealDate = Convert.ToDateTime(this.dtEndDealDate.Text); } problemTrace.Solution = this.txtSolution.Text; problemTrace.Status = this.cbxStatus.Text; problemTrace.ProblemType = this.cbxProblemType.Text; if (problemTrace.Status == "未通过") { problemTrace.TestFlag = 0; } problemTrace.UpdateDate = DateTime.Now; problemTrace.UpdatePerson = currUser.UserCode; problemTrace.IsRepeat = this.cbxIsRepeat.Text; if (problemTrace.Status == "未开始" || problemTrace.Status == "进行中" || problemTrace.Status == "未通过") { problemTrace.EndDealDate = null; } if (problemTrace.Status == "发版关闭") { problemTrace.TestPersonCode = UserInfo.GetInstence().UserCode; problemTrace.TestPerson = UserInfo.GetInstence().UserName; problemTrace.TestPassDate = DateTime.Now; } if (this._problemTraceID == -1) { problemTrace.FindDate = DateTime.Now; problemTrace.CreateDate = DateTime.Now; problemTrace.CreatePerson = currUser.UserCode; problemTrace.DeleteFlag = 0; zEntity.PPM_ProblemTrace.Add(problemTrace); } if (hasUpload)//有上传附件 { problemTrace.AttachmentName = Path.GetFileName(this.txtAttachment.Text); problemTrace.AttachmentUniqueID = this._attachmentUniqueID; problemTrace.AttachmentCreateBy = UserInfo.GetInstence().UserCode; problemTrace.AttachmentCreateDate = DateTime.Now; } if (problemTrace.Status == "进行中") { problemTrace.BeginDealDate = DateTime.Now; } #region 保存图片 if (this._problemTraceID != -1) {//删除以前的图片 var delImage = zEntity.PPM_ProblemTraceImage.Where(p => p.ProblemTraceID == this._problemTraceID); zEntity.PPM_ProblemTraceImage.RemoveRange(delImage); } int i = 1; foreach (Control item in flowLayoutPanel1.Controls) { PictureBox pictureBox = item as PictureBox; if (pictureBox != null) { PPM_ProblemTraceImage image = new PPM_ProblemTraceImage() { ID = pictureBox.Tag.ToString(), StorageType = 1, SerialNo = i++, ImageFile = ImageToBytes(pictureBox.Image), }; problemTrace.PPM_ProblemTraceImage.Add(image); } } #endregion zEntity.SaveChanges(); } MessageBox.Show("保存成功!"); this.Close(); try { var problemTraceList = FormSingle.GetForm(typeof(ProblemTraceList)) as ProblemTraceList; problemTraceList.SearchClick(); bool isExist = FormSingle.IsExist(typeof(ProjectPlanList)); if (isExist) { var tempForm = FormSingle.GetForm(typeof(ProjectPlanList)) as ProjectPlanList; tempForm.SearchClick(); } } catch (Exception ex) { MyLog.LogError("保存问题跟踪后刷新列表页面失败!", ex); } }
/// <summary> /// 数据绑定 /// </summary> private void PageDataBind() { using (BugTraceEntities zEntity = new BugTraceEntities(EntityContextHelper.GetEntityConnString())) { string defaultProjectCode = UserInfo.GetInstence().DefaultProjectCode; IQueryable <PPM_ProblemTrace> query = from c in zEntity.PPM_ProblemTrace where c.DeleteFlag == 0 && c.ProjectCode == defaultProjectCode select c; //提出人查询条件 List <String> strFindPersonCode = new List <string>(); for (int i = 0; i < this.lbFindPerson.SelectedItems.Count; i++) { var drv = (KeyValuePair <string, string>) this.lbFindPerson.SelectedItems[i]; strFindPersonCode.Add(drv.Key.ToString()); } if (strFindPersonCode.Count > 0) { query = query.Where(p => strFindPersonCode.Contains(p.FindPersonCode)); } //任务号查询条件 if (!string.IsNullOrWhiteSpace(this.txtTaskID.Text)) { int taskID = Convert.ToInt32(this.txtTaskID.Text); query = query.Where(p => p.ID == taskID); } //处理人查询条件 List <String> strDealPersonCode = new List <string>(); for (int i = 0; i < this.lbDealPerson.SelectedItems.Count; i++) { var drv = (KeyValuePair <string, string>) this.lbDealPerson.SelectedItems[i]; strDealPersonCode.Add(drv.Key.ToString()); } if (strDealPersonCode.Count > 0) { query = query.Where(p => strDealPersonCode.Contains(p.DealPersonCode)); } //类型查询条件 List <String> strProblemType = new List <string>(); for (int i = 0; i < this.lbProblemType.SelectedItems.Count; i++) { strProblemType.Add(this.lbProblemType.SelectedItems[i].ToString()); } if (strProblemType.Count > 0) { query = query.Where(p => strProblemType.Contains(p.ProblemType)); } //状态查询条件 List <String> strStatus = new List <string>(); for (int i = 0; i < this.lbStatus.SelectedItems.Count; i++) { strStatus.Add(this.lbStatus.SelectedItems[i].ToString()); } if (strStatus.Count > 0) { query = query.Where(p => strStatus.Contains(p.Status)); } //实施客户查询条件 //List<String> strProject = new List<string>(); //for (int i = 0; i < this.lbProjectUse.SelectedItems.Count; i++) //{ // strProject.Add(this.lbProjectUse.SelectedItems[i].ToString()); //} //if (strProject.Count > 0) //{ // query = query.Where(p => strProject.Contains(p.ProjectUse)); //} int pageSize = Int32.Parse(cbxPageSize.Text); int pageNum = Int32.Parse(txtPageNum.Text); var problemList = query.OrderByDescending(p => p.ID).Skip(pageSize * (pageNum - 1)).Take(pageSize) .Select(p => new { p.ID, p.ProblemType, p.Module, p.Problem, p.FindPerson, FindDate = p.FindDate, p.Solution, p.DealPerson, EndDealDate = p.EndDealDate, p.Status, p.ProjectUse, TestFlag = p.TestFlag == 1?"已发":"未发" }).ToList(); this.dgvProblemTrace.DataSource = problemList; var totalRecordCount = query.Count(); this.lblPageInfo.Text = "总共" + totalRecordCount + "条记录,每页"; this.lblPageTotal.Text = Math.Ceiling(Convert.ToDecimal(totalRecordCount) / pageSize) + "页"; } }
private void SystemSetForm_Load(object sender, EventArgs e) { UserInfo userInfo = UserInfo.GetInstence(); this.lblUserCode.Text = userInfo.UserCode + "(" + userInfo.UserName + ")"; using (BugTraceEntities context = new BugTraceEntities(EntityContextHelper.GetEntityConnString())) { List <KeyValuePair <string, string> > kvp = new List <KeyValuePair <string, string> >(); List <KeyValuePair <string, string> > kvpCommon = new List <KeyValuePair <string, string> >(); var userRoleList = context.SYS_UserRole.Where(p => p.UserCode == userInfo.UserCode && p.RoleCode == "DeptManager").FirstOrDefault(); if (userRoleList != null) { var query = from c in context.PPM_ProjectInfo orderby c.BeginDate descending select new { c.ProjectCode, c.ProjectName, c.BeginDate }; foreach (var item in query) { kvp.Add(new KeyValuePair <string, string>(item.ProjectCode, item.ProjectName)); kvpCommon.Add(new KeyValuePair <string, string>(item.ProjectCode, item.ProjectName)); } } else { var query = from c in context.PPM_ProjectInfo join d in context.PPM_ProjectTeam on c.ProjectCode equals d.ProjectCode where d.TeamMember == userInfo.UserCode group c by new { ProjectCode = c.ProjectCode, ProjectName = c.ProjectName } into g orderby g.Max(p => p.BeginDate) descending select new { g.Key.ProjectCode, g.Key.ProjectName, BeginDate = g.Max(p => p.BeginDate) }; foreach (var item in query) { kvp.Add(new KeyValuePair <string, string>(item.ProjectCode, item.ProjectName)); kvpCommon.Add(new KeyValuePair <string, string>(item.ProjectCode, item.ProjectName)); } } this.cbxProjectList.DisplayMember = "value"; this.cbxProjectList.ValueMember = "key"; this.cbxProjectList.DataSource = kvpCommon; this.cbxProjectList.SelectedIndex = -1; this.cbxProject.DisplayMember = "value"; this.cbxProject.ValueMember = "key"; this.cbxProject.DataSource = kvp; this.cbxProject.SelectedValue = userInfo.DefaultProjectCode == null ? "" : userInfo.DefaultProjectCode; var currUser = context.SYS_User.Where(p => p.UserCode == userInfo.UserCode).FirstOrDefault(); if (currUser != null) { this.txtTel.Text = userInfo.Tel; this.txtQQ.Text = userInfo.QQ; } var currUserExt = context.SYS_UserExt.Where(p => p.UserCode == userInfo.UserCode).FirstOrDefault(); if (currUserExt != null && !string.IsNullOrWhiteSpace(currUserExt.EmailPassword)) { this.txtEmailPassword.Text = Encrypt.TripleDESDecrypting(currUserExt.EmailPassword); } var userExt = context.SYS_UserExt.Where(p => p.UserCode == userInfo.UserCode).FirstOrDefault(); if (userExt != null) { if (!string.IsNullOrWhiteSpace(userExt.CommonProject)) { var commonProjectList = context.PPM_ProjectInfo.Where(p => userExt.CommonProject.Contains(p.ProjectCode + ",")); if (commonProjectList != null && commonProjectList.Count() > 0) { lbProjectList.Items.Clear(); foreach (var item in commonProjectList) { lbProjectList.Items.Add("(" + item.ProjectCode + ")" + item.ProjectName); } } } } } }
private void btnSave_Click(object sender, EventArgs e) { #region 验证 if (string.IsNullOrWhiteSpace(this.txtTel.Text)) { MessageBox.Show("电话不能为空", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); this.txtTel.Focus(); return; } if (string.IsNullOrWhiteSpace(this.txtQQ.Text)) { MessageBox.Show("QQ不能为空", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); this.txtQQ.Focus(); return; } #endregion using (BugTraceEntities context = new BugTraceEntities(EntityContextHelper.GetEntityConnString())) { string strProject = string.Empty; if (this.lbProjectList.Items.Count > 0) { foreach (var item in this.lbProjectList.Items) { strProject = strProject + item.ToString().Split(')')[0].Replace("(", "") + ","; } //strProject = strProject.Substring(0, strProject.Length-1); } string userCode = UserInfo.GetInstence().UserCode; var currUserExt = context.SYS_UserExt.Where(p => p.UserCode == userCode).FirstOrDefault(); if (currUserExt != null) { if (!string.IsNullOrWhiteSpace(this.txtEmailPassword.Text)) { currUserExt.EmailPassword = Encrypt.TripleDESEncrypting(this.txtEmailPassword.Text); currUserExt.CommonProject = strProject; context.SaveChanges(); } } else { currUserExt = new SYS_UserExt(); currUserExt.UserCode = userCode; if (!string.IsNullOrWhiteSpace(this.txtEmailPassword.Text)) { currUserExt.EmailPassword = Encrypt.TripleDESEncrypting(this.txtEmailPassword.Text); } currUserExt.CommonProject = strProject; context.SYS_UserExt.Add(currUserExt); context.SaveChanges(); } var currUser = context.SYS_User.Where(p => p.UserCode == userCode).FirstOrDefault(); if (currUser != null && !string.IsNullOrWhiteSpace(this.cbxProject.SelectedValue.ToString())) { currUser.DefaultProjectCode = this.cbxProject.SelectedValue.ToString(); currUser.QQ = this.txtQQ.Text; currUser.Tel = this.txtTel.Text; context.SaveChanges(); UserInfo.GetInstence().DefaultProjectCode = this.cbxProject.SelectedValue.ToString(); UserInfo.GetInstence().QQ = this.txtQQ.Text; UserInfo.GetInstence().Tel = this.txtTel.Text; MessageBox.Show("保存成功!"); try { bool isExist = FormSingle.IsExist(typeof(ProblemTraceList)); if (isExist) { var tempForm = FormSingle.GetForm(typeof(ProblemTraceList)); tempForm.Close(); tempForm = FormSingle.GetForm(typeof(ProblemTraceList)); tempForm.ShowNormal(this.ParentForm); } bool isExistPPL = FormSingle.IsExist(typeof(ProjectPlanList)); if (isExistPPL) { var tempForm = FormSingle.GetForm(typeof(ProjectPlanList)); tempForm.Close(); tempForm = FormSingle.GetForm(typeof(ProjectPlanList)); tempForm.ShowNormal(this.ParentForm); } bool isExistIndex = FormSingle.IsExist(typeof(FrmIndex)); if (isExistIndex) { var tempForm = FormSingle.GetForm(typeof(FrmIndex)) as FrmIndex; tempForm.Close(); tempForm = FormSingle.GetForm(typeof(FrmIndex)) as FrmIndex; tempForm.ShowNormal(this.ParentForm); } } catch (Exception ex) { MyLog.LogError("保存个人设置后刷新各窗口失败!", ex); } this.Close(); } } }