コード例 #1
0
        public List <clsspcprp> Disp_Rec()
        {
            if (con.State == ConnectionState.Closed)
            {
                con.Open();
            }
            SqlCommand cmd = new SqlCommand("dspspc", con);

            cmd.CommandType = CommandType.StoredProcedure;
            SqlDataReader    dr  = cmd.ExecuteReader();
            List <clsspcprp> obj = new List <clsspcprp>();

            while (dr.Read())
            {
                clsspcprp k = new clsspcprp();
                k.spccod = Convert.ToInt32(dr[0]);
                k.spcnam = dr[1].ToString();
                k.spcdsc = dr[2].ToString();
                obj.Add(k);
            }
            dr.Close();
            cmd.Dispose();
            con.Close();
            return(obj);
        }
コード例 #2
0
        public List <clsspcprp> Find_Rec(Int32 spccod)
        {
            if (con.State == ConnectionState.Closed)
            {
                con.Open();
            }
            SqlCommand cmd = new SqlCommand("fndspc", con);

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@spccod", spccod);
            SqlDataReader    dr  = cmd.ExecuteReader();
            List <clsspcprp> obj = new List <clsspcprp>();

            if (dr.HasRows)
            {
                dr.Read();
                clsspcprp k = new clsspcprp();
                k.spccod = Convert.ToInt32(dr[0]);
                k.spcnam = dr[1].ToString();
                k.spcdsc = dr[2].ToString();
                obj.Add(k);
            }
            dr.Close();
            cmd.Dispose();
            con.Close();
            return(obj);
        }
コード例 #3
0
 protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
 {
     nsgetwell.clsspc    obj    = new nsgetwell.clsspc();
     nsgetwell.clsspcprp objprp = new nsgetwell.clsspcprp();
     objprp.spccod = Convert.ToInt32(GridView1.DataKeys
                                     [e.RowIndex][0]);
     obj.Delete_Rec(objprp);
     GridView1.DataBind();
     e.Cancel = true;
 }
コード例 #4
0
        public void Delete_Rec(clsspcprp p)
        {
            if (con.State == ConnectionState.Closed)
            {
                con.Open();
            }
            SqlCommand cmd = new SqlCommand("delspc", con);

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@spccod", p.spccod);
            cmd.ExecuteNonQuery();
            cmd.Dispose();
            con.Close();
        }
コード例 #5
0
 protected void btnsub_Click(object sender, EventArgs e)
 {
     nsgetwell.clsspc    obj    = new nsgetwell.clsspc();
     nsgetwell.clsspcprp objprp = new nsgetwell.clsspcprp();
     objprp.spcnam = txtspcnam.Text;
     objprp.spcdsc = txtdsc.Text;
     if (btnsub.Text == "Submit")
     {
         obj.Save_Rec(objprp);
     }
     else
     {
         objprp.spccod = Convert.ToInt32(ViewState["cod"]);
         obj.Update_Rec(objprp);
         btnsub.Text = "Submit";
     }
     txtspcnam.Text = String.Empty;
     txtdsc.Text    = String.Empty;
     GridView1.DataBind();
 }