예제 #1
0
파일: BaseDB.cs 프로젝트: mercaditu/ERP
        /// <summary>
        /// Takes all Changes made to the Entity, and reverts it to the original state.
        /// </summary>
        public void CancelAllChanges()
        {
            string str = LocExtension.GetLocalizedValue <string>("Cognitivo:local:" + "Question_Cancel");

            if (MessageBox.Show(str, "Cognitivo ERP", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
            {
                foreach (var entry in ChangeTracker.Entries())
                {
                    switch (entry.State)
                    {
                    case EntityState.Modified:
                    {
                        entry.CurrentValues.SetValues(entry.OriginalValues);
                        entry.State = EntityState.Unchanged;
                        break;
                    }

                    case EntityState.Deleted:
                    {
                        entry.State = EntityState.Unchanged;
                        break;
                    }

                    case EntityState.Added:
                    {
                        entry.State = EntityState.Detached;
                        break;
                    }
                    }
                }
            }
        }
예제 #2
0
        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            if (CollectionViewSource != null)
            {
                MainGrid.DataContext = CollectionViewSource;
                //  db db= new entity.db();

                // Grid1.ItemsSource = _CollectionViewSource;
                foreach (SmartBoxColumn item in Columns)
                {
                    if (!Grid.Columns.Contains(item) && item.Hide != true)
                    {
                        Grid.Columns.Add(item);
                    }
                }

                // TxtSearched.Text =Text;
            }


            foreach (var Column in Columns)
            {
                string str = LocExtension.GetLocalizedValue <string>("Cognitivo:local:" + Column.Header.ToString());
                if (!string.IsNullOrEmpty(str))
                {
                    Column.Header = str;
                }
            }
        }
        public MainWindow()
        {
            ResxLocalizationProvider.Instance.ProviderError += (s, e) =>
            {
                Debug.WriteLine("Missing Key: " + e.Key);
            };

            this.DataContext = new MyViewModel();
            InitializeComponent();

            string localisedValue = string.Empty;

            //ILocalizationProvider cvsProvider = new CSVLocalizationProvider() { FileName = "Example", HasHeader = true };
            //LocalizeDictionary.Instance.DefaultProvider = cvsProvider;

            //LocExtension locExtension = new LocExtension();
            //locExtension.Key = "TestText";

            //locExtension.ResolveLocalizedValue<string>(out localisedValue, new CultureInfo("de"));

            //localisedValue = (string)LocalizeDictionary.Instance.GetLocalizedObject("TestText", null, new CultureInfo("de"), cvsProvider);

            localisedValue = LocExtension.GetLocalizedValue <string>("AssemblyTestResourceLib:Strings:TestText");

            Console.WriteLine(localisedValue);
        }
예제 #4
0
파일: dbContext.cs 프로젝트: mercaditu/ERP
        /// <summary>
        /// Cancel changes for selected entity only.
        /// </summary>
        /// <param name="entry">Object of DbEntityEntry</param>
        public void CancelChangesForSingleEntry(DbEntityEntry entry)
        {
            string str = LocExtension.GetLocalizedValue <string>("Cognitivo:local:" + "Question_Cancel");

            if (MessageBox.Show(str, "Cognitivo ERP",
                                MessageBoxButton.YesNo,
                                MessageBoxImage.Question) == MessageBoxResult.Yes)
            {
                switch (entry.State)
                {
                case EntityState.Modified:
                    entry.State = EntityState.Unchanged;
                    break;

                case EntityState.Added:
                    entry.State = EntityState.Detached;
                    break;

                case EntityState.Deleted:
                    entry.Reload();
                    break;

                default: break;
                }
            }
        }
예제 #5
0
 void DenyAccess()
 {
     ErrorText = LocExtension.GetLocalizedValue <string>("CoreModule_AccessDenied");
     //ErrorText = LocExtension.GetLocalizedValue<string>("Poseidon.BackOffice.Core:Strings:CoreModuleWrongPassword");
     User     = string.Empty;
     Password = string.Empty;
 }
예제 #6
0
 private bool ShowLegacyDialog(IWin32Window owner)
 {
     using (OpenFileDialog frm = new OpenFileDialog())
     {
         frm.CheckFileExists = false;
         frm.CheckPathExists = true;
         //frm.CreatePrompt = false;
         //frm.Filter = "|" + Guid.Empty.ToString();
         //frm.FileName = "any";
         if (InitialFolder != null)
         {
             frm.InitialDirectory = InitialFolder;
         }
         //frm.OverwritePrompt = false;
         frm.Title         = LocExtension.GetLocalizedValue <string>("ChooseFolder");
         frm.ValidateNames = false;
         if (frm.ShowDialog(owner) == DialogResult.OK)
         {
             Folder = Path.GetDirectoryName(frm.FileName);
             return(true);
         }
         else
         {
             return(false);
         }
     }
 }
예제 #7
0
 public static T GetLocalizedValue <T>(string key, string resources = "Resources", string assembly = null)
 {
     if (assembly == null)
     {
         assembly = Assembly.GetCallingAssembly().GetName().Name;
     }
     return(LocExtension.GetLocalizedValue <T>(assembly + ":" + resources + ":" + key));
 }
예제 #8
0
 static IOfficeModule CreateHomePage()
 {
     return(new OfficeModule
     {
         Title = LocExtension.GetLocalizedValue <string>("CoreModule_Title"),
         Description = LocExtension.GetLocalizedValue <string>("CoreModule_Description"),
         ToolTip = LocExtension.GetLocalizedValue <string>("CoreModule_Tooltip"),
         TargetUri = new Uri(CoreViews.ModulesView, UriKind.Relative),
     });
 }
예제 #9
0
파일: Localize.cs 프로젝트: mercaditu/ERP
        public static string StringText(string key)
        {
            string s = LocExtension.GetLocalizedValue <string>("Cognitivo:local:" + key);

            if (s == null)
            {
                s = key;
            }
            return(s);
        }
예제 #10
0
        public static string L(string key)
        {
            var text = LocExtension.GetLocalizedValue <string>(key);

            if (string.IsNullOrEmpty(text))
            {
                return(key);
            }
            return(text);
        }
예제 #11
0
파일: DataGrid.cs 프로젝트: mercaditu/ERP
 private void Localize()
 {
     foreach (var Column in Columns)
     {
         string str = LocExtension.GetLocalizedValue <string>("Cognitivo:local:" + Column.Header.ToString());
         if (!string.IsNullOrEmpty(str))
         {
             Column.Header = str;
         }
     }
 }
예제 #12
0
파일: dbContext.cs 프로젝트: mercaditu/ERP
        /// <summary>
        /// Cancels changes made to Entity asking the user to approve this method before continuing.
        /// </summary>
        public void CancelChanges_withQuestion()
        {
            string str = LocExtension.GetLocalizedValue <string>("Cognitivo:local:" + "Question_Cancel");

            if (MessageBox.Show(str, "Cognitivo ERP",
                                MessageBoxButton.YesNo,
                                MessageBoxImage.Question) == MessageBoxResult.Yes)
            {
                CancelChanges();
            }
        }
예제 #13
0
        /// <summary>
        /// 多言語対応のためにResourcesから文言を抜き出すためのメソッド
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="key"></param>
        /// <returns></returns>
        public static T GetLocalizedValue <T>(string key)
        {
            //メインアプリのリソースを使う時
            //var temp = Assembly.GetCallingAssembly().GetName().Name + ":Resources:" + key;

            //任意のプロジェクトのリソースを固定して使う時は直接書けばいい
            var temp = "CommonModels:Resources:" + key;
            var ret  = LocExtension.GetLocalizedValue <T>(temp);

            return(ret);
        }
예제 #14
0
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            int _value = (int)value;

            if ((int)Status.Documents_General.Approved == _value)
            {
                return(LocExtension.GetLocalizedValue <string>("Cognitivo:local:" + "Approve"));;
            }
            else
            {
                return(LocExtension.GetLocalizedValue <string>("Cognitivo:local:" + "Pending"));;
            }
        }
