예제 #1
0
    protected void Del_Click(string D_no)
    {
        SqlConnection Conn = new SqlConnection();

        Conn.ConnectionString = ConfigurationManager.ConnectionStrings["sqlString"].ConnectionString;
        DataTable dt = new DataTable();

        try
        {
            string CmdString = @"";
            CmdString = @"DELETE FROM DealersD where D_no=@D_no ";
            SqlCommand cmd = new SqlCommand(CmdString, Conn);
            cmd.Parameters.AddWithValue("D_no", D_no);
            Conn.Open();
            cmd.ExecuteNonQuery();

            DataTable dt2 = DealerD();
            Grid_DealerD.DataSource = dt2;
            Grid_DealerD.DataBind();
            del_img(D_no);
            ScriptManager.RegisterStartupScript(Page, GetType(), "alert", "<script>swal('刪除成功')</script>", false);
        }
        catch (Exception ex)
        {
            DB_string.log("DealerD_del:", ex.ToString());
            ScriptManager.RegisterStartupScript(Page, GetType(), "alert", "<script>swal('刪除失敗')</script>", false);
        }
        finally
        {
            Conn.Close();
        }
    }
예제 #2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         if (Session["Username"] == null)
         {
             Response.Redirect("../../login.aspx");
         }
         else
         {
             DataTable dt = DealerD();
             Grid_DealerD.DataSource = dt;
             Grid_DealerD.DataBind();
         }
     }
 }