/// <summary> /// Create by Isaac on 2018-08-31 /// CheckWord when input value in VoucherID begin With S /// </summary> /// <param name="dr"></param> /// <param name="n"></param> /// <returns></returns> private string CheckWord(DataRow dr, out decimal n) { string originalResult = dr["RealResult"].ToString(); string _result; MinValue = dr["MinValue"].ToString(); MaxValue = dr["MaxValue"].ToString(); bool isCheck = decimal.TryParse(originalResult, out n); if (isCheck) //if it is a decimal { _result = Math.Round(Convert.ToDecimal(n), Convert.ToInt32(dr["Prec"].ToString()), MidpointRounding.AwayFromZero).ToString(); } else { //If it is a word if (VoucherID.StartsWith("S")) // Check VoucherID if Start with S { if (!string.IsNullOrEmpty(MinValue) || !string.IsNullOrEmpty(MaxValue)) //check if word have Min and Max value { _result = null; } else { _result = originalResult.ToUpper();// Upper string } } else { _result = null; } } return(_result); }
private void tmr_Tick(object sender, EventArgs e) { this.tmr.Stop(); var p = Application.StartupPath; ServiceLocator.LanguageCatalog.Load(p + "\\locale\\de_DE.mo"); PluginLoader.AddObject("include", new Action <string>(fn => { PluginLoader.Eval(File.ReadAllText(fn)); })); PluginLoader.AddObject("eval", new Func <string, object>(fn => { return(PluginLoader.Eval(fn)); })); PluginLoader.AddObject("import", new Action <string>(fn => { ModuleLoader.Load(PluginLoader.GetEngine(), Assembly.LoadFile(fn)); })); if (!Directory.Exists(string.Format("{0}\\data", p))) { Directory.CreateDirectory(string.Format("{0}\\data", p)); } if (!Directory.Exists(string.Format("{0}\\data\\invoices", p))) { Directory.CreateDirectory(string.Format("{0}\\data\\invoices", p)); } if (!Directory.Exists(string.Format("{0}\\themes", p))) { Directory.CreateDirectory(string.Format("{0}\\themes", p)); } foreach (var f in Directory.GetFiles(string.Format("{0}\\themes", p), "*.tssp", SearchOption.AllDirectories)) { ThemeResolutionService.LoadPackageFile(f); } BsonMapper.Global.RegisterAutoId <VoucherID>( isEmpty: (value) => VoucherID.IsEmpty(value), newId: (collection) => VoucherID.NewID()); DbContext.Open(p + "\\data.db"); var pP = new Product { Category = new DbRef <ProductCategory>(DbContext.ProductCategoryCollection, 1), ID = "Rose", Price = 0.81, Tax = 0.19, Image = Resources.box.ToBytes(ImageFormat.Png) }; DbContext.ProductCategoryCollection.Insert(new ProductCategory() { Name = "Pflanze" }); DbContext.ProductCollection.Insert(pP); DbContext.Commit(); var c = DbContext.ProductCollection.Include(cc => cc.Category.Fetch(DbContext.DB)).FindAll(); var frm = new MainForm(); var ps = PluginLoader.Load(Application.StartupPath + "\\Plugins"); var fs = PluginLoader.Call("init"); frm.Show(); //hide this form this.Hide(); }
/// <summary> /// When loading /// </summary> /// <param name="countryId"></param> /// <param name="retailerId"></param> /// <param name="voucherId"></param> /// <returns></returns> public bool Equals(int countryId, int retailerId, int voucherId) { #if DEBUGGER Trace.WriteLine(string.Concat("\r\n ", CountryID, " <> ", RetailerID, " <> ", VoucherID, "\r\n ", countryId, " <> ", retailerId, " <> ", voucherId), Strings.VRPINT); #endif return((CountryID == countryId) && RetailerID.CompareSmart(RetailerIDCD, retailerId, 0) && VoucherID.CompareSmart(VoucherIDCD, voucherId, 0)); }
/// <summary> /// When scanning /// </summary> /// <param name="other"></param> /// <returns></returns> public bool Equals(VoucherItem other) { Debug.Assert(other != null); #if DEBUGGER Trace.WriteLine(string.Concat("\r\n ", CountryID, " <> ", RetailerID, " <> ", VoucherID, "\r\n ", other.CountryID, " <> ", other.RetailerID, " <> ", other.VoucherID), Strings.VRPINT); #endif return(RetailerID.CompareSmart(RetailerIDCD, other.RetailerID, other.RetailerIDCD) && VoucherID.CompareSmart(VoucherIDCD, other.VoucherID, other.VoucherIDCD)); //(CountryID == other.CountryID) }
public static bool Validate(Coupon c) { VoucherID result; return(VoucherID.TryParse(c.Code.ToString(), out result)); }
public static Coupon NewCoupon() { return(new Coupon { Code = VoucherID.NewID() }); }