Пример #1
0
        public static Customer getCustomerByAccount(String account)
        {
            Customer customer = new Customer();
            SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder();
            SqlConnection conn = GetConnection(builder);
            SqlCommand cmd = conn.CreateCommand();
            cmd.CommandText = "select * from Customer WHERE Account = @Account";
            cmd.Parameters.AddWithValue("@Account", account);
            conn.Open();
            SqlDataReader dr = cmd.ExecuteReader();
            if (dr.HasRows)
            {
                while (dr.Read())
                {
                    customer.FirstName = dr["FirstName"].ToString();
                    customer.LastName = dr["LastName"].ToString();
                    customer.Age = Convert.ToInt16(dr["Age"]);
                    customer.Gender = dr["Gender"].ToString();
                    customer.Email = dr["Email"].ToString();
                    customer.Account = dr["Account"].ToString();
                    customer.password = dr["password"].ToString();
                    customer.CustID = Convert.ToInt32(dr["CustID"]);
                }
            }
            else
            {
                customer = null;
            }

            return customer;
        }
 partial void DeleteCustomer(Customer instance);
 partial void UpdateCustomer(Customer instance);
 partial void InsertCustomer(Customer instance);