コード例 #1
0
        public string checkMedal(long acc)
        {
            BankEntities2 dbContext2 = new BankEntities2();
            int           amt;
            CustomerClass obj = new CustomerClass();

            Account account = dbContext.Accounts.Where(val => val.accountNo == acc).Single <Account>();

            amt = (int)(account.amount);
            CustomerMedal medal = dbContext2.CustomerMedals.Where(val => val.min <amt && val.max> amt).Single <CustomerMedal>();

            account.type = medal.type;
            dbContext.SaveChanges();

            return(account.type);
        }
コード例 #2
0
        public string checkMedal(long acc)
        {
            int           amt;
            CustomerClass obj = new CustomerClass();

            amt = obj.getAmount(acc);
            String        ConnectionString = System.Configuration.ConfigurationManager.AppSettings["ConnectionString"];
            SqlConnection con = new SqlConnection(ConnectionString);

            con.Open();
            string       sql     = "changeMedal";
            SqlCommand   command = new SqlCommand(sql, con);
            SqlParameter param1  = new SqlParameter("@amt", amt);

            command.Parameters.Add(param1);
            command.CommandType = CommandType.StoredProcedure;
            command.ExecuteNonQuery();


            string       sql2     = "getMedal";
            SqlCommand   command2 = new SqlCommand(sql2, con);
            SqlParameter param12  = new SqlParameter("@acc", acc);

            command2.Parameters.Add(param12);
            command2.CommandType = CommandType.StoredProcedure;
            SqlDataAdapter da2 = new SqlDataAdapter(command2);
            DataSet        ds  = new DataSet();

            da2.Fill(ds);
            string res = null;

            if (ds.Tables[0].Rows.Count > 0)
            {
                res = ds.Tables[0].Rows[0]["type"].ToString();
            }

            con.Close();
            return(res);
        }