コード例 #1
0
 internal static PacificCode getPacificCode(string sCodeNumber)
 {
     DBMoneyPacificDataContext mpdb = new DBMoneyPacificDataContext();
     PacificCode oPacificCode = mpdb.PacificCodes.Where(p => p.CodeNumber == sCodeNumber).Single<PacificCode>();
     mpdb.Connection.Close();
     return oPacificCode;
 }
コード例 #2
0
 internal static Customer getCustomer(string sPhone)
 {
     DBMoneyPacificDataContext mpdb = new DBMoneyPacificDataContext();
     Customer oCustomer = mpdb.Customers.Where(c => c.Phone == sPhone).Single<Customer>();
     mpdb.Connection.Close();
     return oCustomer;
 }
コード例 #3
0
 internal static bool IsExist(string sPhone)
 {
     DBMoneyPacificDataContext mpdb = new DBMoneyPacificDataContext();
     bool bResult = mpdb.StoreUsers.Any(l => l.Phone.Trim() == sPhone.Trim());
     mpdb.Connection.Close();
     return bResult;
 }
コード例 #4
0
        internal static void updateAfterInsertNewCode(PacificCode newPacificCode)
        {
            DBMoneyPacificDataContext mpdb = new DBMoneyPacificDataContext();
            // GET
            StoreUser existStore = mpdb.StoreUsers.Where(s => s.Id == newPacificCode.StoreId).Single<StoreUser>();

            // EXEC
            if (existStore != null)
            {
                if (existStore.NumberSales == null)
                {
                    existStore.NumberSales = 1;
                }
                else
                {
                    existStore.NumberSales++;
                }

                if (existStore.TotalSales == null)
                {
                    existStore.TotalSales = newPacificCode.ActualAmount;
                }
                else
                {
                    existStore.TotalSales += newPacificCode.ActualAmount;
                }
                // SAVE
                mpdb.SubmitChanges();
            }

            mpdb.Connection.Close();
        }
コード例 #5
0
 internal static bool isExist(string sPhone)
 {
     DBMoneyPacificDataContext mpdb = new DBMoneyPacificDataContext();
     bool bResult = mpdb.Customers.Where(c=>c.Phone == sPhone).Any();
     mpdb.Connection.Close();
     return bResult;
 }
コード例 #6
0
 internal static bool IsExist(string sPhone)
 {
     DBMoneyPacificDataContext mpdb = new DBMoneyPacificDataContext();
     bool bResult = mpdb.StoreManagers.Where(s => s.ManagerPhone.Trim() == sPhone.Trim()).Any();
     mpdb.Connection.Close();
     return bResult;            
 }
コード例 #7
0
 public static List<PacificCode> GetList(int storeId)
 {
     DBMoneyPacificDataContext mpdb = new DBMoneyPacificDataContext();
     List<PacificCode> lstPacificCode = mpdb.PacificCodes.Where(p => p.StoreId == storeId).ToList<PacificCode>();
     mpdb.Connection.Close();
     return lstPacificCode;
 }
コード例 #8
0
 internal static Agent GetItem(int id)
 {
     DBMoneyPacificDataContext mpdb = new DBMoneyPacificDataContext();
     Agent existAgent = mpdb.Agents.Where(a => a.Id == id).SingleOrDefault<Agent>();
     mpdb.Connection.Close();
     return existAgent;
 }
コード例 #9
0
 internal static bool isValidAmount(int amountBuy)
 {
     DBMoneyPacificDataContext mpdb = new DBMoneyPacificDataContext();
     bool bResult =  (mpdb.Categories.Where(c => c.Value == amountBuy && c.Active == true).Any());
     mpdb.Connection.Close();
     return bResult;
 }
コード例 #10
0
 internal static void addNew(PacificCode newPacificCode)
 {
     DBMoneyPacificDataContext mpdb = new DBMoneyPacificDataContext();
     mpdb.PacificCodes.InsertOnSubmit(newPacificCode);
     mpdb.SubmitChanges();
     mpdb.Connection.Close();
 }
コード例 #11
0
 internal static StoreUser[] GetArray(int managerId)
 {
     DBMoneyPacificDataContext mpdb = new DBMoneyPacificDataContext();
     StoreUser[] lstUser = mpdb.StoreUsers.Where(s => s.ManagerId == managerId).ToArray();
     mpdb.Connection.Close();
     return lstUser;
 }
コード例 #12
0
        //private static DBMoneyPacificDataContext mpdb = new DBMoneyPacificDataContext();

        internal static void updateAfterInsertNewCode(PacificCode newPacificCode)
        {
            DBMoneyPacificDataContext mpdb = new DBMoneyPacificDataContext();
            // GET
            Customer existCustomer = mpdb.Customers.Where(c => c.Id == newPacificCode.CustomerId).Single<Customer>();
            
            // EXEC
            if (existCustomer != null)
            {
                // . NumberTransaction
                if (existCustomer.NumberTransaction == null)
                {
                    existCustomer.NumberTransaction = 1;
                }
                else
                {
                    existCustomer.NumberTransaction++;
                }

                // . Total Amount
                if (existCustomer.TotalAmount == null)
                {
                    existCustomer.TotalAmount = newPacificCode.ActualAmount;
                }
                else
                {
                    existCustomer.TotalAmount += newPacificCode.ActualAmount;
                }

            }

            // SAVE
            mpdb.SubmitChanges();
            mpdb.Connection.Close();
        }