예제 #15
0
 private void Window_StateChanged(object sender, EventArgs e)
 {
     if (this.WindowState == WindowState.Minimized)
     {
         this.Hide();
         if (!this.notification_showed)
         {
             this.notification_showed = true;
             var title = LocExtension.GetLocalizedValue <string>("BililiveRecorder.WPF:Strings:TaskbarIconControl_Title");
             var body  = LocExtension.GetLocalizedValue <string>("BililiveRecorder.WPF:Strings:TaskbarIconControl_MinimizedNotification");
             this.ShowBalloonTipCallback?.Invoke(title, body, BalloonIcon.Info);
         }
     }
 }
예제 #16
0
        public BindingLoc(string path) : base()
        {
            Converter = new MultiConverter <string>(data =>
            {
                if (data.Values?.Length > 0)
                {
                    try
                    {
                        var culture = LocalizeDictionary.Instance.SpecificCulture;
                        var key     = data.Values[0].ToString();

                        var value = LocExtension.GetLocalizedValue(data.TargetType, key, culture, null);
                        if (value == null)
                        {
                            var missingKeyEventResult = LocalizeDictionary.Instance.OnNewMissingKeyEvent(this, key);
                            if
                            (
                                LocalizeDictionary.Instance.OutputMissingKeys
                                &&
                                !string.IsNullOrEmpty(key) &&
                                (data.TargetType == typeof(string) ||
                                 data.TargetType == typeof(object))
                            )
                            {
                                value = missingKeyEventResult.MissingKeyResult != null
                                ? missingKeyEventResult.MissingKeyResult
                                : "Key: " + key;
                            }
                        }
                        var result = $"{Prefix}{value}{Suffix}";
                        result     = Format?.F(result) ?? result;
                        result     = Lower ? result.ToLower() : Upper ? result.ToUpper() : result;
                        return(result);
                    }
                    catch { }
                }
                return(null);
            });

            KeyBinding = new Binding(path);
            Bindings.Add(KeyBinding);
            Bindings.Add(new Markup.Options()
            {
                Path = new PropertyPath("Language")
            });
        }
