protected void GV_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "EditData" || e.CommandName == "DeleteData")
            {
                using (GridViewRow row = (GridViewRow)((Control)e.CommandSource).NamingContainer)
                {
                    ////抓key
                    //string strid = GV.DataKeys[row.RowIndex].Values[0].ToString();
                    ////抓資料
                    //Session["Uid"] = GV.Rows[row.RowIndex].Cells[3].Text;
                    switch (e.CommandName)
                    {
                    case "EditData":
                        int iId = (int)GV.DataKeys[row.RowIndex].Values[0];
                        Session["UpdateId"] = iId;
                        using (SqlConnection conn = new SqlConnection(strConnectString))
                        {
                            using (SqlCommand command = new SqlCommand())
                            {
                                command.CommandText = $"select DataModifyDate,款號,料號,Qty,ReasonCode,收料人員,備註 from GGF收料報告 where id= {iId} ";
                                command.Connection  = conn;   //資料庫連接
                                conn.Open();
                                using (SqlDataReader dr = command.ExecuteReader())
                                {
                                    while (dr.Read())
                                    {
                                        string strDDL = dr.IsDBNull(dr.GetOrdinal("ReasonCode")) ? "" : dr["ReasonCode"].ToString();
                                        備註TB.Text    = (strDDL == "OTHER") ? dr.IsDBNull(dr.GetOrdinal("備註")) ? "" : dr["備註"].ToString() : "";
                                        收料人員TB.Text  = dr.IsDBNull(dr.GetOrdinal("收料人員")) ? "" : dr["收料人員"].ToString();
                                        StyleLB.Text = dr["款號"].ToString();
                                        收料日期LB.Text  = dr["DataModifyDate"].ToString();
                                        備註TB.Visible = (strDDL == "OTHER") ? true : false;
                                        if (!string.IsNullOrEmpty(strDDL))
                                        {
                                            if (錯誤原因DDL.Items.Contains(錯誤原因DDL.Items.FindByValue(strDDL)) == true)
                                            {
                                                錯誤原因DDL.SelectedValue = 錯誤原因DDL.Items.FindByValue(strDDL).Value;
                                            }
                                            else
                                            {
                                            }
                                        }
                                        else
                                        {
                                            錯誤原因DDL.SelectedValue = "";
                                        }
                                    }
                                }
                            }
                        }
                        EditPanel_ModalPopupExtender.Show();
                        break;

                    default:
                        break;
                    }
                }
            }
        }
예제 #2
0
 protected void 錯誤原因DDL_SelectedIndexChanged(object sender, EventArgs e)
 {
     備註TB.Visible = 錯誤原因DDL.SelectedValue == "OTHER";
     EditPanel_ModalPopupExtender.Show();
 }
 protected void 錯誤原因DDL_SelectedIndexChanged(object sender, EventArgs e)
 {
     //DDL因為AutoPostback會重刷畫面,因為file_load無法使用UpPanel所以要再將ModalPopupExtender.Show()
     備註TB.Visible = 錯誤原因DDL.SelectedValue == "OTHER";
     EditPanel_ModalPopupExtender.Show();
 }