Пример #1
0
        public async Task <Projectinfo> SaveAsync(Projectinfo projectInfo)
        {
            _appDbContext.Projectinfo.Add(projectInfo);
            await _appDbContext.SaveChangesAsync();

            return(projectInfo);
        }
Пример #2
0
 public string Post([FromBody] Projectinfo projectinfo)
 {
     //Create
     db.Projectinfo.Add(projectinfo);
     db.SaveChanges();
     return(JsonConvert.SerializeObject(projectinfo));
 }
Пример #3
0
        /// <summary>
        /// 检查是否有更改
        /// </summary>
        /// <returns></returns>
        public bool CheckChange()
        {
            bool change = false;
            List <Projectinfo> dgvSort = new List <Projectinfo>();

            foreach (DataGridViewRow item in dgvEvents.Rows)
            {
                Projectinfo pro = new Projectinfo()
                {
                    ProjectId   = Convert.ToInt32(item.Cells["ProjectId"].Value),
                    ProjectName = item.Cells["ProjectName"].Value.ToString(),
                    StartTime   = Convert.ToDateTime(item.Cells["StartTime"].Value)
                };
                dgvSort.Add(pro);
            }
            DataTable dt = ProjectInfoServices.Instance.GetTableByMatchId(CommParam.PublicParam.GlobalMatchId);

            if (dgvSort.Count == dt.Rows.Count)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    if (dgvSort[i].ProjectId != Convert.ToInt32(dt.Rows[i]["ProjectId"]) || dgvSort[i].ProjectName != dt.Rows[i]["ProjectName"].ToString() || dgvSort[i].StartTime.ToString("yyyy/MM/dd hh:mm") != Convert.ToDateTime(dt.Rows[i]["StartTime"]).ToString("yyyy/MM/dd hh:mm"))
                    {
                        change = true;
                        break;
                    }
                }
            }
            else
            {
                change = true;
            }
            return(change);
        }