예제 #17
0
 private void Regedit(object sender, RoutedEventArgs e)
 {
     try
     {
         // Directory
         Registry.ClassesRoot.DeleteSubKeyTree(@"Directory\shell\sd_pck", false);
         Registry.ClassesRoot.DeleteSubKeyTree(".pck", false);
         Registry.ClassesRoot.DeleteSubKeyTree(".cup", false);
         Registry.ClassesRoot.DeleteSubKeyTree("sdPck", false);
         using (var key = Registry.ClassesRoot.CreateSubKey(@"Directory\shell").CreateSubKey("sd_pck", RegistryKeyPermissionCheck.ReadWriteSubTree))
         {
             key.SetValue("Icon", $"{System.Reflection.Assembly.GetExecutingAssembly().Location},0");
             key.SetValue("MUIVerb", LocExtension.GetLocalizedValue <string>("ContextCompress"), RegistryValueKind.String);
             using (var key1 = key.CreateSubKey("command"))
             {
                 key1.SetValue(string.Empty, $"{System.Reflection.Assembly.GetExecutingAssembly().Location} \"%1\"", RegistryValueKind.ExpandString);
             }
         }
         // PCK
         using (var key = Registry.ClassesRoot.CreateSubKey(".pck"))
         {
             key.SetValue(string.Empty, $"sdPck", RegistryValueKind.String);
         }
         // CUP
         using (var key = Registry.ClassesRoot.CreateSubKey(".cup"))
         {
             key.SetValue(string.Empty, $"sdPck", RegistryValueKind.String);
         }
         using (var key = Registry.ClassesRoot.CreateSubKey("sdPck"))
         {
             key.SetValue(string.Empty, "Archive manager for Angelica Engine by Wanmei");
             using (var key1 = key.CreateSubKey("DefaultIcon"))
             {
                 key1.SetValue(string.Empty, $"{System.Reflection.Assembly.GetExecutingAssembly().Location},0");
             }
             key.CreateSubKey(@"Shell\Open\Command").SetValue(string.Empty, $"{System.Reflection.Assembly.GetExecutingAssembly().Location} \"%1\"");
         }
     }
     catch
     {
         MessageBox.Show("Для изменения реестра нужно запустить программу от имени администратора");
     }
 }
        /// <inheritdoc/>
        public string GetLocalisedString(
            string key)
        {
            if (string.IsNullOrWhiteSpace(key))
            {
                throw new ArgumentNullException(nameof(key));
            }

            var lookupValue = _resourceFiles
                              .OrderBy(pair => pair.Value)
                              .Select(
                pair =>
            {
                var lookup = $"{pair.Key}:{key}";
                return(LocExtension.GetLocalizedValue <string>(lookup));
            })
                              .FirstOrDefault(value => !string.IsNullOrWhiteSpace(value));

            return(lookupValue ?? throw new KeyNotFoundException($"Cannot find key {key} in resource dictionary"));
        }
