2019年10月29日 星期二

sql語法int轉varchar及varchar轉int

/****** SSMS 中 SelectTopNRows 命令的指令碼  ******/
SELECT TOP 1000 [RowId]
      ,[ProductID]
      ,[ProductName]
      ,[UnitPathId]
      ,[Item]
      ,[Amount]
      ,[Size]
      ,[Kind]
      ,[OriginalHolder]
      ,[Worth]
      ,[Material]
      ,[ObjectTime]
      ,[Maker]
      ,[Status]
      ,[Place]
      ,[ImageUrl]
      ,[Remark]
      ,[Remark2]
      ,[CreateDate]
      ,[CreateUserId]
      ,[UpdateDate]
      ,[UpdateUserId]
      ,[Cancel],
  CONVERT(varchar,RowId) as string
  FROM [AFM].[dbo].[AFM_Product]
  order by CONVERT(int,ProductID) asc

2019年10月27日 星期日

GridView RowCommand與PageIndexChanging事件

https://bbs.csdn.net/topics/350100104

    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {

        if (e.CommandName == "edit_admin")
        {
            GridView1.EditIndex = Convert.ToInt32(e.CommandArgument);
            db_common();
        }
        else
        {
            if (e.CommandName == "Page")
            {

            }
            else
            {
                SqlCommand cmd = new SqlCommand();
                string sql = "";
                fun fun = new fun();
                fun.Page = this.Page;
                DataTable dt = new DataTable();
                Button x = e.CommandSource as Button;
                TextBox textBox1 = x.FindControl("TextBox1") as TextBox;
                TextBox textBox2 = x.FindControl("TextBox2") as TextBox;
                TextBox textBox3 = x.FindControl("TextBox3") as TextBox;
                Label label = x.FindControl("Label3") as Label;
                sql = "UPDATE AFM_USER SET Name = @Name,MyPhone = @MyPhone,Title = @Title,UpdateDate=@UpdateDate,UpdateUserId=@UpdateUserId WHERE Account=@Account ";
                cmd.CommandText = sql;
                cmd.Parameters.Clear();
                cmd.Parameters.AddWithValue("@Account", label.Text);
                cmd.Parameters.AddWithValue("@Name", textBox1.Text);
                cmd.Parameters.AddWithValue("@MyPhone", textBox3.Text);
                cmd.Parameters.AddWithValue("@Title", textBox2.Text);
                cmd.Parameters.AddWithValue("@UpdateDate", DateTime.Now);
                cmd.Parameters.AddWithValue("@UpdateUserId", Session["Account"].ToString());
                int a = fun.CmdExec(cmd);
                if (a == 0)
                {
                    fun.message("更新失敗!!!");
                }
                else
                {
                    fun.message("已成功更新了" + a + "筆資料");
                }
                GridView1.EditIndex = -1;
                db_common();
            }
        }
    }

WPF聊天室应用(ASP.NET Core SignalR)

  WPF聊天室应用(ASP.NET Core SignalR) https://www.bilibili.com/video/BV1Q741187Si?p=2 https://www.bilibili.com/video/BV1UV411e75T?from=search...