public bool UpdateProjectDetail(Models.ProjectDetails projectDetails)
        {
            var projectDetailsObj = Mapper.Map <Models.ProjectDetails, DataAccessLayer.ProjectDetail>(projectDetails);
            var status            = ProjectEntities.UpdateProjectDetail(projectDetailsObj);

            return(status);
        }
Exemple #2
0
        private void backgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            try
            {
                if (this.Details.Where(p => string.IsNullOrWhiteSpace(p.Project.ParentProject.ParentProject.ProjectName)).Count() > 0)
                {
                    ShowMessageAndSetButtonEnabled("有一级菜单为空", false);
                    return;
                }
                if (this.Details.Where(p => string.IsNullOrWhiteSpace(p.Project.ParentProject.ProjectName)).Count() > 0)
                {
                    ShowMessageAndSetButtonEnabled("有二级菜单为空", false);
                    return;
                }
                if (this.Details.Where(p => string.IsNullOrWhiteSpace(p.Project.ProjectName)).Count() > 0)
                {
                    ShowMessageAndSetButtonEnabled("有三级菜单为空", false);
                    return;
                }
                if (this.Details.Where(p => string.IsNullOrWhiteSpace(p.CementContent)).Count() > 0)
                {
                    ShowMessageAndSetButtonEnabled("每立方米水泥用量为空", false);
                    return;
                }
                if (this.Details.Where(p => string.IsNullOrWhiteSpace(p.DetailsTilte)).Count() > 0)
                {
                    ShowMessageAndSetButtonEnabled("有四级菜单为空", false);
                    return;
                }
                if (this.Details.Where(p => string.IsNullOrWhiteSpace(p.SerialNumber)).Count() > 0)
                {
                    ShowMessageAndSetButtonEnabled("有项目工程编号为空", false);
                    return;
                }

                Models.ProjectDetails details = this.Details.Where(p => string.IsNullOrWhiteSpace(p.Mileage)).FirstOrDefault();
                if (this.Details.Where(p => string.IsNullOrWhiteSpace(p.Mileage)).Count() > 0)
                {
                    ShowMessageAndSetButtonEnabled("有取样里程为空", false);
                    return;
                }
                if (this.Details.Where(p => string.IsNullOrWhiteSpace(p.MixDesign)).Count() > 0)
                {
                    ShowMessageAndSetButtonEnabled("有混合比例为空", false);
                    return;
                }
                if (this.Details.Where(p => string.IsNullOrWhiteSpace(p.Intensity)).Count() > 0)
                {
                    ShowMessageAndSetButtonEnabled("有设计强度为空", false);
                    return;
                }
            }
            catch (Exception ex)
            {
                ShowMessageAndSetButtonEnabled("数据异常", false);
            }
            ShowMessageAndSetButtonEnabled("读取数据成功", true);
        }
 private bool SaveDeviceDate(Models.DeviceData data)
 {
     Models.ProjectDetails ProjectDetail = data.ProjectDetail;
     if (SaveProjectDetails(ProjectDetail))
     {
         /*
          * 读卡数据处理逻辑
          */
         return(dataBll.Create(data).ExcuteState);
     }
     return(false);
 }
        public bool InsertProjectDetail(Models.ProjectDetails projectDetails)
        {
            bool status = false;

            if (ModelState.IsValid)
            {
                projectDetails.Id = ProjectEntities.GetMaxProjectId() + 1;
                var projectDetailsObj = Mapper.Map <Models.ProjectDetails, DataAccessLayer.ProjectDetail>(projectDetails);
                status = ProjectEntities.InsertProjectDetail(projectDetailsObj);
            }
            return(status);
        }
        public JsonResult <Models.ProjectDetails> GetProjectDetail(int id)
        {
            var ProjectEntitiesInfo = ProjectEntities.GetProject(id);
            var project             = new Models.ProjectDetails();

            Models.ProjectDetails obj = Mapper.Map <DataAccessLayer.ProjectDetail, Models.ProjectDetails>(ProjectEntitiesInfo);

            var managerInfo = UserEntities.GetUsers((int)ProjectEntitiesInfo.ManagerId);

            obj.Manager = Mapper.Map <DataAccessLayer.User, Models.User>(managerInfo);
            return(Json <Models.ProjectDetails>(obj));
        }
 private bool SaveProjectDetails(Models.ProjectDetails details)
 {
     Models.ProjectDetails temp = detailsBll.GetModel(details.DetailsId);
     if (temp != null)  //已存在的数据不再插入
     {
         return(true);
     }
     Models.Project project = details.Project;
     if (SaveProject(project))
     {
         /*
          * 四级菜单处理逻辑
          */
         return(detailsBll.Create(details).ExcuteState);
     }
     return(false);
 }