예제 #19
0
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value == null)
            {
                return(string.Empty);
            }
            var sb     = new StringBuilder();
            var svalue = value.ToString();

            if (parameter != null)
            {
                var sparam = parameter.ToString();
                if (!string.IsNullOrWhiteSpace(sparam))
                {
                    svalue = $"{svalue}.{sparam}";
                }
            }
            var res = LocExtension.GetLocalizedValue <string>(svalue, Settings.Instance.Localization.Culture);

            return(res);
        }
예제 #20
0
        /// <inheritdoc/>
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value != null)
            {
                try
                {
                    culture = LocalizeDictionary.Instance.SpecificCulture;
                    var _key = value.ToString();

                    var result = LocExtension.GetLocalizedValue(targetType, _key, culture, null);

                    if (result == null)
                    {
                        var missingKeyEventResult = LocalizeDictionary.Instance.OnNewMissingKeyEvent(this, _key);

                        if (LocalizeDictionary.Instance.OutputMissingKeys &&
                            !string.IsNullOrEmpty(_key) && (targetType == typeof(String) || targetType == typeof(object)))
                        {
                            if (missingKeyEventResult.MissingKeyResult != null)
                            {
                                result = missingKeyEventResult.MissingKeyResult;
                            }
                            else
                            {
                                result = "Key: " + _key;
                            }
                        }
                    }
                    return(result);
                }
                catch
                { }
            }

            return(null);
        }
예제 #21
0
 /// <summary>
 /// Get localized resource.
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="key"></param>
 /// <returns></returns>
 public static T GetLocalizedValue <T> (string key)
 {
     return(LocExtension.GetLocalizedValue <T> (Assembly.GetCallingAssembly().GetName().Name + ":Resources:" + key));
 }
예제 #22
0
 public T GetLocalizedValue <T>(string key) => LocExtension.GetLocalizedValue <T>(Assembly.GetCallingAssembly().GetName().Name + $":{this.resourcesIdentifier}:" + key);
예제 #23
0
 public static T GetValue <T>(string key)
 {
     return(LocExtension.GetLocalizedValue <T>(Assembly.GetExecutingAssembly().GetName().Name + ":Main:" + key));
 }
 public static T GetLocalizedValue <T>(string key) => LocExtension.GetLocalizedValue <T>($"{CallingAssemblyName}:Strings:{key}");
