示例#1
0
        public string withdraw(long acc, int amt)
        {
            string comment = "withdraw done";
            string type    = "withdraw";

            try
            {
                Account transactionWithdraw = dbContext.Accounts.Where(var => var.accountNo == acc).Single <Account>();
                if (transactionWithdraw.amount >= amt)
                {
                    transactionWithdraw.amount -= amt;
                    dbContext.SaveChanges();
                }
                else
                {
                    return("amountNotSufficient");
                }
            }
            catch (Exception exe)
            {
                return("accountNotFound");
            }
            TransactionClass obj1 = new TransactionClass();

            obj1.insTrans(acc, acc, amt, type, comment);
            return("Success");
        }
示例#2
0
        public string deposit(long acc, int amt)
        {
            string           comment = "deposit done";
            string           type    = "deposit";
            TransactionClass obj1    = new TransactionClass();
            SqlConnection    con     = new SqlConnection(ConnectionString);

            con.Open();
            string sql = "checkAcc";

            SqlCommand   command = new SqlCommand(sql, con);
            SqlParameter param1  = new SqlParameter("@acc", acc);


            command.Parameters.Add(param1);
            command.CommandType = CommandType.StoredProcedure;
            SqlDataAdapter da = new SqlDataAdapter(command);
            DataSet        ds = new DataSet();

            da.Fill(ds);
            //int res, res1;
            if (ds.Tables[0].Rows.Count > 0)
            {
                string sql3 = "deposit";

                SqlCommand   command2 = new SqlCommand(sql3, con);
                SqlParameter param3   = new SqlParameter("@acc", acc);


                command2.Parameters.Add(param3);
                SqlParameter param4 = new SqlParameter("@amt", amt);


                command2.Parameters.Add(param4);

                command2.CommandType = CommandType.StoredProcedure;
                command2.ExecuteNonQuery();
            }
            else
            {
                con.Close();
                return("accountNotFound");
            }
            obj1.insTrans(acc, acc, amt, type, comment);

            return("success");
        }
示例#3
0
        public string deposit(long acc, int amt)
        {
            string comment = "deposit done";
            string type    = "deposit";

            try
            {
                Account transactionWithdraw = dbContext.Accounts.Where(var => var.accountNo == acc).Single <Account>();

                transactionWithdraw.amount += amt;
                dbContext.SaveChanges();
            }
            catch (Exception exe)
            {
                return("accountNotFound");
            }
            TransactionClass obj1 = new TransactionClass();

            obj1.insTrans(acc, acc, amt, type, comment);
            return("success");
        }
示例#4
0
        public string withdraw(long acc, int amt)
        {
            string           comment = "withdraw done";
            string           type    = "withdraw";
            TransactionClass obj1    = new TransactionClass();
            SqlConnection    con     = new SqlConnection(ConnectionString);

            con.Open();
            string sql = "checkAcc";

            SqlCommand   command = new SqlCommand(sql, con);
            SqlParameter param1  = new SqlParameter("@acc", acc);


            command.Parameters.Add(param1);
            command.CommandType = CommandType.StoredProcedure;
            SqlDataAdapter da = new SqlDataAdapter(command);
            DataSet        ds = new DataSet();

            da.Fill(ds);
            int res, res1;

            if (ds.Tables[0].Rows.Count > 0)
            {
                res = (int)ds.Tables[0].Rows[0]["customerId"];
                string sql1 = "checkAmo";

                SqlCommand   command1 = new SqlCommand(sql1, con);
                SqlParameter param2   = new SqlParameter("@acc", acc);


                command1.Parameters.Add(param2);
                command1.CommandType = CommandType.StoredProcedure;
                SqlDataAdapter da1 = new SqlDataAdapter(command1);
                DataSet        ds1 = new DataSet();
                da1.Fill(ds1);
                if (ds1.Tables[0].Rows.Count > 0)
                {
                    res1 = (int)ds1.Tables[0].Rows[0]["amount"];
                    if (res1 >= amt)
                    {
                        string sql3 = "withdraw";

                        SqlCommand   command2 = new SqlCommand(sql3, con);
                        SqlParameter param3   = new SqlParameter("@acc", acc);


                        command2.Parameters.Add(param3);
                        SqlParameter param4 = new SqlParameter("@amt", amt);


                        command2.Parameters.Add(param4);

                        command2.CommandType = CommandType.StoredProcedure;
                        command2.ExecuteNonQuery();
                    }
                    else
                    {
                        return("amountNotSufficient");
                    }
                }
            }
            else
            {
                return("accountNotFound");
            }

            obj1.insTrans(acc, acc, amt, type, comment);

            return("success");
        }