示例#1
0
        public void update(dealer_class dc)
        {
            SqlConnection con = new SqlConnection("Data Source=.\\sqlexpress;Initial Catalog=egas;Integrated Security=True;Pooling=False");
            SqlDataAdapter da = new SqlDataAdapter("select * from dealer", con);
            DataSet ds = new DataSet();
            da.Fill(ds, "dealer");

            cylinder_dealer_keeper cdk = new cylinder_dealer_keeper();
            dc._stock_no = cdk.count(dc._id);  

            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                if (int.Parse(dr[0].ToString()) == dc._id)
                {
                    dr.BeginEdit();
                    dr[1] = dc._name;
                    dr[2] = dc._address;
                    dr[3] = dc._city;
                    dr[4] = dc._state;
                    dr[5] = dc._pincode;
                    dr[6] = dc._stock_no;
                    dr[7] = dc._password;
                    dr[8] = dc._status; 
                    dr[9] = dc._contact;
                    dr.EndEdit();
                }

            }
            SqlCommandBuilder cb = new SqlCommandBuilder(da);
            da.Update(ds.Tables[0]);
        }
示例#2
0
        public void update_count(int id)
        {
            SqlConnection con = new SqlConnection("Data Source=.\\sqlexpress;Initial Catalog=egas;Integrated Security=True;Pooling=False");
            SqlDataAdapter da = new SqlDataAdapter("select * from dealer", con);
            DataSet ds = new DataSet();
            da.Fill(ds, "dealer");

            cylinder_dealer_keeper cdk = new cylinder_dealer_keeper();
            int stock = cdk.count(id);
            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                if (int.Parse(dr[0].ToString()) == id)
                {
                    dr.BeginEdit();
                    dr[6] = stock;
                    dr.EndEdit();
                }

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

        }