Beispiel #1
0
        private void btnDel_Click(object sender, EventArgs e)
        {
            if (txtProNum.Text == "")
            {
                MessageBox.Show("学号不能为空!\n 请重新输入!");
            }
            else
            {

                ProfessionBLL objSelCourseBLLClass = new ProfessionBLL();
                ProfessionModel objProfessionModel = new ProfessionModel();

                objProfessionModel.ProNum = txtProNum.Text;

                if (objSelCourseBLLClass.DelProfession(objProfessionModel) == true)
                {
                    MessageBox.Show("删除成功!!");
                }
                else
                {
                    MessageBox.Show("删除失败!");
                }
            }

            ShowTable();
        }
 public HttpResponseMessage DeleteProfession(ProfessionModel model)
 {
     try
     {
         if (this.ModelState.IsValid)
         {
             var result = _professionService.DeleteProfession(model);
             if (result != null)
             {
                 return(Request.CreateResponse(HttpStatusCode.OK, result));
             }
             else
             {
                 string message = "Not deleted successfully";
                 return(Request.CreateErrorResponse(HttpStatusCode.Forbidden, message));
             }
         }
         else
         {
             return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
         }
     }
     catch (Exception ex)
     {
         return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex));
     }
 }
Beispiel #3
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (txtProNum.Text == "")
            {
                MessageBox.Show("专业号不能为空!\n 请重新输入!");

            }
            else
            {
                ProfessionBLL objProfessionBLL = new ProfessionBLL();

                ProfessionModel objProfessionModel = new ProfessionModel();

                objProfessionModel.ProNum = txtProNum.Text;
                objProfessionModel.ProName = txtProName.Text;
                objProfessionModel.DepartNum = txtDepartNum.Text;
                objProfessionModel.DepartName = txtDepartName.Text;

                if(objProfessionBLL.InsertProfession(objProfessionModel)==true)
                {
                    MessageBox.Show("录入成功!");
                }
                else
                    MessageBox.Show("录入失败!");
            }

            ShowTable();
        }
 public HttpResponseMessage GetProfessionModels(ProfessionModel model)
 {
     try
     {
         if (this.ModelState.IsValid)
         {
             var ProfessionList = _professionService.GetAllProfessionList(model);
             if (ProfessionList != null)
             {
                 return(Request.CreateResponse(HttpStatusCode.OK, ProfessionList));
             }
             else
             {
                 string message = "Error in getting Data";
                 return(Request.CreateErrorResponse(HttpStatusCode.Forbidden, message));
             }
         }
         else
         {
             return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
         }
     }
     catch (Exception ex)
     {
         return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.InnerException.Message));
     }
 }
        private void cmbx_faculty_SelectedIndexChanged(object sender, EventArgs e)
        {
            string facValue = cmbx_faculty.SelectedValue.ToString();
            string sesValue = cmbx_session.SelectedValue.ToString();

            List <ProfessionModel> professionModels = new List <ProfessionModel>();

            List <GroupsAVGModel> groupsAVGModels = new List <GroupsAVGModel>();

            string connection = "Data Source= DESKTOP-A4JVK6F\\SQLEXPRESS; Initial Catalog=AZTU; Integrated Security=true;";

            //Filling combo query
            string query = @"SELECT PR.ID AS PrID, PR.Name AS PrName FROM Professions AS PR
                        INNER JOIN Departments AS DP
                        ON PR.DepartmentID = DP.ID
                        INNER JOIN Faculties AS F
                        ON F.ID = DP.FacultyID
                        WHERE F.ID = " + facValue;


            using (SqlConnection sqlConnection = new SqlConnection(connection))
            {
                sqlConnection.Open();


                using (SqlCommand sqlCommand = new SqlCommand(query, sqlConnection))
                {
                    using (SqlDataReader sqlDataReader = sqlCommand.ExecuteReader())
                    {
                        using (DataTable dataTable = new DataTable())
                        {
                            while (sqlDataReader.Read())
                            {
                                ProfessionModel professionModel = new ProfessionModel()
                                {
                                    ID   = int.Parse(sqlDataReader["PrID"].ToString()),
                                    Name = sqlDataReader["PrName"].ToString()
                                };
                                professionModels.Add(professionModel);
                            }
                        }
                    }
                }
            }
            List <Comboitem> comboitems = new List <Comboitem>();

            for (int i = 0; i < professionModels.Count; i++)
            {
                Comboitem comboitem = new Comboitem()
                {
                    Id   = professionModels[i].ID,
                    Name = professionModels[i].Name
                };
                comboitems.Add(comboitem);
            }
            cmbx_profession.ValueMember   = "ID";
            cmbx_profession.DisplayMember = "Name";
            cmbx_profession.DataSource    = comboitems;
        }
