示例#1
0
    protected void Del_Click(string Username)
    {
        SqlConnection Conn = new SqlConnection();

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

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

            DataTable dt2 = Employee();
            Grid_Employee.DataSource = dt2;
            Grid_Employee.DataBind();

            ScriptManager.RegisterStartupScript(Page, GetType(), "alert", "<script>swal('刪除成功')</script>", false);
        }
        catch (Exception ex)
        {
            DB_string.log("Employee_del:", ex.ToString());
            ScriptManager.RegisterStartupScript(Page, GetType(), "alert", "<script>swal('刪除失敗')</script>", false);
        }
        finally
        {
            Conn.Close();
        }
    }
示例#2
0
 private void btn_View_Emp_No_Click(object sender, EventArgs e)
 {
     try
     {
         Grid_Employee grid = new Grid_Employee();
         grid.ShowDialog();
     }
     catch
     {
     }
 }
示例#3
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         if (Session["Username"] == null)
         {
             Response.Redirect("../../login.aspx");
         }
         else
         {
             DataTable dt = Employee();
             ViewState["Data"]        = dt;
             Grid_Employee.DataSource = dt;
             Grid_Employee.DataBind();
         }
     }
 }