Ejemplo n.º 1
0
        public Replaceitem(Form1 mpform)
        {
            InitializeComponent();
            m_parent = mpform;
            checkedListBox1.Items.Clear();
            checkedListBox2.Items.Clear();
            checkedListBox1.Items.Add("二分鐘仰臥起坐", false);
            checkedListBox1.Items.Add("二分鐘俯地挺身", false);
            checkedListBox1.Items.Add("三千公尺徒手跑步", false);

            try
            {
                center_code = System.Configuration.ConfigurationManager.AppSettings["centercode"].ToString();

                //Lib.DataUtility du_center = new Lib.DataUtility();
                //DataTable dt_center = du_center.getDataTableByText("select distinct C.center_code as center_code, C.center_name as center_name  from Result R, Center C where R.center_code = C.center_code ");
                //if (dt_center.Rows.Count == 1)
                //{
                //    center_code = dt_center.Rows[0]["center_code"].ToString();
                //    center_name = dt_center.Rows[0]["center_name"].ToString();
                //}
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            try
            {
                Lib.DataUtility             du = new Lib.DataUtility();
                Dictionary <string, object> d  = new Dictionary <string, object>();
                d.Add("center_code", center_code);
                DataTable dt_isSwin = du.getDataTableByText("select IsSwin from Center where center_code = @center_code", d);
                DataTable dt        = new DataTable();
                if (dt_isSwin.Rows.Count > 0)
                {
                    d.Clear();
                    //有游泳項目
                    if (Convert.ToBoolean(dt_isSwin.Rows[0]["IsSwin"]))
                    {
                        d.Add("Gender", m_parent.Gender);
                        dt = du.getDataTableBysp("GetRepMent", d);
                    }
                    else
                    {   //沒有游泳項目
                        d.Add("Gender", m_parent.Gender);
                        dt = du.getDataTableBysp("GetRepMentNonSwin", d);
                    }
                }
                if (dt.Rows.Count > 0)
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        checkedListBox2.Items.Add(dt.Rows[i]["rep_title"].ToString(), false);
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }
Ejemplo n.º 2
0
 private void button2_Click(object sender, EventArgs e)
 {
     try
     {
         if (RB_Standard.Checked == true)
         {
             if (!string.IsNullOrEmpty(TB_FileName.Text))
             {
                 Dictionary <string, object> d  = new Dictionary <string, object>();
                 Lib.DataUtility             du = new Lib.DataUtility();
                 string[] FileLists             = Directory.GetFiles(TB_FileName.Text);
                 int      Total = 0;
                 foreach (string Name in FileLists)
                 {
                     var reader = new StreamReader(File.OpenRead(@Name), Encoding.GetEncoding("Big5"));
                     int count  = 0;
                     while (reader.Peek() >= 0)
                     {
                         var      line     = reader.ReadLine();
                         string[] operater = { "," };
                         string[] values   = line.Split(operater, StringSplitOptions.None);
                         if (values.Length > 0)
                         {
                             if (values[0] != "項目" && values.Length == 6)
                             {
                                 d.Clear();
                                 d.Add("item", values[0]);
                                 d.Add("gender", values[1]);
                                 d.Add("agemin", values[2]);
                                 d.Add("agemax", values[3]);
                                 d.Add("standard", values[4]);
                                 d.Add("score", values[5]);
                                 du.executeNonQueryByText(@"Insert into Standard (item, gender, agemin, agemax, standard, score) values (@item, @gender, @agemin, @agemax, @standard, @score)", d);
                                 du.executeNonQueryByText(@"Insert into StandardEncrypt (item, gender, agemin, agemax, standard, score) values (@item, @gender, @agemin, @agemax, @standard, @score)", d);
                                 count++;
                             }
                         }
                     }
                     Total += count;
                     //MessageBox.Show("Load File " + Name + " 共" + count + "筆成績");
                 }
                 MessageBox.Show("Load score success." + " 共" + Total + "筆.");
             }
         }
         else
         {
             if (!string.IsNullOrEmpty(TB_FileName.Text))
             {
                 Dictionary <string, object> d  = new Dictionary <string, object>();
                 Lib.DataUtility             du = new Lib.DataUtility();
                 string[] FileLists             = Directory.GetFiles(TB_FileName.Text);
                 int      Total = 0;
                 foreach (string Name in FileLists)
                 {
                     var reader = new StreamReader(File.OpenRead(@Name), Encoding.GetEncoding("Big5"));
                     int count  = 0;
                     while (reader.Peek() >= 0)
                     {
                         var      line     = reader.ReadLine();
                         string[] operater = { "," };
                         string[] values   = line.Split(operater, StringSplitOptions.None);
                         if (values.Length > 0)
                         {
                             if (values[0] != "項目" && values.Length == 5)
                             {
                                 d.Clear();
                                 d.Add("item_id", values[0]);
                                 d.Add("gender", values[1]);
                                 d.Add("start", values[2]);
                                 d.Add("end", values[3]);
                                 d.Add("standard", values[4]);
                                 du.executeNonQueryByText(@"Insert into ReplaceStandard (item_id, gender, start, [end], standard) values (@item_id, @gender, @start, @end, @standard)", d);
                                 du.executeNonQueryByText(@"Insert into ReplaceStandardEncrypt (item_id, gender, start, [end], standard) values (@item_id, @gender, @start, @end, @standard)", d);
                                 count++;
                             }
                         }
                     }
                     Total += count;
                     //MessageBox.Show("Load File " + Name + " 共" + count + "筆成績");
                 }
                 MessageBox.Show("Load score success." + " 共" + Total + "筆.");
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }