Beispiel #1
0
        public bool Update(DepositAccount deposInfo)        //예금을 연장할 때 부르는 함수
        {
            MySqlTransaction trans = conn.BeginTransaction();

            try
            {
                string       sql = @"update depositaccount
                                  set 
                                        OutAccount = @outaccount,
                                        OutAccountPwd = @outpwd,
                                        NewPwd = @newpd,
                                        Duration = Duration + @duration
                                 where DAccountNum = @daccoutnum";
                MySqlCommand cmd = new MySqlCommand(sql, conn);
                cmd.Transaction = trans;


                cmd.Parameters.Add("@outaccount", MySqlDbType.VarChar);
                cmd.Parameters["@outaccount"].Value = deposInfo.OutAccount;

                cmd.Parameters.Add("@outpwd", MySqlDbType.VarChar);
                cmd.Parameters["@outpwd"].Value = deposInfo.OutAccountPw;

                cmd.Parameters.Add("@newpd", MySqlDbType.VarChar);
                cmd.Parameters["@newpd"].Value = deposInfo.NewPwd;

                cmd.Parameters.Add("@duration", MySqlDbType.VarChar);
                cmd.Parameters["@duration"].Value = deposInfo.Duration;

                cmd.Parameters.Add("@daccoutnum", MySqlDbType.Int32);
                cmd.Parameters["@daccoutnum"].Value = deposInfo.DAccountNum;

                if (cmd.ExecuteNonQuery() > 0)
                {
                    trans.Commit();
                    return(true);
                }
                else
                {
                    trans.Rollback();
                    return(false);
                }
            }
            catch (Exception)
            {
                trans.Rollback();
                return(false);
            }
        }
Beispiel #2
0
        public bool Insert(DepositAccount deposInfo)        //처음에 예금계좌를 생성할 때만 사용
        //첫 생성의 계좌 금액은 예치금액과 일치 이후에는 업데이트를 활용하여 기존의 돈에 계속 더해줄 것
        {
            MySqlTransaction trans = conn.BeginTransaction();

            try
            {
                string       sql = @"insert into depositaccount (DateCreated, CustomerNum, CustomerName, KindofAcc, 
                                               AmountOfDeposit, OutAccount, OutAccountPwd, NewPwd, CurrentMoney, Duration)
                                    values (now(), @customernum, @customername, @kindofacc,
                                                @amountofdeposit, @outaccount, @outaccountpw, @newpwd, @amountofdeposit, @duration)";
                MySqlCommand cmd = new MySqlCommand(sql, conn);
                cmd.Transaction = trans;

                cmd.Parameters.Add("@customernum", MySqlDbType.Int32);
                cmd.Parameters["@customernum"].Value = Convert.ToInt32(deposInfo.CustomerNum);

                cmd.Parameters.Add("@customername", MySqlDbType.VarChar);
                cmd.Parameters["@customername"].Value = deposInfo.CustomerName;

                cmd.Parameters.Add("@kindofacc", MySqlDbType.VarChar);
                cmd.Parameters["@kindofacc"].Value = deposInfo.KindOfAcc;

                cmd.Parameters.Add("@amountofdeposit", MySqlDbType.VarChar);
                cmd.Parameters["@amountofdeposit"].Value = deposInfo.AmountOfDeposit;

                cmd.Parameters.Add("@outaccount", MySqlDbType.VarChar);
                cmd.Parameters["@outaccount"].Value = deposInfo.OutAccount;

                cmd.Parameters.Add("@outaccountpw", MySqlDbType.VarChar);
                cmd.Parameters["@outaccountpw"].Value = deposInfo.OutAccountPw;

                cmd.Parameters.Add("@newpwd", MySqlDbType.VarChar);
                cmd.Parameters["@newpwd"].Value = deposInfo.NewPwd;

                cmd.Parameters.Add("@duration", MySqlDbType.VarChar);
                cmd.Parameters["@duration"].Value = deposInfo.Duration;

                cmd.ExecuteNonQuery();

                trans.Commit();
                return(true);
            }
            catch (Exception)
            {
                trans.Rollback();
                return(false);
            }
        }