Пример #1
0
        //***************************************************
        //선택되지 않은 부서 조회 1:성공 0:실패
        //***************************************************
        public void SelectRightDG(BindingList <SelectSurveyViewModel.Dept> RDG, string id)
        {
            string sql = "select * from sasu_suvDept where suv_Id = @id";

            if (conn2.State == System.Data.ConnectionState.Closed)
            {
                conn2.Open();
            }
            try
            {
                cmd2 = new MySqlCommand(sql, conn2);
                cmd2.Parameters.AddWithValue("@id", id);
                MySqlDataReader reader = cmd2.ExecuteReader();
                RDG.Clear();
                while (reader.Read())
                {
                    SelectSurveyViewModel.Dept temp = new SelectSurveyViewModel.Dept
                    {
                        DeptCode = "R",
                        DeptId   = reader["dept_id"].ToString(),
                        DeptName = reader["dept_name"].ToString()
                    };
                    RDG.Insert(RDG.Count, temp);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }
            finally
            {
                cmd2 = null;
                conn2.Close();
            }
        }
Пример #2
0
        //***************************************************
        //선택 부서 추가
        //***************************************************
        public void AddSelectSurvetDept(SelectSurveyViewModel.Dept data, string id)
        {
            string sql = "insert into sasu_suvDept values(@survid,@deptid, @deptname)";

            connectionOpen();
            try
            {
                cmd = new MySqlCommand(sql, conn);
                cmd.Parameters.AddWithValue("@survid", id);
                cmd.Parameters.AddWithValue("@deptid", data.DeptId);
                cmd.Parameters.AddWithValue("@deptname", data.DeptName);
                cmd.ExecuteNonQuery();
            }catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }
            finally
            {
                cmd = null;
                conn.Close();
            }
        }
Пример #3
0
 //*****************************************************************
 // 저장 버튼 클릭
 //*****************************************************************
 private void SaveButton_Click(object sender, RoutedEventArgs e)
 {
     for (int i = 0; i < myViewModel.Count; i++)
     {
         //입력
         if (myViewModel[i].SurveyCode == "A")
         {
             Sql.InsertSelectSurvey(myViewModel[i], "dkxltks25 박재홍");
         }
         else if (myViewModel[i].SurveyCode == "U")
         {
             Sql.UpdateSelectSurvey(myViewModel[i], "dkxltks25 박재홍");
         }
         else if (myViewModel[i].SurveyCode == "D")
         {
             Sql.DeleteSelectSurvey(myViewModel[i].SurveyId);
         }
         for (int j = 0; j < myViewModel[i].RDG.Count; j++)
         {
             SelectSurveyViewModel.Dept dept = myViewModel[i].RDG[j];
             if (dept.DeptCode == "C")
             {
                 Sql.AddSelectSurvetDept(dept, myViewModel[i].SurveyId);
             }
         }
         for (int j = myViewModel[i].LDG.Count - 1; j >= 0; j--)
         {
             SelectSurveyViewModel.Dept dept = myViewModel[i].LDG[j];
             if (dept.DeptCode == "C")
             {
                 Sql.DeleteSelectSurveyDept(dept.DeptId, myViewModel[i].SurveyId);
             }
         }
     }
     SelectTable();
 }