예제 #1
0
        //
        private void T_M_USING_btn_Click(object sender, EventArgs e)
        {
            List <string> d_name = new List <string>();
            List <string> d_pno  = new List <string>();
            List <string> d_sno  = new List <string>();
            string        d_yyyy = comboYear.Text.ToString();
            string        d_mm   = comboMonth.Text.ToString();

            Sql_Conn sqlConn = new Sql_Conn();

            int totalLines = userDataDGV.Rows.Count - 1;

            for (int i = 0; i < totalLines; i++)
            {
                var    targetRow = userDataDGV.Rows[i].Cells;
                string name      = targetRow[0].Value.ToString();
                string pNo       = targetRow[1].Value.ToString();
                string sNo       = targetRow[3].Value.ToString();

                d_name.Add(name);
                d_pno.Add(pNo);
                d_sno.Add(sNo);
            }

            sqlConn.Add_T_M_USING_Data(d_yyyy, d_mm, d_pno, d_sno);
        }
예제 #2
0
        private void T_USER_btn_Click(object sender, EventArgs e)
        {
            List <string> d_name = new List <string>();
            List <string> d_pno  = new List <string>();
            List <string> d_mf   = new List <string>();

            Sql_Conn sqlConn = new Sql_Conn();

            int totalLines = userDataDGV.Rows.Count - 1;

            for (int i = 0; i < totalLines; i++)
            {
                var    targetRow = userDataDGV.Rows[i].Cells;
                string name      = targetRow[0].Value.ToString();
                string pNo       = targetRow[1].Value.ToString();
                string sex       = targetRow[2].Value.ToString();

                d_name.Add(name);
                d_pno.Add(pNo);
                d_mf.Add(sex);
            }

            sqlConn.Add_T_USER_Data(d_name, d_pno, d_mf);
        }
예제 #3
0
파일: Form1.cs 프로젝트: pandavas89/ReadCSV
        public void DB_btn(object sender, EventArgs e)
        {
            //string[,] keep = new string[0, 0];

            List <string> d_name = new List <string>();
            List <string> d_pno  = new List <string>();
            List <string> d_mf   = new List <string>();


            StreamReader sr = new StreamReader(file_path);

            string pline = sr.ReadLine();

            string[] ldata = pline.Split(',');

            // 첫 줄 예외
            int nameIdx = 0;
            int pNoIdx  = 0;
            int sNoIdx  = 0;

            for (int i = 0; i < ldata.Length; i++)
            {
                if (ldata[i] == "사용자이름")
                {
                    nameIdx = i;
                }
                else if (ldata[i] == "핸드폰번호")
                {
                    pNoIdx = i;
                }
                else if (ldata[i] == "좌석번호")
                {
                    sNoIdx = i;
                }
            }
            //
            while (!sr.EndOfStream)
            {
                // 한 줄씩 읽어온다.
                string line = sr.ReadLine();
                // , 기준으로 분리
                string[] data = line.Split(',');
                // 출력   1 사용자이름, 4 전화번호, 7 좌석번호(성별)
                //Console.WriteLine("{0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}", data[0], data[1], data[2], data[3], data[4], data[5], data[6], data[7]);

                //성별 분류
                string seatAndSex = data[sNoIdx];
                string sex        = "F";

                if (seatAndSex.Substring(0, 2) == "남자")
                {
                    sex = "M";
                }

                // 좌석 번호
                //string sNo = seatAndSex.Split(' ')[1].Substring(0, seatAndSex.Split(' ')[1].Length - 1);

                //string[] input = new string[] { data[nameIdx], data[pNoIdx].Substring(4, 9).Remove(4, 1), sex };
                // 이름, 전화번호, 성별
                // 전화번호 5자리, - 지움 처리

                // 입력

                d_name.Add(data[nameIdx]);
                d_pno.Add(data[pNoIdx].Substring(4, 9).Remove(4, 1));
                d_mf.Add(sex);
            }
            //
            var Sql_Conn = new Sql_Conn();

            Sql_Conn.AddData(d_name, d_pno, d_mf);
            //
            MessageBox.Show("while done");
        }