Exemple #7
0
        private void button1_Click(object sender, EventArgs e)
        {
            //Task.Factory.StartNew(() =>
            //{
            if (yanzhengGroupText())
            {
                Models.ProjectDetails details = detailsBLL.GetModel(this.comboBox4.SelectedValue.ToString());
                //details.DeviceDataList = new List<Models.DeviceData>();
                BLL.DeviceDataBLL DeviceDataBLL = new BLL.DeviceDataBLL();
                List <string>     list          = new List <string>()
                {
                    "A", "B", "C", "D", "E", "F", "G", "H", "I"
                };
                int    n                  = (this.GroupInfo.SelectedIndex + 1) * 3;
                bool   ifSuccess          = true;
                string CreateDataStr      = DateTime.Now.ToString("yyyyMMddHHmmss");
                string CreateDataStrGroup = "";

                int m = this.GroupTextlist.Where(p => !string.IsNullOrWhiteSpace(p.Text)).Count();
                int a = m / 3;
                int b = m % 3;
                //if (a == 0)
                //{
                //    DialogResult dr = MessageBox.Show("至少需要填写一组数据,是否继续","提示",MessageBoxButtons.OKCancel );
                //    if (dr != DialogResult.OK)
                //    {
                //        MoveToNextText();
                //        return;
                //    }
                //}
                if (b != 0)
                {
                    string messagestr = "";

                    if (this.GroupInfo.SelectedIndex == 0)
                    {
                        if (textBox1.Text.Length == 0 || textBox2.Text.Length == 0 || textBox3.Text.Length == 0)
                        {
                            messagestr += "第一组数据不完整,是否继续提交绑定\r\n\r\n";
                        }
                    }
                    else if (this.GroupInfo.SelectedIndex == 1)
                    {
                        if (textBox1.Text.Length == 0 || textBox2.Text.Length == 0 || textBox3.Text.Length == 0)
                        {
                            messagestr += "第一组数据不完整,是否继续提交绑定\r\n\r\n";
                        }
                        if (textBox4.Text.Length == 0 || textBox5.Text.Length == 0 || textBox6.Text.Length == 0)
                        {
                            messagestr += "第二组数据不完整,是否继续提交绑定\r\n\r\n";
                        }
                    }
                    else if (this.GroupInfo.SelectedIndex == 2)
                    {
                        if (textBox1.Text.Length == 0 || textBox2.Text.Length == 0 || textBox3.Text.Length == 0)
                        {
                            messagestr += "第一组数据不完整,是否继续提交绑定\r\n\r\n";
                        }
                        if (textBox4.Text.Length == 0 || textBox5.Text.Length == 0 || textBox6.Text.Length == 0)
                        {
                            messagestr += "第二组数据不完整,是否继续提交绑定\r\n\r\n";
                        }
                        if (textBox7.Text.Length == 0 || textBox8.Text.Length == 0 || textBox9.Text.Length == 0)
                        {
                            messagestr += "第三组数据不完整,是否继续提交绑定\r\n\r\n";
                        }
                    }



                    DialogResult dr = MyDialogOption.show("提示", messagestr, "是,继续完成绑定", "否,返回补充完整");
                    // DialogResult dr = MessageBoxEx.Show("数据不完整,是否继续提交绑定", "提示", MessageBoxButtons.OKCancel, new string[] { "是,继续完成绑定", "否,返回补充完整" });
                    // DialogResult dr = MessageBox.Show("数据不完整,是否继续提交绑定?", "确认", MessageBoxButtons.OKCancel);
                    if (dr != DialogResult.OK)
                    {
                        MoveToNextText();
                        return;
                    }
                }

                for (int i = 0; i < n; i++)
                {
                    if (list[i] == "A" || list[i] == "B" || list[i] == "C")
                    {
                        CreateDataStrGroup = CreateDataStr + "A";
                    }
                    else if (list[i] == "D" || list[i] == "E" || list[i] == "F")
                    {
                        CreateDataStrGroup = CreateDataStr + "B";
                    }
                    else
                    {
                        CreateDataStrGroup = CreateDataStr + "C";
                    }
                    Models.DeviceData deviceData = new Models.DeviceData()
                    {
                        DataId          = this.comboBox4.SelectedValue.ToString() + "_" + list[i] + "_" + Utils.getGUID(),
                        DeviceValue     = this.GroupTextlist[i].Text,
                        GroupName       = list[i],
                        ProjectDetailId = this.comboBox4.SelectedValue.ToString(),
                        Instar          = this.Instar.SelectedItem.ToString(),
                        YangSheng       = this.yangsheng.SelectedItem.ToString(),
                        SamplingDate    = this.SamplingDate.Value.ToString("yyyy-MM-dd"),
                        CreateDate      = CreateDataStrGroup,
                        IfUpload        = 0,
                        NotUploadReason = "网络"
                    };

                    if (!Regex.IsMatch(deviceData.DeviceValue, "^\\d{15}$"))
                    {
                        continue;
                    }
                    //判断重复
                    if (DeviceDataBLL.GetModelByWhere(" DeviceValue='" + deviceData.DeviceValue + "'") != null)
                    {
                        MessageBox.Show("绑定数据库中已经存在[" + deviceData.DeviceValue + "]RFID编号请核实!");
                        return;
                    }



                    BLL.FunctionResult result = DeviceDataBLL.Create(deviceData);
                    if (!result.ExcuteState)
                    {
                        ifSuccess = false;
                        break;
                    }
                    this.DeviceDataTotal++;
                    setProcess();

                    this.DetailsForUpload.Enqueue(deviceData);
                }
                if (ifSuccess)
                {
                    details.DetailState = 1;

                    this.Invoke(new EventHandler((aa, bb) =>
                    {
                        MessageBox.Show("绑定数据完成!");
                        resetTextBox();
                        MoveToNextText();
                    }));
                }
            }
            //});
        }
