private void OpenAddType()
        {
            AddTypeOfAgencyWindow wd = new AddTypeOfAgencyWindow();

            this.ListType = DataProvider.Instance.DB.TypeOfAgencies.ToList <TypeOfAgency>();

            string[] rules = this.cache.Split(' ');
            if (this.ListType.Count >= int.Parse(rules[0]))
            {
                MessageBox.Show("Over the limit in Setting");
                return;
            }
            try
            {
                wd.txtID.Text = (this.ListType.Last().ID + 1).ToString();
            }
            catch
            {
                wd.txtID.Text = "1";
            }
            finally
            {
                wd.ShowDialog();
            }
        }
        private void SaveStore(AddTypeOfAgencyWindow para)
        {
            if (String.IsNullOrEmpty(para.txtName.Text))
            {
                para.txtName.Focus();
                return;
            }
            if (String.IsNullOrEmpty(para.txtDebt.Text))
            {
                para.txtDebt.Focus();
                return;
            }

            int          id   = int.Parse(para.txtID.Text);
            TypeOfAgency item = new TypeOfAgency();

            item.ID        = id;
            item.Name      = para.txtName.Text;
            item.MaxOfDebt = ConvertToNumber(para.txtDebt.Text);

            DataProvider.Instance.DB.TypeOfAgencies.AddOrUpdate(item);
            DataProvider.Instance.DB.SaveChanges();

            int count = this.HomeWindow.stkListType_Setting.Children.Count;

            for (int i = 0; i < count - 1; i++)
            {
                this.HomeWindow.stkListType_Setting.Children.RemoveAt(0);
            }

            para.Close();
            LoadSettingWindow(this.HomeWindow);
        }
        private void EditType(TypeOfAgencyUC para)
        {
            int stt = int.Parse(para.txbSTT.Text);

            this.ListType = DataProvider.Instance.DB.TypeOfAgencies.ToList();

            AddTypeOfAgencyWindow wd = new AddTypeOfAgencyWindow();

            wd.txtID.Text   = this.ListType[stt - 1].ID.ToString();
            wd.txtName.Text = this.ListType[stt - 1].Name;
            wd.txtDebt.Text = SeparateThousands(this.ListType[stt - 1].MaxOfDebt.ToString());

            wd.ShowDialog();
        }