예제 #1
0
        public port_class GetDataFull(int id)
        {
            SqlConnection con = new SqlConnection("Data Source=.\\sqlexpress;Initial Catalog=egas;Integrated Security=True;Pooling=False");
            SqlDataAdapter da = new SqlDataAdapter("select * from porting", con);
            DataSet ds = new DataSet();
            da.Fill(ds, "porting");

            port_class pc = new port_class();

            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                if (int.Parse(dr[0].ToString()) == id)
                {
                    pc._porting_id = id;
                    pc._customer_id = int.Parse(dr[1].ToString());
                    pc._status = dr[2].ToString();
                    pc._new_dist_id = int.Parse(dr[3].ToString());
                    pc._new_address = dr[4].ToString();
                    break;
                }
            }
            return pc;
        }
예제 #2
0
        public void update(port_class pc)
        {
            SqlConnection con = new SqlConnection("Data Source=.\\sqlexpress;Initial Catalog=egas;Integrated Security=True;Pooling=False");
            SqlDataAdapter da = new SqlDataAdapter("select * from porting", con);
            DataSet ds = new DataSet();
            da.Fill(ds, "porting");
            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                if (pc._porting_id == int.Parse(dr[0].ToString()))
                {
                    dr.BeginEdit(); 
                    dr[1] = pc._customer_id;
                    dr[2] = pc._status ;
                    dr[3] = pc._new_dist_id;
                    dr[4] = pc._new_address;
                    dr.EndEdit(); 
                }
            }

            
            SqlCommandBuilder cb = new SqlCommandBuilder(da);
            da.Update(ds.Tables[0]);
        }