Exemple #8
0
        private bool work(BackgroundWorker bk)
        {
            try
            {
                BLL.ProjectBLL Bll_Project = new BLL.ProjectBLL();
                string         fileName    = this.textBox4.Text;
                IWorkbook      workbook    = null;
                FileStream     fs          = new FileStream(fileName, FileMode.Open, FileAccess.Read);
                if (fileName.IndexOf(".xlsx") > 0) // 2007版本
                {
                    workbook = new XSSFWorkbook(fs);
                }
                else if (fileName.IndexOf(".xls") > 0) // 2003版本
                {
                    workbook = new HSSFWorkbook(fs);
                }
                int n = workbook.NumberOfSheets;
                showMessage("发现" + n + "个sheet页");

                for (int i = 0; i < n; i++)
                {
                    int order = 1;
                    showMessage("正在处理" + (i + 1) + "个sheet页");
                    ISheet sheet = workbook.GetSheetAt(i);

                    int start = sheet.FirstRowNum;
                    int end   = sheet.LastRowNum;
                    for (int r = 2; r <= end; r++)
                    {
                        IRow row = sheet.GetRow(r);
                        if (row == null || row.FirstCellNum == -1)
                        {
                            continue;
                        }
                        try
                        {
                            #region

                            string p1Name = row.GetCell(0).StringCellValue;
                            string p2Name = row.GetCell(1).StringCellValue;
                            string p3Name = row.GetCell(2).StringCellValue;
                            if (!Utils.IsEmptyOrNull(p1Name))
                            {
                                AddProject(p1Name, 1, i);
                            }
                            if (!Utils.IsEmptyOrNull(p2Name))
                            {
                                AddProject(p2Name, 2, i, Level_1_List.Last().ProjectId);
                            }

                            if (!Utils.IsEmptyOrNull(p3Name))
                            {
                                AddProject(p3Name, 3, i, Level_2_List.Last().ProjectId);
                            }
                            int                   CIndex      = 3;
                            Models.Project        tempProject = Level_3_List.Last();
                            int                   index       = order++;
                            Models.ProjectDetails details     = new Models.ProjectDetails()
                            {
                                DetailsTilte  = row.GetCell(3).GetValue(out CIndex),                                       //.StringCellValue,
                                SerialNumber  = row.GetCell(CIndex).GetValue(out CIndex),                                  //.StringCellValue,
                                Mileage       = row.GetCell(CIndex).GetValue(out CIndex),                                  //.StringCellValue,
                                Intensity     = row.GetCell(CIndex).GetValue(out CIndex),                                  //.StringCellValue,
                                CementContent = row.GetCell(CIndex).GetValue(out CIndex),                                  //.StringCellValue.ToString(),
                                MixDesign     = row.GetCell(CIndex).GetValue(out CIndex),                                  //.NumericCellValue.ToString(),
                                DetailsId     = ProjectCode + "_" + biaoduanCode + "_M4_" + index + "_" + Utils.getGUID(), // Utils.getGUID(),
                                DisplayOrder  = index,
                                ProjectId     = tempProject.ProjectId,
                                Project       = tempProject
                            };
                            this.Details.Add(details);
                            #endregion
                        }
                        catch (Exception ex)
                        {
                            showMessage("第" + i + "页,第" + r + "行:" + ex.Message);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                showMessage(ex.Message);
            }
            finally
            {
                this.Invoke(new EventHandler((a, b) =>
                {
                    this.dataGridView1.DataSource = Details.Select(p => new
                    {
                        一级菜单    = p.Project.ParentProject.ParentProject.ProjectName,
                        二级菜单    = p.Project.ParentProject.ProjectName,
                        级菜单     = p.Project.ProjectName,
                        四级菜单    = p.DetailsTilte,
                        分项工程编号  = p.SerialNumber,
                        取样里程    = p.Mileage,
                        设计强度    = p.Intensity,
                        每立方水泥用量 = p.CementContent,
                        设计配合比   = p.MixDesign
                    }).ToList();
                }));
            }
            return(true);
        }