コード例 #1
0
        public static PacificCode SendMoney(string codeNumber, string Phone, double Amount)
        {
            bool bExists = PacificCodeDAO.IsExist(codeNumber);
            PacificCode newPacificCode = null;
            if (bExists)
            {
                PacificCode pacificCode = PacificCodeDAO.GetItem(codeNumber);
                if (pacificCode.ActualAmount > Amount)
                {
                    newPacificCode = new PacificCode();

                    bool bExist02;
                    do
                    {
                        newPacificCode.CodeNumber = Generator.getNewCode();
                        bExist02 = PacificCodeDAO.IsExist(newPacificCode.CodeNumber);
                    } while (bExist02);

                    pacificCode.ActualAmount -= (int)Amount;
                    newPacificCode.InitialAmount = (int)Amount;
                    newPacificCode.ActualAmount = (int)Amount;

                    PacificCodeDAO.UpdateAmount(pacificCode, (int)pacificCode.ActualAmount);
                    PacificCodeDAO.AddItem(newPacificCode);
                }
            }
            return newPacificCode;            
        }
コード例 #2
0
 internal static void AddItem(PacificCode newPacificCode)
 {
     MoneyPacificEntities db = new MoneyPacificEntities();
     db.PacificCodes.AddObject(newPacificCode);
     db.SaveChanges();
     db.Connection.Close();            
 }
コード例 #3
0
 internal static void UpdateAmount(PacificCode pacificCode, int actualAmount)
 {
     MoneyPacificEntities db = new MoneyPacificEntities();
     PacificCode existPacificCode = PacificCodeDAO.GetItem(pacificCode.CodeNumber);
     existPacificCode.ActualAmount = actualAmount;
     db.SaveChanges();
     db.Connection.Close();            
 }
コード例 #4
0
        /*
        * Gửi tiền  cho một số một khách hàng khác
        * - Kiểm tra tiền tồn tại trong tài khoản gửi
        * - Trừ tiền gửi
        * - Tạo một tài khoản bằng với số tiền vừa trừ
        * - Tài khoản mới tạo có số phone khách hàng là số phone truyền vào
        * - Trả ra PacificCode mới 
        * */
        public static PacificCode SendMoney(string CodeNumber, string Phone, double Amount)
        {
            MoneyPacificEntities db = new MoneyPacificEntities();
            bool bExist = db.PacificCodes.Where
                (p=>p.CodeNumber.Trim() == CodeNumber.Trim()).Any();
            
            PacificCode newPacificCode = null;

            if (bExist)
            {
                PacificCode pacificCode = db.PacificCodes.Where
                    (p => p.CodeNumber.Trim() == CodeNumber.Trim()).Single<PacificCode>();

                if (pacificCode.ActualAmount > Amount)
                {
                    newPacificCode = new PacificCode();

                    //newPacificCode.CodeNumber = "1111222233334444"; // Thay bằng GenerateCode
                    bool bExist02;
                    do
                    {
                        newPacificCode.CodeNumber = Generator.getNewCode();
                        bExist02 = db.PacificCodes.Where
                            (p => p.CodeNumber.Trim() == newPacificCode.CodeNumber.Trim()).Any();
                    }while(bExist02);

                    pacificCode.ActualAmount -= (int)Amount;
                    newPacificCode.InitialAmount = (int)Amount;
                    newPacificCode.ActualAmount = (int)Amount;

                    //newPacificCode.ExpireDate = new DateTime(
                    //    DateTime.Now.Year + 1,
                    //    DateTime.Now.Month,
                    //    DateTime.Now.Day
                    //    );

                    Customer receiverCustomer = CustomerBUS.getCustomerOrCreateNotYetBuy(Phone);
                    newPacificCode.CustomerId = receiverCustomer.Id;
                    // Không có storeId

                    db.PacificCodes.AddObject(newPacificCode);
                }
            }
            db.SaveChanges();
            db.Connection.Close();
            return newPacificCode;
        }
コード例 #5
0
	private void detach_PacificCodes(PacificCode entity)
	{
		this.SendPropertyChanging();
		entity.Customer = null;
	}
コード例 #6
0
 partial void DeletePacificCode(PacificCode instance);
コード例 #7
0
 partial void UpdatePacificCode(PacificCode instance);
コード例 #8
0
 partial void InsertPacificCode(PacificCode instance);
コード例 #9
0
	private void attach_PacificCodes(PacificCode entity)
	{
		this.SendPropertyChanging();
		entity.Store = this;
	}
コード例 #10
0
	private void detach_PacificCodes(PacificCode entity)
	{
		this.SendPropertyChanging();
		entity.PacificCodeStatus = null;
	}