예제 #25
0
        public void Approve()
        {
            foreach (sales_return sales_return in base.sales_return.Local.Where(x => x.status != Status.Documents_General.Approved))
            {
                if (sales_return.status != Status.Documents_General.Approved &&
                    sales_return.IsSelected &&
                    sales_return.Error == null)
                {
                    if (sales_return.id_sales_return == 0)
                    {
                        SaveChanges();
                    }

                    if (sales_return.status != Status.Documents_General.Approved)
                    {
                        if (sales_return.number == null && sales_return.id_range != null)
                        {
                            Brillo.Logic.Range.branch_Code   = base.app_branch.Where(x => x.id_branch == sales_return.id_branch).FirstOrDefault().code;
                            Brillo.Logic.Range.terminal_Code = base.app_terminal.Where(x => x.id_terminal == sales_return.id_terminal).FirstOrDefault().code;
                            app_document_range app_document_range = base.app_document_range.Where(x => x.id_range == sales_return.id_range).FirstOrDefault();
                            sales_return.number = Brillo.Logic.Range.calc_Range(app_document_range, true);
                            sales_return.RaisePropertyChanged("number");
                            sales_return.is_issued = true;

                            //Save values bofore printing.
                            SaveChanges();

                            Brillo.Document.Start.Automatic(sales_return, app_document_range);
                        }
                        else
                        {
                            sales_return.is_issued = false;
                        }

                        List <payment_schedual> payment_schedualList = new List <payment_schedual>();
                        Brillo.Logic.Payment    _Payment             = new Brillo.Logic.Payment();
                        payment_schedualList = _Payment.insert_Schedual(sales_return);

                        Brillo.Logic.Stock   _Stock            = new Brillo.Logic.Stock();
                        List <item_movement> item_movementList = new List <item_movement>();
                        item_movementList = _Stock.insert_Stock(this, sales_return);

                        if (payment_schedualList != null && payment_schedualList.Count > 0)
                        {
                            payment_schedual.AddRange(payment_schedualList);
                        }
                        if (item_movementList != null && item_movementList.Count > 0)
                        {
                            item_movement.AddRange(item_movementList);
                        }

                        if (sales_return.sales_invoice != null)
                        {
                            payment payment = new payment();
                            payment.id_contact = sales_return.id_contact;
                            payment_detail payment_detailreturn = new payment_detail();
                            // payment_detailreturn.id_account = payment_quick.payment_detail.id_account;
                            payment_detailreturn.id_currencyfx = sales_return.id_currencyfx;

                            //Check for Credit Note PaymentType.
                            if (base.payment_type.Where(x => x.payment_behavior == entity.payment_type.payment_behaviours.CreditNote).FirstOrDefault() != null)
                            {
                                //Gets Payment Type form Database.
                                payment_detailreturn.id_payment_type = base.payment_type.Where(x => x.payment_behavior == entity.payment_type.payment_behaviours.CreditNote).FirstOrDefault().id_payment_type;
                            }
                            else
                            {
                                //In case Payment type doesn not exist, this will create it and try to fix the error.
                                payment_type payment_type = new payment_type();
                                payment_type.payment_behavior = entity.payment_type.payment_behaviours.CreditNote;
                                payment_type.name             = LocExtension.GetLocalizedValue <string>("Cognitivo:local:SalesReturn");
                                base.payment_type.Add(payment_type);

                                payment_detailreturn.payment_type = payment_type;
                            }

                            payment_detailreturn.id_sales_return = sales_return.id_sales_return;
                            payment_detailreturn.value           = sales_return.GrandTotal;

                            payment_schedual payment_schedualReturn = new payment_schedual();
                            payment_schedualReturn.debit         = 0;
                            payment_schedualReturn.credit        = sales_return.GrandTotal;
                            payment_schedualReturn.id_currencyfx = sales_return.id_currencyfx;
                            payment_schedualReturn.sales_return  = sales_return;
                            payment_schedualReturn.trans_date    = sales_return.trans_date;
                            payment_schedualReturn.expire_date   = sales_return.trans_date;
                            payment_schedualReturn.status        = entity.Status.Documents_General.Approved;
                            payment_schedualReturn.id_contact    = sales_return.id_contact;
                            payment_schedualReturn.can_calculate = true;
                            payment_schedualReturn.parent        = sales_return.sales_invoice.payment_schedual.FirstOrDefault();

                            payment_detailreturn.payment_schedual.Add(payment_schedualReturn);
                            payment.payment_detail.Add(payment_detailreturn);
                            base.payments.Add(payment);
                        }

                        sales_return.status = Status.Documents_General.Approved;
                        SaveChanges();
                    }

                    else if (sales_return.Error != null)
                    {
                        sales_return.HasErrors = true;
                    }
                }
            }
        }