コード例 #13
0
 internal static CollectMoney[] GetListStatusId(int statusId)
 {
     DBMoneyPacificDataContext db = new DBMoneyPacificDataContext();
     CollectMoney[] arrResult = db.CollectMoneys                
         .Where(c => c.StatusId == statusId).ToArray();
     db.Connection.Close();
     return arrResult;
 }
コード例 #14
0
        //internal static bool Update(string sCollectCode)
        //{
        //    DBMoneyPacificDataContext db = new DBMoneyPacificDataContext();
        //    bool iResult = false;
        //    if (IsExist(sCollectCode))
        //    {
        //    }
        //    else
        //    {
        //        iResult = false;
        //    }
        //    db.Connection.Close();
        //    return iResult;
        //}

        internal static bool IsExist(string sCollectCode)
        {
            DBMoneyPacificDataContext db = new DBMoneyPacificDataContext();
            bool bResult = db.CollectMoneys
                .Where(c => c.CollectNumber.Trim() == sCollectCode.Trim()).Any();
            db.Connection.Close();
            return bResult;
        }
コード例 #15
0
 internal static StoreManager GetItem(int managerId)
 {
     DBMoneyPacificDataContext mpdb = new DBMoneyPacificDataContext();
     StoreManager existStore = mpdb.StoreManagers.
         Where(s => s.Id == managerId).Single<StoreManager>();
     mpdb.Connection.Close();
     return existStore;            
 }
コード例 #16
0
 internal static StoreManager GetItem(string sPhone)
 {
     DBMoneyPacificDataContext mpdb = new DBMoneyPacificDataContext();
     StoreManager existStore = mpdb.StoreManagers.
         Where(s => s.ManagerPhone.Trim() == sPhone.Trim()).Single<StoreManager>();
     mpdb.Connection.Close();
     return existStore;
 }
コード例 #17
0
        // private static DBMoneyPacificDataContext mpdb = new DBMoneyPacificDataContext();

        internal static bool isExist(string sCodeNumber)
        {
            DBMoneyPacificDataContext mpdb = new DBMoneyPacificDataContext();
            bool bResult = mpdb.PacificCodes.Where(p => p.CodeNumber.Trim() == sCodeNumber.Trim()).Any();
            mpdb.Connection.Close();
            return bResult;

        }
コード例 #18
0
 internal static StoreUser GetStoreUser(string storePhone, string PINStore)
 {
     DBMoneyPacificDataContext mpdb = new DBMoneyPacificDataContext();
     StoreUser existStore = mpdb.StoreUsers
         .Where(s => s.Phone.Trim() == storePhone.Trim() && s.PINStore == PINStore)
         .FirstOrDefault();
     mpdb.Connection.Close();
     return existStore;
 }
コード例 #19
0
 public static int GetId(string nameState)
 {
     DBMoneyPacificDataContext db = new DBMoneyPacificDataContext();
     int id = (int)db.CollectStates
         .Where(c => c.Name.Trim() == nameState.Trim())
         .Single<CollectState>().Id;
     db.Connection.Close();
     return id;
 }
コード例 #20
0
 internal static CollectMoney GetItem(string sCollectCode)
 {
     DBMoneyPacificDataContext db = new DBMoneyPacificDataContext();
     CollectMoney existCollectMoney = db.CollectMoneys                
         .Where(c => c.CollectNumber.Trim() == sCollectCode.Trim())
         .SingleOrDefault<CollectMoney>();
     db.Connection.Close();
     return existCollectMoney;
 }
コード例 #21
0
        // private static DBMoneyPacificDataContext mpdb = new DBMoneyPacificDataContext();

        internal static bool CheckPassword(StoreUser senderStore)
        {
            DBMoneyPacificDataContext mpdb = new DBMoneyPacificDataContext();
            bool bResult = mpdb.StoreUsers.Where(l => (l.Phone == senderStore.Phone
                 && l.PINStore == senderStore.PINStore)).Any();
            mpdb.Connection.Close();
            return bResult;

        }
コード例 #22
0
 internal static int getActualAmount(string sCodeNumber)
 {
     DBMoneyPacificDataContext mpdb = new DBMoneyPacificDataContext();
     
     PacificCode pCode = mpdb.PacificCodes.Where
         (p => p.CodeNumber.Trim() == sCodeNumber.Trim()).Single<PacificCode>();
     
     int iResult = (int)pCode.ActualAmount;
     mpdb.Connection.Close();
     
     return iResult;
 }
コード例 #23
0
        internal static Customer addNew(string sPhone)
        {
            DBMoneyPacificDataContext mpdb = new DBMoneyPacificDataContext();

            Customer newCustomer = new Customer();
            
            newCustomer.Phone = sPhone;
            // Default: Customer.status = "001" (normal customer & not yet buy)
            
            newCustomer.StatusID = CustomerStateBUS.getId("001");

            mpdb.Customers.InsertOnSubmit(newCustomer);
            mpdb.SubmitChanges();

            mpdb.Connection.Close();
            return newCustomer;
        }
コード例 #24
0
        // internal static DBMoneyPacificDataContext mpdb = new DBMoneyPacificDataContext();
        internal static void AddNew(DTO.PacificCode newSuccessPacificCode)
        {
            DBMoneyPacificDataContext mpdb = new DBMoneyPacificDataContext();

            Transaction newTransaction = new Transaction();

            newTransaction.CreateDate = newSuccessPacificCode.Date;
            newTransaction.CustomerId = newSuccessPacificCode.CustomerId;
            newTransaction.StoreId = newSuccessPacificCode.StoreId;
            newTransaction.Amount = newSuccessPacificCode.InitialAmount;
            newTransaction.Origine = "Buy MP";
            //newTranSaction.StatusID = 1; // StatusID = 1 : Status = '11'

            mpdb.Transactions.InsertOnSubmit(newTransaction);
            mpdb.SubmitChanges();

            mpdb.Connection.Close();
        }
コード例 #25
0
        internal static bool Update(CollectMoney updateCollectMoney)
        {
            DBMoneyPacificDataContext db = new DBMoneyPacificDataContext();
            bool iResult = false;
            CollectMoney exitCollectMoney = db.CollectMoneys
                .Where(c => c.CollectNumber.Trim() == updateCollectMoney.CollectNumber.Trim())
                .Single<CollectMoney>();

            exitCollectMoney.Amount = updateCollectMoney.Amount;
            exitCollectMoney.CollecteDate = updateCollectMoney.CollecteDate;
            exitCollectMoney.StatusId = updateCollectMoney.StatusId;
            
            db.SubmitChanges();
            db.Connection.Close();

            iResult = true;
            return iResult;
        }
コード例 #26
0
        internal static int getMoneyForPayMent(string sCodeNumber, int Amount)
        {
            try
            {
                DBMoneyPacificDataContext mpdb = new DBMoneyPacificDataContext();
                
                PacificCode pCode = mpdb.PacificCodes.Where
                    (p => p.CodeNumber.Trim() == sCodeNumber.Trim()).Single<PacificCode>();
                
                int iMin = Utility.Min((int)pCode.ActualAmount, Amount);

                pCode.ActualAmount = pCode.ActualAmount - iMin;
                Amount = Amount - iMin;

                mpdb.SubmitChanges();
                mpdb.Connection.Close();
                return iMin;
            }
            catch
            {
                return 0;
            }
        }
コード例 #27
0
 internal static StoreUser GetItem(int storeId)
 {
     DBMoneyPacificDataContext mpdb = new DBMoneyPacificDataContext();
     StoreUser exitStore = mpdb.StoreUsers
         .Where(l => l.Id == storeId)
         .Single<StoreUser>();
     mpdb.Connection.Close();
     return exitStore;            
 }
コード例 #28
0
        internal static StoreUser GetItem(string sPhone)
        {
            DBMoneyPacificDataContext mpdb = new DBMoneyPacificDataContext();
            StoreUser result = mpdb.StoreUsers
                .Where(l => l.Phone.Trim() == sPhone.Trim())
                .Single<StoreUser>();

            mpdb.Connection.Close();
            return result;
        }
コード例 #29
0
        internal static bool UnLock(int storeId)
        {
            DBMoneyPacificDataContext mpdb = new DBMoneyPacificDataContext();
            StoreUser exitStore = mpdb.StoreUsers
                .Where(l => l.Id == storeId)
                .Single<StoreUser>();

            /// UNLOCK
            exitStore.Enable = true;
            ///

            mpdb.SubmitChanges();
            mpdb.Connection.Close();
            return true;
        }
コード例 #30
0
        /// <summary>
        /// Lấy tất cả các PacificCode được mua bởi StoreUser này, 
        /// ở trong tháng. Tính tổng tất cả InitialAmount 
        /// </summary>        
        internal static int GetTotalAmount(int storeId)
        {
            DBMoneyPacificDataContext db = new DBMoneyPacificDataContext();
            int iTotalAmount = 0;

            //iTotalAmount = (from p in db.PacificCodes
            //                where p.StoreId == storeId
            //                select (int)p.InitialAmount).DefaultIfEmpty().Sum();

            List<PacificCode> lstPacificCode = PacificCodeDAO.GetList(storeId);
            foreach (PacificCode p in lstPacificCode)
            {
                if (p.InitialAmount == null) p.InitialAmount = 0;
                iTotalAmount += (int)p.InitialAmount;
            }

            db.Connection.Close();
            return iTotalAmount;
        }