protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { try { if (e.CommandName.Equals("cmdEdit")) { string strUrl = ResolveUrl(string.Format("~/PermitEdit.aspx?cmd={0}&ID={1}", "edit", e.CommandArgument.ToString())); Response.Redirect(strUrl); } if (e.CommandName.Equals("cmdDel")) { if (1 == 1) { string strSql = "Update [Account] Set Rec_Status='R' Where ID=@ID"; SqlCommand cmd = new SqlCommand(strSql); cmd.Parameters.Add("@ID", SqlDbType.UniqueIdentifier).Value = new Guid(e.CommandArgument.ToString()); conn = new MyConnection(); conn.ExecuteQuery(cmd); } querySql(); } } catch (Exception ex) { PublicLib.handleError("", this.GetType().Name, ex.Message); } }
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { try { if (e.CommandName.Equals("cmdEdit")) { string strUrl = ResolveUrl(string.Format("~/PkgAddEdit.aspx?cmd={0}&PkgId={1}", "edit", e.CommandArgument.ToString())); Response.Redirect(strUrl); } if (e.CommandName.Equals("cmdEditR")) { string strUrl = ResolveUrl(string.Format("~/PkgRunDownSet.aspx?PkgId={0}", e.CommandArgument.ToString())); Response.Redirect(strUrl); } if (e.CommandName.Equals("cmdDel")) { string strPkgid = e.CommandArgument.ToString().Split(',')[0].Trim(); string strPkgCode = e.CommandArgument.ToString().Split(',')[1].Trim(); //刪除套餐.... string strcmd = "DELETE FROM [HMC_PkgM] Where Id=@Id"; SqlCommand cmd = new SqlCommand(strcmd); cmd.Parameters.Add("@Id", SqlDbType.Int).Value = int.Parse(strPkgid); conn = new MyConnection(); conn.ExecuteQuery(cmd); //刪除關聯階層... strcmd = "DELETE FROM [HMC_Relative] Where Pkg_Id=@Pkg_Id"; cmd = new SqlCommand(strcmd); cmd.Parameters.Add("@Pkg_Id", SqlDbType.Int).Value = int.Parse(strPkgid); conn = new MyConnection(); conn.ExecuteQuery(cmd); //刪除細項... strcmd = "DELETE FROM [HMC_PkgD] Where PkgCode=@PkgCode"; cmd = new SqlCommand(strcmd); cmd.Parameters.Add("@PkgCode", SqlDbType.VarChar).Value = strPkgCode; conn = new MyConnection(); conn.ExecuteQuery(cmd); //刪除流程... strcmd = "DELETE FROM [HMC_PkgRunDown] Where Pkg_Id=@Pkg_Id"; cmd = new SqlCommand(strcmd); cmd.Parameters.Add("@Pkg_Id", SqlDbType.Int).Value = int.Parse(strPkgid); conn = new MyConnection(); conn.ExecuteQuery(cmd); Response.Redirect("~/PkgIndex.aspx"); } } catch (Exception ex) { PublicLib.handleError("", this.GetType().Name, ex.Message); } }
protected void Insert_Rundown() //新增 { conn = new MyConnection(); string strSql = "Insert Into [HMC_Rundown] (Name, Cre_Date, Cre_User) Values (@Name, @Cre_Date, @Cre_user)"; SqlCommand cmd = new SqlCommand(strSql); cmd.Parameters.Add("@Name", SqlDbType.NVarChar).Value = txtName.Text; cmd.Parameters.Add("@Cre_Date", SqlDbType.DateTime).Value = DateTime.Now; cmd.Parameters.Add("@Cre_User", SqlDbType.VarChar).Value = "05890"; conn.ExecuteQuery(cmd); }
protected void deleteData(string argId) { conn = new MyConnection(); string strSql = "Update [HMC_Rundown] Set Mod_Date=@Mod_Date, Mod_User=@Mod_USER, Rec_Status=@Rec_Status Where Id=@Id"; SqlCommand cmd = new SqlCommand(strSql); cmd.Parameters.Add("@Id", SqlDbType.Int).Value = argId; cmd.Parameters.Add("@Mod_Date", SqlDbType.DateTime).Value = DateTime.Now; cmd.Parameters.Add("@Mod_User", SqlDbType.VarChar).Value = "05890"; cmd.Parameters.Add("@Rec_Status", SqlDbType.VarChar).Value = "R"; conn.ExecuteQuery(cmd); }
protected void Update_Rundown() //編輯 { conn = new MyConnection(); string strSql = "Update [HMC_Rundown] Set Name=@Name, Mod_Date=@Mod_Date, Mod_User=@Mod_USER Where Id=@Id"; SqlCommand cmd = new SqlCommand(strSql); cmd.Parameters.Add("@Id", SqlDbType.Int).Value = strQueID; cmd.Parameters.Add("@Name", SqlDbType.NVarChar).Value = txtName.Text; cmd.Parameters.Add("@Mod_Date", SqlDbType.DateTime).Value = DateTime.Now; cmd.Parameters.Add("@Mod_User", SqlDbType.VarChar).Value = "05890"; conn.ExecuteQuery(cmd); }
private void delete_Relative(string ID) { try { conn = new MyConnection(); string strcmd = "Delete From [HMC_Relative] Where Id=@Id"; SqlCommand cmd = new SqlCommand(strcmd); cmd.Parameters.Add("@Id", SqlDbType.Int).Value = int.Parse(ID); conn.ExecuteQuery(cmd); } catch (Exception ex) { PublicLib.handleError("", this.GetType().Name, ex.Message); } }
protected void btnSubmit_Click(object sender, EventArgs e) { try { conn = new MyConnection(); string strSql = "Insert Into [HMC_Relative] (Type,Pkg_Id,Parent_Id, Cre_Date, Cre_User) Values (@Type,@Pkg_Id, @Parent_Id, @Cre_Date, @Cre_user)"; SqlCommand cmd = new SqlCommand(strSql); cmd.Parameters.Add("@Type", SqlDbType.Int).Value = 1; cmd.Parameters.Add("@Pkg_Id", SqlDbType.Int).Value = ddlPkgCode.SelectedValue; cmd.Parameters.Add("@Parent_Id", SqlDbType.Int).Value = strQuePID; cmd.Parameters.Add("@Cre_Date", SqlDbType.DateTime).Value = DateTime.Now; cmd.Parameters.Add("@Cre_User", SqlDbType.VarChar).Value = "05890"; conn.ExecuteQuery(cmd); } catch (Exception ex) { PublicLib.handleError("", this.GetType().Name, ex.Message); } string strUrl = ResolveUrl(string.Format("~/PkgRelative.aspx?PID={0}", strQuePID)); Response.Redirect(strUrl); }
private void button1_Click(object sender, EventArgs e) { dataGridView1.DataSource = myConn.ExecuteQuery(txtString.Text.Trim()); }