Beispiel #1
0
    protected void Del_Click(string G_no)
    {
        SqlConnection Conn = new SqlConnection();

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

        try
        {
            string CmdString = @"";
            CmdString = @"DELETE FROM [Group] where G_no=@G_no ";
            SqlCommand cmd = new SqlCommand(CmdString, Conn);
            cmd.Parameters.AddWithValue("G_no", G_no);
            Conn.Open();
            cmd.ExecuteNonQuery();

            DataTable dt2 = Auth();
            Grid_Auth.DataSource = dt2;
            Grid_Auth.DataBind();

            ScriptManager.RegisterStartupScript(Page, GetType(), "alert", "<script>swal('刪除成功')</script>", false);
        }
        catch (Exception ex)
        {
            DB_string.log("Auth_del:", ex.ToString());
            ScriptManager.RegisterStartupScript(Page, GetType(), "alert", "<script>swal('刪除失敗')</script>", false);
        }
        finally
        {
            Conn.Close();
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Session["Username"] == null)
            {
                Response.Redirect("../../login.aspx");
            }
            else
            {
                if ((Request.QueryString["id"] != null) && (Request.QueryString["id"].ToString() != ""))
                {
                    id.Value = Request.QueryString["id"];
                    DataTable dt = Auth();
                    Grid_Auth.DataSource = dt;
                    Grid_Auth.DataBind();

                    ViewState["Get_Init"] = Get_Init();//拿已勾選資料
                    Set_Init();

                    //del_btn.Visible = true;
                }
                else
                {
                    // del_btn.Visible = false;
                }
            }
        }
    }
Beispiel #3
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         if (Session["Username"] == null)
         {
             Response.Redirect("../../login.aspx");
         }
         else
         {
             DB_fountion.GetNo("G_no", "Group");
             DataTable dt = Auth();
             Grid_Auth.DataSource = dt;
             Grid_Auth.DataBind();
         }
     }
 }
Beispiel #4
0
    protected void Enter_Click(object sender, EventArgs e)
    {
        DataTable     dt   = new DataTable();
        SqlConnection Conn = new SqlConnection();

        Conn.ConnectionString = ConfigurationManager.ConnectionStrings["sqlString"].ConnectionString;
        Conn.Open();
        SqlTransaction tran   = Conn.BeginTransaction();
        DataTable      serial = new DataTable();

        serial = DB_fountion.GetNo("G_no", "Group");
        try
        {
            string InsCmdString = @"";
            InsCmdString = @"INSERT INTO [Group]( G_no, Group_name, Group_value )
                             SELECT  @G_no,@Group_name,isnull(max(Group_value),0)+1 FROM [Group]";

            SqlCommand Inscmd = new SqlCommand(InsCmdString, Conn, tran);
            Inscmd.Parameters.AddWithValue("G_no", DateTime.Now.ToString("yyyyMMdd") + serial.Rows[0]["sno"].ToString());
            Inscmd.Parameters.AddWithValue("Group_name", Group_name.Value);
            Inscmd.ExecuteNonQuery();
            tran.Commit();
        }
        catch (Exception ex)
        {
            tran.Rollback();
            DB_string.log("Auth_Enter_Click:", ex.ToString());
        }
        finally
        {
            Conn.Close();
        }
        ScriptManager.RegisterStartupScript(Page, Page.GetType(), "closepup", "$('#modal-ins').modal('hide');", true);
        //刷新
        dt = Auth();
        Grid_Auth.DataSource = dt;
        Grid_Auth.DataBind();
    }