예제 #26
0
파일: Localize.cs 프로젝트: mercaditu/ERP
 public static T Text <T>(string key)
 {
     return(LocExtension.GetLocalizedValue <T>("Cognitivo:local:" + key));
 }
예제 #27
0
 private static string LocValue(string key)
 {
     return(LocExtension.GetLocalizedValue <string>(key, Settings.Instance.Localization.Culture));
 }
예제 #28
0
        private static ShellCommandVerb GetVerb(RegistryKey verbkey, string id, string appUserModeId)
        {
            if (id.ToUpperInvariant() == "RUNAS")
            {
                return(null);
            }
            //We are not taking DDE
            RegistryKey cmd = verbkey.OpenSubKey("ddeexec");

            if (cmd != null && !string.IsNullOrEmpty(cmd.GetValue(string.Empty, string.Empty).ToString()))
            {
                return(null);
            }

            ShellCommandVerb verb = new ShellCommandVerb
            {
                Verb = id,
                Name = id
            };

            string name = verbkey.GetValue("MUIVerb", string.Empty).ToString();

            if (string.IsNullOrEmpty(name))
            {
                name = verbkey.GetValue(string.Empty, string.Empty).ToString();
            }

            if (name.StartsWith("@", StringComparison.Ordinal))
            {
                StringBuilder outBuff = new StringBuilder(1024);
                if (SafeNativeMethods.SHLoadIndirectString(name, outBuff, outBuff.Capacity, IntPtr.Zero) == 0)
                {
                    verb.Name = outBuff.ToString();
                }
            }
            else
            {
                string locname = LocExtension.GetLocalizedValue <string>($"PresentationCore:ExceptionStringTable:{id}Text");
                if (string.IsNullOrEmpty(locname))
                {
                    locname = LocExtension.GetLocalizedValue <string>(id);
                }

                if (!string.IsNullOrEmpty(locname))
                {
                    verb.Name = locname;
                }
                else if (!string.IsNullOrEmpty(name))
                {
                    verb.Name = name;
                }
            }

            if (id.ToUpperInvariant() == "RUNASUSER")
            {
                verb.Command = "cmd:runasuser";
                return(verb);
            }

            cmd = verbkey.OpenSubKey("command");
            if (cmd != null)
            {
                verb.Command = cmd.GetValue(string.Empty, string.Empty).ToString();
                if (string.IsNullOrEmpty(verb.Command))
                {
                    name = cmd.GetValue("DelegateExecute", string.Empty).ToString();
                    if (!string.IsNullOrEmpty(name))
                    {
                        cmd = Registry.ClassesRoot.OpenSubKey("CLSID\\" + name);
                        if (cmd != null)
                        {
                            cmd = cmd.OpenSubKey("LocalServer32");
                            if (cmd != null)
                            {
                                name = cmd.GetValue(string.Empty, string.Empty).ToString();
                                if (!string.IsNullOrEmpty(name))
                                {
                                    verb.Command = name;
                                }
                            }
                            if (string.IsNullOrEmpty(name))
                            {
                                cmd = cmd.OpenSubKey("InProcServer32");
                                if (cmd != null)
                                {
                                    name = cmd.GetValue(string.Empty, string.Empty).ToString();
                                    if (!string.IsNullOrEmpty(name))
                                    {
                                        verb.Command = "dll:" + name;
                                    }
                                }
                            }
                        }
                    }
                }
            }

            if (string.IsNullOrEmpty(verb.Command))
            {
                if (!string.IsNullOrEmpty(appUserModeId))
                {
                    verb.Command = "Id:" + appUserModeId;
                }
            }

            if (string.IsNullOrEmpty(verb.Command))
            {
            }
            return(verb);
        }
예제 #29
0
 public static string Key(string key) => (string)LocExtension.GetLocalizedValue(typeof(string), key, LocalizeDictionary.Instance.SpecificCulture, null);
예제 #30
0
 protected static string L(string key)
 {
     return(LocExtension.GetLocalizedValue <string>(key));
 }