Пример #4
0
        /// <summary>
        /// 保存更改
        /// </summary>
        private void SaveChange()
        {
            List <Projectinfo> proList = new List <Projectinfo>();

            foreach (DataGridViewRow item in dgvEvents.Rows)
            {
                Projectinfo pro = new Projectinfo()
                {
                    ProjectId   = Convert.ToInt32(item.Cells["ProjectId"].Value),
                    ProjectName = item.Cells["ProjectName"].Value.ToString(),
                    StartTime   = Convert.ToDateTime(item.Cells["StartTime"].Value),
                    SortIndex   = Convert.ToInt32(item.Cells["SortIndex"].Value)
                };
                proList.Add(pro);
            }
            if (proList.Count > 0)
            {
                if (ProjectInfoServices.Instance.Update(proList) > 0)
                {
                    MessageBox.Show("保存成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }
                else
                {
                    MessageBox.Show("保存失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }
            }
        }
Пример #5
0
        /// <summary>
        /// 添加按钮点击事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnAdd_Click(object sender, EventArgs e)
        {
            string groupName = this.txtGroupName.Text;

            if (string.IsNullOrEmpty(groupName))
            {
                MessageBox.Show("请输入组别名称", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                return;
            }
            List <Projectinfo> proList = new List <Projectinfo>();
            int groupId      = GroupInfoServices.Instance.GetGourpIdByName(CommParam.PublicParam.GlobalMatchId, groupName);
            int maxSortIndex = ProjectInfoServices.Instance.MaxSortIndex(CommParam.PublicParam.GlobalMatchId);

            for (int i = 0; i < this.dgvStandardProjectList.Rows.Count; i++)
            {
                if (Convert.ToBoolean(this.dgvStandardProjectList.Rows[i].Cells["IsSelected"].Value))
                {
                    maxSortIndex++;
                    Projectinfo pro = new Projectinfo();
                    pro.Distance = Convert.ToInt32(this.dgvStandardProjectList.Rows[i].Cells["Distance"].Value);
                    pro.DistanceForQualification = Convert.ToInt32(this.dgvStandardProjectList.Rows[i].Cells["DistanceForQualification"].Value);
                    pro.StartTime = this.dtpStartTime.Value;
                    pro.EndTime   = this.dtpStartTime.Value;
                    pro.MatchId   = CommParam.PublicParam.GlobalMatchId;
                    pro.GroupId   = groupId;
                    pro.Sex       = this.dgvStandardProjectList.Rows[i].Cells["Sex"].Value.ToString() == "男" ? 0 : 1;
                    pro.SortIndex = maxSortIndex;
                    if (!groupName.Equals("专业"))
                    {
                        pro.ProjectName = this.dgvStandardProjectList.Rows[i].Cells["ProName"].Value.ToString().Insert(2, groupName);
                    }
                    else
                    {
                        pro.ProjectName = this.dgvStandardProjectList.Rows[i].Cells["ProName"].Value.ToString();
                    }
                    pro.TypeId             = 1;
                    pro.EnglishProjectName = this.dgvStandardProjectList.Rows[i].Cells["EnglishName"].Value.ToString();
                    proList.Add(pro);
                }
            }
            if (proList.Count > 0)
            {
                if (ProjectInfoServices.Instance.Add(proList) > 0)
                {
                    dgvCompetitionItemListDataSource();
                    for (int i = 0; i < this.dgvStandardProjectList.Rows.Count; i++)
                    {
                        this.dgvStandardProjectList.Rows[i].Cells["IsSelected"].Value = 0;
                    }
                    this.cbxCheckAll.Checked = false;
                    this.txtGroupName.Text   = "";
                }
            }
            else
            {
                MessageBox.Show("请选择项目", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
        }
Пример #6
0
        public async Task <Projectinfo> DeleteAsync(int projectInfoId)
        {
            Projectinfo projectInfoInDb = await GetByIdAsync(projectInfoId);

            _appDbContext.Projectinfo.Remove(projectInfoInDb);
            await _appDbContext.SaveChangesAsync();

            return(projectInfoInDb);
        }
Пример #7
0
        public IActionResult Project(int id)
        {
            Projectinfo model = new Projectinfo()
            {
                ProjectId = id
            };

            return(View(model));
        }
Пример #8
0
        public async Task <IActionResult> SaveProjectWorkingHours(AddProjectWorkingHoursViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }


            Projectinfo newProjectInfo = await _projectInfoRepository.SaveAsync(_mapper.Map <AddProjectWorkingHoursViewModel, Projectinfo>(model));

            if (newProjectInfo == null)
            {
                ModelState.AddModelError("", "Something went wrong.");
                return(View(model));
            }
            return(View("success", "Working hours added successfuly!"));
        }
Пример #9
0
        /// <summary>
        /// 项目信息更改完成后触发事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void dgvEvents_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            Projectinfo pro          = new Projectinfo();
            string      proName      = this.dgvEvents.Rows[e.RowIndex].Cells["ProjectName"].Value.ToString();
            string      strStartTime = this.dgvEvents.Rows[e.RowIndex].Cells["StartTime"].Value.ToString();
            DateTime    dtStartTime;

            if (string.IsNullOrEmpty(proName))
            {
                MessageBox.Show("项目名称不能为空", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                return;
            }
            if (!DateTime.TryParse(strStartTime, out dtStartTime))
            {
                MessageBox.Show("请输入正确的时间格式,如2019/1/1 12:00", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                return;
            }
        }
Пример #10
0
 /// <summary>
 /// 删除按钮点击事件
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnDelete_Click(object sender, EventArgs e)
 {
     if (dgvEvents.SelectedRows.Count == 0)
     {
         MessageBox.Show("没有选中任何项目", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
         return;
     }
     if (MessageBox.Show("确定删除所选项目?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
     {
         List <Projectinfo> proIdList = new List <Projectinfo>();
         foreach (DataGridViewRow item in dgvEvents.SelectedRows)
         {
             Projectinfo pro = new Projectinfo()
             {
                 ProjectId = Convert.ToInt32(item.Cells["ProjectId"].Value),
                 GroupId   = Convert.ToInt32(item.Cells["GroupId"].Value)
             };
             proIdList.Add(pro);
         }
         ProjectInfoServices.Instance.Delete(proIdList, CommParam.PublicParam.GlobalMatchId);
         dgvCompetitionItemListDataSource();
     }
 }
Пример #11
0
 public string Delete([FromBody] Projectinfo projectinfo)
 {
     db.Projectinfo.Remove(projectinfo);
     db.SaveChanges();
     return(JsonConvert.SerializeObject("Ok"));
 }
Пример #12
0
 public void Put(int id, [FromBody] Projectinfo projectinfo)
 {
     //Update
     db.Projectinfo.Update(projectinfo);
     db.SaveChanges();
 }