public void Initialize_Page()
        {
            IndxPart.Visible = false;
            EditFlag         = false;
            string date = DateTime.Now.Year + "-" + DateTime.Now.Month + "-" + DateTime.Now.Day;

            DateTxt.Text                 = date;
            AccountNameTxt.Text          = "";
            DateRow.Visible              = false;
            Main_Account                 = new MainAccount();
            Main_Account_List            = new List <MainAccount>();
            Sub_Account                  = new SubAccount();
            UpAccountDrop.DataSource     = GetAllMainStartBy(1, int.Parse(AccountLevelDrop.SelectedValue));
            UpAccountDrop.DataTextField  = "name";
            UpAccountDrop.DataValueField = "ID";
            UpAccountDrop.DataBind();

            Dictionary <int, string> AccountsDictionary = new Dictionary <int, string>();

            foreach (var M in db.MainAccount.ToList())
            {
                AccountsDictionary.Add(int.Parse(M.ID.ToString()), M.name);
            }
            foreach (var S in db.SubAccount.ToList())
            {
                AccountsDictionary.Add(int.Parse(S.ID.ToString()), S.name);
            }
            AccountNoForSearchDrop.DataSource     = AccountsDictionary;
            AccountNoForSearchDrop.DataTextField  = "Value";
            AccountNoForSearchDrop.DataValueField = "Key";
            AccountNoForSearchDrop.DataBind();
            RootDrop.SelectedIndex         = 0;
            AccountLevelDrop.SelectedIndex = 0;
            AccountTypeDrop.SelectedIndex  = 0;
            long AccountID = 1;

            try
            {
                if (int.Parse(AccountLevelDrop.SelectedValue) == 2)
                {
                    var up = int.Parse(RootDrop.SelectedValue);
                    AccountID = db.MainAccount.Where(ma => ma.UpAccount == up).Select(i => i.ID).Max() + 1;

                    UpAccountRow.Visible = false;
                }
                else
                {
                    var up = int.Parse(UpAccountDrop.SelectedValue);
                    AccountID = db.MainAccount.Where(ma => ma.UpAccount == up).Select(i => i.ID).Max() + 1;
                }

                AccountIDTxt.Text = AccountID.ToString();
                subAccountID      = int.Parse(AccountIDTxt.Text);
            }
            catch (Exception ex)
            {
            }
            if (int.Parse(AccountLevelDrop.SelectedValue) < 4)
            {
                AccountStateRow.Visible   = false;
                AccountBalanceRow.Visible = false;
            }
            else
            {
                AccountStateRow.Visible   = true;
                AccountBalanceRow.Visible = true;
            }

            //Fill Search Drop Down List
            FillSearchDropDown();
            ClearIndxControls();

            //CheckForPrivilage();
        }
        public void CommonInitializeFunction()
        {
            Main_Account      = new MainAccount();
            Main_Account_List = new List <MainAccount>();
            Sub_Account_List  = new List <SubAccount>();
            Sub_Account       = new SubAccount();
            int    Root        = int.Parse(RootDrop.SelectedValue);
            int    level       = int.Parse(AccountLevelDrop.SelectedValue);
            string AccountType = AccountTypeDrop.SelectedValue;

            if (level < 4)
            {
                if (level == 2)
                {
                    UpAccountRow.Visible = false;
                }
                else
                {
                    UpAccountRow.Visible = true;
                }
                AccountType = "رئيسى";
                AccountTypeDrop.SelectedIndex = 0;
            }
            else if (level != 2)
            {
                UpAccountRow.Visible = true;
            }
            if (AccountType == "رئيسى" && int.Parse(AccountLevelDrop.SelectedValue) < 4)
            {
                long AccountID;
                DateRow.Visible              = false;
                UpAccountDrop.DataSource     = GetAllMainStartBy(int.Parse(RootDrop.SelectedValue), int.Parse(AccountLevelDrop.SelectedValue) - 1);
                UpAccountDrop.DataTextField  = "name";
                UpAccountDrop.DataValueField = "ID";
                UpAccountDrop.DataBind();
                try
                {
                    if (int.Parse(AccountLevelDrop.SelectedValue) == 2)
                    {
                        var up = int.Parse(RootDrop.SelectedValue);
                        AccountID = db.MainAccount.Where(ma => ma.UpAccount == up).Select(i => i.ID).Max() + 1;
                    }
                    else
                    {
                        var up = int.Parse(UpAccountDrop.SelectedValue);
                        AccountID = db.MainAccount.Where(ma => ma.UpAccount == up).Select(i => i.ID).Max() + 1;
                    }

                    if (AccountID.ToString().Length < 2)
                    {
                        AccountIDTxt.Text = UpAccountDrop.SelectedValue + "01";
                    }
                    else
                    {
                        AccountIDTxt.Text = AccountID.ToString();
                    }
                    subAccountID = int.Parse(AccountIDTxt.Text);
                }
                catch (Exception ex)
                {
                }
            }
            else
            {
                DateRow.Visible = true;
                AccountTypeDrop.SelectedIndex = 1;
                if (int.Parse(AccountLevelDrop.SelectedValue) - 1 >= 4)
                {
                    UpAccountDrop.DataSource = GetAllSubAccountStartBy(int.Parse(RootDrop.SelectedValue), int.Parse(AccountLevelDrop.SelectedValue) - 1);
                }
                else
                {
                    UpAccountDrop.DataSource = GetAllMainStartBy(int.Parse(RootDrop.SelectedValue), int.Parse(AccountLevelDrop.SelectedValue) - 1);
                }
                UpAccountDrop.DataTextField  = "name";
                UpAccountDrop.DataValueField = "ID";
                UpAccountDrop.DataBind();
                long AccountID;
                try
                {
                    AccountID         = db.SubAccount.Where(ma => ma.UpAccount == UpAccountDrop.SelectedValue).Select(i => i.ID).Max() + 1;
                    AccountIDTxt.Text = AccountID.ToString();
                    subAccountID      = int.Parse(AccountIDTxt.Text);
                }
                catch (Exception ex)
                {
                }

                if (int.Parse(AccountLevelDrop.SelectedValue) < 4 && AccountTypeDrop.SelectedValue == "رئيسى")
                {
                    AccountStateRow.Visible   = false;
                    AccountBalanceRow.Visible = false;
                    DateRow.Visible           = false;
                }
                else
                {
                    AccountStateRow.Visible   = true;
                    AccountBalanceRow.Visible = true;
                    DateRow.Visible           = true;
                }
            }
            if (UpAccountDrop.SelectedValue == "1101" || UpAccountDrop.SelectedValue == "2103")
            {
                IndxPart.Visible = true;
            }
            else
            {
                IndxPart.Visible = false;
            }

            //Fill Search Drop Down List

            FillSearchDropDown();
        }