Example #1
0
        public IActionResult AddProject(Project project)
        {
            var checkProject = _projectRepo.Read(project.Id);

            if (checkProject == null)
            {
                _projectRepo.Add(project);
                return(RedirectToAction("Index", "Projects"));
            }
            return(View());
        }
Example #2
0
        /// <summary>
        /// 保存
        /// </summary>
        /// <returns></returns>
        private bool SaveData()
        {
            if (string.IsNullOrEmpty(this.txtConStructionProjectName.Text))
            {
                TXMessageBoxExtensions.Info("提示:项目名称不能为空!");
                this.tabControl1.SelectedTab = tabPage4;
                txtConStructionProjectName.Focus();
                return(false);
            }


            if (string.IsNullOrEmpty(this.txtConstructionProjectAdd.Text))
            {
                TXMessageBoxExtensions.Info("提示:项目地址不能为空!");
                this.tabControl1.SelectedTab = tabPage4;
                txtConstructionProjectAdd.Focus();
                return(false);
            }

            if (string.IsNullOrEmpty(this.txtCreateUnit.Text))
            {
                TXMessageBoxExtensions.Info("提示:项目建设单位不能为空!");
                this.tabControl1.SelectedTab = tabPage4;
                txtCreateUnit.Focus();
                return(false);
            }

            if (string.IsNullOrEmpty(this.txtPZDW.Text))
            {
                TXMessageBoxExtensions.Info("提示:立项批准单位不能为空!");
                this.tabControl1.SelectedTab = tabPage4;
                txtPZDW.Focus();
                return(false);
            }

            if (this.cboProjectType.SelectedIndex == -1)
            {
                TXMessageBoxExtensions.Info("提示:工程类型必须选择!");
                this.tabControl1.SelectedTab = tabPage4;
                return(false);
            }
            if (txtProjectNo.Text.Trim() == "")
            {
                TXMessageBoxExtensions.Info("提示:工程编号必须填写!");
                this.tabControl1.SelectedTab = tabPage1;
                this.txtProjectNo.Focus();
                return(false);
            }
            if (!MyCommon.isYesProjectNo(txtProjectNo.Text.Trim()))
            {
                TXMessageBoxExtensions.Info("提示:工程编号格式错误!\n【温馨提示:工程编号只允许输入数字,字母,下划线,横线】");
                this.tabControl1.SelectedTab = tabPage1;
                txtProjectNo.Focus();
                return(false);
            }

            if (string.IsNullOrEmpty(txtProjectName.Text))
            {
                TXMessageBoxExtensions.Info("提示:工程名称不能为空!");
                this.tabControl1.SelectedTab = tabPage1;
                txtProjectName.Focus();
                return(false);
            }

            if (cboDistrict.SelectedValue.ToString() == "" || string.IsNullOrEmpty(this.txtAddress.Text))
            {
                TXMessageBoxExtensions.Info("提示:工程地址不能为空!");
                this.tabControl1.SelectedTab = tabPage1;
                txtAddress.Focus();
                return(false);
            }

            if (dtpBeginDate.TextEx == "")
            {
                TXMessageBoxExtensions.Info("提示:开工日期必须填写!\n");
                this.tabControl1.SelectedTab = tabPage1;
                dtpBeginDate.Focus();
                return(false);
            }

            if (dtpEndDate.TextEx == "")
            {
                TXMessageBoxExtensions.Info("提示:竣工日期必须填写!\n");
                this.tabControl1.SelectedTab = tabPage1;
                dtpEndDate.Focus();
                return(false);
            }

            //验证单位
            if (!isCheckUnit(new List <TXTextBoxEX>()
            {
                this.txtJsdw, this.txtLxpzdw, this.txtSjdw, this.txtKcdw, this.txtSgdw, this.txtJldw
            },
                             new string[] { "建设", "立项批准", "设计", "勘察", "施工", "监理" }))
            {
                return(false);
            }

            if (txtGhcode.Text == "")
            {
                TXMessageBoxExtensions.Info("提示:工程规划许可证号必须填写!\n");
                this.tabControl1.SelectedTab = tabPage1;
                txtGhcode.Focus();
                return(false);
            }

            if (ProjectNO == "")//不是编辑
            {
                ERM.BLL.T_Projects_BLL ProjectDB = new ERM.BLL.T_Projects_BLL();
                if (ProjectDB.Exists(txtProjectNo.Text.Trim()))
                {
                    TXMessageBoxExtensions.Info("提示:工程编号有重复的请重新填写!");
                    this.tabControl1.SelectedTab = tabPage1;
                    txtProjectNo.Focus();
                    return(false);
                }
                if (txtProjectName.Text.Trim() != "" &&
                    ProjectDB.ExistsName(txtProjectName.Text.Trim()))
                {
                    TXMessageBoxExtensions.Info("提示:工程名称有重复的请重新填写!");
                    this.tabControl1.SelectedTab = tabPage1;
                    txtProjectName.Focus();
                    return(false);
                }
            }

            if ((!String.IsNullOrEmpty(this.dtpBeginDate.TextEx)) && dtpBeginDate.TextEx != "")
            {
                if (this.dtpEndDate.TextEx != "" &&
                    (!this.dtpBeginDate.TextEx.Equals(this.dtpEndDate.TextEx)) &&
                    (MyCommon.ToDate(dtpBeginDate.TextEx) >
                     MyCommon.ToDate(dtpEndDate.TextEx)))
                {
                    TXMessageBoxExtensions.Info("提示:工程基本信息:开工日期 必须小于 竣工日期!");
                    this.tabControl1.SelectedTab = tabPage1;
                    this.dtpEndDate.Focus();
                    return(false);
                }
            }

            projectMDL = obj.GetInfo(ProjectNo, projectMDL, 1) as T_Projects;

            projectMDL.ProjectNO       = MyCommon.ToSqlString(txtProjectNo.Text);   //工程编号
            projectMDL.district        = MyCommon.ToSqlString(cboDistrict.Text);    //所属区域
            projectMDL.projectname     = MyCommon.ToSqlString(txtProjectName.Text); //工程名称
            projectMDL.address         = MyCommon.ToSqlString(txtAddress.Text);     //工程地址
            projectMDL.ajdh            = MyCommon.ToSqlString(txtysbah.Text);       //验收备案号
            projectMDL.ProjectCategory = cboProjectType.SelectedValue.ToString();
            projectMDL.begindate       = dtpBeginDate.TextEx;                       //开工时间
            projectMDL.enddate         = dtpEndDate.TextEx;                         //竣工时间
            projectMDL.ghcode          = MyCommon.ToSqlString(txtGhcode.Text);
            projectMDL.sgcode          = MyCommon.ToSqlString(txtSgcode.Text);
            projectMDL.tbr             = Globals.Fullname;

            //projectMDL.ydpzcode = MyCommon.ToSqlString(txtYdpzcode.Text);
            projectMDL.ydxkcode = MyCommon.ToSqlString(txtYdghxkCode.Text);
            SetItemInfo(itemMDL.ItemID, 1);

            if (this.ProjectNO == "")
            {
                projectMDL.createdate = DateTime.Now.ToString("yyyy.MM.dd");
                itemMDL.ItemID        = Guid.NewGuid().ToString();
                projectMDL.ItemID     = itemMDL.ItemID;
                SaveUnit();
                if (!obj.Add(projectMDL, itemMDL))
                {
                    TXMessageBoxExtensions.Info("保存失败!");
                    return(false);
                }
                this.ProjectNO       = txtProjectNo.Text;
                txtProjectNo.Enabled = false;
                try
                {
                    System.IO.Directory.CreateDirectory(Globals.ProjectPathParent + MyCommon.ToSqlString(txtProjectNo.Text));
                }
                catch
                {
                    TXMessageBoxExtensions.Info("发生错误,请检查存放电子文件的目录是否存在及可写!");
                }
            }
            else
            {
                SaveUnit();
                if (!obj.Updates(projectMDL, itemMDL))
                {
                    TXMessageBoxExtensions.Info("保存失败!");
                    return(false);
                }
            }
            return(true);
        }
Example #3
0
 public IActionResult Add(ProjectAdminModel projectAdminModel)
 {
     _project.Add(ToResumeDataProject(projectAdminModel, true));
     return(LocalRedirect("/admin"));
 }
Example #4
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int  Add(Library.Model.Project model)
 {
     return(dal.Add(model));
 }