protected void GD_CATE_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        clsMySQL db = new clsMySQL();

        try
        {
            GridViewRow gvrow    = GD_CATE.Rows[e.RowIndex];
            string      stage    = gvrow.Cells[1].Text;
            string      Input    = gvrow.Cells[2].Text;
            string      sp       = gvrow.Cells[3].Text;
            string      md       = gvrow.Cells[4].Text;
            string      category = gvrow.Cells[5].Text;
            string      kp       = gvrow.Cells[6].Text;


            if (Input == " ")
            {
                Input = "";
            }
            if (sp == " ")
            {
                sp = "";
            }
            if (md == " ")
            {
                md = "";
            }
            if (category == " ")
            {
                category = "";
            }
            if (kp == " ")
            {
                kp = "";
            }



            //lblError.Text = gvrow.Cells[1].Text + "////" + gvrow.Cells[2].Text;

            string strSQL_Delete = string.Format("Delete from npi_ep_category where EP_Cate_Stage='{0}' and EP_Cate_Iiitems='{1}' and EP_Cate_SpeChar='{2}' and  EP_Cate_Md='{3}' and EP_Cate_Cate='{4}' and  EP_Cate_KP='{5}'",
                                                 stage, Input, sp, md, category, kp);

            if (db.QueryExecuteNonQuery(strSQL_Delete))
            {
                RegisterStartupScript("訊息通知", "<script> alert('資料已刪除,成功!!');</script>");
                Response.Redirect(Request.Url.AbsoluteUri);
                DBint(stage);
            }
            else
            {
                //lblError.Text = strSQL_Delete;
                RegisterStartupScript("訊息通知", "<script> alert('資料刪除,失敗!!');</script>");
            }
        }
        catch (FormatException ex)
        {
            lblError.Text = "[Error Message::NPI Category Form Delete Function]: " + ex.ToString();
        }
    }
Esempio n. 2
0
    protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        //lblError.Text = e.Keys["C_Code"].ToString() + "////" + e.Values.ToString();
        clsMySQL db = new clsMySQL();

        try
        {
            GridViewRow gvrow = GridView1.Rows[e.RowIndex];

            lblError.Text = gvrow.Cells[1].Text + "////" + gvrow.Cells[2].Text;
            string strSQL_Delete = string.Format("Delete from npiManual where New_Customer='{0}' and  New_Device='{1}'",
                                                 gvrow.Cells[1].Text.Trim(), gvrow.Cells[2].Text.Trim());

            if (db.QueryExecuteNonQuery(strSQL_Delete))
            {
                RegisterStartupScript("訊息通知", "<script> alert('資料已刪除,成功!!');</script>");
                ChangeViewMode();
            }
            else
            {
                //lblError.Text = strSQL_Delete;
                RegisterStartupScript("訊息通知", "<script> alert('資料刪除,失敗!!');</script>");
            }
        }
        catch (FormatException ex)
        {
            lblError.Text = "[Error Message::NPI Manual Form Delete Function]: " + ex.ToString();
        }
    }
Esempio n. 3
0
    protected void GD_CAP_RowDeleting1(object sender, GridViewDeleteEventArgs e)
    {
        clsMySQL db = new clsMySQL();

        try
        {
            GridViewRow gvrow = GD_CAP.Rows[e.RowIndex];

            //lblError.Text = gvrow.Cells[1].Text + "////" + gvrow.Cells[2].Text;
            string strSQL_Delete = string.Format("Delete from npiManual where CAP_EP_Name='{0}'",
                                                 gvrow.Cells[1].Text.Trim());

            if (db.QueryExecuteNonQuery(strSQL_Delete))
            {
                RegisterStartupScript("訊息通知", "<script> alert('資料已刪除,成功!!');</script>");
                //ChangeViewMode();
            }
            else
            {
                //lblError.Text = strSQL_Delete;
                RegisterStartupScript("訊息通知", "<script> alert('資料刪除,失敗!!');</script>");
            }
        }
        catch (FormatException ex)
        {
            lblError.Text = "[Error Message::NPI Manual Form Delete Function]: " + ex.ToString();
        }
    }
