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(); }
//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(); }
internal static PacificCode getNewPacificCode(int storeId, int customerId, int amountBuy) { PacificCode newPacificCode = new PacificCode(); // Generate NewCode from XML File bool bGetNewPacificCode = false; do { newPacificCode.CodeNumber = Generator.getNewCode(); bGetNewPacificCode = !PacificCodeBUS.isExist(newPacificCode.CodeNumber); } while (bGetNewPacificCode == false); // Add information newPacificCode.StoreId = storeId; newPacificCode.CustomerId = customerId; newPacificCode.InitialAmount = amountBuy; newPacificCode.ActualAmount = amountBuy; newPacificCode.Date = DateTime.Now; int iYear = DateTime.Now.Year + 1; int iMonth = DateTime.Now.Month; int iDay = DateTime.Now.Day; newPacificCode.ExpireDate = new DateTime(iYear, iMonth, iDay); // Submit for save & update (store, customer) // Update Action on STORE & CUSTOMER should be done by // Trigger or CLR Trigger in Database PacificCodeBUS.addNew(newPacificCode); return newPacificCode; }
internal static void addNew(PacificCode newPacificCode) { DBMoneyPacificDataContext mpdb = new DBMoneyPacificDataContext(); mpdb.PacificCodes.InsertOnSubmit(newPacificCode); mpdb.SubmitChanges(); mpdb.Connection.Close(); }
internal static void addNew(PacificCode newPacificCode) { TransactionDAO.AddNew(newPacificCode); }
partial void DeletePacificCode(PacificCode instance);
partial void UpdatePacificCode(PacificCode instance);
partial void InsertPacificCode(PacificCode instance);
private void detach_PacificCodes(PacificCode entity) { this.SendPropertyChanging(); entity.StoreUser = null; }
private void detach_PacificCodes(PacificCode entity) { this.SendPropertyChanging(); entity.PacificCodeState = null; }
private void attach_PacificCodes(PacificCode entity) { this.SendPropertyChanging(); entity.Customer = this; }
// TODO: Shout get from from CONFIG file private static void addNew(PacificCode newPacificCode) { StoreUserDAO.updateAfterInsertNewCode(newPacificCode); CustomerDAO.updateAfterInsertNewCode(newPacificCode); PacificCodeDAO.addNew(newPacificCode); }
internal static PacificCode generateNewCode() { PacificCode newPCode = new PacificCode(); List<PCArg> lstArg = new List<PCArg>(); XmlDocument xmlDoc = new XmlDocument(); // LOAD All information about Argument from XML file xmlDoc.Load(xmlRuleFile); XmlNode rootNode = xmlDoc.DocumentElement; foreach (XmlNode childNode in rootNode.ChildNodes) { PCArg newArg = new PCArg(); newArg.name = childNode.Attributes["name"].Value.Trim(); newArg.value = childNode.Attributes["value"].Value.Trim(); lstArg.Add(newArg); } // CALC the values for all Arguments // . Random Random randomNumer = new Random(); foreach (PCArg arg in lstArg) { if (arg.value.ToLower()== "random") { arg.value = randomNumer.Next(10).ToString(); } } // . Ruled Arguments /* foreach (PCArg arg in lstArg) { if (!Validator.isNumber(arg.value)) { foreach (PCArg argConst in lstArg) { // Replace all argruments in the expression by the correlative values if(Validator.isNumber(argConst.value)) { arg.value = arg.value.Replace(argConst.name[0],argConst.value[0]); } } arg.value = ((int)ExpressionClass.evaluateExp(arg.value)).ToString(); } } /*/ CalculateArgs(lstArg); // */ // MERGE all to CodeNumber string sResultCode = ""; for (int i = 0; i < lstArg.Count; i++) { sResultCode += lstArg[i].value; } // EXPORT the result; newPCode.CodeNumber = sResultCode; return newPCode; }