Beispiel #6
0
        private static ProfessionModel GetProfessionCandidates(string profession)
        {
            ProfessionModel outputProfessionCandidates = new ProfessionModel();

            outputProfessionCandidates.Profession = profession;

            return(outputProfessionCandidates);
        }
Beispiel #7
0
        public int Update(ProfessionModel model)
        {
            string sqlUpdate = "UPDATE Profession SET Name = @Name WHERE Id = @Id";

            using (_connection)
            {
                return(_connection.Execute(sqlUpdate, model));
            }
        }
Beispiel #8
0
        public int Insert(ProfessionModel model)
        {
            string sqlInsert = "INSERT INTO Profession (Id, Name) Values (@Id, @Name)";

            using (_connection)
            {
                return(_connection.Execute(sqlInsert, model));
            }
        }
Beispiel #9
0
        public int Delete(ProfessionModel model)
        {
            string sqlDelete = "DELETE FROM Profession WHERE Id = @Id";

            using (_connection)
            {
                return(_connection.Execute(sqlDelete, model));
            }
        }
        private void cmbx_faculty_SelectedIndexChanged(object sender, EventArgs e)
        {
            string sesValue = cmbx_session.SelectedValue.ToString();
            string facValue = cmbx_faculty.SelectedValue.ToString();
            List <ProfessionModel> professionModels = new List <ProfessionModel>();

            List <FinishResult> allFinishResults = new List <FinishResult>();

            string query = @"SELECT PR.ID AS PrID, PR.Name AS PrName FROM Professions AS PR
                        INNER JOIN Departments AS DP
                        ON PR.DepartmentID = DP.ID
                        INNER JOIN Faculties AS F
                        ON F.ID = DP.FacultyID
                        WHERE F.ID = " + facValue;

            using (SqlConnection sqlConnection = new SqlConnection(Extension.ConnectToDb()))
            {
                sqlConnection.Open();
                using (SqlCommand sqlCommand = new SqlCommand(query, sqlConnection))
                {
                    using (SqlDataReader sqlDataReader = sqlCommand.ExecuteReader())
                    {
                        using (DataTable dataTable = new DataTable())
                        {
                            while (sqlDataReader.Read())
                            {
                                ProfessionModel professionModel = new ProfessionModel()
                                {
                                    ID   = int.Parse(sqlDataReader["PrID"].ToString()),
                                    Name = sqlDataReader["PrName"].ToString()
                                };
                                professionModels.Add(professionModel);
                            }
                        }
                    }
                }
            }
            List <Comboitem> comboitems = new List <Comboitem>();

            for (int i = 0; i < professionModels.Count; i++)
            {
                Comboitem comboitem = new Comboitem()
                {
                    Id   = professionModels[i].ID,
                    Name = professionModels[i].Name
                };
                comboitems.Add(comboitem);
            }
            cmbx_profession.ValueMember   = "ID";
            cmbx_profession.DisplayMember = "Name";
            cmbx_profession.DataSource    = comboitems;
        }
        public static void SetUp()
        {
            _testProfModel = new ProfessionModel
            {
                EmployeeModelId = 1,
                ProfessionName  = "profone"
            };
            _testEmployeeModel = new EmployeeModel
            {
                Age         = 20,
                FirstName   = "firstName",
                LastName    = "firstSurname",
                Professions = new List <ProfessionModel> {
                    _testProfModel
                }
            };
            _testEmployeeModel2 = new EmployeeModel
            {
                Age       = 30,
                FirstName = "secondName",
                LastName  = "secondSurname"
            };
            _testEmployeeDbSet = new TestDbSet <EmployeeModel> {
                _testEmployeeModel
            };
            _testProfessionDbSet = new TestDbSet <ProfessionModel> {
                _testProfModel
            };
            switch (TestContext.CurrentContext.Test.MethodName)
            {
            case nameof(TestGetAdd_InputDataSet_OkResultWithEmployeeModel):
                _testEmployeeModel.Professions = new List <ProfessionModel>();
                break;

            case nameof(TestGetUpdate_Id_Not_Found):
                _testEmployeeModel.Id = 1;
                break;

            case nameof(TestGetRemove):
                _testEmployeeModel.Id  = 1;
                _testEmployeeModel2.Id = 2;
                _testEmployeeDbSet.Add(_testEmployeeModel2);
                break;
            }
        }
Beispiel #12
0
        private void cmbx_department_SelectedIndexChanged(object sender, EventArgs e)
        {
            string dpValue = cmbx_department.SelectedValue.ToString();

            string connection = "Data Source= DESKTOP-A4JVK6F\\SQLEXPRESS; Initial Catalog=AZTU; Integrated Security=true;";
            List <ProfessionModel> professionModels = new List <ProfessionModel>();

            using (SqlConnection sqlConnection = new SqlConnection(connection))
            {
                sqlConnection.Open();
                string query = @"SELECT ID, Name FROM Professions WHERE DepartmentID =" + dpValue;
                using (SqlCommand sqlCommand = new SqlCommand(query, sqlConnection))
                {
                    using (SqlDataReader sqlDataReader = sqlCommand.ExecuteReader())
                    {
                        using (DataTable dataTable = new DataTable())
                        {
                            while (sqlDataReader.Read())
                            {
                                ProfessionModel professionModel = new ProfessionModel()
                                {
                                    ID   = int.Parse(sqlDataReader["ID"].ToString()),
                                    Name = sqlDataReader["Name"].ToString()
                                };
                                professionModels.Add(professionModel);
                            }
                        }
                    }
                }
            }
            List <DpPrfCombo> dpPrfCombos = new List <DpPrfCombo>();

            for (int i = 0; i < professionModels.Count; i++)
            {
                DpPrfCombo dpPrfCombo = new DpPrfCombo()
                {
                    ID   = professionModels[i].ID,
                    Name = professionModels[i].Name
                };
                dpPrfCombos.Add(dpPrfCombo);
            }
            cmbx_profession.ValueMember   = "ID";
            cmbx_profession.DisplayMember = "Name";
            cmbx_profession.DataSource    = dpPrfCombos;
        }
Beispiel #13
0
        private void AddProfessions(ICollection <ProfessionModel> newProfessions,
                                    ICollection <ProfessionModel> existProfessions)
        {
            var tempCollection = existProfessions.Select(i => i).ToList();

            foreach (var profession in newProfessions)
            {
                var existProfessionsModel = tempCollection
                                            .SingleOrDefault(p => p.ProfessionName == profession.ProfessionName);
                if (existProfessionsModel != null)
                {
                    continue;
                }

                var newProfession = new ProfessionModel
                {
                    ProfessionName = profession.ProfessionName
                };
                existProfessions.Add(newProfession);
            }
        }
Beispiel #14
0
        public IHttpActionResult AssignProfession(ProfessionModel model)
        {
            if (!ModelState.IsValid)
            {
                return(InternalServerError(new Exception("Invalid model state")));
            }

            UserProfessions newProfessionAssignment;

            try
            {
                Users currentUser = GetUser();
                newProfessionAssignment = ProfessionService.AssignProfessionToUser(currentUser.Id, model.ProfessionToAssign);
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }

            return(Ok(newProfessionAssignment));
        }
Beispiel #15
0
 public void MarkAsModified(ProfessionModel item)
 {
     Entry(item).State = EntityState.Modified;
 }
Beispiel #16
0
        private void btnModify_Click_1(object sender, EventArgs e)
        {
            if (txtProNum.Text==""|| txtProName.Text == "")
            {
                MessageBox.Show("专业号,专业名称不能为空!\n 请重新输入!");
            }
            else
            {
                ProfessionBLL objProfessionBLL = new ProfessionBLL();

                ProfessionModel objProfessionModel = new ProfessionModel();

                objProfessionModel.ProNum = txtProNum.Text;
                objProfessionModel.ProName = txtProName.Text;
                objProfessionModel.DepartNum = txtDepartNum.Text;
                objProfessionModel.DepartName = txtDepartName.Text;

                if(objProfessionBLL.UpdatejProfession(objProfessionModel)==true)
                {
                    MessageBox.Show("修改成功!");
                }
                else
                    MessageBox.Show("修改失败!");
            }

            ShowTable();
        }
Beispiel #17
0
 /// <summary>
 /// Method whose purpose is to update an existing
 /// ProfessionModel record.
 /// </summary>
 /// <param name="profession">
 /// Existing ProfessionModel object.
 /// </param>
 /// <returns>
 /// Returns true if the query is successfully executed
 /// otherwise returns false.
 /// </returns>
 public bool Update(ProfessionModel profession)
 {
     return(_professionRepository.Update(profession) > 0 ? true : false);
 }
Beispiel #18
0
 /// <summary>
 /// Method whose purpose is to
 /// insert a new ProfessionModel record.
 /// </summary>
 /// <param name="profession">
 /// Newly created ProfessionModel object.
 /// </param>
 /// <returns>
 /// Returns true if the query is successfully executed
 /// otherwise returns false.
 /// </returns>
 public bool Insert(ProfessionModel profession)
 {
     return(_professionRepository.Insert(profession) > 0 ? true : false);
 }