Esempio n. 4
0
    protected void insert_cate(int item_num, List <string> Cate_Iiitems, List <string> Cate_SpeChar, List <string> Cate_Md, List <string> Cate_Cate, List <string> Cate_KP, string name, string status, string stage)
    {
        clsMySQL      db             = new clsMySQL();
        List <int>    success_insert = new List <int>();
        List <int>    fail_insert    = new List <int>();
        int           success_count  = 0;
        int           fail_count     = 0;
        List <string> history_cate   = new List <string>();

        for (int i = 0; i < item_num; i++)
        {
            String insert_cate = string.Format("insert into npi_cap_ep" +
                                               "(npi_EP_Cate_Username,npi_EP_Cate_UpdateTime,npi_EP_Cate_Status," +
                                               "EP_Cate_Stage,EP_Cate_Iiitems,EP_Cate_SpeChar," +
                                               "EP_Cate_Md,EP_Cate_Cate,EP_Cate_KP)values" +
                                               "('{0}',NOW(),'{1}'," +
                                               "'{2}','{3}','{4}','{5}','{6}','{7}')"
                                               , name, status, stage, Cate_Iiitems[i], Cate_SpeChar[i], Cate_Md[i], Cate_Cate[i], Cate_KP[i]);
            if (db.QueryExecuteNonQuery(insert_cate) == true)
            {
                success_count++;
            }
            else
            {
                fail_count++;
                history_cate.Add(Cate_Iiitems[i] + "|" + Cate_SpeChar[i] + "|" + Cate_Md[i] + "|" + Cate_Cate[i] + "|" + Cate_KP[i]);
            }
        }



        /*
         * try
         * {
         *  /*if (Text_Packge_insert.Text.Trim() == "")
         *  {
         *      string strScript = string.Format("<script language='javascript'>alert('您沒有輸入Packge_Name!');</script>");
         *      Page.ClientScript.RegisterStartupScript(this.GetType(), "onload", strScript);
         *  }
         *  if ()
         *  {
         *      string strScript = string.Format("<script language='javascript'>alert('Category新增成功');</script>");
         *      Page.ClientScript.RegisterStartupScript(this.GetType(), "onload", strScript);
         *
         *  }
         *  else
         *  {
         *      string strScript = string.Format("<script language='javascript'>alert('Category新增成功');</script>");
         *      Page.ClientScript.RegisterStartupScript(this.GetType(), "onload", strScript);
         *  }
         * }
         * catch (Exception ex)
         * {
         *  throw ex;
         * }
         *
         */
    }
    protected void but_Save_lv_Click(object sender, EventArgs e)
    {
        clsMySQL db = new clsMySQL();

        string SpeChar = "";
        string md      = "";
        string cate    = "";
        string key     = "";

        string t = "";
        string f = "";


        for (int i = 0; i < GridView1.Rows.Count; i++)
        {
            SpeChar = GridView1.Rows[i].Cells[0].Text;
            md      = GridView1.Rows[i].Cells[1].Text;
            cate    = GridView1.Rows[i].Cells[2].Text;
            key     = GridView1.Rows[i].Cells[3].Text;
            DropDownList ddl_Lv     = (DropDownList)GridView1.Rows[i].Cells[4].FindControl("Doe_Lv");
            String       insert_cap = string.Format("insert into npi_eptra_doe_lv" +
                                                    "(Lv_filename,Lv_stage,Lv_SpecChar," +
                                                    "Lv_Iiitems,Lv_md,Lv_cate," +
                                                    "Lv_kp,Lv_TraLv)values" +
                                                    "('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}')",
                                                    "ver.1", "PI1", SpeChar, "PI Thickness (um)", md,
                                                    cate, key, ddl_Lv.SelectedItem);



            try
            {
                if (db.QueryExecuteNonQuery(insert_cap) == true)
                {
                    t += Convert.ToString(i) + ",";
                }
                else
                {
                    f += Convert.ToString(i) + ",";
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }



        //string strScript = string.Format("<script language='javascript'>alert("+f+"\n"+t+");</script>");
        //Page.ClientScript.RegisterStartupScript(this.GetType(), "onload", strScript);
    }
    protected void LinkButton_Insert_Add_Click(object sender, EventArgs e)
    {
        clsMySQL db = new clsMySQL();

        string Status     = "Y";
        string User_Name  = "CIM";
        String insert_cap = string.Format("insert into npi_ep_category" +
                                          "(npi_EP_Cate_Username,npi_EP_Cate_UpdateTime,npi_EP_Cate_Status," +
                                          "EP_Cate_Stage,EP_Cate_Iiitems,EP_Cate_SpeChar," +
                                          "EP_Cate_Md,EP_Cate_Cate,EP_Cate_KP)values" +
                                          "('{0}',NOW(),'{1}','{2}','{3}','{4}','{5}','{6}','{7}')",
                                          text_ad_cate_user.Text, Status, text_ad_cate_stage.Text, text_ad_cate_input.Text,
                                          text_ad_cate_sp.Text, text_ad_cate_md.Text, text_ad_cate_cate.Text, text_ad_cate_kp.Text);



        try
        {
            if (text_ad_cate_stage.Text.Trim() == "")
            {
                string strScript = string.Format("<script language='javascript'>alert('您沒有輸入Stage,請重新輸入!');</script>");
                Page.ClientScript.RegisterStartupScript(this.GetType(), "onload", strScript);
                Panel_Add_Category.Visible    = true;
                Panel_Category_View.Visible   = false;
                Panel_update_category.Visible = false;
                Panel_Category.Visible        = false;
            }
            else if (db.QueryExecuteNonQuery(insert_cap) == true)
            {
                string strScript = string.Format("<script language='javascript'>alert('Stage:" + text_ad_cate_stage.Text + "新增成功');</script>");
                Page.ClientScript.RegisterStartupScript(this.GetType(), "onload", strScript);
                Panel_Add_Category.Visible    = false;
                Panel_update_category.Visible = false;
                Panel_Category.Visible        = true;
                Response.Redirect(Request.Url.AbsoluteUri);
                DBint(text_ad_cate_stage.Text);
            }
            else
            {
                string strScript = string.Format("<script language='javascript'>alert('新增失敗');</script>");
                Page.ClientScript.RegisterStartupScript(this.GetType(), "onload", strScript);
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }
    protected void up_lv_signoff_sta(string sign, int rowindex, string com)
    {
        string ver     = GridView1.Rows[rowindex].Cells[2].Text;
        string Lv_Sign = Lv_sign.Value;

        string   sign_Name = "jj";
        clsMySQL db        = new clsMySQL();

        String update_Lv = string.Format("UPDATE npieptra_main_signoff_status " +
                                         "SET Signoff_Status='{0}',Signoff_Name='{1}',Signoff_Time=NOW(),Signoff_Command='{2}'" +
                                         "where Ver_Name='{3}' and Signoff_Status='{4}' "
                                         , sign, sign_Name, com, ver, "NA");

        string str_eptraver_main_sta = "select * from npieptra_main_signoff_status where Ver_Name='" + ver + "'";

        try
        {
            if (db.QueryExecuteNonQuery(update_Lv) == true)
            {
                if (Lv_Sign == "Acc")
                {
                    string strScript = string.Format("<script language='javascript'>alert('" + ver + "簽核完成!');</script>");
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "onload", strScript);
                }
                else if (Lv_Sign == "Rej")
                {
                    string strScript = string.Format("<script language='javascript'>alert('" + ver + "簽核完成!');</script>");
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "onload", strScript);
                }

                Panel_gv2.Visible = true;
                clsMySQL.DBReply dr = db.QueryDS(str_eptraver_main_sta);
                GridView2.DataSource = dr.dsDataSet.Tables[0].DefaultView;
                GridView2.DataBind();
                set_sta_srt("gv2");
            }
            else
            {
                lblError.Text = update_Lv;
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }
        db.Close();
    }
    /*public void getData()
     * {
     *  DataTable aTb = WebUtility.GetSQLdata("select * from product where id='0';", "teachDB");
     *
     *  if (aTb.Rows.Count == 0)
     *  {
     *
     *      aTb.Rows.Add(aTb.NewRow());
     *
     *      GridView1.DataSource = aTb;
     *      GridView1.DataBind();
     *
     *
     *      int columnCount = GridView1.Rows[0].Cells.Count;
     *      GridView1.Rows[0].Cells.Clear();
     *      GridView1.Rows[0].Cells.Add(new TableCell());
     *
     *      GridView1.Rows[0].Cells[0].ColumnSpan = columnCount;
     *      GridView1.Rows[0].Cells[0].Text = "無資料!";
     *      GridView1.RowStyle.HorizontalAlign = System.Web.UI.WebControls.HorizontalAlign.Center;
     *  }
     *  else
     *  {
     *      GridView1.DataSource = aTb;
     *      GridView1.DataBind();
     *  }
     *
     *
     * }*/



    protected void Button_Update_Click(object sender, EventArgs e)
    {
        clsMySQL db = new clsMySQL();
        int      index;
        string   Status = "Y";

        index = Convert.ToInt32(Session["gvrow_index"].ToString());
        GridViewRow gvrow = GD_CATE.Rows[index];

        Session.Clear();



        String update_cate = string.Format("update  npi_ep_category set " +
                                           "npi_EP_Cate_Username='******',npi_EP_Cate_UpdateTime=NOW(),npi_EP_Cate_Status='{1}'," +
                                           "EP_Cate_Stage='{2}',EP_Cate_Iiitems='{3}',EP_Cate_SpeChar='{4}'," +
                                           "EP_Cate_Md='{5}',EP_Cate_Cate='{6}',EP_Cate_KP='{7}' " +
                                           "where EP_Cate_Stage='{8}' and  EP_Cate_Iiitems='{9}' and EP_Cate_SpeChar='{10}'" +
                                           "and EP_Cate_Md='{11}'and EP_Cate_Cate='{12}' and EP_Cate_KP='{13}' "
                                           , text_up_cate_user.Text, Status, text_cate_stage.Text, text_cate_input.Text
                                           , text_cate_sp.Text, text_cate_md.Text, text_cate_cate.Text, text_cate_kp.Text
                                           , gvrow.Cells[1].Text.Trim(), gvrow.Cells[2].Text.Trim(), gvrow.Cells[3].Text.Trim()
                                           , gvrow.Cells[4].Text.Trim(), gvrow.Cells[5].Text.Trim(), gvrow.Cells[6].Text.Trim());


        try
        {
            if (db.QueryExecuteNonQuery(update_cate))
            {
                RegisterStartupScript("訊息通知", "<script> alert('資料更新,成功!!');</script>");
                Panel_update_category.Visible = false;
                Panel_Category.Visible        = true;
                DBint(text_cate_stage.Text);
                //ChangeViewMode();
            }
            else
            {
                //lblError.Text = strSQL_Delete;
                RegisterStartupScript("訊息通知", "<script> alert('資料更新,失敗!!');</script>");
            }
        }
        catch (FormatException ex)
        {
            lblError.Text = "[Error Message::NPI Manual Form Delete Function]: " + ex.ToString();
        }
    }
Esempio n. 9
0
    public static string test_pass(string str)
    {
        List <string> DOE_list = new List <string>();
        clsMySQL      db       = new clsMySQL();

        //string File_Name = .Session["Version_Name"].ToString();
        string[] str_list = str.Split('|');
        for (int i = 0; i < str_list.Length; i++)
        {
            DOE_list.Add(str_list[i]);
        }


        String insert_DOE = string.Format("insert into npi_eptra_doe" +
                                          "(eptra_filename,doe_stage,doe_SpeChar,doe_md," +
                                          "doe_cate,doe_kp,doe_legs_1,doe_legs_2,doe_wafer," +
                                          "doe_wt_dm,doe_wt_pc,doe_wt_live,doe_attr,doe_note," +
                                          "doe_lot,doe_duedate,doe_result)values" +
                                          "('{0}','{1}','{2}'," +
                                          "'{3}','{4}','{5}','{6}','{7}'," +
                                          "'{8}','{9}','{10}','{11}','{12}'," +
                                          "'{13}','{14}','{15}','{16}')"
                                          , DOE_list[0], DOE_list[1], DOE_list[2], DOE_list[3],
                                          DOE_list[4], DOE_list[5], DOE_list[6], DOE_list[7],
                                          DOE_list[8], DOE_list[9], DOE_list[10], DOE_list[11],
                                          DOE_list[12], DOE_list[13], DOE_list[14], DOE_list[15], "bruno");

        try
        {
            if (db.QueryExecuteNonQuery(insert_DOE))
            {
                return("1");
            }
            else
            {
                return("0");
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }
Esempio n. 10
0
    protected void up_lv_signoff_sta(int RowIndex, string com)
    {
        string ver = gv_display_Lv_signoffdata.Rows[RowIndex].Cells[1].Text;



        string   up_Name = "bruno";
        clsMySQL db      = new clsMySQL();

        String update_Lv = string.Format("UPDATE npieptra_lv_main_status " +
                                         " SET Ver_Status='{0}',UpdateName='{1}',UpdateTime=NOW(),LV_Signoff_Status_Change_Command='{2}'" +
                                         "where Ver_Name='{3}' and Ver_Status='{4}'",
                                         "Disable", up_Name, com, ver, "Enable");

        string str_eptraver_main_sta = "select * from npieptra_lv_main_Status where Ver_Name='" + ver + "'";

        try
        {
            if (db.QueryExecuteNonQuery(update_Lv) == true)
            {
                Panel_gv1.Visible = false;
                Panel_gv2.Visible = true;

                clsMySQL.DBReply dr = db.QueryDS(str_eptraver_main_sta);
                signoff_gv2.DataSource = dr.dsDataSet.Tables[0].DefaultView;
                signoff_gv2.DataBind();
                set_sta_srt("gv2");
            }
            else
            {
                lblError.Text = update_Lv + db.ToString();
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }
        db.Close();
    }
    public static string DEL_Category(string str_stage)
    {
        string strError = "";

        string[] category_spilit_inf = new string[6];
        category_spilit_inf = str_stage.Split('|');

        for (int i = 0; i < category_spilit_inf.Length; i++)
        {
            if (category_spilit_inf[i] == "&nbsp;")
            {
                category_spilit_inf[i] = "";
            }
        }


        string strSQL_Delete = string.Format("Delete from npi_ep_category where EP_Cate_Stage='{0}' and EP_Cate_Iiitems='{1}' and EP_Cate_SpeChar='{2}' and  EP_Cate_Md='{3}' and EP_Cate_Cate='{4}' and  EP_Cate_KP='{5}'",
                                             category_spilit_inf[0], category_spilit_inf[1], category_spilit_inf[2], category_spilit_inf[3], category_spilit_inf[4], category_spilit_inf[5]);


        clsMySQL db = new clsMySQL();

        if (db.QueryExecuteNonQuery(strSQL_Delete))
        {
            strError = "刪除成功!";
            //DBint(category_spilit_inf[0]);

            HttpContext.Current.Session["value_del_stage"] = category_spilit_inf[0];
            db.Close();
        }
        else
        {
            strError = "Error Message:[NPI ManualForm] Delete Fail!!";
        }
        return(strError);
    }
    protected void cmdFilter_Click(object sender, EventArgs e)
    {


        string CreateName = "cre_CIM";
        string UpName = "up_CIM";
        string Signoff_SendName = "sing_CIM";
        clsMySQL db = new clsMySQL();

        String insert_lv = string.Format("insert into npieptra_lv_main_status" +
                       "(Ver_Name,Ver_No,Ver_Status,CreateTime,CreateName,UpdateTime,UpdateName," +
                       "LV_Signoff_Status,LV_Signoff_SendName,LV_Signoff_SendTime)Values" +
                       "('{0}','{1}','{2}',NOW(),'{3}',NOW(),'{4}','{5}','{6}',NOW())"+
                        "ON DUPLICATE KEY UPDATE LV_Signoff_SendName='{6}',LV_Signoff_SendTime=NOW(),UpdateTime=NOW(),UpdateName='{4}',LV_Signoff_Status='{5}'",
                       global_Ver_Name, global_Ver_No, global_Ver_Sta, CreateName, UpName, "NA", Signoff_SendName);

        if (!db.QueryExecuteNonQuery(insert_lv))
        {
            lblError.Text = insert_lv;
            string strScript = string.Format("<script language='javascript'>alert('送審失敗!');</script>");
            Page.ClientScript.RegisterStartupScript(this.GetType(), "onload", strScript);


        }
        else
        {
            Response.Write("<script language=javascript>alert('送審成功!')</script>");
            Response.Write("<script language=javascript>window.location.href='EPTRA_LV_SigoffList.aspx'</script>");
            
        }
    }
    protected void GD_CATE_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        clsMySQL db = new clsMySQL();
        try
        {
            GridViewRow gvrow = GD_CATE.Rows[e.RowIndex];
            string stage = gvrow.Cells[1].Text;
            string Input = gvrow.Cells[2].Text;
            string sp = gvrow.Cells[3].Text;
            string md = gvrow.Cells[4].Text;
            string category = gvrow.Cells[5].Text;
            string kp = gvrow.Cells[6].Text;


            if (Input == "&nbsp;")
                Input = "";
            if (sp == "&nbsp;")
                sp = "";
            if (md == "&nbsp;")
                 md = "";
            if (category == "&nbsp;")
                category = "";
            if (kp == "&nbsp;")
                kp = "";
           


            //lblError.Text = gvrow.Cells[1].Text + "////" + gvrow.Cells[2].Text;

            string strSQL_Delete = string.Format("Delete from npi_ep_category where EP_Cate_Stage='{0}' and EP_Cate_Iiitems='{1}' and EP_Cate_SpeChar='{2}' and  EP_Cate_Md='{3}' and EP_Cate_Cate='{4}' and  EP_Cate_KP='{5}'",
                                     stage,Input,sp,md,category,kp);

            if (db.QueryExecuteNonQuery(strSQL_Delete))
            {
                RegisterStartupScript("訊息通知", "<script> alert('資料已刪除,成功!!');</script>");
                Response.Redirect(Request.Url.AbsoluteUri);
                DBint(stage);
            }
            else
            {
                //lblError.Text = strSQL_Delete;
                RegisterStartupScript("訊息通知", "<script> alert('資料刪除,失敗!!');</script>");
            }
        }
        catch (FormatException ex)
        {
            lblError.Text = "[Error Message::NPI Category Form Delete Function]: " + ex.ToString();
        }
    }
    protected void all_lv_setting(string lv_sign, string keyitem, string stage, string SpeChar)
    {
        clsMySQL db = new clsMySQL();
        string insert_sign = "";
        String insert_lv = string.Format("insert into npieptra_lv_main" +
                               "(Ver_Name,EPTRA_KeyItem,EPTRA_LV_Stage,EPTRA_LV_SpecChar,EPTRA_LV)Values" +
                               "('{0}','{1}','{2}','{3}','{4}')" +
                               "ON DUPLICATE KEY UPDATE EPTRA_KeyItem='{1}',EPTRA_LV_Stage='{2}',EPTRA_LV_SpecChar='{3}',EPTRA_LV='{4}'",
                               global_Ver_Name, keyitem, stage, SpeChar, lv_sign);


        try
        {

            if (db.QueryExecuteNonQuery(insert_lv) == true)
            {

                //t += Convert.ToString(i) + ",";
                insert_sign = "true";

            }
            else
            {
                //f += Convert.ToString(i) + ",";
                insert_sign = "false";
                lblError.Text = insert_lv + db.ToString();

            }
        }
        catch (Exception ex)
        {
            lblError.Text = ex.ToString();
            throw ex;
        }


    }
    public void ImportToDataTable()
    {
        string fileName = "";
        lblMsg.Text = "";
        try
        {
            fileName = Path.GetFileName(FileUploadToServer.PostedFile.FileName);
            string filePath = Server.MapPath("~\\FileUpload\\") + Path.GetFileName(FileUploadToServer.PostedFile.FileName);
            FileUploadToServer.SaveAs(filePath);
            DataTable dt = new DataTable();           
            //---------------取出file type : DIF/D_R/DRC,取檔名的前三字元
            if (CheckExcelFile(fileName))         //判斷File是否為xlsx
            {
                string strType = fileName.Substring(0, 3);
                string strSQL = "";
                switch (strType)
                {
                    case "DIF":
                        strSQL = "select Mtype,Mname,Mpos,MRow,MCol from npimap where mtype = 'DIF' order by mid";
                        break;
                    case "Q_R":
                        strSQL = "select Mtype,Mname,Mpos,MRow,MCol from npimap where mtype = 'Q_R' order by mid";
                        break;
                    case "DRC":
                        strSQL = "select Mtype,Mname,Mpos,MRow,MCol from npimap where mtype = 'DRC' order by mid";
                        break;
                    default:
                        lblMsg.ForeColor = System.Drawing.Color.Red;
                        lblMsg.Text = "您選擇的檔案:["+ fileName +"]無法匯入,請重新選擇正確的Excel檔案!!!";
                        strSQL = "";
                        break;
                }            
            //--------------------------------------------------------------------------------
            var existingFile = new FileInfo(filePath);
            
                using (var package = new ExcelPackage(existingFile))
                {
                    ExcelWorkbook workBook = package.Workbook;
                    if (workBook != null && strSQL != "")
                    {
                        if (workBook.Worksheets.Count > 0)
                        {
                            ExcelWorksheet worksheet = workBook.Worksheets.First();//Excel File的第一個Sheet1                           
                            DataTable dt_Pos = new DataTable();
                            clsMySQL db = new clsMySQL();
                            ArrayList arSQL = new ArrayList();
                            db.dbConn();

                            dt_Pos = db.dbQueryDT(strSQL);//db.QueryDataTable(strSQL);
                            db.dbClose();

                            dt.Columns.Add("檔案類型");
                            dt.Columns.Add("欄位名稱");
                            dt.Columns.Add("欄位位置");
                            //dt.Columns.Add("Rows");
                            //dt.Columns.Add("Cols");
                            dt.Columns.Add("欄位內容");
                            //Get Customer and Device value----------------------------------------------------------------
                            string tmpCustomer = "";
                            string tmpDevice = "";
                            for (int t = 0; t <= 2; t++)
                            {
                                if (dt_Pos.Rows[t][1].ToString() == "Customer")
                                {
                                    if (strType == "DRC")
                                    {
                                        string[] str2 = worksheet.Cells[Convert.ToInt32(dt_Pos.Rows[t][3].ToString()), Convert.ToInt32(dt_Pos.Rows[t][4].ToString())].Value.ToString().Split(':');
                                        tmpCustomer = str2[1];
                                    }
                                    else
                                    {
                                        tmpCustomer = worksheet.Cells[Convert.ToInt32(dt_Pos.Rows[t][3].ToString()), Convert.ToInt32(dt_Pos.Rows[t][4].ToString())].Value.ToString();
                                    }
                                }
                                else
                                {
                                    if (dt_Pos.Rows[t][1].ToString() == "Device")
                                    {
                                        if (strType == "DRC")
                                        {
                                            string[] str2 = worksheet.Cells[Convert.ToInt32(dt_Pos.Rows[t][3].ToString()), Convert.ToInt32(dt_Pos.Rows[t][4].ToString())].Value.ToString().Split(':');
                                            tmpDevice = str2[1];
                                        }
                                        else
                                        {
                                            tmpDevice = worksheet.Cells[Convert.ToInt32(dt_Pos.Rows[t][3].ToString()), Convert.ToInt32(dt_Pos.Rows[t][4].ToString())].Value.ToString();
                                        }
                                    }
                                }
                            }
                            //---------------------------------------------------------------------------------------------------------
                            for (int i = 0; i < dt_Pos.Rows.Count; i++)
                            {
                                DataRow dr = dt.NewRow();
                                string tmpValue = "";
                                int x = 0;
                                db.dbConn();
                                dr[x++] = dt_Pos.Rows[i][0].ToString();
                                dr[x++] = dt_Pos.Rows[i][1].ToString();
                                dr[x++] = dt_Pos.Rows[i][2].ToString();
                                //dr[x++] = dt_Pos.Rows[i][3].ToString();
                                //dr[x++] = dt_Pos.Rows[i][4].ToString();
                                if (strType == "DRC" && (dt_Pos.Rows[i][2].ToString() == "B46" || dt_Pos.Rows[i][2].ToString() == "B47" || dt_Pos.Rows[i][2].ToString() == "B48"))
                                {
                                    string[] str1 = worksheet.Cells[Convert.ToInt32(dt_Pos.Rows[i][3].ToString()), Convert.ToInt32(dt_Pos.Rows[i][4].ToString())].Value.ToString().Split(':');
                                    dr[x++] = str1[1];
                                    tmpValue = str1[1];
                                }
                                else
                                {
                                    dr[x++] = worksheet.Cells[Convert.ToInt32(dt_Pos.Rows[i][3].ToString()), Convert.ToInt32(dt_Pos.Rows[i][4].ToString())].Value;

                                    if (worksheet.Cells[Convert.ToInt32(dt_Pos.Rows[i][3].ToString()), Convert.ToInt32(dt_Pos.Rows[i][4].ToString())].Value == null)
                                    {
                                        tmpValue = "";
                                    }
                                    else
                                    {
                                        tmpValue = worksheet.Cells[Convert.ToInt32(dt_Pos.Rows[i][3].ToString()), Convert.ToInt32(dt_Pos.Rows[i][4].ToString())].Value.ToString();
                                    }
                                }
                                dt.Rows.Add(dr);
                                gvRecord.DataSource = dt;
                                gvRecord.DataBind();

                                //-----------------------------------insert MySql Database: npiImportData                                   
                                string strSQL_Query = string.Format("select * from npiImportData where New_Customer = '{0}' and New_Device ='{1}' and Stype='{2}' and Im_Pos='{3}'", tmpCustomer.Trim(), tmpDevice.Trim(), strType.Trim(), dt_Pos.Rows[i][2].ToString().Trim());
                                string strSQL_Del = string.Format("Delete from npiImportData where New_Customer='{0}' and New_Device='{1}' and Stype='{2}' and Im_Pos='{3}'", tmpCustomer.Trim(), tmpDevice.Trim(), strType.Trim(), dt_Pos.Rows[i][2].ToString().Trim());
                                arSQL.Add(strSQL_Del);
                                string strSQL_Insert = string.Format("Insert into npiImportData (New_Customer,New_Device,Stype,UpdateTime,npiUser,Im_Name,Im_Pos,Im_Value) values (" +
                                                       "'{0}','{1}','{2}',NOW(),'','{3}','{4}','{5}')", tmpCustomer.Trim(), tmpDevice.Trim(), strType.Trim(), dt_Pos.Rows[i][1].ToString().Trim(), dt_Pos.Rows[i][2].ToString().Trim(), tmpValue.Trim());
                                arSQL.Add(strSQL_Insert);
                                lblMsg.ForeColor = System.Drawing.Color.Red;
                                //if (db.QueryDataReader(strSQL_Query).HasRows)
                                if (db.dbQueryDR(strSQL_Query).HasRows)
                                {
                                    if (!db.myBatchNonQuery(arSQL))
                                    {
                                        lblMsg.Text = "[Import Error Message] Delete/Insert Fail!!<br/>";
                                    }
                                }
                                else
                                {
                                    if (!db.QueryExecuteNonQuery(strSQL_Insert))
                                    {
                                        lblMsg.Text = "[Import Error Message] Insert Fail!! <br/>";
                                    }
                                }
                                arSQL.Clear();
                                lblMsg.Text = strSQL_Insert + "<br/>" + lblMsg.Text;
                                //---------------------------------------
                                db.dbClose();
                            }
                            lblMsg.ForeColor = System.Drawing.Color.Green;
                            lblMsg.Text = "[" + fileName + "],完成資料匯入!!";
                        }
                        else 
                        {
                            lblMsg.ForeColor = System.Drawing.Color.Red;
                            lblMsg.Text = "您選擇的[" + fileName + "]無法匯入,請重新選擇Excel檔案或檢查Excel檔案內容!!";
                        }
                    }
                    else
                    {
                        gvRecord.DataSource = dt;
                        gvRecord.DataBind();
                    }                    
                }
            }
            File.Delete(filePath); //將IIS上的excel file刪除,C:\inetpub\wwwroot\BU3Web\FileUpload           
        }
        catch (Exception exfile)
        {
            lblMsg.ForeColor = System.Drawing.Color.Red;
            if (fileName == "")
            {
                lblMsg.Text = "[Import Error Message] 請選擇要匯入的Excel檔案!!";
            }
            else {
                lblMsg.Text = "[Import Error Message]您選擇的[" +fileName +"]無法匯入,請重新選擇Excel檔案或檢查Excel檔案內容!!";
            }            
        }
    }
    protected void LinkButton_Insert_Add_Click(object sender, EventArgs e)
    {
        clsMySQL db = new clsMySQL();

        string Status = "Y";
        string User_Name = "CIM";
        String insert_cap = string.Format("insert into npi_ep_category" +
                            "(npi_EP_Cate_Username,npi_EP_Cate_UpdateTime,npi_EP_Cate_Status," +
                            "EP_Cate_Stage,EP_Cate_Iiitems,EP_Cate_SpeChar," +
                            "EP_Cate_Md,EP_Cate_Cate,EP_Cate_KP)values" +
                            "('{0}',NOW(),'{1}','{2}','{3}','{4}','{5}','{6}','{7}')",
                            text_ad_cate_user.Text, Status, text_ad_cate_stage.Text, text_ad_cate_input.Text,
                            text_ad_cate_sp.Text, text_ad_cate_md.Text, text_ad_cate_cate.Text, text_ad_cate_kp.Text);



        try
        {
            if (text_ad_cate_stage.Text.Trim() == "")
            {
                string strScript = string.Format("<script language='javascript'>alert('您沒有輸入Stage,請重新輸入!');</script>");
                Page.ClientScript.RegisterStartupScript(this.GetType(), "onload", strScript);
                Panel_Add_Category.Visible = true;
                Panel_Category_View.Visible = false;
                Panel_update_category.Visible = false;
                Panel_Category.Visible = false;
                
            }
            else if (db.QueryExecuteNonQuery(insert_cap) == true)
            {
                string strScript = string.Format("<script language='javascript'>alert('Stage:" + text_ad_cate_stage.Text + "新增成功');</script>");
                Page.ClientScript.RegisterStartupScript(this.GetType(), "onload", strScript);
                Panel_Add_Category.Visible = false;
                Panel_update_category.Visible = false;
                Panel_Category.Visible = true;
                Response.Redirect(Request.Url.AbsoluteUri);
                DBint(text_ad_cate_stage.Text);
            }
            else
            {
                string strScript = string.Format("<script language='javascript'>alert('新增失敗');</script>");
                Page.ClientScript.RegisterStartupScript(this.GetType(), "onload", strScript);
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }
    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        clsMySQL db = new clsMySQL();

        int index;
        int i = 0;
        index = Convert.ToInt32(e.CommandArgument);
        GridViewRow selecteRow = GridView1.Rows[index];
        TableCell Version = selecteRow.Cells[1];
        TableCell Update_Time  = selecteRow.Cells[2];
        TableCell User = selecteRow.Cells[3];
        TableCell Status = selecteRow.Cells[4];
        TableCell Customer = selecteRow.Cells[5];
        TableCell Device = selecteRow.Cells[6];
        TableCell Site = selecteRow.Cells[7];
        TableCell PKG = selecteRow.Cells[8];
        TableCell WT = selecteRow.Cells[9];
        TableCell FAB = selecteRow.Cells[10];
        TableCell RVSI = selecteRow.Cells[11];
        TableCell New_Customer = selecteRow.Cells[12];
        TableCell New_Device = selecteRow.Cells[13];

        if (e.CommandName == "Setting")
        {
            HttpContext.Current.Session["Version_Name"] = Version.Text ;
            global_Ver_Name = Version.Text;
            string sql_porgodlen = "select * from npieptraver_por where Ver_Name='" + Version.Text + "'";
            string sql_newdevice = "select * from npieptraver_new where Ver_Name='" + Version.Text + "'";
            string sql_gap = "select * from npieptraver_gap where Ver_Name='" + Version.Text + "'";
            string sql_capability = "select * from npieptraver_cap where Ver_Name='" + Version.Text + "'";
            string sql_no = "select * from npieptraver_main where Ver_Name = '" + Version.Text + "'";


            ddl_select_alllv.SelectedIndex = 0;


            string del_str = "delete from npieptra_lv_main where Ver_Name='" + global_Ver_Name + "'";

            if (!db.QueryExecuteNonQuery(del_str))
            {
                lblError.Text = del_str;

            }


            Panel_EPTRA.Visible = true;
            display_PORGOlden_data(sql_porgodlen);
            display_NewDevice_data(sql_newdevice);
            display_Capability_data(sql_capability);
            display_gap_data(sql_gap);
            gap_compare();

            Hide_Value.Value =count_white_lamp.ToString();
            


            string strScript2 = string.Format("<script language='javascript'>var count_lamp =" + count_white_lamp + ";</script>");
            Page.ClientScript.RegisterStartupScript(this.GetType(), "onload", strScript2);
            count_white_lamp = 0;
            string str_no_sta = search_no_sta(sql_no);
            string[] temp_str = str_no_sta.Split('|');
            global_Ver_No = Convert.ToInt32(temp_str[0]);
            global_Ver_Sta = temp_str[1];

           

            Panel_Query_Vername.Visible = false;
            Panel_eptraview.Visible = false;

        }
    }
    protected void Setting_Panel_Lv(Panel temp_Lv,Panel temp_stage,Panel temp_pot, string keyitem,string Lv_sign,Label lab_stage, Label lab_pot)
    {

        List<int> amount_Poten = new List<int>(); // 存放count_EffectLabel_stage 值
        int amount_stage = count_Effectstage(keyitem);
        //int b = count_EffectLabel(keyitem);
        string temp_effect_name = "";
        string temp_pot_name = "";
        string br = "";
        string temp_pot_name2 = "";

       

        if (jude_keyitem(keyitem) == true)
        {
            for (int i = 0; i < amount_stage; i++)
            {
                Label effect = new Label();
                ImageButton TraLv = new ImageButton();
                Label Tratext = new Label();

                temp_effect_name = display_Effectstage(keyitem, i);
                effect.ID ="KeyItem_"+ keyitem +"stage_" + temp_effect_name;
                TraLv.ID = "Imagebutton_" + keyitem + "_" + temp_effect_name;
                amount_Poten.Add(count_EffectLabel_stage(keyitem, temp_effect_name));

                for (int j = 0; j < amount_Poten[i] + 1; j++)
                {
                    br += "<br>";

                }
                count_white_lamp++;
                effect.Text = temp_effect_name + br;
                temp_stage.Controls.Add(effect);

               

                Label Potential = new Label();
                string str = "";

                for (int k = 0; k < amount_Poten[i]; k++) /**/
                {

                    temp_pot_name = display_EffectLabel(keyitem, temp_effect_name, k);
                    temp_pot_name2 += temp_pot_name + "<br />";
                    if (k != (amount_Poten[i] - 1))
                    {
                        str += temp_pot_name + "|";
                    }
                    else
                    {
                        str += temp_pot_name;
                    }


                    if (amount_Poten[i] - 1 == k)
                    {
                        Potential.Text += "<br>";
                    }


                   

                    //Potential.Attributes.Remove("href");
                    //temp_pot.Controls.Add(Potential);
                    all_lv_setting(Lv_sign, keyitem, temp_effect_name, temp_pot_name);
                }

                


                if (Lv_sign == "自行選擇LV")
                {
                    TraLv.ImageUrl = "icon/white.gif";
                }
                else if (Lv_sign== "RC(Lv.3)")
                {
                    TraLv.ImageUrl = "icon/red.gif";
                }
                else if (Lv_sign == "MC(Lv.4)")
                {
                    TraLv.ImageUrl = "icon/red.gif";
                    
                }
                else if (Lv_sign == "LC(Lv.5)")
                {
                    TraLv.ImageUrl = "icon/green.gif";
                    
                }
                



                string session = "filename=" + global_Ver_Name + "&" + "keyitem=" + keyitem + "&" + "stage=" + temp_effect_name + "";


                //TraLv.OnClientClick = "test(" + "\"" + session + "\"" + ");";
                TraLv.OnClientClick = "AddWork_Lv_Setting('" + global_Ver_Name+"','" + keyitem+"','"+temp_effect_name+"')";
                TraLv.Attributes.Add("onclick", "return false;");

                TraLv.Width = Unit.Pixel(30);
                TraLv.Height = Unit.Pixel(30);
                temp_Lv.Controls.Add(TraLv);



                Tratext.Text = br;

                temp_Lv.Controls.Add(Tratext);


                br = "";

                //string redirect = "File_Name='" + Version_name + "'&" + "keyitem='" + keyitem + "'&" + "stage='" + temp_effect_name + "'&" + "SpeChar='" + temp_pot_name + "'";
                //string redirect = "File_Name='" + Version_name + "'&" + "keyitem='" + keyitem + "'&" + "stage='" + temp_effect_name + "'";
                //string url = "DOE_yes.aspx?" + redirect;

                //Potential.NavigateUrl = url;
                //Potential.Target = "_self";
                Potential.ID = "KeyItem" + "_" + keyitem + "Potential_" + temp_pot_name;
                Potential.Text = temp_pot_name2 + "<br />";
                temp_pot_name2 = "";
                temp_pot.Controls.Add(Potential);
            }

        }
        else
        {
            lab_stage.Text = "Not Defined!";
            lab_stage.ForeColor = System.Drawing.Color.Red;
            lab_pot.Text = "Not Defined!";
            lab_pot.ForeColor = System.Drawing.Color.Red;

        }

    }



    protected void all_lv_setting_update(string lv_sign, string keyitem, string stage, string SpeChar)
    {
        clsMySQL db = new clsMySQL();
        string insert_sign = "";
        String insert_lv = string.Format("insert into npieptra_lv_main" +
                               "(Ver_Name,EPTRA_KeyItem,EPTRA_LV_Stage,EPTRA_LV_SpecChar,EPTRA_LV)Values" +
                               "('{0}','{1}','{2}','{3}','{4}')" +
                               "ON DUPLICATE KEY UPDATE EPTRA_KeyItem='{1}',EPTRA_LV_Stage='{2}',EPTRA_LV_SpecChar='{3}',EPTRA_LV='{4}'",
                               global_Ver_Name, keyitem, stage, SpeChar, lv_sign);





        try
        {

            if (db.QueryExecuteNonQuery(insert_lv) == true)
            {

                //t += Convert.ToString(i) + ",";
                insert_sign = "true";

            }
            else
            {
                //f += Convert.ToString(i) + ",";
                insert_sign = "false";
                lblError.Text = insert_lv + db.ToString();

            }
        }
        catch (Exception ex)
        {
            lblError.Text = ex.ToString();
            throw ex;
        }


    }






    protected void all_lv_setting(string lv_sign,string keyitem,string stage,string SpeChar)
    {
        clsMySQL db = new clsMySQL();
        string insert_sign = "";
        String insert_lv = string.Format("insert into npieptra_lv_main" +
                               "(Ver_Name,EPTRA_KeyItem,EPTRA_LV_Stage,EPTRA_LV_SpecChar,EPTRA_LV)Values" +
                               "('{0}','{1}','{2}','{3}','{4}')"+
                               "ON DUPLICATE KEY UPDATE EPTRA_KeyItem='{1}',EPTRA_LV_Stage='{2}',EPTRA_LV_SpecChar='{3}',EPTRA_LV='{4}'",                              
                               global_Ver_Name, keyitem, stage, SpeChar, lv_sign);





        try
        {

            if (db.QueryExecuteNonQuery(insert_lv) == true)
            {

                //t += Convert.ToString(i) + ",";
                insert_sign = "true";
                
            }
            else
            {
                //f += Convert.ToString(i) + ",";
                insert_sign = "false";
                lblError.Text = insert_lv+ db.ToString();
                
            }
        }
        catch (Exception ex)
        {
            lblError.Text = ex.ToString();
            throw ex;
        }
      

    }




    protected void all_lv_put_keyitem_data(string Lv_Sign)
    {

        if (lab_gap1.Text == "Y")
        {
            lab_Eff_01.Text = "--";
            lab_Pot_01.Text = "--";
        }
        else
        {
            lab_Eff_01.Text = "--";
            lab_Pot_01.Text = "--";
        }
        if (lab_gap2.Text == "Y")
        {
            lab_Eff_01.Text = "--";
            lab_Pot_01.Text = "--";
        }
        else
        {
            lab_Eff_01.Text = "--";
            lab_Pot_01.Text = "--";
        }
        if (lab_gap3.Text == "Y")
        {
            lab_Eff_01.Text = "--";
            lab_Pot_01.Text = "--";
        }
        else
        {
            lab_Eff_01.Text = "--";
            lab_Pot_01.Text = "--";
        }
        if (lab_gap4.Text == "Y")
        {
            lab_gap4.Text = "Y";
            lab_gap4.ForeColor = System.Drawing.Color.Red;
           
            Setting_Panel_Lv(Panel_Lv_4, Panel_Eff_04, Panel_Pot_04, Lab_keyitem_04.Text, Lv_Sign, lab_Eff_04, lab_Pot_04);

        }
        else
        {
            lab_gap4.Text = "N";
            lab_gap4.ForeColor = System.Drawing.Color.Blue;
            lab_Eff_04.Text = "--";
            lab_Pot_04.Text = "--";

        }

        if (lab_gap5.Text == "Y")
        {
            lab_gap5.Text = "Y";
            lab_gap5.ForeColor = System.Drawing.Color.Red;
            Setting_Panel_Lv(Panel_Lv_5, Panel_Eff_05, Panel_Pot_05, Lab_keyitem_05.Text, Lv_Sign, lab_Eff_05, lab_Pot_05);
            
        }
        else
        {
            lab_gap5.Text = "N";
            lab_gap5.ForeColor = System.Drawing.Color.Blue;
            lab_Eff_05.Text = "--";
            lab_Pot_05.Text = "--";
        }

        if (lab_gap6.Text == "Y")
        {
            lab_gap6.Text = "Y";
            lab_gap6.ForeColor = System.Drawing.Color.Red;
            Setting_Panel_Lv(Panel_Lv_6, Panel_Eff_06, Panel_Pot_06, Lab_keyitem_06.Text, Lv_Sign, lab_Eff_06, lab_Pot_06);
        }
        else
        {
            lab_gap6.Text = "N";
            lab_gap6.ForeColor = System.Drawing.Color.Blue;
            lab_Eff_06.Text = "--";
            lab_Pot_06.Text = "--";
        }
        if (lab_gap7.Text == "Y")
        {
            lab_gap7.Text = "Y";
            lab_gap7.ForeColor = System.Drawing.Color.Red;
            Setting_Panel_Lv(Panel_Lv_7, Panel_Eff_07, Panel_Pot_07, Lab_keyitem_07.Text, Lv_Sign, lab_Eff_07, lab_Pot_07);
        }
        else
        {
            lab_gap7.Text = "N";
            lab_gap7.ForeColor = System.Drawing.Color.Blue;
            lab_Eff_07.Text = "--";
            lab_Pot_07.Text = "--";
        }
        if (lab_gap8.Text == "Y")
        {
            lab_gap8.Text = "Y";
            lab_gap8.ForeColor = System.Drawing.Color.Red;
            Setting_Panel_Lv(Panel_Lv_8, Panel_Eff_08, Panel_Pot_08, Lab_keyitem_08.Text, Lv_Sign, lab_Eff_08, lab_Pot_08);
        }
        else
        {
            lab_gap8.Text = "N";
            lab_gap8.ForeColor = System.Drawing.Color.Blue;
            lab_Eff_08.Text = "--";
            lab_Pot_08.Text = "--";
        }
        if (lab_gap9.Text == "Y")
        {
            lab_gap9.Text = "Y";
            lab_gap9.ForeColor = System.Drawing.Color.Red;

            Setting_Panel_Lv(Panel_Lv_9, Panel_Eff_09, Panel_Pot_09, Lab_keyitem_09.Text, Lv_Sign, lab_Eff_09, lab_Pot_09);
        }
        else
        {
            lab_gap9.Text = "N";
            lab_gap9.ForeColor = System.Drawing.Color.Blue;
            lab_Eff_09.Text = "--";
            lab_Pot_09.Text = "--";
        }
        if (lab_gap10.Text == "Y")
        {
            lab_gap10.Text = "Y";
            lab_gap10.ForeColor = System.Drawing.Color.Red;
            Setting_Panel_Lv(Panel_Lv_10, Panel_Eff_10, Panel_Pot_10, Lab_keyitem_10.Text, Lv_Sign, lab_Eff_10, lab_Pot_10);
        }
        else
        {
            lab_gap10.Text = "N";
            lab_gap10.ForeColor = System.Drawing.Color.Blue;
            lab_Eff_10.Text = "--";
            lab_Pot_10.Text = "--";
        }
        if (lab_gap11.Text == "Y")
        {
            lab_gap11.Text = "Y";
            lab_gap11.ForeColor = System.Drawing.Color.Red;
            Setting_Panel_Lv(Panel_Lv_11, Panel_Eff_11, Panel_Pot_11, Lab_keyitem_11.Text, Lv_Sign, lab_Eff_11, lab_Pot_11);
        }
        else
        {
            lab_gap11.Text = "N";
            lab_gap11.ForeColor = System.Drawing.Color.Blue;
            lab_Eff_11.Text = "--";
            lab_Pot_11.Text = "--";
        }
        if (lab_gap12.Text == "Y")
        {
            lab_gap12.Text = "Y";
            lab_gap12.ForeColor = System.Drawing.Color.Red;
            Setting_Panel_Lv(Panel_Lv_12, Panel_Eff_12, Panel_Pot_12, Lab_keyitem_12.Text, Lv_Sign, lab_Eff_12, lab_Pot_12);
        }
        else
        {
            lab_gap12.Text = "N";
            lab_gap12.ForeColor = System.Drawing.Color.Blue;
            lab_Eff_12.Text = "--";
            lab_Pot_12.Text = "--";
        }
        if (lab_gap13.Text == "Y")
        {
            lab_gap13.Text = "Y";
            lab_gap13.ForeColor = System.Drawing.Color.Red;
            Setting_Panel_Lv(Panel_Lv_13, Panel_Eff_13, Panel_Pot_13, Lab_keyitem_13.Text, Lv_Sign, lab_Eff_13, lab_Pot_13);
        }
        else
        {
            lab_gap13.Text = "N";
            lab_gap13.ForeColor = System.Drawing.Color.Blue;
            lab_Eff_13.Text = "--";
            lab_Pot_13.Text = "--";
        }

        if (lab_gap14.Text == "Y")
        {
            lab_gap14.Text = "Y";
            lab_gap14.ForeColor = System.Drawing.Color.Red;
            Setting_Panel_Lv(Panel_Lv_14, Panel_Eff_14, Panel_Pot_14, Lab_keyitem_14.Text, Lv_Sign, lab_Eff_14, lab_Pot_14);
        }
        else
        {
            lab_gap14.Text = "N";
            lab_gap14.ForeColor = System.Drawing.Color.Blue;
            lab_Eff_14.Text = "--";
            lab_Pot_14.Text = "--";
        }
        if (lab_gap15.Text == "Y")
        {
            lab_gap15.Text = "Y";
            lab_gap15.ForeColor = System.Drawing.Color.Red;
            Setting_Panel_Lv(Panel_Lv_15, Panel_Eff_15, Panel_Pot_15, Lab_keyitem_15.Text, Lv_Sign, lab_Eff_15, lab_Pot_15);
        }
        else
        {
            lab_gap15.Text = "N";
            lab_gap15.ForeColor = System.Drawing.Color.Blue;
            lab_Eff_15.Text = "--";
            lab_Pot_15.Text = "--";
        }
        if (lab_gap16.Text == "Y")
        {
            lab_gap16.Text = "Y";
            lab_gap16.ForeColor = System.Drawing.Color.Red;
            ///PI Thickness (um)
            Setting_Panel_Lv(Panel_Lv_16, Panel_Eff_16, Panel_Pot_16, Lab_keyitem_16.Text, Lv_Sign, lab_Eff_16, lab_Pot_16);

        }
        else
        {
            lab_gap16.Text = "N";
            lab_gap16.ForeColor = System.Drawing.Color.Blue;
            lab_Eff_16.Text = "--";
            lab_Pot_16.Text = "--";
        }

        if (lab_gap17.Text == "Y")
        {
            lab_gap17.Text = "Y";
            lab_gap17.ForeColor = System.Drawing.Color.Red;
            Setting_Panel_Lv(Panel_Lv_17, Panel_Eff_17, Panel_Pot_17, Lab_keyitem_17.Text, Lv_Sign, lab_Eff_17, lab_Pot_17);
        }
        else
        {
            lab_gap17.Text = "N";
            lab_gap17.ForeColor = System.Drawing.Color.Blue;
            lab_Eff_17.Text = "--";
            lab_Pot_17.Text = "--";
        }

        if (lab_gap18.Text == "Y")
        {
            lab_gap18.Text = "Y";
            lab_gap18.ForeColor = System.Drawing.Color.Red;
            Setting_Panel_Lv(Panel_Lv_18, Panel_Eff_18, Panel_Pot_18, Lab_keyitem_18.Text, Lv_Sign, lab_Eff_18, lab_Pot_18);
        }
        else
        {
            lab_gap18.Text = "N";
            lab_gap18.ForeColor = System.Drawing.Color.Blue;
            lab_Eff_18.Text = "--";
            lab_Pot_18.Text = "--";
        }

        if (lab_gap19.Text == "Y")
        {
            lab_gap19.Text = "Y";
            lab_gap19.ForeColor = System.Drawing.Color.Red;
            Setting_Panel_Lv(Panel_Lv_19, Panel_Eff_19, Panel_Pot_19, Lab_keyitem_19.Text, Lv_Sign, lab_Eff_19, lab_Pot_19);
        }

        else
        {
            lab_gap19.Text = "N";
            lab_gap19.ForeColor = System.Drawing.Color.Blue;
            lab_Eff_19.Text = "--";
            lab_Pot_19.Text = "--";
        }

        if (lab_gap20.Text == "Y")
        {
            lab_gap20.Text = "Y";
            lab_gap20.ForeColor = System.Drawing.Color.Red;
            Setting_Panel_Lv(Panel_Lv_20, Panel_Eff_20, Panel_Pot_20, Lab_keyitem_20.Text, Lv_Sign, lab_Eff_20, lab_Pot_20);
        }
        else
        {
            lab_gap20.Text = "N";
            lab_gap20.ForeColor = System.Drawing.Color.Blue;
            lab_Eff_20.Text = "--";
            lab_Pot_20.Text = "--";
        }

        if (lab_gap21.Text == "Y")
        {
            lab_gap21.Text = "Y";
            lab_gap21.ForeColor = System.Drawing.Color.Red;
            Setting_Panel_Lv(Panel_Lv_21, Panel_Eff_21, Panel_Pot_21, Lab_keyitem_21.Text, Lv_Sign, lab_Eff_21, lab_Pot_21);
        }
        else
        {
            lab_gap21.Text = "N";
            lab_gap21.ForeColor = System.Drawing.Color.Blue;
            lab_Eff_21.Text = "--";
            lab_Pot_21.Text = "--";
        }

        if (lab_gap22.Text == "Y")
        {
            lab_gap22.Text = "Y";
            lab_gap22.ForeColor = System.Drawing.Color.Red;
            Setting_Panel_Lv(Panel_Lv_22, Panel_Eff_22, Panel_Pot_22, Lab_keyitem_22.Text, Lv_Sign, lab_Eff_22, lab_Pot_22);
            
        }
        else
        {
            lab_gap22.Text = "N";
            lab_gap22.ForeColor = System.Drawing.Color.Blue;
            lab_Eff_22.Text = "--";
            lab_Pot_22.Text = "--";
        }

        if (lab_gap23.Text == "Y")
        {
            lab_gap23.Text = "Y";
            lab_gap23.ForeColor = System.Drawing.Color.Red;
            Setting_Panel_Lv(Panel_Lv_23, Panel_Eff_23, Panel_Pot_23, Lab_keyitem_23.Text, Lv_Sign, lab_Eff_23, lab_Pot_23);
           
        }
        else
        {
            lab_gap23.Text = "N";
            lab_gap23.ForeColor = System.Drawing.Color.Blue;
            lab_Eff_23.Text = "--";
            lab_Pot_23.Text = "--";
        }
        if (lab_gap24.Text == "Y")
        {
            lab_gap24.Text = "Y";
            lab_gap24.ForeColor = System.Drawing.Color.Red;
            Setting_Panel_Lv(Panel_Lv_24, Panel_Eff_24, Panel_Pot_24, Lab_keyitem_24.Text, Lv_Sign, lab_Eff_24, lab_Pot_24);
        }
        else
        {
            lab_gap24.Text = "N";
            lab_gap24.ForeColor = System.Drawing.Color.Blue;
            lab_Eff_24.Text = "--";
            lab_Pot_24.Text = "--";
        }

        if (lab_gap25.Text == "Y")
        {
            lab_gap25.Text = "Y";
            lab_gap25.ForeColor = System.Drawing.Color.Red;
            Setting_Panel_Lv(Panel_Lv_25, Panel_Eff_25, Panel_Pot_25, Lab_keyitem_25.Text, Lv_Sign, lab_Eff_25, lab_Pot_25);
        }
        else
        {
            lab_gap25.Text = "N";
            lab_gap25.ForeColor = System.Drawing.Color.Blue;
            lab_Eff_25.Text = "--";
            lab_Pot_25.Text = "--";
        }

        if (lab_gap26.Text == "Y")
        {
            lab_gap26.Text = "Y";
            lab_gap26.ForeColor = System.Drawing.Color.Red;
            Setting_Panel_Lv(Panel_Lv_26, Panel_Eff_26, Panel_Pot_26, Lab_keyitem_26.Text, Lv_Sign, lab_Eff_26, lab_Pot_26);
        }
        else
        {
            lab_gap26.Text = "N";
            lab_gap26.ForeColor = System.Drawing.Color.Blue;
            lab_Eff_26.Text = "--";
            lab_Pot_26.Text = "--";
        }

        if (lab_gap27.Text == "Y")
        {
            lab_gap27.Text = "Y";
            lab_gap27.ForeColor = System.Drawing.Color.Red;
            Setting_Panel_Lv(Panel_Lv_27, Panel_Eff_27, Panel_Pot_27, Lab_keyitem_27.Text, Lv_Sign, lab_Eff_27, lab_Pot_27);

        }
        else
        {
            lab_gap27.Text = "N";
            lab_gap27.ForeColor = System.Drawing.Color.Blue;
            lab_Eff_27.Text = "--";
            lab_Pot_27.Text = "--";
        }

        if (lab_gap28.Text == "Y")
        {
            lab_gap28.Text = "Y";
            lab_gap28.ForeColor = System.Drawing.Color.Red;
            Setting_Panel_Lv(Panel_Lv_28, Panel_Eff_28, Panel_Pot_28, Lab_keyitem_28.Text, Lv_Sign, lab_Eff_28, lab_Pot_28);
        }
        else
        {
            lab_gap28.Text = "N";
            lab_gap28.ForeColor = System.Drawing.Color.Blue;
            lab_Eff_28.Text = "--";
            lab_Pot_28.Text = "--";
        }

        if (lab_gap29.Text == "Y")
        {
            lab_gap29.Text = "Y";
            lab_gap29.ForeColor = System.Drawing.Color.Red;
            Setting_Panel_Lv(Panel_Lv_29, Panel_Eff_29, Panel_Pot_29, Lab_keyitem_29.Text, Lv_Sign, lab_Eff_29, lab_Pot_29);
        }
        else
        {
            lab_gap29.Text = "N";
            lab_gap29.ForeColor = System.Drawing.Color.Blue;
            lab_Eff_29.Text = "--";
            lab_Pot_29.Text = "--";
        }

        if (lab_gap30.Text == "Y")
        {
            lab_gap30.Text = "Y";
            lab_gap30.ForeColor = System.Drawing.Color.Red;
            Setting_Panel_Lv(Panel_Lv_30, Panel_Eff_30, Panel_Pot_30, Lab_keyitem_30.Text, Lv_Sign, lab_Eff_30, lab_Pot_30);
        }
        else
        {
            lab_gap30.Text = "N";
            lab_gap30.ForeColor = System.Drawing.Color.Blue;
            lab_Eff_30.Text = "--";
            lab_Pot_30.Text = "--";
        }

        if (lab_gap31.Text == "Y")
        {
            lab_gap31.Text = "Y";
            lab_gap31.ForeColor = System.Drawing.Color.Red;
            Setting_Panel_Lv(Panel_Lv_31, Panel_Eff_31, Panel_Pot_31, Lab_keyitem_31.Text, Lv_Sign, lab_Eff_31, lab_Pot_31);
        }
        else
        {
            lab_gap31.Text = "N";
            lab_gap31.ForeColor = System.Drawing.Color.Blue;
            lab_Eff_31.Text = "--";
            lab_Pot_31.Text = "--";
        }

        if (lab_gap32.Text == "Y")
        {
            lab_gap32.Text = "Y";
            lab_gap32.ForeColor = System.Drawing.Color.Red;
            Setting_Panel_Lv(Panel_Lv_32, Panel_Eff_32, Panel_Pot_32, Lab_keyitem_32.Text, Lv_Sign, lab_Eff_32, lab_Pot_32);
        }
        else
        {
            lab_gap32.Text = "N";
            lab_gap32.ForeColor = System.Drawing.Color.Blue;
            lab_Eff_32.Text = "--";
            lab_Pot_32.Text = "--";
        }

        if (lab_gap33.Text == "Y")
        {
            lab_gap33.Text = "Y";
            lab_gap33.ForeColor = System.Drawing.Color.Red;
            lab_Eff_33.Text = "--";
            lab_Pot_33.Text = "--";
            Setting_Panel_Lv(Panel_Lv_33, Panel_Eff_33, Panel_Pot_33, Lab_keyitem_33.Text, Lv_Sign, lab_Eff_33, lab_Pot_33);
        }
        else
        {
            lab_gap33.Text = "N";
            lab_gap33.ForeColor = System.Drawing.Color.Blue;
            lab_Eff_33.Text = "--";
            lab_Pot_33.Text = "--";
        }

        if (lab_gap34.Text == "Y")
        {
            lab_gap34.Text = "Y";
            lab_gap34.ForeColor = System.Drawing.Color.Red;
            Setting_Panel_Lv(Panel_Lv_34, Panel_Eff_34, Panel_Pot_34, Lab_keyitem_34.Text, Lv_Sign, lab_Eff_34, lab_Pot_34);
        }
        else
        {
            lab_gap34.Text = "N";
            lab_gap34.ForeColor = System.Drawing.Color.Blue;
            lab_Eff_34.Text = "--";
            lab_Pot_34.Text = "--";
        }

        if (lab_gap35.Text == "Y")
        {
            lab_gap35.Text = "Y";
            lab_gap35.ForeColor = System.Drawing.Color.Red;
            Setting_Panel_Lv(Panel_Lv_35, Panel_Eff_35, Panel_Pot_35, Lab_keyitem_35.Text, Lv_Sign, lab_Eff_35, lab_Pot_35);
        }
        else
        {
            lab_gap35.Text = "N";
            lab_gap35.ForeColor = System.Drawing.Color.Blue;
            lab_Eff_35.Text = "--";
            lab_Pot_35.Text = "--";
        }

        if (lab_gap36.Text == "Y")
        {
            lab_gap36.Text = "Y";
            lab_gap36.ForeColor = System.Drawing.Color.Red;
            Setting_Panel_Lv(Panel_Lv_36, Panel_Eff_36, Panel_Pot_36, Lab_keyitem_36.Text, Lv_Sign, lab_Eff_36, lab_Pot_36);
        }
        else
        {
            lab_gap36.Text = "N";
            lab_gap36.ForeColor = System.Drawing.Color.Blue;
            lab_Eff_36.Text = "--";
            lab_Pot_36.Text = "--";
        }

        if (lab_gap37.Text == "Y")
        {
            lab_gap37.Text = "Y";
            lab_gap37.ForeColor = System.Drawing.Color.Red;
            Setting_Panel_Lv(Panel_Lv_37, Panel_Eff_37, Panel_Pot_37, Lab_keyitem_37.Text, Lv_Sign, lab_Eff_37, lab_Pot_37);
        }
        else
        {
            lab_gap37.Text = "N";
            lab_gap37.ForeColor = System.Drawing.Color.Blue;
            lab_Eff_37.Text = "--";
            lab_Pot_37.Text = "--";
        }

        if (lab_gap38.Text == "Y")
        {
            lab_gap38.Text = "Y";
            lab_gap38.ForeColor = System.Drawing.Color.Red;
            Setting_Panel_Lv(Panel_Lv_38, Panel_Eff_38, Panel_Pot_38, Lab_keyitem_38.Text, Lv_Sign, lab_Eff_38, lab_Pot_38);
        }
        else
        {
            lab_gap38.Text = "N";
            lab_gap38.ForeColor = System.Drawing.Color.Blue;
            lab_Eff_38.Text = "--";
            lab_Pot_38.Text = "--";
        }

        if (lab_gap39.Text == "Y")
        {
            lab_gap39.Text = "Y";
            lab_gap39.ForeColor = System.Drawing.Color.Red;
            Setting_Panel_Lv(Panel_Lv_39, Panel_Eff_39, Panel_Pot_39, Lab_keyitem_39.Text, Lv_Sign, lab_Eff_39, lab_Pot_39);
        }
        else
        {
            lab_gap39.Text = "N";
            lab_gap39.ForeColor = System.Drawing.Color.Blue;
            lab_Eff_39.Text = "--";
            lab_Pot_39.Text = "--";
        }


        if (lab_gap40.Text == "Y")
        {
            lab_gap40.Text = "Y";
            lab_gap40.ForeColor = System.Drawing.Color.Red;
            Setting_Panel_Lv(Panel_Lv_40, Panel_Eff_40, Panel_Pot_40, Lab_keyitem_40.Text, Lv_Sign, lab_Eff_40, lab_Pot_40);
        }
        else
        {
            lab_gap40.Text = "N";
            lab_gap40.ForeColor = System.Drawing.Color.Blue;
            lab_Eff_40.Text = "--";
            lab_Pot_40.Text = "--";
        }


        if (lab_gap41.Text == "Y")
        {
            lab_gap41.Text = "Y";
            lab_gap41.ForeColor = System.Drawing.Color.Red;
            Setting_Panel_Lv(Panel_Lv_41, Panel_Eff_41, Panel_Pot_41, Lab_keyitem_41.Text, Lv_Sign, lab_Eff_41, lab_Pot_41);
        }
        else
        {

            lab_gap41.Text = "N";
            lab_gap41.ForeColor = System.Drawing.Color.Blue;
            lab_Eff_41.Text = "--";
            lab_Pot_41.Text = "--";
        }

        if (lab_gap42.Text == "Y")
        {
            lab_gap42.Text = "Y";
            lab_gap42.ForeColor = System.Drawing.Color.Red;
            Setting_Panel_Lv(Panel_Lv_42, Panel_Eff_42, Panel_Pot_42, Lab_keyitem_42.Text, Lv_Sign, lab_Eff_42, lab_Pot_42);
        }
        else
        {
            lab_gap42.Text = "N";
            lab_gap42.ForeColor = System.Drawing.Color.Blue;
            lab_Eff_42.Text = "--";
            lab_Pot_42.Text = "--";
        }

        if (lab_gap43.Text == "Y")
        {
            lab_gap43.Text = "Y";
            lab_gap43.ForeColor = System.Drawing.Color.Red;
            Setting_Panel_Lv(Panel_Lv_43, Panel_Eff_43, Panel_Pot_43, Lab_keyitem_43.Text, Lv_Sign, lab_Eff_43, lab_Pot_43);
        }
        else
        {
            lab_gap43.Text = "N";
            lab_gap43.ForeColor = System.Drawing.Color.Blue;
            lab_Eff_43.Text = "--";
            lab_Pot_43.Text = "--";
        }

        if (lab_gap44.Text == "Y")
        {
            lab_gap44.Text = "Y";
            lab_gap44.ForeColor = System.Drawing.Color.Red;
            //Setting_Panel_Lv(Panel_Lv_23, Panel_Eff_23, Panel_Pot_23, Lab_keyitem_23.Text, Lv_Sign, lab_Eff_23, lab_Pot_23);
        }
        else
        {
            lab_gap44.Text = "N";
            lab_gap44.ForeColor = System.Drawing.Color.Blue;
            lab_Eff_44.Text = "--";
            lab_Pot_44.Text = "--";
        }

        if (lab_gap45.Text == "Y")
        {
            lab_gap45.Text = "Y";
            lab_gap45.ForeColor = System.Drawing.Color.Red;
            //Setting_Panel_Lv(Panel_Lv_23, Panel_Eff_23, Panel_Pot_23, Lab_keyitem_23.Text, Lv_Sign, lab_Eff_23, lab_Pot_23);
        }
        else
        {
            lab_gap45.Text = "N";
            lab_gap45.ForeColor = System.Drawing.Color.Blue;
            lab_Eff_45.Text = "--";
            lab_Pot_45.Text = "--";
        }

        if (lab_gap46.Text == "Y")
        {
            lab_gap46.Text = "Y";
            lab_gap46.ForeColor = System.Drawing.Color.Red;
            //Setting_Panel_Lv(Panel_Lv_23, Panel_Eff_23, Panel_Pot_23, Lab_keyitem_23.Text, Lv_Sign, lab_Eff_23, lab_Pot_23);
        }
        else
        {
            lab_gap46.Text = "N";
            lab_gap46.ForeColor = System.Drawing.Color.Blue;
            lab_Eff_46.Text = "--";
            lab_Pot_46.Text = "--";
        }


        if (lab_gap47.Text == "Y")
        {
            lab_gap47.Text = "Y";
            lab_gap47.ForeColor = System.Drawing.Color.Red;
            //Setting_Panel_Lv(Panel_Lv_23, Panel_Eff_23, Panel_Pot_23, Lab_keyitem_23.Text, Lv_Sign, lab_Eff_23, lab_Pot_23);
        }
        else
        {
            lab_gap47.Text = "N";
            lab_gap47.ForeColor = System.Drawing.Color.Blue;
            lab_Eff_47.Text = "--";
            lab_Pot_47.Text = "--";

        }

        if (lab_gap48.Text == "Y")
        {
            lab_gap48.Text = "Y";
            lab_gap48.ForeColor = System.Drawing.Color.Red;
            //Setting_Panel_Lv(Panel_Lv_23, Panel_Eff_23, Panel_Pot_23, Lab_keyitem_23.Text, Lv_Sign, lab_Eff_23, lab_Pot_23);
        }
        else
        {
            lab_gap48.Text = "N";
            lab_gap48.ForeColor = System.Drawing.Color.Blue;
            lab_Eff_48.Text = "--";
            lab_Pot_48.Text = "--";
        }

        if (lab_gap49.Text == "Y")
        {
            lab_gap49.Text = "Y";
            lab_gap49.ForeColor = System.Drawing.Color.Red;
            //Setting_Panel_Lv(Panel_Lv_23, Panel_Eff_23, Panel_Pot_23, Lab_keyitem_23.Text, Lv_Sign, lab_Eff_23, lab_Pot_23);
        }
        else
        {
            lab_gap49.Text = "N";
            lab_gap49.ForeColor = System.Drawing.Color.Blue;
            lab_Eff_49.Text = "--";
            lab_Pot_49.Text = "--";
        }






        if (lab_gap51.Text == "Y")
        {
            lab_gap51.Text = "Y";
            lab_gap51.ForeColor = System.Drawing.Color.Red;
            //Setting_Panel_Lv(Panel_Lv_23, Panel_Eff_23, Panel_Pot_23, Lab_keyitem_23.Text, Lv_Sign, lab_Eff_23, lab_Pot_23);
        }
        else
        {
            lab_gap51.Text = "N";
            lab_gap51.ForeColor = System.Drawing.Color.Blue;
            lab_Pot_51.Text = "--";
            lab_Eff_51.Text = "--";
        }

        if (lab_gap52.Text == "Y")
        {
            lab_gap52.Text = "Y";
            lab_gap52.ForeColor = System.Drawing.Color.Red;
            //Setting_Panel_Lv(Panel_Lv_23, Panel_Eff_23, Panel_Pot_23, Lab_keyitem_23.Text, Lv_Sign, lab_Eff_23, lab_Pot_23);
        }
        else
        {
            lab_gap52.Text = "N";
            lab_gap52.ForeColor = System.Drawing.Color.Blue;
            lab_Eff_52.Text = "--";
            lab_Pot_52.Text = "--";
        }

        if (lab_gap53.Text == "Y")
        {
            lab_gap53.Text = "Y";
            lab_gap53.ForeColor = System.Drawing.Color.Red;
            Setting_Panel_Lv(Panel_Lv_23, Panel_Eff_23, Panel_Pot_23, Lab_keyitem_23.Text, Lv_Sign, lab_Eff_23, lab_Pot_23);
        }
        else
        {
            lab_gap53.Text = "N";
            lab_gap53.ForeColor = System.Drawing.Color.Blue;
            lab_Eff_53.Text = "--";
            lab_Pot_53.Text = "--";
        }

        if (lab_gap54.Text == "Y")
        {
            lab_gap54.Text = "Y";
            lab_gap54.ForeColor = System.Drawing.Color.Red;
            Setting_Panel_Lv(Panel_Lv_54, Panel_Eff_54, Panel_Pot_54, Lab_keyitem_45_4.Text, Lv_Sign, lab_Eff_54, lab_Pot_54);
        }
        else
        {
            lab_gap54.Text = "N";
            lab_gap54.ForeColor = System.Drawing.Color.Blue;
            lab_Eff_54.Text = "--";
            lab_Pot_54.Text = "--";
        }

        if (lab_gap55.Text == "Y")
        {
            lab_gap55.Text = "Y";
            lab_gap55.ForeColor = System.Drawing.Color.Red;
            Setting_Panel_Lv(Panel_Lv_55, Panel_Eff_55, Panel_Pot_55, Lab_keyitem_46.Text, Lv_Sign, lab_Eff_55, lab_Pot_55);
        }
        else
        {
            lab_gap55.Text = "N";
            lab_gap55.ForeColor = System.Drawing.Color.Blue;
            lab_Eff_55.Text = "--";
            lab_Pot_55.Text = "--";
        }

        if (lab_gap56.Text == "Y")
        {
            lab_gap56.Text = "Y";
            lab_gap56.ForeColor = System.Drawing.Color.Red;
            Setting_Panel_Lv(Panel_Lv_56, Panel_Eff_56, Panel_Pot_56, Lab_keyitem_47.Text, Lv_Sign, lab_Eff_56, lab_Pot_56);
        }
        else
        {
            lab_gap56.Text = "N";
            lab_gap56.ForeColor = System.Drawing.Color.Blue;
            lab_Eff_56.Text = "--";
            lab_Pot_56.Text = "--";
        }

        if (lab_gap57.Text == "Y")
        {
            lab_gap57.Text = "Y";
            lab_gap57.ForeColor = System.Drawing.Color.Red;
            Setting_Panel_Lv(Panel_Lv_57, Panel_Eff_57, Panel_Pot_57, Lab_keyitem_48.Text, Lv_Sign, lab_Eff_57, lab_Pot_57);
        }
        else
        {
            lab_gap57.Text = "N";
            lab_gap57.ForeColor = System.Drawing.Color.Blue;
            lab_Eff_57.Text = "--";
            lab_Pot_57.Text = "--";
        }

        if (lab_gap58.Text == "Y")
        {
            lab_gap58.Text = "Y";
            lab_gap58.ForeColor = System.Drawing.Color.Red;
            Setting_Panel_Lv(Panel_Lv_58, Panel_Eff_58, Panel_Pot_58, Lab_keyitem_49.Text, Lv_Sign, lab_Eff_58, lab_Pot_58);
        }
        else
        {
            lab_gap58.Text = "N";
            lab_gap58.ForeColor = System.Drawing.Color.Blue;
            lab_Eff_58.Text = "--";
            lab_Pot_58.Text = "--";
        }


        if (lab_gap59.Text == "Y")
        {
            lab_gap59.Text = "Y";
            lab_gap59.ForeColor = System.Drawing.Color.Red;
            Setting_Panel_Lv(Panel_Lv_59, Panel_Eff_59, Panel_Pot_59, Lab_keyitem_59.Text, Lv_Sign, lab_Eff_59, lab_Pot_59);

        }
        else
        {
            lab_gap59.Text = "N";
            lab_gap59.ForeColor = System.Drawing.Color.Blue;
            lab_Eff_59.Text = "--";
            lab_Pot_59.Text = "--";
        }


        if (lab_gap60.Text == "Y")
        {
            lab_gap60.Text = "Y";
            lab_gap60.ForeColor = System.Drawing.Color.Red;
            Setting_Panel_Lv(Panel_Lv_60, Panel_Eff_60, Panel_Pot_60, Lab_keyitem_60.Text, Lv_Sign, lab_Eff_60, lab_Pot_60);
        }
        else
        {
            lab_gap60.Text = "N";
            lab_gap60.ForeColor = System.Drawing.Color.Blue;
            lab_Eff_60.Text = "--";
            lab_Pot_60.Text = "--";
        }

        if (lab_gap61.Text == "Y")
        {
            lab_gap61.Text = "Y";
            lab_gap61.ForeColor = System.Drawing.Color.Red;
            Setting_Panel_Lv(Panel_Lv_61, Panel_Eff_61, Panel_Pot_61, Lab_keyitem_61.Text, Lv_Sign, lab_Eff_61, lab_Pot_61);
        }
        else
        {
            lab_gap61.Text = "N";
            lab_gap61.ForeColor = System.Drawing.Color.Blue;
            lab_Eff_61.Text = "--";
            lab_Pot_61.Text = "--";
        }

        if (lab_gap62.Text == "Y")
        {
            lab_gap62.Text = "Y";
            lab_gap62.ForeColor = System.Drawing.Color.Red;
            lab_Eff_62.Text = "--";
            lab_Pot_62.Text = "--";
        }
        else
        {
            lab_gap62.Text = "N";
            lab_gap62.ForeColor = System.Drawing.Color.Blue;
            lab_Eff_62.Text = "--";
            lab_Pot_62.Text = "--";
        }

        if (lab_gap63.Text == "Y")
        {
            lab_gap63.Text = "Y";
            lab_gap63.ForeColor = System.Drawing.Color.Red;
            lab_Eff_63.Text = "--";
            lab_Pot_63.Text = "--";
        }
        else
        {
            lab_gap63.Text = "N";
            lab_gap63.ForeColor = System.Drawing.Color.Blue;
            lab_Pot_63.Text = "--";
            lab_Eff_63.Text = "--";
        }

        if (lab_gap64.Text == "Y")
        {
            lab_gap64.Text = "Y";
            lab_gap64.ForeColor = System.Drawing.Color.Red;
            lab_Eff_64.Text = "--";
            lab_Pot_64.Text = "--";
        }
        else
        {
            lab_gap64.Text = "N";
            lab_gap64.ForeColor = System.Drawing.Color.Blue;
            lab_Eff_64.Text = "--";
            lab_Pot_64.Text = "--";
        }

        if (lab_gap65.Text == "Y")
        {
            lab_gap65.Text = "Y";
            lab_gap65.ForeColor = System.Drawing.Color.Red;
            lab_Eff_65.Text = "--";
            lab_Pot_65.Text = "--";
        }
        else
        {
            lab_gap65.Text = "N";
            lab_gap65.ForeColor = System.Drawing.Color.Blue;
            lab_Eff_65.Text = "--";
            lab_Pot_65.Text = "--";
        }





    }





    [System.Web.Services.WebMethod]
    
    public static void  jyny(string prefix)
    {
        //Response.Redirect("EP_TRA.aspx");
        int i = 0;
    }








    protected void ddl_select_alllv_SelectedIndexChanged(object sender, EventArgs e)
    {
        clsMySQL db = new clsMySQL();
        string lv_sign = ddl_select_alllv.SelectedValue;
        

        switch(lv_sign)
        {

            case "自行選擇LV":
                //ddl_select_alllv.SelectedIndex = 3;

                
                string strScript = string.Format("<script language='javascript'>ALL_Level('" + lv_sign + "','" + select_lv_before + "');</script>");
                Page.ClientScript.RegisterStartupScript(this.GetType(), "onload", strScript);

                select_lv_before = ddl_select_alllv.SelectedValue;
              
                break;
            case "RC(Lv.3)":


                string strScript2 = string.Format("<script language='javascript'>ALL_Level('" + lv_sign + "','" + select_lv_before + "');</script>");
                Page.ClientScript.RegisterStartupScript(this.GetType(), "onload", strScript2);
                hf_Lvsign.Value = lv_sign;

                /*if(hf_sign.Value=="t")
                {
                    all_lv_put_keyitem_data(select_lv_before);
                }*/


                select_lv_before = ddl_select_alllv.SelectedValue;
                           
                
                
                break;
            case "MC(Lv.4)":


                string strScript3 = string.Format("<script language='javascript'>ALL_Level('" + lv_sign + "','" + select_lv_before + "');</script>");
                Page.ClientScript.RegisterStartupScript(this.GetType(), "onload", strScript3);
                hf_Lvsign.Value = lv_sign;

                /*if (hf_sign.Value == "t")
                {
                    all_lv_put_keyitem_data(select_lv_before);
                }*/

                select_lv_before = ddl_select_alllv.SelectedValue;
                

            
                
                break;
            case "LC(Lv.5)":


                string strScript4 = string.Format("<script language='javascript'>ALL_Level('" + lv_sign + "','" + select_lv_before + "');</script>");
                Page.ClientScript.RegisterStartupScript(this.GetType(), "onload", strScript4);
                hf_Lvsign.Value = lv_sign;
                /*if (hf_sign.Value == "t")
                {
                    all_lv_put_keyitem_data(select_lv_before);
                }*/

                select_lv_before = ddl_select_alllv.SelectedValue;
               
              
                
                break;
        }




    }

    







    

    protected void cmdFilter_Click(object sender, EventArgs e)
    {
        
        
            string CreateName = "cre_CIM";
            string UpName = "up_CIM";
            string Signoff_SendName = "sing_CIM";
            clsMySQL db = new clsMySQL();

            String insert_lv = string.Format("insert into npieptra_lv_main_status" +
                           "(Ver_Name,Ver_No,Ver_Status,CreateTime,CreateName,UpdateTime,UpdateName," +
                           "LV_Signoff_Status,LV_Signoff_SendName,LV_Signoff_SendTime)Values" +
                           "('{0}','{1}','{2}',NOW(),'{3}',NOW(),'{4}','{5}','{6}',NOW())",
                           global_Ver_Name, global_Ver_No, global_Ver_Sta, CreateName, UpName, "NA", Signoff_SendName);

            if (!db.QueryExecuteNonQuery(insert_lv))
            {
                lblError.Text = insert_lv;
                string strScript = string.Format("<script language='javascript'>alert('送審失敗!');</script>");
                Page.ClientScript.RegisterStartupScript(this.GetType(), "onload", strScript);


            }
            else
            {
                Response.Write("<script language=javascript>alert('送審成功!')</script>");
                Response.Write("<script language=javascript>window.location.href='EPTRA_LV_Setting.aspx'</script>");

            }
     }
    protected void btnUpload_Click(object sender, EventArgs e)
    {
        
        string sheet_name = "";
        int sheet_num;
        int dLastNum;
        int cate_items = 0;
        String Cate_Username = "******";
        String Cate_Status = "Y";
        DateTime dt = DateTime.Now;
        string inf_ID = "";
        List<string> List_Inf_ID = new List<string>();
        Boolean sign_count = false;
        /*List<string> Cate_Iiitems = new List<string>();
        List<string> Cate_SpeChar = new List<string>();
        List<string> Cate_Md = new List<string>();
        List<string> Cate_Cate = new List<string>();
        List<string> Cate_KP = new List<string>();
        */
        List<int> success_insert = new List<int>();
        List<int> fail_insert = new List<int>();
        int success_count = 0;
        int fail_count = 0;
        List<string> history_cate = new List<string>();
        string fileName = "";
        string time = "";
        string count_sheet_name = "";
       int debug_count=0;
        Boolean sign = false;
        Boolean sign_repeat = false;
       clsMySQL db = new clsMySQL();



        try
        {



            fileName = Path.GetFileName(FileUploadToServer.PostedFile.FileName);
            //string filePath = Server.MapPath("~\\bruno\\FileUpload_Folder\\") + Path.GetFileName(FileUploadToServer.PostedFile.FileName);
            string filePath = Server.MapPath("FileUpload_Folder\\") + Path.GetFileName(FileUploadToServer.PostedFile.FileName);
            FileUploadToServer.SaveAs(filePath);





            if (CheckExcelFile(fileName))
            {

                /*
                 if (FileUploadToServer.HasFile)
                {

                }
                 */

                XSSFWorkbook wk = new XSSFWorkbook(FileUploadToServer.FileContent);
                XSSFSheet hst;
                XSSFRow hr;
                DataTable myDT = new DataTable();

                sheet_num = wk.NumberOfSheets;

                for (int k = 0; k < sheet_num; k++) //從每張工作表開始做
                {
                    hst = (XSSFSheet)wk.GetSheetAt(k);
                    cate_items = hst.LastRowNum; //每一張工作表有幾筆資料

                    sheet_name = hst.SheetName;

                    if (k != sheet_num - 1) //顯示匯入的Stage有哪些
                        count_sheet_name += sheet_name + ",";
                    else
                        count_sheet_name += sheet_name;

                    hr = (XSSFRow)hst.GetRow(0);
                    dLastNum = hr.LastCellNum; //每一列的欄位數


                    /*  for (int i = hr.FirstCellNum; i < hr.LastCellNum; i++)
                      {
                          if (hr.GetCell(i) != null)
                          {
                              DataColumn myColumn = new DataColumn(hr.GetCell(i).StringCellValue);
                              myDT.Columns.Add(myColumn);

                          }

                      }*/



                    for (int j = 1; j <= cate_items; j++)
                    {
                        hr = (XSSFRow)hst.GetRow(j);
                        //XSSFRow row = (XSSFRow) mySheet.GetRow(i);
                        DataRow myrow = myDT.NewRow();
                        /*for(int i=1;i<dLastNum;i++)
                        {
                            //string strcell = hr.GetCell(i) == null ? "0" : hr.GetCell(i).ToString();
                            myrow = 

                        }*/



                        String insert_cate = string.Format("insert into npi_ep_category" +
                                                   "(npi_EP_Cate_Username,npi_EP_Cate_UpdateTime,npi_EP_Cate_Status," +
                                                 "EP_Cate_Stage,EP_Cate_Iiitems,EP_Cate_SpeChar," +
                                                 "EP_Cate_Md,EP_Cate_Cate,EP_Cate_KP)values" +
                                                 "('{0}',NOW(),'{1}'," +
                                                  "'{2}','{3}','{4}','{5}','{6}','{7}')"
                                                  , Cate_Username, Cate_Status, sheet_name, hr.GetCell(0), hr.GetCell(1), hr.GetCell(2), hr.GetCell(3), hr.GetCell(4));
                        string excel_sql = sheet_name +"|"+ hr.GetCell(0) + "|" + hr.GetCell(1) + "|" + hr.GetCell(2) + "|" + hr.GetCell(3) + "|" + hr.GetCell(4);
                        Label1.Text = dt.ToString("yyyy/MM/dd hh:mm:ss");
                        time = Label1.Text;

                       

                        
                        if (jude_npiepcategory_data(excel_sql, sheet_name) == true)
                        {
                            if (db.QueryExecuteNonQuery(insert_cate) == true)
                            {
                                success_count++;
                                sign = true;

                            }
                            else
                            {
                                fail_count++;
                                history_cate.Add(hr.GetCell(0) + "|" + hr.GetCell(1) + "|" + hr.GetCell(2) + "|" + hr.GetCell(3) + "|" + hr.GetCell(4));
                            }
                            debug_count++;
                        }                        
                        else
                        { 
                            List_Inf_ID.Add(Session["value_ID"].ToString());                            
                            sign_repeat = true;
                            sign_count = true;
                        }
                        Session.Clear();
                        debug_count = 0;
                    }
                }
                wk = null;
                hst = null;
                hr = null;

            }
            else {
                lblMsg.ForeColor = System.Drawing.Color.Red;
                lblMsg.Text = "您選擇的[" + fileName + "]無法匯入,請重新選擇Excel檔案或檢查Excel檔案內容!!";
            }

            
            /*string strScript2 = string.Format("<script language='javascript'>alert('完成匯入\\n成功匯入筆數:" + success_count + "\\n匯入的Stage:" + count_sheet_name + "');</script>");
            Page.ClientScript.RegisterStartupScript(this.GetType(), "onload", strScript2);*/
            Lab_item.Text = success_count.ToString();
            Lab_Stage.Text = count_sheet_name;
            lblMsg.Text = fileName + "上傳成功!!";
            System.IO.File.Delete(filePath);

            if (sign_count == true) { 
            for (int i = 0; i < List_Inf_ID.Count; i++)
            {
                inf_ID += List_Inf_ID[i];
            }
                string[] spilit_inf_id = inf_ID.Split(',');
                
            


            string strScript2 = string.Format("<script language='javascript'>alert('重複資料筆數:"+List_Inf_ID.Count.ToString()+"\\n資料重複編號:" + str_id(spilit_inf_id) + "');</script>");
            Page.ClientScript.RegisterStartupScript(this.GetType(), "onload", strScript2);
            }

        }
        catch (Exception exfile)
        {
            lblMsg.ForeColor = System.Drawing.Color.Red;
            excp.Text = exfile.ToString();
            if (fileName == "")
            {
                lblMsg.Text = "[Import Error Message] 請選擇要匯入的Excel檔案!!";
            }
            else {
                lblMsg.Text = "[Import Error Message]您選擇的[" + fileName + "]無法匯入,請重新選擇Excel檔案或檢查Excel檔案內容!!";
            }
        }

        finally
        {
            /*string strScript = string.Format("<script language='javascript'>alert('您沒有輸入Packge_Name!');</script>");
            Page.ClientScript.RegisterStartupScript(this.GetType(), "onload", strScript);*/
            
        }

        string sql_cate_datetime = "select * from npi_ep_category where npi_ep_category.npi_EP_Cate_UpdateTime >= DATE_FORMAT('" + time+ "', '%Y/%m/%d %H:%i:%s')";
        //DATE_FORMAT('2016/04/28 11:26:00', '%Y/%m/%d %H:%i:%s')
        

        if (sign == true)
        {
            clsMySQL ds = new clsMySQL();
            clsMySQL.DBReply dr = ds.QueryDS(sql_cate_datetime);
            gvRecord.DataSource = dr.dsDataSet.Tables[0].DefaultView;
            gvRecord.DataBind();
            ds.Close();
        }
        /*if(sign==true)
        {
            clsMySQL ds = new clsMySQL();
            clsMySQL.DBReply dr = ds.QueryDS(sql_cate_datetime);
            gvRecord2.DataSource = dr.dsDataSet.Tables[0].DefaultView;
            gvRecord2.DataBind();
            ds.Close();
        }*/







    }
    protected void LinkButton1_Click(object sender, EventArgs e)
    {
        clsMySQL db = new clsMySQL();

        string temp = "";
        temp = Session["value_cap_pkgname"].ToString();

        string Status = "Y";
        string User_Name = "CIM";
        String update_cap = string.Format("update  npi_cap_ep set " +
                                   "CAP_EP_Name='{0}',Update_Time=NOW(),npiuser='******',CAP_EP_Status='{2}'," +
                                 "CAP_EP_01='{3}',CAP_EP_02='{4}',CAP_EP_03='{5}',CAP_EP_04='{6}',CAP_EP_05='{7}'," +
                                 "CAP_EP_06='{8}',CAP_EP_07='{9}',CAP_EP_08='{10}',CAP_EP_09='{11}',CAP_EP_10='{12}'," +
                                 "CAP_EP_11='{13}',CAP_EP_12='{14}',CAP_EP_13='{15}',CAP_EP_14='{16}',CAP_EP_15='{17}'," +
                                 "CAP_EP_16='{18}',CAP_EP_17='{19}',CAP_EP_18='{20}',CAP_EP_19='{21}',CAP_EP_20='{22}'," +
                                 "CAP_EP_21='{23}',CAP_EP_22='{24}',CAP_EP_23='{25}',CAP_EP_24='{26}',CAP_EP_25='{27}'," +
                                 "CAP_EP_26='{28}',CAP_EP_27='{29}',CAP_EP_28='{30}',CAP_EP_29='{31}',CAP_EP_30='{32}'," +
                                 "CAP_EP_31='{33}',CAP_EP_32='{34}',CAP_EP_33='{35}',CAP_EP_34='{36}',CAP_EP_35='{37}'," +
                                 "CAP_EP_36='{38}',CAP_EP_37='{39}',CAP_EP_38='{40}',CAP_EP_39='{41}',CAP_EP_40='{42}'," +
                                 "CAP_EP_41='{43}',CAP_EP_42='{44}',CAP_EP_43='{45}',CAP_EP_44='{46}',CAP_EP_45='{47}'," +
                                 "CAP_EP_46='{48}',CAP_EP_47='{49}',CAP_EP_48='{50}',CAP_EP_49='{51}',CAP_EP_50='{52}'," +
                                 "CAP_EP_51='{53}',CAP_EP_52='{54}',CAP_EP_53='{55}',CAP_EP_54='{56}',CAP_EP_55='{57}'," +
                                 "CAP_EP_56='{58}',CAP_EP_57='{59}',CAP_EP_58='{60}',CAP_EP_59='{61}',CAP_EP_60='{62}'," +
                                 "CAP_EP_61='{63}',CAP_EP_62='{64}',CAP_EP_63='{65}',CAP_EP_64='{66}',CAP_EP_65='{67}'," +
                                 "CAP_POR_EP_01='{68}',CAP_POR_EP_02='{69}',CAP_POR_EP_03='{70}',CAP_POR_EP_04='{71}',CAP_POR_EP_05='{72}'," +
                                 "CAP_POR_EP_06='{73}',CAP_POR_EP_07='{74}',CAP_POR_EP_08='{75}',CAP_POR_EP_09='{76}',CAP_POR_EP_10='{77}'," +
                                 "CAP_POR_EP_11='{78}',CAP_POR_EP_12='{79}',CAP_POR_EP_13='{80}',CAP_POR_EP_14='{81}',CAP_POR_EP_15='{82}' where CAP_EP_Name='" + temp + "'"
                                  , Text_UP_PK_Name.Text, User_Name, Status,
                                  Text__UP_CAP_1.Text, Text__UP_CAP_2.Text, Text__UP_CAP_3.Text, Text__UP_CAP_4.Text, Text__UP_CAP_5.Text,
                                  Text__UP_CAP_6.Text, Text__UP_CAP_7.Text, Text__UP_CAP_8.Text, Text__UP_CAP_9.Text, Text__UP_CAP_10.Text,
                                  Text__UP_CAP_11.Text, Text__UP_CAP_12.Text, Text__UP_CAP_13.Text, Text__UP_CAP_14.Text, Text__UP_CAP_15.Text,
                                  Text__UP_CAP_16.Text, Text__UP_CAP_17.Text, Text__UP_CAP_18.Text, Text__UP_CAP_19.Text, Text__UP_CAP_20.Text,
                                  Text__UP_CAP_21.Text, Text__UP_CAP_21.Text, Text__UP_CAP_22.Text, Text__UP_CAP_23.Text, Text__UP_CAP_25.Text,
                                  Text__UP_CAP_26.Text, Text__UP_CAP_27.Text, Text__UP_CAP_28.Text, Text__UP_CAP_29.Text, Text__UP_CAP_30.Text,
                                  Text__UP_CAP_31.Text, Text__UP_CAP_32.Text, Text__UP_CAP_33.Text, Text__UP_CAP_34.Text, Text__UP_CAP_35.Text,
                                  Text__UP_CAP_36.Text, Text__UP_CAP_37.Text, Text__UP_CAP_38.Text, Text__UP_CAP_39.Text, Text__UP_CAP_40.Text,
                                  Text__UP_CAP_41.Text, Text__UP_CAP_42.Text, Text__UP_CAP_43.Text, Text__UP_CAP_44.Text, Text__UP_CAP_45.Text,
                                  Text__UP_CAP_46.Text, Text__UP_CAP_47.Text, Text__UP_CAP_48.Text, Text__UP_CAP_49.Text, Text__UP_CAP_50.Text,
                                  Text__UP_CAP_51.Text, Text__UP_CAP_52.Text, Text__UP_CAP_53.Text, Text__UP_CAP_54.Text, Text__UP_CAP_55.Text,
                                  Text__UP_CAP_56.Text, Text__UP_CAP_57.Text, Text__UP_CAP_58.Text, Text__UP_CAP_59.Text, Text__UP_CAP_60.Text,
                                  Text__UP_CAP_61.Text, Text__UP_CAP_62.Text, Text__UP_CAP_63.Text, Text__UP_CAP_64.Text, Text__UP_CAP_65.Text,
                                   Text_UP_CAP_POR_1.Text, Text_UP_CAP_POR_2.Text, Text_UP_CAP_POR_3.Text, Text_UP_CAP_POR_4.Text, Text_UP_CAP_POR_5.Text,
                                 Text_UP_CAP_POR_6.Text, Text_UP_CAP_POR_7.Text, Text_UP_CAP_POR_8.Text, Text_UP_CAP_POR_9.Text, Text_UP_CAP_POR_10.Text,
                                 Text_UP_CAP_POR_11.Text, Text_UP_CAP_POR_12.Text, Text_UP_CAP_POR_13.Text, Text_UP_CAP_POR_14.Text, Text_UP_CAP_POR_15.Text);


        try
        {

            if (db.QueryExecuteNonQuery(update_cap))
            {
                RegisterStartupScript("訊息通知", "<script> alert('資料更新,成功!!');</script>");
                Panel_CAP_Table_View.Visible = false;
                Panel_CAP_Table_Update.Visible = false;
                Panel_CAP_table.Visible = false;
                Panel_Packge.Visible = true;
                DBint();
                //ChangeViewMode();
            }
            else
            {
                //lblError.Text = strSQL_Delete;
                RegisterStartupScript("訊息通知", "<script> alert('資料更新,失敗!!');</script>");
            }
        }
        catch (FormatException ex)
        {
            lblError.Text = "[Error Message::NPI Manual Form Delete Function]: " + ex.ToString();
        }

    }
    protected void up_lv_signoff_sta(string sign,int rowindex,string com)
    {
        string ver = GridView1.Rows[rowindex].Cells[2].Text;
        string Lv_Sign = Lv_sign.Value;

        string sign_Name = "jj";
        clsMySQL db = new clsMySQL();

        String update_Lv = string.Format("UPDATE npieptra_lv_main_status " +
                              "SET LV_Signoff_Status='{0}',LV_Signoff_Name='{1}',LV_Signoff_Time=NOW(),LV_Signoff_Command='{2}'" +
                              "where Ver_Name='{3}' and LV_Signoff_Status='{4}' "
                              ,sign, sign_Name,com, ver, "NA");

        string str_eptraver_main_sta = "select * from npieptra_lv_main_Status where Ver_Name='" + ver + "'";
        
        try
        {

            if (db.QueryExecuteNonQuery(update_Lv) == true)
            {

                if(Lv_Sign == "Acc")
                {
                    string strScript = string.Format("<script language='javascript'>alert('"+ver+"簽核完成!');</script>");
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "onload", strScript);
                }
                else if(Lv_Sign == "Rej")
                {
                    string strScript = string.Format("<script language='javascript'>alert('" + ver + "簽核完成!');</script>");
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "onload", strScript);
                }                               
                

                clsMySQL.DBReply dr = db.QueryDS(str_eptraver_main_sta);
                GridView2.DataSource = dr.dsDataSet.Tables[0].DefaultView;
                GridView2.DataBind();
                set_sta_srt("gv2");

            }
            else
            {
                lblError.Text = update_Lv;
            }

        }
        catch (Exception ex)
        {
            throw ex;
        }
        db.Close();


    }
Esempio n. 22
0
    protected void Button_Add_Click(object sender, EventArgs e)
    {
        clsMySQL db = new clsMySQL();

        string Status     = "Y";
        string User_Name  = "CIM";
        String insert_cap = string.Format("insert into npi_cap_ep" +
                                          "(CAP_EP_Name,Update_Time,npiuser,CAP_EP_Status," +
                                          "CAP_EP_01,CAP_EP_02,CAP_EP_03,CAP_EP_04,CAP_EP_05," +
                                          "CAP_EP_06,CAP_EP_07,CAP_EP_08,CAP_EP_09,CAP_EP_10," +
                                          "CAP_EP_11,CAP_EP_12,CAP_EP_13,CAP_EP_14,CAP_EP_15," +
                                          "CAP_EP_16,CAP_EP_17,CAP_EP_18,CAP_EP_19,CAP_EP_20," +
                                          "CAP_EP_21,CAP_EP_22,CAP_EP_23,CAP_EP_24,CAP_EP_25," +
                                          "CAP_EP_26,CAP_EP_27,CAP_EP_28,CAP_EP_29,CAP_EP_30," +
                                          "CAP_EP_31,CAP_EP_32,CAP_EP_33,CAP_EP_34,CAP_EP_35," +
                                          "CAP_EP_36,CAP_EP_37,CAP_EP_38,CAP_EP_39,CAP_EP_40," +
                                          "CAP_EP_41,CAP_EP_42,CAP_EP_43,CAP_EP_44,CAP_EP_45," +
                                          "CAP_EP_46,CAP_EP_47,CAP_EP_48,CAP_EP_49,CAP_EP_50," +
                                          "CAP_EP_51,CAP_EP_52,CAP_EP_53,CAP_EP_54,CAP_EP_55," +
                                          "CAP_EP_56,CAP_EP_57,CAP_EP_58,CAP_EP_59,CAP_EP_60," +
                                          "CAP_EP_61,CAP_EP_62,CAP_EP_63,CAP_EP_64,CAP_EP_65," +
                                          "CAP_POR_EP_01,CAP_POR_EP_02,CAP_POR_EP_03,CAP_POR_EP_04,CAP_POR_EP_05," +
                                          "CAP_POR_EP_06,CAP_POR_EP_07,CAP_POR_EP_08,CAP_POR_EP_09,CAP_POR_EP_10," +
                                          "CAP_POR_EP_11,CAP_POR_EP_12,CAP_POR_EP_13,CAP_POR_EP_14,CAP_POR_EP_15)values" +
                                          "('{0}',NOW(),'{1}','{2}'," +
                                          "'{3}','{4}','{5}','{6}','{7}'," +
                                          "'{8}','{9}','{10}','{11}','{12}'," +
                                          "'{13}','{14}','{15}','{16}','{17}'," +
                                          "'{18}','{19}','{20}','{21}','{22}'," +
                                          "'{23}','{24}','{25}','{26}','{27}'," +
                                          "'{28}','{29}','{30}','{31}','{32}'," +
                                          "'{33}','{34}','{35}','{36}','{37}'," +
                                          "'{38}','{39}','{40}','{41}','{42}'," +
                                          "'{43}','{44}','{45}','{46}', '{47}'," +
                                          "'{48}','{49}','{50}','{51}','{52}'," +
                                          "'{53}','{54}','{55}','{56}','{57}'," +
                                          "'{58}','{59}','{60}','{61}','{62}'," +
                                          "'{63}','{64}','{65}','{66}','{67}'," +
                                          "'{68}','{69}','{70}','{71}','{72}'," +
                                          "'{73}','{74}','{75}','{76}','{77}'," +
                                          "'{78}','{79}','{80}','{81}','{82}')"
                                          , Text_Packge_insert.Text, User_Name, Status,
                                          Text__CAP_1.Text, Text__CAP_2.Text, Text__CAP_3.Text, Text__CAP_4.Text, Text__CAP_5.Text,
                                          Text__CAP_6.Text, Text__CAP_7.Text, Text__CAP_8.Text, Text__CAP_9.Text, Text__CAP_10.Text,
                                          Text__CAP_11.Text, Text__CAP_12.Text, Text__CAP_13.Text, Text__CAP_14.Text, Text__CAP_15.Text,
                                          Text__CAP_16.Text, Text__CAP_17.Text, Text__CAP_18.Text, Text__CAP_19.Text, Text__CAP_20.Text,
                                          Text__CAP_21.Text, Text__CAP_21.Text, Text__CAP_22.Text, Text__CAP_23.Text, Text__CAP_25.Text,
                                          Text__CAP_26.Text, Text__CAP_27.Text, Text__CAP_28.Text, Text__CAP_29.Text, Text__CAP_30.Text,
                                          Text__CAP_31.Text, Text__CAP_32.Text, Text__CAP_33.Text, Text__CAP_34.Text, Text__CAP_35.Text,
                                          Text__CAP_36.Text, Text__CAP_37.Text, Text__CAP_38.Text, Text__CAP_39.Text, Text__CAP_40.Text,
                                          Text__CAP_41.Text, Text__CAP_42.Text, Text__CAP_43.Text, Text__CAP_44.Text, Text__CAP_45.Text,
                                          Text__CAP_46.Text, Text__CAP_47.Text, Text__CAP_48.Text, Text__CAP_49.Text, Text__CAP_50.Text,
                                          Text__CAP_51.Text, Text__CAP_52.Text, Text__CAP_53.Text, Text__CAP_54.Text, Text__CAP_55.Text,
                                          Text__CAP_56.Text, Text__CAP_57.Text, Text__CAP_58.Text, Text__CAP_59.Text, Text__CAP_60.Text,
                                          Text__CAP_61.Text, Text__CAP_62.Text, Text__CAP_63.Text, Text__CAP_64.Text, Text__CAP_65.Text,
                                          Text_CAP_POR_EP_01.Text, Text_CAP_POR_EP_2.Text, Text_CAP_POR_EP_3.Text, Text_CAP_POR_EP_4.Text, Text_CAP_POR_EP_5.Text,
                                          Text_CAP_POR_EP_6.Text, Text_CAP_POR_EP_7.Text, Text_CAP_POR_EP_8.Text, Text_CAP_POR_EP_9.Text, Text_CAP_POR_EP_10.Text,
                                          Text_CAP_POR_EP_11.Text, Text_CAP_POR_EP_12.Text, Text_CAP_POR_EP_13.Text, Text_CAP_POR_EP_14.Text, Text_CAP_POR_EP_15.Text);

        try
        {
            if (Text_Packge_insert.Text.Trim() == "")
            {
                string strScript = string.Format("<script language='javascript'>alert('您沒有輸入Packge_Name!');</script>");
                Page.ClientScript.RegisterStartupScript(this.GetType(), "onload", strScript);
            }
            else if (db.QueryExecuteNonQuery(insert_cap) == true)
            {
                string strScript = string.Format("<script language='javascript'>alert('Packge:" + Text_Packge_insert.Text + "新增成功');</script>");
                Page.ClientScript.RegisterStartupScript(this.GetType(), "onload", strScript);
                Panel_CAP_table.Visible = false;
                Panel_Packge.Visible    = true;
                DBint();
            }
            else
            {
                string strScript = string.Format("<script language='javascript'>alert('Packge:" + Text_Packge_insert.Text + "新增失敗');</script>");
                Page.ClientScript.RegisterStartupScript(this.GetType(), "onload", strScript);
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }
Esempio n. 23
0
    protected void btnInsert_Click(object sender, EventArgs e)
    {
        string user    = "******";
        string vn      = Session["Version_Name"].ToString();
        string keyitem = Session["keyitem"].ToString();
        string stage   = Session["stage"].ToString();

        clsMySQL db = new clsMySQL();

        string SpeChar = "";
        string md      = "";
        string cate    = "";
        string kp      = "";

        string t = "";
        string f = "";


        for (int i = 0; i < GridView1.Rows.Count; i++)
        {
            SpeChar = GridView1.Rows[i].Cells[0].Text;
            md      = GridView1.Rows[i].Cells[1].Text;
            cate    = GridView1.Rows[i].Cells[2].Text;
            kp      = GridView1.Rows[i].Cells[3].Text;
            DropDownList ddl_Lv      = (DropDownList)GridView1.Rows[i].Cells[4].FindControl("Doe_Lv");
            string       select_str2 = ddl_Lv.SelectedValue;

            String insert_cap = string.Format("insert into npi_eptra_doe_lv" +
                                              "(Lv_filename,Lv_User,Lv_UpdateTime,Lv_stage,Lv_SpecChar," +
                                              "Lv_Iiitems,Lv_md,Lv_cate," +
                                              "Lv_kp,Lv_TraLv)values" +
                                              "('{0}','{1}',NOW(),'{2}','{3}','{4}','{5}','{6}','{7}','{8}')",
                                              vn, user, stage, SpeChar,
                                              keyitem, md, cate, kp, select_str2);



            try
            {
                if (db.QueryExecuteNonQuery(insert_cap) == true)
                {
                    t += Convert.ToString(i) + ",";
                }
                else
                {
                    f += Convert.ToString(i) + ",";
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }


        //Response.Redirect("EP_TRA_DOE_Create.aspx");



        string strScript = string.Format("<script language='javascript'>temp(" + stage + ");</script>");

        Page.ClientScript.RegisterStartupScript(this.GetType(), "onload", strScript);
    }
    protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        //lblError.Text = e.Keys["C_Code"].ToString() + "////" + e.Values.ToString();        
        clsMySQL db = new clsMySQL();
        try
        {   
            GridViewRow gvrow = GridView1.Rows[e.RowIndex];

            lblError.Text = gvrow.Cells[1].Text + "////" + gvrow.Cells[2].Text;
            string strSQL_Delete = string.Format("Delete from npiManual where New_Customer='{0}' and  New_Device='{1}'",
                                                gvrow.Cells[1].Text.Trim(), gvrow.Cells[2].Text.Trim());

            if (db.QueryExecuteNonQuery(strSQL_Delete))
            {
                RegisterStartupScript("訊息通知", "<script> alert('資料已刪除,成功!!');</script>");                
                ChangeViewMode();
            }
            else
            {
                //lblError.Text = strSQL_Delete;
                RegisterStartupScript("訊息通知", "<script> alert('資料刪除,失敗!!');</script>");
            }
        }
        catch (FormatException ex)
        {
            lblError.Text = "[Error Message::NPI Manual Form Delete Function]: " + ex.ToString();
        }        
    }
Esempio n. 25
0
    protected void LinkButton1_Click(object sender, EventArgs e)
    {
        clsMySQL db = new clsMySQL();

        string temp = "";

        temp = Session["value_cap_pkgname"].ToString();

        string Status     = "Y";
        string User_Name  = "CIM";
        String update_cap = string.Format("update  npi_cap_ep set " +
                                          "CAP_EP_Name='{0}',Update_Time=NOW(),npiuser='******',CAP_EP_Status='{2}'," +
                                          "CAP_EP_01='{3}',CAP_EP_02='{4}',CAP_EP_03='{5}',CAP_EP_04='{6}',CAP_EP_05='{7}'," +
                                          "CAP_EP_06='{8}',CAP_EP_07='{9}',CAP_EP_08='{10}',CAP_EP_09='{11}',CAP_EP_10='{12}'," +
                                          "CAP_EP_11='{13}',CAP_EP_12='{13}',CAP_EP_13='{14}',CAP_EP_14='{15}',CAP_EP_15='{16}'," +
                                          "CAP_EP_16='{17}',CAP_EP_17='{18}',CAP_EP_18='{19}',CAP_EP_19='{20}',CAP_EP_20='{21}'," +
                                          "CAP_EP_21='{22}',CAP_EP_22='{23}',CAP_EP_23='{24}',CAP_EP_24='{25}',CAP_EP_25='{26}'," +
                                          "CAP_EP_26='{27}',CAP_EP_27='{28}',CAP_EP_28='{29}',CAP_EP_29='{30}',CAP_EP_30='{31}'," +
                                          "CAP_EP_31='{32}',CAP_EP_32='{33}',CAP_EP_33='{34}',CAP_EP_34='{35}',CAP_EP_35='{36}'," +
                                          "CAP_EP_36='{37}',CAP_EP_37='{38}',CAP_EP_38='{39}',CAP_EP_39='{40}',CAP_EP_40='{41}'," +
                                          "CAP_EP_41='{42}',CAP_EP_42='{43}',CAP_EP_43='{44}',CAP_EP_44='{45}',CAP_EP_45='{46}'," +
                                          "CAP_EP_46='{47}',CAP_EP_47='{48}',CAP_EP_48='{49}',CAP_EP_49='{50}',CAP_EP_50='{51}'," +
                                          "CAP_EP_51='{52}',CAP_EP_52='{53}',CAP_EP_53='{54}',CAP_EP_54='{55}',CAP_EP_55='{56}'," +
                                          "CAP_EP_56='{57}',CAP_EP_57='{58}',CAP_EP_58='{59}',CAP_EP_59='{60}',CAP_EP_60='{61}'," +
                                          "CAP_EP_61='{62}',CAP_EP_62='{63}',CAP_EP_63='{64}',CAP_EP_64='{65}',CAP_EP_65='{66}'," +
                                          "CAP_POR_EP_01='{67}',CAP_POR_EP_02='{68}',CAP_POR_EP_03='{69}',CAP_POR_EP_04='{70}',CAP_POR_EP_05='{70}'," +
                                          "CAP_POR_EP_06='{71}',CAP_POR_EP_07='{72}',CAP_POR_EP_08='{73}',CAP_POR_EP_09='{74}',CAP_POR_EP_10='{75}'," +
                                          "CAP_POR_EP_11='{76}',CAP_POR_EP_12='{77}',CAP_POR_EP_13='{78}',CAP_POR_EP_14='{79}',CAP_POR_EP_15='{80}' where CAP_EP_Name='" + temp + "'"
                                          , Text_UP_PK_Name.Text, User_Name, Status,
                                          Text__UP_CAP_1.Text, Text__UP_CAP_2.Text, Text__UP_CAP_3.Text, Text__UP_CAP_4.Text, Text__UP_CAP_5.Text,
                                          Text__UP_CAP_6.Text, Text__UP_CAP_7.Text, Text__UP_CAP_8.Text, Text__UP_CAP_9.Text, Text__UP_CAP_10.Text,
                                          Text__UP_CAP_11.Text, Text__UP_CAP_12.Text, Text__UP_CAP_13.Text, Text__UP_CAP_14.Text, Text__UP_CAP_15.Text,
                                          Text__UP_CAP_16.Text, Text__UP_CAP_17.Text, Text__UP_CAP_18.Text, Text__UP_CAP_19.Text, Text__UP_CAP_20.Text,
                                          Text__UP_CAP_21.Text, Text__UP_CAP_21.Text, Text__UP_CAP_22.Text, Text__UP_CAP_23.Text, Text__UP_CAP_25.Text,
                                          Text__UP_CAP_26.Text, Text__UP_CAP_27.Text, Text__UP_CAP_28.Text, Text__UP_CAP_29.Text, Text__UP_CAP_30.Text,
                                          Text__UP_CAP_31.Text, Text__UP_CAP_32.Text, Text__UP_CAP_33.Text, Text__UP_CAP_34.Text, Text__UP_CAP_35.Text,
                                          Text__UP_CAP_36.Text, Text__UP_CAP_37.Text, Text__UP_CAP_38.Text, Text__UP_CAP_39.Text, Text__UP_CAP_40.Text,
                                          Text__UP_CAP_41.Text, Text__UP_CAP_42.Text, Text__UP_CAP_43.Text, Text__UP_CAP_44.Text, Text__UP_CAP_45.Text,
                                          Text__UP_CAP_46.Text, Text__UP_CAP_47.Text, Text__UP_CAP_48.Text, Text__UP_CAP_49.Text, Text__UP_CAP_50.Text,
                                          Text__UP_CAP_51.Text, Text__UP_CAP_52.Text, Text__UP_CAP_53.Text, Text__UP_CAP_54.Text, Text__UP_CAP_55.Text,
                                          Text__UP_CAP_56.Text, Text__UP_CAP_57.Text, Text__UP_CAP_58.Text, Text__UP_CAP_59.Text, Text__UP_CAP_60.Text,
                                          Text__UP_CAP_61.Text, Text__UP_CAP_62.Text, Text__UP_CAP_63.Text, Text__UP_CAP_64.Text, Text__UP_CAP_65.Text,
                                          Text_UP_CAP_POR_1.Text, Text_UP_CAP_POR_2.Text, Text_UP_CAP_POR_3.Text, Text_UP_CAP_POR_4.Text, Text_UP_CAP_POR_5.Text,
                                          Text_UP_CAP_POR_6.Text, Text_UP_CAP_POR_7.Text, Text_UP_CAP_POR_8.Text, Text_UP_CAP_POR_9.Text, Text_UP_CAP_POR_10.Text,
                                          Text_UP_CAP_POR_11.Text, Text_UP_CAP_POR_12.Text, Text_UP_CAP_POR_13.Text, Text_UP_CAP_POR_14.Text, Text_UP_CAP_POR_15.Text);


        try
        {
            if (db.QueryExecuteNonQuery(update_cap))
            {
                RegisterStartupScript("訊息通知", "<script> alert('資料更新,成功!!');</script>");
                Panel_CAP_Table_View.Visible   = false;
                Panel_CAP_Table_Update.Visible = false;
                Panel_CAP_table.Visible        = false;
                Panel_Packge.Visible           = true;
                DBint();
                //ChangeViewMode();
            }
            else
            {
                //lblError.Text = strSQL_Delete;
                RegisterStartupScript("訊息通知", "<script> alert('資料更新,失敗!!');</script>");
            }
        }
        catch (FormatException ex)
        {
            lblError.Text = "[Error Message::NPI Manual Form Delete Function]: " + ex.ToString();
        }
    }
Esempio n. 26
0
    protected void btnInsert_Click(object sender, EventArgs e)
    {
        string user = "******";
        string vn = Session["Version_Name"].ToString();
        string keyitem = Session["keyitem"].ToString();
        string stage = Session["stage"].ToString();
        int    Max = 0, count = 0;;
        string sign_Lv    = "";
        string CreateName = "cre_CIM";
        string UpName     = "up_CIM";
        string sta        = "Y";

        clsMySQL db = new clsMySQL();

        string SpeChar = "";
        string md      = "";
        string cate    = "";
        string kp      = "";

        string t           = "";
        string f           = "";
        string insert_sign = "";
        string up_sign     = "";

        string[] split_vn = vn.Split('_');
        string   temp_no  = split_vn[2];

        char[]   pat    = new char[] { 'V', 'e', 'r' };/**/
        string[] str_no = temp_no.Split(pat);

        int no = Convert.ToInt32(str_no[3]);

        if (jude_Lv(vn, stage, keyitem, SpeChar))
        {
            for (int i = 0; i < GridView1.Rows.Count; i++)
            {
                SpeChar = GridView1.Rows[i].Cells[2].Text;

                DropDownList ddl_Lv      = (DropDownList)GridView1.Rows[i].Cells[3].FindControl("Doe_Lv");
                string       select_str2 = ddl_Lv.SelectedValue;



                String insert_lv = string.Format("insert into npieptra_lv_main" +
                                                 "(Ver_Name,Ver_No,Ver_Status,CreateTime,CreateName," +
                                                 "UpdateName,LV_Signoff_Status,LV_Signoff_Name,LV_Signoff_Time," +
                                                 "EPTRA_KeyItem,EPTRA_LV_Stage,EPTRA_LV_SpecChar,EPTRA_LV)values" +
                                                 "('{0}','{1}','{2}',NOW(),'{3}','{4}','{5}','{6}',NOW(),'{7}','{8}','{9}','{10}')",
                                                 vn, no, sta, CreateName, "", "NA", CreateName, keyitem, stage, SpeChar, select_str2);



                try
                {
                    if (db.QueryExecuteNonQuery(insert_lv) == true)
                    {
                        //t += Convert.ToString(i) + ",";
                        insert_sign = "true";
                    }
                    else
                    {
                        //f += Convert.ToString(i) + ",";
                        insert_sign   = "false";
                        lblError.Text = insert_lv;
                        break;
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            if (insert_sign == "true")
            {
                string str1 = string.Format("<script language='javascript'>alert('EPTRA_Lv新增成功!');</script>");
                Page.ClientScript.RegisterStartupScript(this.GetType(), "onload", str1);
            }
            else
            {
                string str1 = string.Format("<script language='javascript'>alert('EPTRA_Lv新增失敗!');</script>");
                Page.ClientScript.RegisterStartupScript(this.GetType(), "onload", str1);
            }
        }
        else
        {
            for (int i = 0; i < GridView1.Rows.Count; i++)
            {
                SpeChar = GridView1.Rows[i].Cells[2].Text;

                DropDownList ddl_Lv      = (DropDownList)GridView1.Rows[i].Cells[3].FindControl("Doe_Lv");
                string       select_str2 = ddl_Lv.SelectedValue;



                /*create user & update user 問題*/
                String update_Lv = string.Format("UPDATE npieptra_lv_main " +
                                                 " SET EPTRA_LV='{0}',UpdateTime=NOW(),UpdateName='{1}'" +
                                                 "where Ver_Name='{2}' and Ver_No='{3}' and EPTRA_KeyItem='{4}' and EPTRA_LV_Stage='{5}' and EPTRA_LV_SpecChar='{6}'"
                                                 , select_str2, UpName, vn, no, keyitem, stage, SpeChar);



                try
                {
                    if (db.QueryExecuteNonQuery(update_Lv) == true)
                    {
                        //t += Convert.ToString(i) + ",";
                        up_sign = "true";
                    }
                    else
                    {
                        //f += Convert.ToString(i) + ",";
                        up_sign       = "false";
                        lblError.Text = update_Lv;
                        break;
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
    protected void GD_CAP_RowDeleting1(object sender, GridViewDeleteEventArgs e)
    {
        clsMySQL db = new clsMySQL();
        try
        {

            GridViewRow gvrow = GD_CAP.Rows[e.RowIndex];

            //lblError.Text = gvrow.Cells[1].Text + "////" + gvrow.Cells[2].Text;
            string strSQL_Delete = string.Format("Delete from npi_cap_ep where CAP_EP_Name='{0}'",
                                                gvrow.Cells[1].Text.Trim());

            if (db.QueryExecuteNonQuery(strSQL_Delete))
            {
                RegisterStartupScript("訊息通知", "<script> alert('資料已刪除,成功!!');</script>");
                DBint();
                //ChangeViewMode();
            }
            else
            {
                //lblError.Text = strSQL_Delete;
                RegisterStartupScript("訊息通知", "<script> alert('資料刪除,失敗!!');</script>");
            }
        }
        catch (FormatException ex)
        {
            lblError.Text = "[Error Message::NPI Manual Form Delete Function]: " + ex.ToString();
        }
    }
Esempio n. 28
0
    protected void btnUpload_Click(object sender, EventArgs e)
    {
        String SavePath   = "D:\\brunohuang\\FileUpload_Folder\\";
        string sheet_name = "";
        int    sheet_num;
        int    dLastNum;
        int    cate_items    = 0;
        String Cate_Username = "******";
        String Cate_Status   = "Y";

        /*List<string> Cate_Iiitems = new List<string>();
         * List<string> Cate_SpeChar = new List<string>();
         * List<string> Cate_Md = new List<string>();
         * List<string> Cate_Cate = new List<string>();
         * List<string> Cate_KP = new List<string>();
         */
        List <int>    success_insert = new List <int>();
        List <int>    fail_insert    = new List <int>();
        int           success_count  = 0;
        int           fail_count     = 0;
        List <string> history_cate   = new List <string>();
        string        fileName       = "";
        clsMySQL      db             = new clsMySQL();

        try {
            fileName = Path.GetFileName(FileUploadToServer.PostedFile.FileName);
            string filePath = Server.MapPath("~\\FileUpload\\") + Path.GetFileName(FileUploadToServer.PostedFile.FileName);
            FileUploadToServer.SaveAs(filePath);


            lblMsg.Text = "上傳成功!!" + SavePath;


            if (CheckExcelFile(fileName))
            {
                /*
                 * if (FileUploadToServer.HasFile)
                 * {
                 *
                 * }
                 */

                XSSFWorkbook wk = new XSSFWorkbook(FileUploadToServer.FileContent);
                XSSFSheet    hst;
                XSSFRow      hr;
                DataTable    myDT = new DataTable();

                sheet_num = wk.NumberOfSheets;

                for (int k = 0; k < sheet_num; k++)
                {
                    hst        = (XSSFSheet)wk.GetSheetAt(k);
                    cate_items = hst.LastRowNum; //每一張工作表有幾筆資料

                    sheet_name = hst.SheetName;

                    hr       = (XSSFRow)hst.GetRow(0);
                    dLastNum = hr.LastCellNum; //每一列的欄位數


                    for (int i = hr.FirstCellNum; i < hr.LastCellNum; i++)
                    {
                        if (hr.GetCell(i) != null)
                        {
                            DataColumn myColumn = new DataColumn(hr.GetCell(i).StringCellValue);
                            myDT.Columns.Add(myColumn);
                        }
                    }



                    for (int j = 1; j <= cate_items; j++)
                    {
                        hr = (XSSFRow)hst.GetRow(j);
                        XSSFRow row   = (XSSFRow)mySheet.GetRow(i);
                        DataRow myrow = myDT.NewRow();
                        for (int i = 1; i < dLastNum; i++)
                        {
                            //string strcell = hr.GetCell(i) == null ? "0" : hr.GetCell(i).ToString();
                            myrow =
                        }



                        String insert_cate = string.Format("insert into npi_ep_category" +
                                                           "(npi_EP_Cate_Username,npi_EP_Cate_UpdateTime,npi_EP_Cate_Status," +
                                                           "EP_Cate_Stage,EP_Cate_Iiitems,EP_Cate_SpeChar," +
                                                           "EP_Cate_Md,EP_Cate_Cate,EP_Cate_KP)values" +
                                                           "('{0}',NOW(),'{1}'," +
                                                           "'{2}','{3}','{4}','{5}','{6}','{7}')"
                                                           , Cate_Username, Cate_Status, sheet_name, hr.GetCell(0), hr.GetCell(1), hr.GetCell(2), hr.GetCell(3), hr.GetCell(4));
                        if (db.QueryExecuteNonQuery(insert_cate) == true)
                        {
                            success_count++;
                        }
                        else
                        {
                            fail_count++;
                            history_cate.Add(hr.GetCell(0) + "|" + hr.GetCell(1) + "|" + hr.GetCell(2) + "|" + hr.GetCell(3) + "|" + hr.GetCell(4));
                        }
                    }
                }
            }
            else
            {
                lblMsg.ForeColor = System.Drawing.Color.Red;
                lblMsg.Text      = "您選擇的[" + fileName + "]無法匯入,請重新選擇Excel檔案或檢查Excel檔案內容!!";
            }
        }
        catch (Exception exfile)
        {
            lblMsg.ForeColor = System.Drawing.Color.Red;
            if (fileName == "")
            {
                lblMsg.Text = "[Import Error Message] 請選擇要匯入的Excel檔案!!";
            }
            else
            {
                lblMsg.Text = "[Import Error Message]您選擇的[" + fileName + "]無法匯入,請重新選擇Excel檔案或檢查Excel檔案內容!!";
            }
        }
    }
    protected void Button_Add_Click(object sender, EventArgs e)
    {
        clsMySQL db = new clsMySQL();

        string Status = "Y";
        string User_Name = "CIM";
        String insert_cap = string.Format("insert into npi_cap_ep" +
                                        "(CAP_EP_Name,Update_Time,npiuser,CAP_EP_Status," +
                                      "CAP_EP_01,CAP_EP_02,CAP_EP_03,CAP_EP_04,CAP_EP_05," +
                                      "CAP_EP_06,CAP_EP_07,CAP_EP_08,CAP_EP_09,CAP_EP_10," +
                                      "CAP_EP_11,CAP_EP_12,CAP_EP_13,CAP_EP_14,CAP_EP_15," +
                                      "CAP_EP_16,CAP_EP_17,CAP_EP_18,CAP_EP_19,CAP_EP_20," +
                                      "CAP_EP_21,CAP_EP_22,CAP_EP_23,CAP_EP_24,CAP_EP_25," +
                                      "CAP_EP_26,CAP_EP_27,CAP_EP_28,CAP_EP_29,CAP_EP_30," +
                                      "CAP_EP_31,CAP_EP_32,CAP_EP_33,CAP_EP_34,CAP_EP_35," +
                                      "CAP_EP_36,CAP_EP_37,CAP_EP_38,CAP_EP_39,CAP_EP_40," +
                                      "CAP_EP_41,CAP_EP_42,CAP_EP_43,CAP_EP_44,CAP_EP_45," +
                                      "CAP_EP_46,CAP_EP_47,CAP_EP_48,CAP_EP_49,CAP_EP_50," +
                                      "CAP_EP_51,CAP_EP_52,CAP_EP_53,CAP_EP_54,CAP_EP_55," +
                                      "CAP_EP_56,CAP_EP_57,CAP_EP_58,CAP_EP_59,CAP_EP_60," +
                                      "CAP_EP_61,CAP_EP_62,CAP_EP_63,CAP_EP_64,CAP_EP_65," +
                                      "CAP_POR_EP_01,CAP_POR_EP_02,CAP_POR_EP_03,CAP_POR_EP_04,CAP_POR_EP_05," +
                                      "CAP_POR_EP_06,CAP_POR_EP_07,CAP_POR_EP_08,CAP_POR_EP_09,CAP_POR_EP_10," +
                                      "CAP_POR_EP_11,CAP_POR_EP_12,CAP_POR_EP_13,CAP_POR_EP_14,CAP_POR_EP_15)values" +
                                      "('{0}',NOW(),'{1}','{2}'," +
                                       "'{3}','{4}','{5}','{6}','{7}'," +
                                       "'{8}','{9}','{10}','{11}','{12}'," +
                                       "'{13}','{14}','{15}','{16}','{17}'," +
                                       "'{18}','{19}','{20}','{21}','{22}'," +
                                       "'{23}','{24}','{25}','{26}','{27}'," +
                                       "'{28}','{29}','{30}','{31}','{32}'," +
                                       "'{33}','{34}','{35}','{36}','{37}'," +
                                       "'{38}','{39}','{40}','{41}','{42}'," +
                                       "'{43}','{44}','{45}','{46}', '{47}'," +
                                       "'{48}','{49}','{50}','{51}','{52}'," +
                                       "'{53}','{54}','{55}','{56}','{57}'," +
                                       "'{58}','{59}','{60}','{61}','{62}'," +
                                       "'{63}','{64}','{65}','{66}','{67}'," +
                                       "'{68}','{69}','{70}','{71}','{72}'," +
                                       "'{73}','{74}','{75}','{76}','{77}'," +
                                       "'{78}','{79}','{80}','{81}','{82}')"
                                       , Text_Packge_insert.Text, User_Name, Status,
                                       Text__CAP_1.Text, Text__CAP_2.Text, Text__CAP_3.Text, Text__CAP_4.Text, Text__CAP_5.Text,
                                       Text__CAP_6.Text, Text__CAP_7.Text, Text__CAP_8.Text, Text__CAP_9.Text, Text__CAP_10.Text,
                                       Text__CAP_11.Text, Text__CAP_12.Text, Text__CAP_13.Text, Text__CAP_14.Text, Text__CAP_15.Text,
                                       Text__CAP_16.Text, Text__CAP_17.Text, Text__CAP_18.Text, Text__CAP_19.Text, Text__CAP_20.Text,
                                       Text__CAP_21.Text, Text__CAP_21.Text, Text__CAP_22.Text, Text__CAP_23.Text, Text__CAP_25.Text,
                                       Text__CAP_26.Text, Text__CAP_27.Text, Text__CAP_28.Text, Text__CAP_29.Text, Text__CAP_30.Text,
                                       Text__CAP_31.Text, Text__CAP_32.Text, Text__CAP_33.Text, Text__CAP_34.Text, Text__CAP_35.Text,
                                       Text__CAP_36.Text, Text__CAP_37.Text, Text__CAP_38.Text, Text__CAP_39.Text, Text__CAP_40.Text,
                                       Text__CAP_41.Text, Text__CAP_42.Text, Text__CAP_43.Text, Text__CAP_44.Text, Text__CAP_45.Text,
                                       Text__CAP_46.Text, Text__CAP_47.Text, Text__CAP_48.Text, Text__CAP_49.Text, Text__CAP_50.Text,
                                       Text__CAP_51.Text, Text__CAP_52.Text, Text__CAP_53.Text, Text__CAP_54.Text, Text__CAP_55.Text,
                                       Text__CAP_56.Text, Text__CAP_57.Text, Text__CAP_58.Text, Text__CAP_59.Text, Text__CAP_60.Text,
                                       Text__CAP_61.Text, Text__CAP_62.Text, Text__CAP_63.Text, Text__CAP_64.Text, Text__CAP_65.Text,
                                        Text_CAP_POR_EP_01.Text, Text_CAP_POR_EP_2.Text, Text_CAP_POR_EP_3.Text, Text_CAP_POR_EP_4.Text, Text_CAP_POR_EP_5.Text,
                                      Text_CAP_POR_EP_6.Text, Text_CAP_POR_EP_7.Text, Text_CAP_POR_EP_8.Text, Text_CAP_POR_EP_9.Text, Text_CAP_POR_EP_10.Text,
                                      Text_CAP_POR_EP_11.Text, Text_CAP_POR_EP_12.Text, Text_CAP_POR_EP_13.Text, Text_CAP_POR_EP_14.Text, Text_CAP_POR_EP_15.Text);

        try
        {
            if (Text_Packge_insert.Text.Trim()=="")
            {
                string strScript = string.Format("<script language='javascript'>alert('您沒有輸入Packge_Name!');</script>");
                Page.ClientScript.RegisterStartupScript(this.GetType(), "onload", strScript);
            }
            else if(db.QueryExecuteNonQuery(insert_cap) == true)
            {
                string strScript = string.Format("<script language='javascript'>alert('Packge:" + Text_Packge_insert.Text + "新增成功');</script>");
                Page.ClientScript.RegisterStartupScript(this.GetType(), "onload", strScript);
                Panel_CAP_table.Visible = false;
                Panel_Packge.Visible = true;
                DBint();
            }
            else
            {
                string strScript = string.Format("<script language='javascript'>alert('Packge:" + Text_Packge_insert.Text + "新增失敗');</script>");
                Page.ClientScript.RegisterStartupScript(this.GetType(), "onload", strScript);
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }
    protected void Button_Cancel_Click(object sender, EventArgs e)
    {
        clsMySQL db = new clsMySQL();
        Panel_Query_Vername.Visible = true;
        Panel_eptraview.Visible = true;
        Panel_EPTRA.Visible = false;
       
        string del_str = "delete from npieptra_lv_main where Ver_Name='" + global_Ver_Name + "'";

        if (!db.QueryExecuteNonQuery(del_str))
        {
            lblError.Text = del_str;

        }
       


    }
    /*public void getData()
    {
        DataTable aTb = WebUtility.GetSQLdata("select * from product where id='0';", "teachDB");

        if (aTb.Rows.Count == 0)
        {

            aTb.Rows.Add(aTb.NewRow());

            GridView1.DataSource = aTb;
            GridView1.DataBind();


            int columnCount = GridView1.Rows[0].Cells.Count;
            GridView1.Rows[0].Cells.Clear();
            GridView1.Rows[0].Cells.Add(new TableCell());

            GridView1.Rows[0].Cells[0].ColumnSpan = columnCount;
            GridView1.Rows[0].Cells[0].Text = "無資料!";
            GridView1.RowStyle.HorizontalAlign = System.Web.UI.WebControls.HorizontalAlign.Center;
        }
        else
        {
            GridView1.DataSource = aTb;
            GridView1.DataBind();
        }


    }*/



    protected void Button_Update_Click(object sender, EventArgs e)
    {
        clsMySQL db = new clsMySQL();
        int index;
        string Status = "Y";
        index = Convert.ToInt32(Session["gvrow_index"].ToString());
        GridViewRow gvrow = GD_CATE.Rows[index];
        Session.Clear();




        String update_cate = string.Format("update  npi_ep_category set " +
            "npi_EP_Cate_Username='******',npi_EP_Cate_UpdateTime=NOW(),npi_EP_Cate_Status='{1}'," +
            "EP_Cate_Stage='{2}',EP_Cate_Iiitems='{3}',EP_Cate_SpeChar='{4}'," +
            "EP_Cate_Md='{5}',EP_Cate_Cate='{6}',EP_Cate_KP='{7}' " +
            "where EP_Cate_Stage='{8}' and  EP_Cate_Iiitems='{9}' and EP_Cate_SpeChar='{10}'" +
            "and EP_Cate_Md='{11}'and EP_Cate_Cate='{12}' and EP_Cate_KP='{13}' "
            , text_up_cate_user.Text, Status, text_cate_stage.Text, text_cate_input.Text
            , text_cate_sp.Text, text_cate_md.Text, text_cate_cate.Text, text_cate_kp.Text
            , gvrow.Cells[1].Text.Trim(), gvrow.Cells[2].Text.Trim(), gvrow.Cells[3].Text.Trim()
            , gvrow.Cells[4].Text.Trim(), gvrow.Cells[5].Text.Trim(), gvrow.Cells[6].Text.Trim());


        try
        {

            if (db.QueryExecuteNonQuery(update_cate))
            {
                RegisterStartupScript("訊息通知", "<script> alert('資料更新,成功!!');</script>");
                Panel_update_category.Visible = false;
                Panel_Category.Visible = true;
                DBint(text_cate_stage.Text);
                //ChangeViewMode();
            }
            else
            {
                //lblError.Text = strSQL_Delete;
                RegisterStartupScript("訊息通知", "<script> alert('資料更新,失敗!!');</script>");
            }
        }
        catch (FormatException ex)
        {
            lblError.Text = "[Error Message::NPI Manual Form Delete Function]: " + ex.ToString();
        }

    }
    protected void but_lv_int_Click(object sender, EventArgs e)
    {

        //string parameter = Request["__EVENTARGUMENT"];
        //string[] allParams = parameter.Split('|');

        clsMySQL db = new clsMySQL();
        string del_str = "delete from npieptra_lv_main where Ver_Name='" + global_Ver_Name + "'";

        if (!db.QueryExecuteNonQuery(del_str))
        {
            lblError.Text = del_str;

        }

        count_white_lamp = 0;
        gap_compare();

        string strScript_count = string.Format("<script language='javascript'>var count_lamp =" + count_white_lamp + ";</script>");
        Page.ClientScript.RegisterStartupScript(this.GetType(), "onload", strScript_count);



        Hide_Value.Value = count_white_lamp.ToString();
        count_white_lamp = 0;

    }
   /* protected void DBint()
    {
        string sql_category = "";
        //string mySQL = "select * from npi_ep_category where EP_Cate_Stage='PI1'";
        int number=0;
        
       

        catch (Exception ex)
        {
            Label2.Text = ex.ToString() + number.ToString();
        }
    }
   */

    protected void insert_cate(int item_num, List<string> Cate_Iiitems, List<string> Cate_SpeChar, List<string> Cate_Md, List<string> Cate_Cate, List<string> Cate_KP, string name,string status,string stage)
    {
        clsMySQL db = new clsMySQL();
        List<int> success_insert = new List<int>();
        List<int> fail_insert = new List<int>();
        int success_count = 0;
        int fail_count = 0;
        List<string> history_cate = new List<string>();

        for (int i = 0; i < item_num; i++)
        {

            String insert_cate = string.Format("insert into npi_cap_ep" +
                                           "(npi_EP_Cate_Username,npi_EP_Cate_UpdateTime,npi_EP_Cate_Status," +
                                         "EP_Cate_Stage,EP_Cate_Iiitems,EP_Cate_SpeChar," +
                                         "EP_Cate_Md,EP_Cate_Cate,EP_Cate_KP)values" +
                                         "('{0}',NOW(),'{1}'," +
                                          "'{2}','{3}','{4}','{5}','{6}','{7}')"
                                          , name, status, stage, Cate_Iiitems[i], Cate_SpeChar[i], Cate_Md[i], Cate_Cate[i], Cate_KP[i]);
            if (db.QueryExecuteNonQuery(insert_cate) == true)
            {
                success_count++;
            }
            else
            {
                fail_count++;
                history_cate.Add(Cate_Iiitems[i] + "|" + Cate_SpeChar[i] + "|" + Cate_Md[i] + "|" + Cate_Cate[i] + "|" + Cate_KP[i]);
            }
        }





        /*
        try
        {
            /*if (Text_Packge_insert.Text.Trim() == "")
            {
                string strScript = string.Format("<script language='javascript'>alert('您沒有輸入Packge_Name!');</script>");
                Page.ClientScript.RegisterStartupScript(this.GetType(), "onload", strScript);
            }
            if ()
            {
                string strScript = string.Format("<script language='javascript'>alert('Category新增成功');</script>");
                Page.ClientScript.RegisterStartupScript(this.GetType(), "onload", strScript);
                
            }
            else
            {
                string strScript = string.Format("<script language='javascript'>alert('Category新增成功');</script>");
                Page.ClientScript.RegisterStartupScript(this.GetType(), "onload", strScript);
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }

        */





    }
    protected void btnInsert_Click(object sender, EventArgs e)
    {
        string user = "******";
        string vn = Session["Version_Name"].ToString();
        string keyitem = Session["keyitem"].ToString();
        string stage = Session["stage"].ToString();
        int    Max = 0, count = 0;;
        string sign_Lv = "";


        clsMySQL db = new clsMySQL();

        string SpeChar = "";
        string md      = "";
        string cate    = "";
        string kp      = "";

        string t = "";
        string f = "";



        if (jude_Lv(vn, stage, keyitem, SpeChar))
        {
            for (int i = 0; i < GridView1.Rows.Count; i++)
            {
                SpeChar = GridView1.Rows[i].Cells[2].Text;

                DropDownList ddl_Lv      = (DropDownList)GridView1.Rows[i].Cells[3].FindControl("Doe_Lv");
                string       select_str2 = ddl_Lv.SelectedValue;



                String insert_cap = string.Format("insert into npi_eptra_doe_lv" +
                                                  "(Lv_filename,Lv_User,Lv_UpdateTime,Lv_Iiitems,Lv_stage,Lv_SpecChar," +
                                                  "Lv_TraLv)values" +
                                                  "('{0}','{1}',NOW(),'{2}','{3}','{4}','{5}')",
                                                  vn, user, keyitem, stage, SpeChar, select_str2);



                try
                {
                    if (db.QueryExecuteNonQuery(insert_cap) == true)
                    {
                        t += Convert.ToString(i) + ",";
                    }
                    else
                    {
                        f += Convert.ToString(i) + ",";
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
        else
        {
            for (int i = 0; i < GridView1.Rows.Count; i++)
            {
                SpeChar = GridView1.Rows[i].Cells[2].Text;

                DropDownList ddl_Lv      = (DropDownList)GridView1.Rows[i].Cells[3].FindControl("Doe_Lv");
                string       select_str2 = ddl_Lv.SelectedValue;



                String update_Lv = string.Format("UPDATE npi_eptra_doe_lv " +
                                                 " SET Lv_TraLv='{0}'" +
                                                 "where Lv_filename='{1}'and Lv_User='******'and Lv_Iiitems='{3}' and Lv_stage='{4}' and Lv_SpecChar='{5}'"
                                                 , select_str2, vn, user, keyitem, stage, SpeChar);



                try
                {
                    if (db.QueryExecuteNonQuery(update_Lv) == true)
                    {
                        t += Convert.ToString(i) + ",";
                    }
                    else
                    {
                        f += Convert.ToString(i) + ",";
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }



        Max   = count_sum_Lv(vn, stage, keyitem);
        count = count_Lv(vn, stage, keyitem);



        if (count > (Max / 2))
        {
            sign_Lv = "l.1";
        }
        else
        {
            sign_Lv = "l.2";
        }



        string strScript = string.Format("<script language='javascript'>temp('" + keyitem + "'" + ',' + "'" + stage + "'" + ",'" + sign_Lv + "'" + ");</script>");

        Page.ClientScript.RegisterStartupScript(this.GetType(), "onload", strScript);
    }
    public void ImportToDataTable()
    {
        string fileName = "";

        lblMsg.Text = "";
        try
        {
            fileName = Path.GetFileName(FileUploadToServer.PostedFile.FileName);
            string filePath = Server.MapPath("~\\FileUpload\\") + Path.GetFileName(FileUploadToServer.PostedFile.FileName);
            FileUploadToServer.SaveAs(filePath);
            DataTable dt = new DataTable();
            //---------------取出file type : DIF/D_R/DRC,取檔名的前三字元
            if (CheckExcelFile(fileName))         //判斷File是否為xlsx
            {
                string strType = fileName.Substring(0, 3);
                string strSQL  = "";
                switch (strType)
                {
                case "DIF":
                    strSQL = "select Mtype,Mname,Mpos,MRow,MCol from npimap where mtype = 'DIF' order by mid";
                    break;

                case "Q_R":
                    strSQL = "select Mtype,Mname,Mpos,MRow,MCol from npimap where mtype = 'Q_R' order by mid";
                    break;

                case "DRC":
                    strSQL = "select Mtype,Mname,Mpos,MRow,MCol from npimap where mtype = 'DRC' order by mid";
                    break;

                default:
                    lblMsg.ForeColor = System.Drawing.Color.Red;
                    lblMsg.Text      = "您選擇的檔案:[" + fileName + "]無法匯入,請重新選擇正確的Excel檔案!!!";
                    strSQL           = "";
                    break;
                }
                //--------------------------------------------------------------------------------
                var existingFile = new FileInfo(filePath);

                using (var package = new ExcelPackage(existingFile))
                {
                    ExcelWorkbook workBook = package.Workbook;
                    if (workBook != null && strSQL != "")
                    {
                        if (workBook.Worksheets.Count > 0)
                        {
                            ExcelWorksheet worksheet = workBook.Worksheets.First();//Excel File的第一個Sheet1
                            DataTable      dt_Pos    = new DataTable();
                            clsMySQL       db        = new clsMySQL();
                            ArrayList      arSQL     = new ArrayList();
                            db.dbConn();

                            dt_Pos = db.dbQueryDT(strSQL);//db.QueryDataTable(strSQL);
                            db.dbClose();

                            dt.Columns.Add("檔案類型");
                            dt.Columns.Add("欄位名稱");
                            dt.Columns.Add("欄位位置");
                            //dt.Columns.Add("Rows");
                            //dt.Columns.Add("Cols");
                            dt.Columns.Add("欄位內容");
                            //Get Customer and Device value----------------------------------------------------------------
                            string tmpCustomer = "";
                            string tmpDevice   = "";
                            for (int t = 0; t <= 2; t++)
                            {
                                if (dt_Pos.Rows[t][1].ToString() == "Customer")
                                {
                                    if (strType == "DRC")
                                    {
                                        string[] str2 = worksheet.Cells[Convert.ToInt32(dt_Pos.Rows[t][3].ToString()), Convert.ToInt32(dt_Pos.Rows[t][4].ToString())].Value.ToString().Split(':');
                                        tmpCustomer = str2[1];
                                    }
                                    else
                                    {
                                        tmpCustomer = worksheet.Cells[Convert.ToInt32(dt_Pos.Rows[t][3].ToString()), Convert.ToInt32(dt_Pos.Rows[t][4].ToString())].Value.ToString();
                                    }
                                }
                                else
                                {
                                    if (dt_Pos.Rows[t][1].ToString() == "Device")
                                    {
                                        if (strType == "DRC")
                                        {
                                            string[] str2 = worksheet.Cells[Convert.ToInt32(dt_Pos.Rows[t][3].ToString()), Convert.ToInt32(dt_Pos.Rows[t][4].ToString())].Value.ToString().Split(':');
                                            tmpDevice = str2[1];
                                        }
                                        else
                                        {
                                            tmpDevice = worksheet.Cells[Convert.ToInt32(dt_Pos.Rows[t][3].ToString()), Convert.ToInt32(dt_Pos.Rows[t][4].ToString())].Value.ToString();
                                        }
                                    }
                                }
                            }
                            //---------------------------------------------------------------------------------------------------------
                            for (int i = 0; i < dt_Pos.Rows.Count; i++)
                            {
                                DataRow dr       = dt.NewRow();
                                string  tmpValue = "";
                                int     x        = 0;
                                db.dbConn();
                                dr[x++] = dt_Pos.Rows[i][0].ToString();
                                dr[x++] = dt_Pos.Rows[i][1].ToString();
                                dr[x++] = dt_Pos.Rows[i][2].ToString();
                                //dr[x++] = dt_Pos.Rows[i][3].ToString();
                                //dr[x++] = dt_Pos.Rows[i][4].ToString();
                                if (strType == "DRC" && (dt_Pos.Rows[i][2].ToString() == "B46" || dt_Pos.Rows[i][2].ToString() == "B47" || dt_Pos.Rows[i][2].ToString() == "B48"))
                                {
                                    string[] str1 = worksheet.Cells[Convert.ToInt32(dt_Pos.Rows[i][3].ToString()), Convert.ToInt32(dt_Pos.Rows[i][4].ToString())].Value.ToString().Split(':');
                                    dr[x++]  = str1[1];
                                    tmpValue = str1[1];
                                }
                                else
                                {
                                    dr[x++] = worksheet.Cells[Convert.ToInt32(dt_Pos.Rows[i][3].ToString()), Convert.ToInt32(dt_Pos.Rows[i][4].ToString())].Value;

                                    if (worksheet.Cells[Convert.ToInt32(dt_Pos.Rows[i][3].ToString()), Convert.ToInt32(dt_Pos.Rows[i][4].ToString())].Value == null)
                                    {
                                        tmpValue = "";
                                    }
                                    else
                                    {
                                        tmpValue = worksheet.Cells[Convert.ToInt32(dt_Pos.Rows[i][3].ToString()), Convert.ToInt32(dt_Pos.Rows[i][4].ToString())].Value.ToString();
                                    }
                                }
                                dt.Rows.Add(dr);
                                gvRecord.DataSource = dt;
                                gvRecord.DataBind();

                                //-----------------------------------insert MySql Database: npiImportData
                                string strSQL_Query = string.Format("select * from npiImportData where New_Customer = '{0}' and New_Device ='{1}' and Stype='{2}' and Im_Pos='{3}'", tmpCustomer.Trim(), tmpDevice.Trim(), strType.Trim(), dt_Pos.Rows[i][2].ToString().Trim());
                                string strSQL_Del   = string.Format("Delete from npiImportData where New_Customer='{0}' and New_Device='{1}' and Stype='{2}' and Im_Pos='{3}'", tmpCustomer.Trim(), tmpDevice.Trim(), strType.Trim(), dt_Pos.Rows[i][2].ToString().Trim());
                                arSQL.Add(strSQL_Del);
                                string strSQL_Insert = string.Format("Insert into npiImportData (New_Customer,New_Device,Stype,UpdateTime,npiUser,Im_Name,Im_Pos,Im_Value) values (" +
                                                                     "'{0}','{1}','{2}',NOW(),'','{3}','{4}','{5}')", tmpCustomer.Trim(), tmpDevice.Trim(), strType.Trim(), dt_Pos.Rows[i][1].ToString().Trim(), dt_Pos.Rows[i][2].ToString().Trim(), tmpValue.Trim());
                                arSQL.Add(strSQL_Insert);
                                lblMsg.ForeColor = System.Drawing.Color.Red;
                                //if (db.QueryDataReader(strSQL_Query).HasRows)
                                if (db.dbQueryDR(strSQL_Query).HasRows)
                                {
                                    if (!db.myBatchNonQuery(arSQL))
                                    {
                                        lblMsg.Text = "[Import Error Message] Delete/Insert Fail!!<br/>";
                                    }
                                }
                                else
                                {
                                    if (!db.QueryExecuteNonQuery(strSQL_Insert))
                                    {
                                        lblMsg.Text = "[Import Error Message] Insert Fail!! <br/>";
                                    }
                                }
                                arSQL.Clear();
                                lblMsg.Text = strSQL_Insert + "<br/>" + lblMsg.Text;
                                //---------------------------------------
                                db.dbClose();
                            }
                            lblMsg.ForeColor = System.Drawing.Color.Green;
                            lblMsg.Text      = "[" + fileName + "],完成資料匯入!!";
                        }
                        else
                        {
                            lblMsg.ForeColor = System.Drawing.Color.Red;
                            lblMsg.Text      = "您選擇的[" + fileName + "]無法匯入,請重新選擇Excel檔案或檢查Excel檔案內容!!";
                        }
                    }
                    else
                    {
                        gvRecord.DataSource = dt;
                        gvRecord.DataBind();
                    }
                }
            }
            File.Delete(filePath); //將IIS上的excel file刪除,C:\inetpub\wwwroot\BU3Web\FileUpload
        }
        catch (Exception exfile)
        {
            lblMsg.ForeColor = System.Drawing.Color.Red;
            if (fileName == "")
            {
                lblMsg.Text = "[Import Error Message] 請選擇要匯入的Excel檔案!!";
            }
            else
            {
                lblMsg.Text = "[Import Error Message]您選擇的[" + fileName + "]無法匯入,請重新選擇Excel檔案或檢查Excel檔案內容!!";
            }
        }
    }
    public static string DEL_Category(string str_stage)
    {
        string strError = "";
        string[] category_spilit_inf = new string[6];
        category_spilit_inf = str_stage.Split('|');

        for (int i = 0; i < category_spilit_inf.Length; i++)
        {
            if (category_spilit_inf[i] == "&nbsp;")
            {
                category_spilit_inf[i] = "";
            }
        }


        string strSQL_Delete = string.Format("Delete from npi_ep_category where EP_Cate_Stage='{0}' and EP_Cate_Iiitems='{1}' and EP_Cate_SpeChar='{2}' and  EP_Cate_Md='{3}' and EP_Cate_Cate='{4}' and  EP_Cate_KP='{5}'",
                                               category_spilit_inf[0], category_spilit_inf[1], category_spilit_inf[2], category_spilit_inf[3], category_spilit_inf[4], category_spilit_inf[5]);


        clsMySQL db = new clsMySQL();
        if (db.QueryExecuteNonQuery(strSQL_Delete))
        {
            strError = "刪除成功!";
            //DBint(category_spilit_inf[0]);

            HttpContext.Current.Session["value_del_stage"] = category_spilit_inf[0];
            db.Close();
        }
        else
        {
            strError = "Error Message:[NPI ManualForm] Delete Fail!!";
        }
        return strError;

    }
    protected void FormView1_ItemInserting(object sender, FormViewInsertEventArgs e)
    {
        DropDownList myddPOR_01 = (DropDownList)FormView1.FindControl("ddPOR01");   //Porduction Site
        DropDownList myddPOR_02 = (DropDownList)FormView1.FindControl("ddPOR02");   //PKG
        TextBox      myPOR_03   = (TextBox)FormView1.FindControl("text_POR03");     //WaferTech
        //TextBox myPOR_04 = (TextBox)FormView1.FindControl("text_POR04");
        DropDownList myddPOR_04 = (DropDownList)FormView1.FindControl("ddPOR04");   //FAB
        //TextBox myPOR_05 = (TextBox)FormView1.FindControl("text_POR05");
        DropDownList myddPOR_05 = (DropDownList)FormView1.FindControl("ddPOR05");   //WaferPSVTypeThickness
        TextBox      myPOR_06   = (TextBox)FormView1.FindControl("text_POR06");     //PRType
        DropDownList myddPOR_07 = (DropDownList)FormView1.FindControl("ddPOR07");   //TietchingChemical
        DropDownList myddPOR_08 = (DropDownList)FormView1.FindControl("ddPOR08");   //TinShellBake
        DropDownList myddPOR_09 = (DropDownList)FormView1.FindControl("ddPOR09");   //PIRougness
        DropDownList myddPOR_10 = (DropDownList)FormView1.FindControl("ddPOR10");   //BumpResistanceCapability
        DropDownList myddPOR_11 = (DropDownList)FormView1.FindControl("ddPOR11");   //推大球
        DropDownList myddPOR_12 = (DropDownList)FormView1.FindControl("ddPOR12");   //LowK
        DropDownList myddPOR_13 = (DropDownList)FormView1.FindControl("ddPOR13");   //PRThickness
        DropDownList myddPOR_14 = (DropDownList)FormView1.FindControl("ddPOR14");   //Customer
        //------------POR_15 For Pord---------------------------
        Label        mylab_Pord = (Label)FormView1.FindControl("lab_Pord");
        DropDownList myddPord   = (DropDownList)FormView1.FindControl("ddPord");
        TextBox      mytext_No  = (TextBox)FormView1.FindControl("text_No");
        string       myPOR_15   = mylab_Pord.Text + "-" + myddPord.SelectedValue.ToString() + "-" + mytext_No.Text;
        //------------For Pord End-----------------------
        DropDownList myddPOR_16 = (DropDownList)FormView1.FindControl("ddPOR16");       //UBMTypeThickness
        TextBox      myPOR_17   = (TextBox)FormView1.FindControl("text_POR17");         //Device
        Label        myPOR_18   = (Label)FormView1.FindControl("labPOR18");
        TextBox      myPOR_19   = (TextBox)FormView1.FindControl("text_POR19");
        DropDownList myddPOR_20 = (DropDownList)FormView1.FindControl("ddPOR20");
        DropDownList myddPOR_21 = (DropDownList)FormView1.FindControl("ddPOR21");
        TextBox      myPOR_22   = (TextBox)FormView1.FindControl("text_POR22");
        DropDownList myddPOR_23 = (DropDownList)FormView1.FindControl("ddPOR23");
        DropDownList myddPOR_24 = (DropDownList)FormView1.FindControl("ddPOR24");
        DropDownList myddPOR_25 = (DropDownList)FormView1.FindControl("ddPOR25");
        DropDownList myddPOR_26 = (DropDownList)FormView1.FindControl("ddPOR26");
        TextBox      myPOR_27   = (TextBox)FormView1.FindControl("text_POR27");
        DropDownList myddPOR_28 = (DropDownList)FormView1.FindControl("ddPOR28");
        TextBox      myPOR_29   = (TextBox)FormView1.FindControl("text_POR29");
        TextBox      myPOR_30   = (TextBox)FormView1.FindControl("text_POR30");
        TextBox      myPOR_31   = (TextBox)FormView1.FindControl("text_POR31");
        TextBox      myPOR_32   = (TextBox)FormView1.FindControl("text_POR32");
        DropDownList myddPOR_33 = (DropDownList)FormView1.FindControl("ddPOR33");
        TextBox      myPOR_34   = (TextBox)FormView1.FindControl("text_POR34");
        TextBox      myPOR_35   = (TextBox)FormView1.FindControl("text_POR35");
        TextBox      myPOR_36   = (TextBox)FormView1.FindControl("text_POR36");
        TextBox      myPOR_37   = (TextBox)FormView1.FindControl("text_POR37");
        //POR38,POR39,POR40,POR41 Default Text = "NA"-----------------------------------------------
        TextBox myPOR_38 = (TextBox)FormView1.FindControl("text_POR38");

        myPOR_38.Text = "NA";
        TextBox myPOR_39 = (TextBox)FormView1.FindControl("text_POR39");

        myPOR_39.Text = "NA";
        TextBox myPOR_40 = (TextBox)FormView1.FindControl("text_POR40");

        myPOR_40.Text = "NA";
        TextBox myPOR_41 = (TextBox)FormView1.FindControl("text_POR41");

        myPOR_41.Text = "NA";
        //------------------------------------------------------------------
        TextBox      myPOR_42   = (TextBox)FormView1.FindControl("text_POR42");
        TextBox      myPOR_43   = (TextBox)FormView1.FindControl("text_POR43");
        TextBox      myPOR_44   = (TextBox)FormView1.FindControl("text_POR44");
        TextBox      myPOR_45   = (TextBox)FormView1.FindControl("text_POR45");
        DropDownList myddPOR_46 = (DropDownList)FormView1.FindControl("ddPOR46");
        TextBox      myPOR_47   = (TextBox)FormView1.FindControl("text_POR47");
        Label        myPOR_48   = (Label)FormView1.FindControl("labPOR48"); //套公式: POR19-POR45
        Label        myPOR_49   = (Label)FormView1.FindControl("labPOR49"); //套公式: POR29/POR36
        Label        myPOR_50   = (Label)FormView1.FindControl("labPOR50"); //套公式: (Math.PI * (POR29 * POR29/4) * POR53) / (POR51 * POR52) * 1000000
        TextBox      myPOR_51   = (TextBox)FormView1.FindControl("text_POR51");
        TextBox      myPOR_52   = (TextBox)FormView1.FindControl("text_POR52");
        TextBox      myPOR_53   = (TextBox)FormView1.FindControl("text_POR53");
        TextBox      myPOR_54   = (TextBox)FormView1.FindControl("text_POR54");
        TextBox      myPOR_55   = (TextBox)FormView1.FindControl("text_POR55");

        clsMySQL db = new clsMySQL();
        DataSet  ds;

        if (myddPOR_14.SelectedValue.ToString() == "")
        {
            RegisterStartupScript("訊息通知", "<script> alert('必須填寫POR Customer!!');</script>");
        }
        else
        {
            if (myPOR_17.Text == "")
            {
                RegisterStartupScript("訊息通知", "<script> alert('必須填寫POR Device!!');</script>");
            }
            else
            {
                if (myddPOR_01.SelectedValue.ToString() == "")
                {
                    RegisterStartupScript("訊息通知", "<script> alert('必須填寫Production Site!!');</script>");
                }
                else
                {
                    string strSQL_Query = "select * from npipor where POR_Customer = '" + myddPOR_14.SelectedValue.ToString() + "' and POR_Device = '" + myPOR_17.Text + "' and POR_01 = '" + myddPOR_01.SelectedValue.ToString() + "'";
                    ds = db.QueryDataSet(strSQL_Query);
                    try
                    {
                        string strSQL_Insert = string.Format("Insert into npiPor " +
                                                             "(POR_Customer, POR_Device, Stype, UpdateTime, npiUser, POR_Status," +
                                                             "POR_01, POR_02, POR_03, POR_04, POR_05, POR_06, POR_07, POR_08, POR_09, POR_10," +
                                                             "POR_11, POR_12, POR_13, POR_14, POR_15, POR_16, POR_17, POR_18, POR_19, POR_20, POR_21, POR_22," +
                                                             "POR_23, POR_24, POR_25, POR_26, POR_27, POR_28, POR_29, POR_30, POR_31, POR_32, POR_33, POR_34," +
                                                             "POR_35, POR_36, POR_37, POR_38, POR_39, POR_40, POR_41, POR_42, POR_43, POR_44, POR_45, POR_46," +
                                                             "POR_47, POR_48, POR_49, POR_50, POR_51, POR_52, POR_53, POR_54, POR_55)values " +
                                                             "('{13}','{16}','POR',NOW(),'','Y','{0}','{1}','{2}','{3}','{4}'," +
                                                             "'{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}','{19}','{20}','{21}'," +
                                                             "'{22}','{23}','{24}','{25}','{26}','{27}','{28}','{29}','{30}','{31}','{32}','{33}','{34}','{35}','{36}','{37}'," +
                                                             "'{38}','{39}','{40}','{41}','{42}','{43}','{44}','{45}','{46}','{47}','{48}','{49}','{50}','{51}','{52}','{53}'," +
                                                             "'{54}')",
                                                             myddPOR_01.SelectedValue.ToString().Trim(), myddPOR_02.SelectedValue.ToString().Trim(), myPOR_03.Text.Trim(), myddPOR_04.SelectedValue.ToString().Trim(),
                                                             myddPOR_05.SelectedValue.ToString().Trim(), myPOR_06.Text.Trim(), myddPOR_07.SelectedValue.ToString().Trim(), myddPOR_08.SelectedValue.ToString().Trim(),
                                                             myddPOR_09.SelectedValue.ToString().Trim(), myddPOR_10.SelectedValue.ToString().Trim(), myddPOR_11.SelectedValue.ToString().Trim(), myddPOR_12.SelectedValue.ToString().Trim(),
                                                             myddPOR_13.SelectedValue.ToString().Trim(), myddPOR_14.SelectedValue.ToString().Trim(), myPOR_15.Trim(), myddPOR_16.SelectedValue.ToString().Trim(), myPOR_17.Text.Trim(),
                                                             myPOR_18.Text.Trim(), myPOR_19.Text.Trim(), myddPOR_20.SelectedValue.ToString().Trim(), myddPOR_21.SelectedValue.ToString().Trim(), myPOR_22.Text.Trim(),
                                                             myddPOR_23.SelectedValue.ToString().Trim(), myddPOR_24.SelectedValue.ToString().Trim(), myddPOR_25.SelectedValue.ToString().Trim(), myddPOR_26.SelectedValue.ToString().Trim(),
                                                             myPOR_27.Text.Trim(), myddPOR_28.SelectedValue.ToString().Trim(), myPOR_29.Text.Trim(), myPOR_30.Text.Trim(), myPOR_31.Text.Trim(), myPOR_32.Text.Trim(),
                                                             myddPOR_33.SelectedValue.ToString().Trim(), myPOR_34.Text.Trim(), myPOR_35.Text.Trim(), myPOR_36.Text.Trim(), myPOR_37.Text.Trim(), myPOR_38.Text.Trim(),
                                                             myPOR_39.Text.Trim(), myPOR_40.Text.Trim(), myPOR_41.Text.Trim(), myPOR_42.Text.Trim(), myPOR_43.Text.Trim(), myPOR_44.Text.Trim(), myPOR_45.Text.Trim(),
                                                             myddPOR_46.SelectedValue.ToString().Trim(), myPOR_47.Text.Trim(), myPOR_48.Text.Trim(), myPOR_49.Text.Trim(), myPOR_50.Text.Trim(), myPOR_51.Text.Trim(),
                                                             myPOR_52.Text.Trim(), myPOR_53.Text.Trim(), myPOR_54.Text.Trim(), myPOR_55.Text.Trim());

                        //lblError.Text = strSQL_Insert;
                        if (db.QueryExecuteNonQuery(strSQL_Insert))
                        {
                            RegisterStartupScript("訊息通知", "<script> alert('POR資料新增,成功!!');</script>");
                            ClearTextBox();
                            ChangeViewMode();
                        }
                        else
                        {
                            //lblError.Text = strSQL_Insert;
                            RegisterStartupScript("訊息通知", "<script> alert('POR資料新增,失敗!!');</script>");
                        }
                    }
                    catch (Exception ex)
                    {
                        ClearTextBox();
                        lblError.Text = "[POR Insert Error Message]:" + ex.ToString();
                    }
                }
            }
        }
    }
    protected void btnUpload_Click(object sender, EventArgs e)
    {
        String        SavePath   = "D:\\brunohuang\\FileUpload_Folder\\";
        string        sheet_name = "";
        int           sheet_num;
        int           dLastNum;
        int           cate_items    = 0;
        String        Cate_Username = "******";
        String        Cate_Status   = "Y";
        DateTime      dt            = DateTime.Now;
        string        inf_ID        = "";
        List <string> List_Inf_ID   = new List <string>();
        Boolean       sign_count    = false;

        /*List<string> Cate_Iiitems = new List<string>();
         * List<string> Cate_SpeChar = new List<string>();
         * List<string> Cate_Md = new List<string>();
         * List<string> Cate_Cate = new List<string>();
         * List<string> Cate_KP = new List<string>();
         */
        List <int>    success_insert   = new List <int>();
        List <int>    fail_insert      = new List <int>();
        int           success_count    = 0;
        int           fail_count       = 0;
        List <string> history_cate     = new List <string>();
        string        fileName         = "";
        string        time             = "";
        string        count_sheet_name = "";
        int           debug_count      = 0;
        Boolean       sign             = false;
        clsMySQL      db = new clsMySQL();



        try
        {
            fileName = Path.GetFileName(FileUploadToServer.PostedFile.FileName);
            //string filePath = Server.MapPath("~\\bruno\\FileUpload_Folder\\") + Path.GetFileName(FileUploadToServer.PostedFile.FileName);
            string filePath = Server.MapPath("FileUpload_Folder\\") + Path.GetFileName(FileUploadToServer.PostedFile.FileName);
            FileUploadToServer.SaveAs(filePath);



            if (CheckExcelFile(fileName))
            {
                /*
                 * if (FileUploadToServer.HasFile)
                 * {
                 *
                 * }
                 */

                XSSFWorkbook wk = new XSSFWorkbook(FileUploadToServer.FileContent);
                XSSFSheet    hst;
                XSSFRow      hr;
                DataTable    myDT = new DataTable();

                sheet_num = wk.NumberOfSheets;

                for (int k = 0; k < sheet_num; k++) //從每張工作表開始做
                {
                    hst        = (XSSFSheet)wk.GetSheetAt(k);
                    cate_items = hst.LastRowNum; //每一張工作表有幾筆資料

                    sheet_name = hst.SheetName;

                    if (k != sheet_num - 1) //顯示匯入的Stage有哪些
                    {
                        count_sheet_name += sheet_name + ",";
                    }
                    else
                    {
                        count_sheet_name += sheet_name;
                    }

                    hr       = (XSSFRow)hst.GetRow(0);
                    dLastNum = hr.LastCellNum; //每一列的欄位數


                    /*  for (int i = hr.FirstCellNum; i < hr.LastCellNum; i++)
                     * {
                     *    if (hr.GetCell(i) != null)
                     *    {
                     *        DataColumn myColumn = new DataColumn(hr.GetCell(i).StringCellValue);
                     *        myDT.Columns.Add(myColumn);
                     *
                     *    }
                     *
                     * }*/



                    for (int j = 1; j <= cate_items; j++)
                    {
                        hr = (XSSFRow)hst.GetRow(j);
                        //XSSFRow row = (XSSFRow) mySheet.GetRow(i);
                        DataRow myrow = myDT.NewRow();

                        /*for(int i=1;i<dLastNum;i++)
                         * {
                         *  //string strcell = hr.GetCell(i) == null ? "0" : hr.GetCell(i).ToString();
                         *  myrow =
                         *
                         * }*/



                        String insert_cate = string.Format("insert into npi_ep_category" +
                                                           "(npi_EP_Cate_Username,npi_EP_Cate_UpdateTime,npi_EP_Cate_Status," +
                                                           "EP_Cate_Stage,EP_Cate_Iiitems,EP_Cate_SpeChar," +
                                                           "EP_Cate_Md,EP_Cate_Cate,EP_Cate_KP)values" +
                                                           "('{0}',NOW(),'{1}'," +
                                                           "'{2}','{3}','{4}','{5}','{6}','{7}')"
                                                           , Cate_Username, Cate_Status, sheet_name, hr.GetCell(0), hr.GetCell(1), hr.GetCell(2), hr.GetCell(3), hr.GetCell(4));
                        string excel_sql = sheet_name + "|" + hr.GetCell(0) + "|" + hr.GetCell(1) + "|" + hr.GetCell(2) + "|" + hr.GetCell(3) + "|" + hr.GetCell(4);
                        Label1.Text = dt.ToString("yyyy/MM/dd hh:mm:ss");
                        time        = Label1.Text;

                        if (jude_npiepcategory_data(excel_sql) == true)
                        {
                            if (db.QueryExecuteNonQuery(insert_cate) == true)
                            {
                                success_count++;
                                sign = true;
                            }
                            else
                            {
                                fail_count++;
                                history_cate.Add(hr.GetCell(0) + "|" + hr.GetCell(1) + "|" + hr.GetCell(2) + "|" + hr.GetCell(3) + "|" + hr.GetCell(4));
                            }
                            debug_count++;
                        }
                        else
                        {
                            List_Inf_ID.Add(Session["value_ID"].ToString() + "|");
                            sign_count = true;
                        }
                        Session.Clear();
                    }
                }
                wk  = null;
                hst = null;
                hr  = null;
            }
            else
            {
                lblMsg.ForeColor = System.Drawing.Color.Red;
                lblMsg.Text      = "您選擇的[" + fileName + "]無法匯入,請重新選擇Excel檔案或檢查Excel檔案內容!!";
            }


            /*string strScript2 = string.Format("<script language='javascript'>alert('完成匯入\\n成功匯入筆數:" + success_count + "\\n匯入的Stage:" + count_sheet_name + "');</script>");
             * Page.ClientScript.RegisterStartupScript(this.GetType(), "onload", strScript2);*/
            Lab_item.Text  = success_count.ToString();
            Lab_Stage.Text = count_sheet_name;
            lblMsg.Text    = fileName + "上傳成功!!";

            if (sign_count == true)
            {
                for (int i = 0; i < List_Inf_ID.Count; i++)
                {
                    inf_ID += List_Inf_ID[i];
                }

                string strScript2 = string.Format("<script language='javascript'>alert('資料重複編號:" + inf_ID + "');</script>");
                Page.ClientScript.RegisterStartupScript(this.GetType(), "onload", strScript2);
            }
        }
        catch (Exception exfile)
        {
            lblMsg.ForeColor = System.Drawing.Color.Red;
            if (fileName == "")
            {
                lblMsg.Text = "[Import Error Message] 請選擇要匯入的Excel檔案!!";
            }
            else
            {
                lblMsg.Text = "[Import Error Message]您選擇的[" + fileName + "]無法匯入,請重新選擇Excel檔案或檢查Excel檔案內容!!";
            }
        }

        finally
        {
            /*string strScript = string.Format("<script language='javascript'>alert('您沒有輸入Packge_Name!');</script>");
             * Page.ClientScript.RegisterStartupScript(this.GetType(), "onload", strScript);*/
        }

        string sql_cate_datetime = "select * from npi_ep_category where npi_ep_category.npi_EP_Cate_UpdateTime >= DATE_FORMAT('" + time + "', '%Y/%m/%d %H:%i:%s')";

        //DATE_FORMAT('2016/04/28 11:26:00', '%Y/%m/%d %H:%i:%s')


        if (sign == true)
        {
            clsMySQL         ds = new clsMySQL();
            clsMySQL.DBReply dr = ds.QueryDS(sql_cate_datetime);
            gvRecord.DataSource = dr.dsDataSet.Tables[0].DefaultView;
            gvRecord.DataBind();
            ds.Close();
        }
    }
Esempio n. 39
0
    protected void but_insert_Click(object sender, EventArgs e)
    {
        string user = "******";
        string vn = Session["Version_Name"].ToString();
        string keyitem = Session["keyitem"].ToString();
        string stage = Session["stage"].ToString();
        int    Max = 0, count = 0;;
        string sign_Lv    = "";
        string CreateName = "cre_CIM";
        string UpName     = "up_CIM";
        string sta        = "Y";

        clsMySQL db = new clsMySQL();

        string SpeChar = "";
        string md      = "";
        string cate    = "";
        string kp      = "";

        string t           = "";
        string f           = "";
        string insert_sign = "";
        string up_sign     = "";
        string str_sign    = "";



        string[] split_vn = vn.Split('_');
        string   temp_no  = split_vn[2];

        char[]   pat    = new char[] { 'V', 'e', 'r' };/**/
        string[] str_no = temp_no.Split(pat);

        int no = Convert.ToInt32(str_no[3]);

        if (jude_Lv(vn, stage, keyitem, SpeChar))
        {
            for (int i = 0; i < GridView1.Rows.Count; i++)
            {
                SpeChar = GridView1.Rows[i].Cells[2].Text;

                DropDownList ddl_Lv      = (DropDownList)GridView1.Rows[i].Cells[3].FindControl("Doe_Lv");
                string       select_str2 = ddl_Lv.SelectedValue;



                String insert_lv = string.Format("insert into npieptra_lv_main" +
                                                 "(Ver_Name,EPTRA_KeyItem,EPTRA_LV_Stage,EPTRA_LV_SpecChar,EPTRA_LV)Values" +
                                                 "('{0}','{1}','{2}','{3}','{4}')",
                                                 vn, keyitem, stage, SpeChar, select_str2);



                try
                {
                    if (db.QueryExecuteNonQuery(insert_lv) == true)
                    {
                        //t += Convert.ToString(i) + ",";
                        insert_sign = "true";
                    }
                    else
                    {
                        //f += Convert.ToString(i) + ",";
                        insert_sign   = "false";
                        lblError.Text = insert_lv;
                        break;
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            if (insert_sign == "true")
            {
                str_sign = "EPTRA_Lv新增成功!";
            }
            else
            {
                str_sign = "EPTRA_Lv新增失敗!";
            }
        }
        else
        {
            for (int i = 0; i < GridView1.Rows.Count; i++)
            {
                SpeChar = GridView1.Rows[i].Cells[2].Text;

                DropDownList ddl_Lv      = (DropDownList)GridView1.Rows[i].Cells[3].FindControl("Doe_Lv");
                string       select_str2 = ddl_Lv.SelectedValue;



                /*create user & update user 問題*/
                String update_Lv = string.Format("UPDATE npieptra_lv_main " +
                                                 " SET EPTRA_LV='{0}'" +
                                                 "where Ver_Name='{1}' and EPTRA_KeyItem='{2}' and EPTRA_LV_Stage='{3}' and EPTRA_LV_SpecChar='{4}'"
                                                 , select_str2, vn, keyitem, stage, SpeChar);



                try
                {
                    if (db.QueryExecuteNonQuery(update_Lv) == true)
                    {
                        //t += Convert.ToString(i) + ",";
                        up_sign = "true";
                    }
                    else
                    {
                        //f += Convert.ToString(i) + ",";
                        up_sign       = "false";
                        lblError.Text = update_Lv;
                        break;
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }