private void Recursive(DevComponents.AdvTree.Node _nd)
        {
            ic.accountC _acc = _nd.Tag as ic.accountC;
            iGRow       _row = null;

            foreach (var t in _nd.Nodes.Cast <DevComponents.AdvTree.Node>())
            {
                _row          = fGrid.Rows.Add();
                _row.Level    = t.Level - 1;
                _row.Font     = new Font("georgia", 12, FontStyle.Regular);
                _row.ReadOnly = iGBool.True;
                _row.Cells["Account Name"].Value  = t.Text;
                _row.Cells["Alias"].Value         = null;
                _row.Cells["section_index"].Value = _acc.account_dept_type.ToByte();
                _row.Cells["section_name"].Value  = _acc.account_dept_type.ToStringNullable();
                _row.Key = _acc.account_id.ToStringNullable();
                _row.AutoHeight();
                if (t.Nodes.Count == 0)
                {
                    continue;
                }
                _row.TreeButton = iGTreeButtonState.Visible;
                Recursive(t);
            }
        }
        private void RecursiveLoad(int parent_id)
        {
            iGRow _row  = null;
            var   nlist = from k in datam.DATA_DEPARTMENT.Values
                          where k.parent_id == parent_id
                          orderby k.index
                          select k;

            if (nlist.Count() > 0)
            {
                foreach (var obj in nlist)
                {
                    _row      = fGrid.Rows.Add();
                    _row.Font = new Font("verdana", 9, FontStyle.Bold);
                    _row.Cells["gp_name"].Col.Width = 220;
                    _row.Cells["mem_cnt"].Col.Width = 100;
                    _row.Cells["gp_name"].Value     = obj.dept_name;
                    _row.Cells["gp_name"].TextAlign = iGContentAlignment.MiddleLeft;
                    _row.Cells["mem_cnt"].ValueType = typeof(int);
                    _row.Key       = obj.dept_id.ToStringNullable();
                    _row.ForeColor = Color.Purple;
                    _row.AutoHeight();
                    _row.Cells["mem_cnt"].Value = obj.MemberCount;
                    _row.Tag        = obj;
                    _row.TreeButton = iGTreeButtonState.Hidden;
                    _row.Level      = 1;
                }
                fGrid.Rows[parent_id.ToString()].TreeButton = iGTreeButtonState.Visible;
            }
        }
示例#3
0
        private void AddRowX(iGrid _grid)
        {
            if (_grid.Rows.Cast <iGRow>().Count(j => j.Cells[0].Value == null) > 0)
            {
                _grid.Focus();
                var _cell = _grid.Rows.Cast <iGRow>().Where(j => j.Cells[0].Value == null).Select(v => v.Cells[0]).FirstOrDefault();
                if (_cell != null)
                {
                    _cell.Selected = true;
                }
                return;
            }
            iGRow _row = null;

            _grid.Focus();
            _row = _grid.Rows.Add();
            _row.Cells[0].Col.Width = 290;
            _row.Cells[1].Col.Width = 22;
            _row.Font      = new Font("verdana", 11, FontStyle.Regular);
            _row.ForeColor = Color.DarkBlue;
            _row.AutoHeight();
            _row.Height += 1;
            _grid.SetCurCell(_grid.Rows.Count - 1, 0);
            SendKeys.Send("{ENTER}");
            _grid.AutoResizeCols = false;
        }
示例#4
0
        public void CreateNewRow(ic.expense_accountC _obj, bool update_mode)
        {
            iGRow _row = null;

            fGrid.BeginUpdate();
            _row           = fGrid.Rows.Add();
            _row.Font      = new Font("georgia", 12, FontStyle.Regular);
            _row.TextAlign = iGContentAlignment.BottomLeft;
            _row.ReadOnly  = iGBool.True;
            _row.Cells["exp_name"].Value = _obj.exp_acc_name.ToProperCase();
            if (_obj.objCategory != null)
            {
                _row.Cells["category"].Value = _obj.objCategory.exp_cat_name;
            }
            if ((_obj.dept_id > 0 | _obj.dept_id == -5000))
            {
                _row.Cells["dept"].Value = datam.DATA_DEPARTMENT[_obj.dept_id].dept_name;
            }
            _row.Cells["exp_type"].Value    = fnn.GetExpenseTypeName(_obj.exp_acc_type);
            _row.Cells["exp_type"].AuxValue = _obj.exp_acc_type.ToByte();
            _row.Cells["colSearch"].Value   = string.Format("{0} {1} {2} {3}", _obj.exp_acc_name.ToLower(), _row.Cells["exp_type"].Text, _row.Cells["dept"].Text, _row.Cells["category"].Text).ToLower();;
            _row.Tag = _obj;
            _row.Key = _obj.exp_acc_id.ToStringNullable();
            _row.AutoHeight();
            _row.Height += 2;
            fGrid.EndUpdate();
        }
        private void LoadMainGrid()
        {
            iGRow _row = null;

            if (datam.DATA_DEPARTMENT == null)
            {
                return;
            }
            if (datam.DATA_DEPARTMENT.Keys.Count == 0)
            {
                return;
            }
            string _key = null;

            if (fGrid.Rows.Count > 0)
            {
                _key = fGrid.CurCell == null ? null : fGrid.CurCell.Row.Key;
                fGrid.Rows.Clear();
                fGrid2.Rows.Clear();
            }
            fGrid.BeginUpdate();
            var nlist = from d in datam.DATA_DEPARTMENT.Values
                        where d.dept_type == em.dept_typeS.main
                        orderby d.dept_id
                        select d;

            foreach (var obj in nlist)
            {
                _row      = fGrid.Rows.Add();
                _row.Font = new Font("verdana", 10, FontStyle.Bold);
                _row.Cells["gp_name"].Col.Width = 220;
                _row.Cells["mem_cnt"].Col.Width = 100;
                _row.Cells["gp_name"].Value     = obj.dept_name;
                _row.Cells["gp_name"].TextAlign = iGContentAlignment.MiddleLeft;
                _row.Cells["mem_cnt"].ValueType = typeof(int);
                _row.Key = obj.dept_id.ToStringNullable();
                _row.AutoHeight();
                _row.Cells["mem_cnt"].Value = obj.MemberCount;
                _row.Tag        = obj;
                _row.TreeButton = iGTreeButtonState.Hidden;
                _row.Level      = 0;
                //  RecursiveLoad(obj.dept_id);
            }
            if (!string.IsNullOrEmpty(_key))
            {
                try
                {
                    fGrid.Rows[_key].Cells[0].Selected = true;
                }
                catch (Exception ex)
                {
                }
            }
            fGrid.Cols.AutoWidth();
            fGrid.AutoResizeCols = false;
            fGrid.EndUpdate();
        }
示例#6
0
        private void FillGrid()
        {
            ClearAllGrids();
            if (datam.DATA_MEM_STATS == null)
            {
                return;
            }
            byte  _index   = 0;
            byte  _counter = 0;
            iGrid _grid    = null;
            iGRow _row     = null;

            foreach (var g in m_grids)
            {
                g.BeginUpdate();
            }
            foreach (var c in datam.DATA_MEM_STATS.Values.OrderBy(j => j.cat_index))
            {
                _grid = m_grids[_index];
                foreach (var t in c.TypeCollection.Values)
                {
                    if (c.is_optional & t.count == 0)
                    {
                        continue;
                    }
                    _row                         = _grid.Rows.Add();
                    _row.ReadOnly                = iGBool.True;
                    _row.Font                    = new Font("verdana", 11, FontStyle.Regular);
                    _row.Cells["name"].Value     = t.type_name;
                    _row.Cells["category"].Value = c.cat_name;
                    _row.Cells["value"].Value    = t.count == 0 ? null : t.count.ToStringNullable();
                    _row.Cells["svalue"].Value   = c.cat_index;
                    _row.Cells[1].ForeColor      = Color.Black;
                    _row.Cells[0].ForeColor      = Color.DarkGreen;
                    _row.AutoHeight();
                }
                _counter++;
                if (_counter == 5 & _index != 2)
                {
                    _index++;
                    _counter = 0;
                }
            }
            SortAndGroup();
            foreach (var g in m_grids)
            {
                g.Cols[0].Width = ((3 * g.ClientSize.Width) / 4);
                g.Cols[1].AutoWidth();
                g.AutoResizeCols = false;
                g.EndUpdate();
            }
        }
        private void LoadMainGrid(IEnumerable <ic.foreign_exchange_convC> _list)
        {
            fGrid.BeginUpdate();
            fGrid.Rows.Clear();
            if (_list == null)
            {
                fGrid.EndUpdate(); return;
            }
            iGRow _row = null;


            foreach (var n in _list)
            {
                _row                           = fGrid.Rows.Add();
                _row.ReadOnly                  = iGBool.True;
                _row.Font                      = new Font("georgia", 12, FontStyle.Regular);
                _row.Cells["date"].Value       = n.fs_date.ToMyShortDate();
                _row.Cells["currency"].Value   = datam.DATA_FOREIGN_CURRENCY[n.currency_id].fr_currency_name;
                _row.Cells["amount"].Value     = n.exchanged_amount;
                _row.Cells["amount"].TextAlign = iGContentAlignment.MiddleCenter;
                //
                _row.Cells["rate"].Value     = n.used_exch_rate;
                _row.Cells["sys_rate"].Value = n.curr_sys_exch_rate;
                //
                _row.Cells["ug_amount"].Value     = n.converted_ug_amount;
                _row.Cells["ug_amount"].TextAlign = iGContentAlignment.MiddleCenter;
                if (n.exch_loss > 0)
                {
                    _row.Cells["loss"].Value = n.exch_loss;
                }
                _row.Cells["loss"].ForeColor = Color.Maroon;
                if (n.exch_gain > 0)
                {
                    _row.Cells["gain"].Value = n.exch_gain;
                }
                _row.Cells["gain"].ForeColor = Color.DarkGreen;

                _row.Cells["pc_us_id"].Value = sdata.GetUserName(n.pc_us_id);

                _row.Key = n.un_id.ToStringNullable();
                _row.Tag = n;
                _row.AutoHeight();

                n.is_updated = false;
            }

            fGrid.EndUpdate();
            fGrid.Cols.AutoWidth();
            fGrid.AutoResizeCols = false;
        }
        public void NewRecord(ic.pledgeC n)
        {
            fGrid.BeginUpdate();


            iGRow _row     = null;
            float _total   = 0f;
            float _paid    = 0f;
            float _percent = 0f;

            _row                              = fGrid.Rows.Add();
            _row.Font                         = new Font("verdana", 12, FontStyle.Regular);
            _row.ReadOnly                     = iGBool.True;
            _row.Cells["no"].Value            = fGrid.Rows.Count;
            _row.Cells["pledge"].Value        = n.source_name;
            _row.Cells["pledge_amount"].Value = n.amount_pledged;
            _row.Cells["paid"].Value          = n.amount_paid;
            _row.Cells["phone"].Value         = n.source_phone;
            if (n.balance > 0)
            {
                _row.Cells["balance"].Value = n.balance;
            }
            if (n.amount_paid > 0)
            {
                _total   = n.amount_pledged;
                _paid    = n.amount_paid;
                _percent = ((_paid / _total) * 100);
                _row.Cells["p_comp"].Value = string.Format(" {0} %", Math.Round(_percent, 1));
            }
            else
            {
                _row.Cells["p_comp"].Value = string.Format(" {0} %", 0);
            }
            _row.Key = string.Format("{0}", n.pl_id);
            _row.AutoHeight();
            _row.Height += 2;
            _row.Tag     = n;



            fGrid.Cols.AutoWidth();
            fGrid.AutoResizeCols = false;
            fGrid.EndUpdate();
            if (this.Tag != null)
            {
                this.Tag = null;
            }
        }
        private void LoadMainGrid()
        {
            fGrid.BeginUpdate();
            fGrid.Rows.Clear();

            iGRow _row     = null;
            float _total   = 0f;
            float _paid    = 0f;
            float _percent = 0f;
            var   _list    = from j in datam.DATA_CURRENT_PLEDGES.Values
                             where j.pls_id == m_pledge_settings.pls_id & j.pledge_status != em.pledge_statusS.deleted
                             select j;

            foreach (var n in _list)
            {
                _row                              = fGrid.Rows.Add();
                _row.Font                         = new Font("verdana", 12, FontStyle.Regular);
                _row.ReadOnly                     = iGBool.True;
                _row.Cells["no"].Value            = fGrid.Rows.Count;
                _row.Cells["pledge"].Value        = n.source_name;
                _row.Cells["pledge_amount"].Value = n.amount_pledged;
                _row.Cells["paid"].Value          = n.amount_paid;
                _row.Cells["phone"].Value         = n.source_phone;
                if (n.balance > 0)
                {
                    _row.Cells["balance"].Value = n.balance;
                }
                if (n.amount_paid > 0)
                {
                    _total   = n.amount_pledged;
                    _paid    = n.amount_paid;
                    _percent = ((_paid / _total) * 100);
                    _row.Cells["p_comp"].Value = string.Format(" {0} %", Math.Round(_percent, 1));
                }
                else
                {
                    _row.Cells["p_comp"].Value = string.Format(" {0} %", 0);
                }
                _row.Tag = n;
                _row.Key = string.Format("{0}", n.pl_id);
                _row.AutoHeight();
                _row.Height += 2;
            }

            fGrid.Cols.AutoWidth();
            fGrid.AutoResizeCols = false;
            fGrid.EndUpdate();
        }
        private void LoadMainGrid(IEnumerable <ic.pledgeC> _list)
        {
            fGrid.BeginUpdate();
            fGrid.Rows.Clear();
            if (_list == null)
            {
                fGrid.EndUpdate(); return;
            }
            iGRow _row     = null;
            float _total   = 0f;
            float _paid    = 0f;
            float _percent = 0f;

            foreach (var n in _list)
            {
                _row          = fGrid.Rows.Add();
                _row.Font     = new Font("verdana", 12, FontStyle.Regular);
                _row.ReadOnly = iGBool.True;
                _row.Cells["pledge"].Value        = n.source_name;
                _row.Cells["pledge_amount"].Value = n.amount_pledged;
                _row.Cells["paid"].Value          = n.amount_paid;
                _row.Cells["phone"].Value         = n.source_phone;
                if (n.balance > 0)
                {
                    _row.Cells["balance"].Value = n.balance;
                }
                if (n.amount_paid > 0)
                {
                    _total   = n.amount_pledged;
                    _paid    = n.amount_paid;
                    _percent = ((_paid / _total) * 100);
                    _row.Cells["p_comp"].Value = string.Format(" {0} %", Math.Round(_percent, 1));
                }
                else
                {
                    _row.Cells["p_comp"].Value = string.Format(" {0} %", 0);
                }
                _row.Key = string.Format("P-{0}", n.pl_id);
                _row.AutoHeight();
                _row.Height += 2;
            }

            fGrid.Cols.AutoWidth();
            fGrid.AutoResizeCols = false;
            fGrid.EndUpdate();
        }
示例#11
0
        private void LoadMainGrid(IEnumerable <ic.cash_transferC> _list)
        {
            fGrid.BeginUpdate();
            fGrid.Rows.Clear();
            if (_list == null)
            {
                fGrid.EndUpdate(); return;
            }
            iGRow _row = null;

            ic.accountC _acc = null;
            foreach (var n in _list)
            {
                _row                             = fGrid.Rows.Add();
                _row.ReadOnly                    = iGBool.True;
                _row.Font                        = new Font("georgia", 12, FontStyle.Regular);
                _row.Cells["date"].Value         = n.fs_date.Value.ToMyShortDate();
                _acc                             = datam.DATA_ACCOUNTS[n.source_id];
                _row.Cells["from_account"].Value = _acc.account_name;
                //
                _acc = datam.DATA_ACCOUNTS[n.destination_id];
                _row.Cells["to_account"].Value = _acc.account_name;
                if (_acc.account_id == -2355)
                {
                    _row.Cells["to_account"].Value = "LCB";
                }
                //
                _row.Cells["amount"].Value     = n.amount;
                _row.Cells["amount"].TextAlign = iGContentAlignment.MiddleCenter;
                _row.Cells["amount"].ForeColor = Color.DarkBlue;
                //
                _row.Cells["details"].Value = n.transfer_reason;
                //

                _row.Key = n.un_id.ToStringNullable();
                _row.Tag = n;
                _row.AutoHeight();

                n.is_updated = false;
            }

            fGrid.EndUpdate();
            fGrid.Cols.AutoWidth();
            fGrid.AutoResizeCols = false;
        }
示例#12
0
        private void LoadCategoryGrid()
        {
            iGRow _row = null;

            iGridCategory.BeginUpdate();
            foreach (var r in datam.DATA_CG_TYPES.Values)
            {
                _row = iGridCategory.Rows.Add();
                _row.Cells[0].Col.Width = 290;
                _row.Cells[1].Col.Width = 22;
                _row.Font      = new Font("verdana", 11, FontStyle.Regular);
                _row.ForeColor = Color.DarkBlue;
                _row.AutoHeight();
                _row.Height        += 1;
                _row.Tag            = r;
                _row.Cells[0].Value = r.cg_type_name;
            }
            iGridCategory.EndUpdate();
        }
示例#13
0
        public void load_items()
        {
            fGrid.Rows.Clear();

            if (datam.DATA_EXPENSE_ACCOUNTS == null || datam.DATA_EXPENSE_ACCOUNTS.Count == 0)
            {
                return;
            }
            iGRow _row = null;

            fGrid.BeginUpdate();
            var nlist = from s in datam.DATA_EXPENSE_ACCOUNTS.Values
                        where s.exp_acc_status == em.exp_acc_statusS.valid & s.isActualExpense
                        select s;

            foreach (var _obj in nlist)
            {
                _row           = fGrid.Rows.Add();
                _row.Font      = new Font("georgia", 12, FontStyle.Regular);
                _row.TextAlign = iGContentAlignment.BottomLeft;
                _row.ReadOnly  = iGBool.True;
                _row.Cells["exp_name"].Value = _obj.exp_acc_name.ToProperCase();
                if (_obj.objCategory != null)
                {
                    _row.Cells["category"].Value = _obj.objCategory.exp_cat_name;
                }
                if (_obj.dept_id > 0 | _obj.dept_id == -5000)
                {
                    _row.Cells["dept"].Value = datam.DATA_DEPARTMENT[_obj.dept_id].dept_name;
                }
                _row.Cells["exp_type"].Value    = fnn.GetExpenseTypeName(_obj.exp_acc_type);
                _row.Cells["exp_type"].AuxValue = _obj.exp_acc_type.ToByte();
                _row.Cells["colSearch"].Value   = string.Format("{0} {1} {2} {3}", _obj.exp_acc_name.ToLower(), _row.Cells["exp_type"].Text, _row.Cells["dept"].Text, _row.Cells["category"].Text).ToLower();;
                _row.Tag = _obj;
                _row.Key = _obj.exp_acc_id.ToStringNullable();
                _row.AutoHeight();
                _row.Height += 2;
            }
            fGrid.Cols.AutoWidth();
            fGrid.AutoResizeCols = false;
            fGrid.EndUpdate();
        }
        private void LoadMainGrid()
        {
            iGRow _row = null;

            if (datam.DATA_CHURCH_GROUPS == null)
            {
                return;
            }
            if (datam.DATA_CHURCH_GROUPS.Keys.Count == 0)
            {
                return;
            }
            fGrid.BeginUpdate();
            foreach (var obj in datam.DATA_CHURCH_GROUPS.Values)
            {
                _row      = fGrid.Rows.Add();
                _row.Font = new Font("verdana", 10, FontStyle.Bold);
                _row.Cells["gp_name"].Col.Width = 220;
                _row.Cells["mem_cnt"].Col.Width = 100;
                _row.Cells["gp_name"].Value     = obj.cg_name;
                _row.Cells["gp_name"].TextAlign = iGContentAlignment.BottomRight;
                _row.Cells["mem_cnt"].ValueType = typeof(int);
                _row.Key = obj.cg_id.ToStringNullable();
                _row.AutoHeight();
                _row.Cells["type_id"].Value = obj.cg_type_id;
                _row.Cells["mem_cnt"].Value = obj.MemberCount;
                _row.Tag = obj;
            }
            fGrid.SortObject.Add("type_id");
            fGrid.Sort();
            fGrid.GroupObject.Add("type_id");
            fGrid.Group();
            fGrid.Cols.AutoWidth();
            fGrid.AutoResizeCols = false;
            fGrid.PerformAction(iGActions.CollapseAll);
            if (fGrid.Rows.Count > 0)
            {
                fGrid.Rows[0].Expanded = true;
            }
            fGrid.EndUpdate();
        }
        private void LoadMainGrid(IEnumerable <ic.bank_reconc_transC> _list)
        {
            fGrid.BeginUpdate();
            fGrid.Rows.Clear();
            if (_list == null)
            {
                fGrid.EndUpdate(); return;
            }
            iGRow _row = null;


            foreach (var n in _list)
            {
                _row                              = fGrid.Rows.Add();
                _row.ReadOnly                     = iGBool.True;
                _row.Font                         = new Font("georgia", 12, FontStyle.Regular);
                _row.Cells["no"].Value            = fGrid.Rows.Count;
                _row.Cells["date"].Value          = n.fs_date.ToMyShortDate();
                _row.Cells["rc_type"].Value       = n.br_acc_type == em.bank_reconc_typeS.addition ? "+" : "-";
                _row.Cells["rc_type"].TextAlign   = iGContentAlignment.MiddleCenter;
                _row.Cells["rc_amount"].Value     = n.amount;
                _row.Cells["rc_amount"].TextAlign = iGContentAlignment.MiddleCenter;
                _row.Cells["bank"].Value          = n.objBankAccount.BankName;

                //
                _row.Cells["rc_account"].Value     = n.objReconcAccount.br_acc_name;
                _row.Cells["rc_account"].ForeColor = Color.DarkBlue;
                _row.Cells["desc"].Value           = n.desc;
                //
                _row.Key = n.un_id.ToStringNullable();
                _row.Tag = n;
                _row.AutoHeight();

                n.is_updated = false;
            }

            fGrid.EndUpdate();
            fGrid.Cols.AutoWidth();
            fGrid.AutoResizeCols = false;
        }
示例#16
0
        private void LoadGrid()
        {
            iGRow _row   = null;
            var   _nlist = (from d in datam.DATA_ACCOUNTS.Values
                            where d.account_status == em.account_statusS.DisContinued
                            select d);

            fGrid.BeginUpdate();
            foreach (var n in _nlist)
            {
                _row                             = fGrid.Rows.Add();
                _row.ReadOnly                    = iGBool.True;
                _row.Font                        = new Font("georgia", 12, FontStyle.Regular);
                _row.Cells["no"].Value           = fGrid.Rows.Count;
                _row.Cells["account_name"].Value = datam.DATA_ACCOUNTS[n.account_id].account_name;

                _row.Key = n.account_id.ToStringNullable();
                _row.Tag = n;
                _row.AutoHeight();
            }
            fGrid.AutoResizeCols = false;
            fGrid.Cols.AutoWidth();
            fGrid.EndUpdate();
        }
示例#17
0
        private void DrawLeftTree()
        {
            if (labelCalender.Tag == null)
            {
                return;
            }

            Application.DoEvents();
            var _dt = Convert.ToDateTime(labelCalender.Tag);

            m_YEAR  = _dt.Year;
            m_MONTH = _dt.Month;
            int new_val = string.Format("{0}{1}", m_YEAR, m_MONTH).ToInt32();

            iGrid1.BeginUpdate();
            iGrid1.Rows.Clear();
            fGrid.Rows.Clear();
            if (!datam.GetMonthCashTransfers(new_val))
            {
            }
            var   _days = DateTime.DaysInMonth(m_YEAR, m_MONTH);
            iGRow _row  = null;

            #region draw_month header
            _row           = iGrid1.Rows.Add();
            _row.Font      = new Font("georgia", 12, FontStyle.Bold);
            _row.ForeColor = Color.Blue;
            _row.Cells["payments"].ForeColor = Color.FromArgb(64, 64, 64);
            _row.Cells["expenses"].ForeColor = Color.FromArgb(64, 64, 64);
            _row.Cells["total"].ForeColor    = Color.Maroon;
            _row.Cells[0].Value = datam.MONTHS[m_MONTH - 1];
            _row.TreeButton     = iGTreeButtonState.Visible;
            _row.Level          = 0;
            _row.ReadOnly       = iGBool.True;
            _row.Height        += 2;
            _row.Key            = m_MONTH.ToStringNullable();
            _row.AutoHeight();
            #endregion
            _row            = iGrid1.Rows.Add();
            _row.Height     = 7;
            _row.BackColor  = Color.Lavender;
            _row.Selectable = false;
            _row.Level      = 1;
            _row.TreeButton = iGTreeButtonState.Hidden;
            _row.Key        = "sddd";
            #region draw month details
            DateTime?_last_date  = new DateTime(m_YEAR, m_MONTH, _days);
            int      start_fs_id = fn.GetFSID(_last_date.Value);
            for (int j = _days; j > 0; j--)
            {
                _row            = iGrid1.Rows.Add();
                _row.ReadOnly   = iGBool.True;
                _row.Level      = 1;
                _row.TreeButton = iGTreeButtonState.Hidden;
                _row.Font       = new Font("georgia", 12, FontStyle.Regular);
                _row.ForeColor  = Color.Maroon;
                //_row.Cells["payments"].ForeColor = Color.FromArgb(64, 64, 64);
                //_row.Cells["expenses"].ForeColor = Color.FromArgb(64, 64, 64);
                _row.Cells[0].Value    = j.ToNthDay();
                _row.Cells[0].AuxValue = j;
                _row.AutoHeight();
                _row.Height += 2;
                _row.Key     = start_fs_id.ToStringNullable();
                _row.Visible = false;
                _row.Tag     = new DateTime(m_YEAR, m_MONTH, j).ToMyLongDate();

                start_fs_id--;
            }
            #endregion
            if (datam.DATA_MONTH_CASH_TRANSFERS[new_val].Keys.Count > 0)
            {
                var nlist = from n in datam.DATA_MONTH_CASH_TRANSFERS[new_val]
                            where n.Value.status == em.cashTransferStatus.valid
                            orderby n.Value.fs_id descending
                            group n by n.Value.fs_id
                            into new_group
                            select new
                {
                    fs_id         = new_group.Key,
                    total_entries = new_group.Count(),
                };
                if (nlist.Count() > 0)
                {
                    iGrid1.Rows[m_MONTH.ToString()].Cells["total"].Value = nlist.Sum(k => k.total_entries);
                    if ((nlist.Max(j => j.fs_id) != sdata.CURR_FS.fs_id) & new_val == string.Format("{0}{1}", sdata.CURR_DATE.Year, sdata.CURR_DATE.Month).ToInt32())
                    {
                        iGrid1.Rows[sdata.CURR_FS.fs_id.ToString()].Cells["total"].Value = null;
                        iGrid1.Rows[sdata.CURR_FS.fs_id.ToString()].Visible = true;
                    }
                    foreach (var d in nlist)
                    {
                        iGrid1.Rows[d.fs_id.ToString()].Cells["total"].Value = d.total_entries;
                        iGrid1.Rows[d.fs_id.ToString()].Visible = true;
                    }
                    if (new_val == string.Format("{0}{1}", sdata.CURR_DATE.Year, sdata.CURR_DATE.Month).ToInt32())
                    {
                        iGrid1.SetCurCell(sdata.CURR_FS.fs_id.ToString(), 0);
                    }
                }
            }
            else
            {
                iGrid1.Rows[m_MONTH.ToString()].Cells["total"].Value = null;
                if (m_YEAR == sdata.CURR_DATE.Year & m_MONTH == sdata.CURR_DATE.Month)
                {
                    iGrid1.Rows[sdata.CURR_FS.fs_id.ToString()].Cells["total"].Value = null;
                    iGrid1.Rows[sdata.CURR_FS.fs_id.ToString()].Visible = true;
                }
            }

            iGrid1.Cols.AutoWidth();
            iGrid1.AutoResizeCols = false;
            iGrid1.EndUpdate();
        }
        private void backworker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            string _str = null;

            switch (m_source_type)
            {
            case em.off_source_typeS.church_member:
            {
                m_SourceTypeName = "Registered Church Members";
                break;
            }

            case em.off_source_typeS.unregistered:
            {
                m_SourceTypeName = "UNRegistered Church Members";
                break;
            }

            case em.off_source_typeS.none:
            {
                m_SourceTypeName = string.Empty;
                break;
            }
            }
            if (!switchButton1.Value)
            {
                switch (m_xOffType)
                {
                case xoff_type.singleSabbath:
                {
                    #region single_sabbath
                    if (_cg_id > -1)
                    {
                        _str = string.Format("select m.off_id,m.source_name,m.source_id,m.source_type_id,m.sab_date,m.receipt_status,c.amount,c.cg_id,c.account_id from off_main_tb as m,off_accounts_tb as c" +
                                             " where m.sab_fs_id={0} and m.off_id=c.off_id and m.receipt_status=1 and c.account_id={1} and c.receipt_status=1 and cg_id={2} order by c.cg_id", _sab_fs_id, _account_id, _cg_id);
                    }
                    else
                    {
                        _str = string.Format("select m.off_id,m.source_name,m.source_id,m.source_type_id,m.sab_date,m.receipt_status,c.amount,c.cg_id,c.account_id from off_main_tb as m,off_accounts_tb as c" +
                                             " where m.sab_fs_id={0} and m.off_id=c.off_id and m.receipt_status=1 and c.account_id={1} and c.receipt_status=1 order by c.cg_id ", _sab_fs_id, _account_id);
                    }
                    #endregion
                    break;
                }

                case xoff_type.singleSabbathCombined:
                {
                    #region single_sabbath_combined
                    var    _accounts = accn.GetChildAccounts("COMBINED_OFFERING", em.account_typeS.ActualAccount).Select(l => l.account_id).ToList();
                    string _in_str   = "(";
                    foreach (var k in _accounts)
                    {
                        _in_str += (_in_str.Length == 1) ? string.Format("{0}", k) : string.Format(",{0}", k);
                    }
                    _in_str += ")";
                    _str     = string.Format("select m.off_id,m.source_name,m.source_id,m.source_type_id,m.sab_date,m.receipt_status,c.amount,c.cg_id,c.account_id from off_main_tb as m,off_accounts_tb as c" +
                                             " where m.sab_fs_id={0} and m.off_id=c.off_id and m.receipt_status=1 and c.account_id in {1} and c.receipt_status=1 order by c.account_id ", _sab_fs_id, _in_str);
                    #endregion
                    break;
                }

                case xoff_type.monthSingle:
                {
                    fGrid.Cols["rpt_no"].Visible   = false;
                    fGrid.Cols["sab_date"].Visible = false;
                    var _fs_ids = fn.GetFsIDMonth(_month, _year);
                    #region month_single_sabbath
                    if (m_source_type != em.off_source_typeS.none)
                    {
                        if (_cg_id > -1)
                        {
                            _str = string.Format("select m.off_id,m.source_name,m.source_id,m.source_type_id,m.sab_date,m.receipt_status,sum(c.amount) as _sum,count(c.un_id) as _freq, c.cg_id,c.account_id from off_main_tb as m,off_accounts_tb as c" +
                                                 " where m.sab_fs_id between {0} and {1} and m.off_id=c.off_id and m.receipt_status=1 and c.account_id={2} and c.cg_id={3} and m.source_type_id={4} group by m.source_type_id,m.source_id,m.source_type_id,c.cg_id", _fs_ids[0], _fs_ids[1], _account_id, _cg_id, m_source_type.ToInt32());
                        }
                        else
                        {
                            _str = string.Format("select m.off_id,m.source_name,m.source_id,m.source_type_id,m.sab_date,m.receipt_status,sum(c.amount) as _sum,count(c.un_id) as _freq,c.cg_id,c.account_id from off_main_tb as m,off_accounts_tb as c" +
                                                 " where m.sab_fs_id between {0} and {1}  and m.off_id=c.off_id and m.receipt_status=1 and c.account_id={2} and c.source_type_id={3} group by c.source_type_id,c.source_id", _fs_ids[0], _fs_ids[1], _account_id, m_source_type.ToInt32());
                        }
                    }
                    else
                    {
                        if (_cg_id > -1)
                        {
                            _str = string.Format("select m.off_id,m.source_name,m.source_id,m.source_type_id,m.sab_date,m.receipt_status,sum(c.amount) as _sum,count(c.un_id) as _freq, c.cg_id,c.account_id from off_main_tb as m,off_accounts_tb as c" +
                                                 " where m.sab_fs_id between {0} and {1} and m.off_id=c.off_id and m.receipt_status=1 and c.account_id={2} and c.cg_id={3} group by m.source_type_id,m.source_id,m.source_type_id,c.cg_id", _fs_ids[0], _fs_ids[1], _account_id, _cg_id);
                        }
                        else
                        {
                            _str = string.Format("select m.off_id,m.source_name,m.source_id,m.source_type_id,m.sab_date,m.receipt_status,sum(c.amount) as _sum,count(c.un_id) as _freq,c.cg_id,c.account_id from off_main_tb as m,off_accounts_tb as c" +
                                                 " where m.sab_fs_id between {0} and {1}  and m.off_id=c.off_id and m.receipt_status=1 and c.account_id={2} group by c.source_type_id,c.source_id", _fs_ids[0], _fs_ids[1], _account_id);
                        }
                    }
                    #endregion
                    break;
                }

                case xoff_type.range:
                {
                    fGrid.Cols["rpt_no"].Visible   = false;
                    fGrid.Cols["sab_date"].Visible = false;
                    var _fs_ids = (this.Owner as OfferingYearMemberActivity).GetRangeFsIds();
                    #region range
                    if (m_source_type != em.off_source_typeS.none)
                    {
                        if (_cg_id > -1)
                        {
                            _str = string.Format("select m.off_id,m.source_name,m.source_id,m.source_type_id,m.sab_date,m.receipt_status,sum(c.amount) as _sum,count(c.un_id) as _freq, c.cg_id,c.account_id from off_main_tb as m,off_accounts_tb as c" +
                                                 " where m.sab_fs_id between {0} and {1} and m.off_id=c.off_id and m.receipt_status=1 and c.account_id={2} and c.cg_id={3} and m.source_type_id={4} group by m.source_type_id,m.source_id,m.source_type_id,c.cg_id", _fs_ids[0], _fs_ids[1], _account_id, _cg_id, m_source_type.ToInt32());
                        }
                        else
                        {
                            _str = string.Format("select m.off_id,m.source_name,m.source_id,m.source_type_id,m.sab_date,m.receipt_status,sum(c.amount) as _sum,count(c.un_id) as _freq,c.cg_id,c.account_id from off_main_tb as m,off_accounts_tb as c" +
                                                 " where m.sab_fs_id between {0} and {1}  and m.off_id=c.off_id and m.receipt_status=1 and c.account_id={2} and c.source_type_id={3} group by c.source_type_id,c.source_id", _fs_ids[0], _fs_ids[1], _account_id, m_source_type.ToInt32());
                        }
                    }
                    else
                    {
                        if (_cg_id > -1)
                        {
                            _str = string.Format("select m.off_id,m.source_name,m.source_id,m.source_type_id,m.sab_date,m.receipt_status,sum(c.amount) as _sum,count(c.un_id) as _freq, c.cg_id,c.account_id from off_main_tb as m,off_accounts_tb as c" +
                                                 " where m.sab_fs_id between {0} and {1} and m.off_id=c.off_id and m.receipt_status=1 and c.account_id={2} and c.cg_id={3} group by m.source_type_id,m.source_id,m.source_type_id,c.cg_id", _fs_ids[0], _fs_ids[1], _account_id, _cg_id);
                        }
                        else
                        {
                            _str = string.Format("select m.off_id,m.source_name,m.source_id,m.source_type_id,m.sab_date,m.receipt_status,sum(c.amount) as _sum,count(c.un_id) as _freq,c.cg_id,c.account_id from off_main_tb as m,off_accounts_tb as c" +
                                                 " where m.sab_fs_id between {0} and {1}  and m.off_id=c.off_id and m.receipt_status=1 and c.account_id={2} group by c.source_type_id,c.source_id", _fs_ids[0], _fs_ids[1], _account_id);
                        }
                    }
                    #endregion
                    break;
                }

                case xoff_type.monthSingleCombined:
                {
                    #region month_single_combined
                    var    _fs_ids   = fn.GetFsIDMonth(_month, _year);
                    var    _accounts = accn.GetChildAccounts("COMBINED_OFFERING", em.account_typeS.ActualAccount).Select(l => l.account_id).ToList();
                    string _in_str   = "(";
                    foreach (var k in _accounts)
                    {
                        _in_str += (_in_str.Length == 1) ? string.Format("{0}", k) : string.Format(",{0}", k);
                    }
                    _in_str += ")";
                    _str     = string.Format("select m.off_id,m.source_name,m.source_id,m.source_type_id,m.sab_date,m.receipt_status,c.amount,c.cg_id,c.account_id from off_main_tb as m,off_accounts_tb as c" +
                                             " where m.sab_fs_id between {0} and {1} and m.off_id=c.off_id and m.receipt_status=1 and c.account_id in {2} and  c.receipt_status=1 order by m.sab_fs_id, c.source_type_id,c.source_id,c.account_id ", _fs_ids[0], _fs_ids[1], _in_str);
                    #endregion
                    break;
                }
                }
            }
            else
            {
                switch (m_xOffType)
                {
                case xoff_type.singleSabbath:
                {
                    fGrid.Cols["rpt_no"].Visible   = true;
                    fGrid.Cols["sab_date"].Visible = true;
                    #region single_sabbath
                    if (_cg_id > -1)
                    {
                        _str = string.Format("select m.off_id,m.source_name,m.source_id,m.source_type_id,m.sab_date,m.receipt_status,c.amount,c.cg_id,c.account_id from off_main_tb as m,off_accounts_tb as c" +
                                             " where m.sab_fs_id={0} and m.off_id=c.off_id and m.receipt_status=1 and c.account_id={1} and c.receipt_status=1 and cg_id={2} order by c.cg_id", _sab_fs_id, _account_id, _cg_id);
                    }
                    else
                    {
                        _str = string.Format("select m.off_id,m.source_name,m.source_id,m.source_type_id,m.sab_date,m.receipt_status,c.amount,c.cg_id,c.account_id from off_main_tb as m,off_accounts_tb as c" +
                                             " where m.sab_fs_id={0} and m.off_id=c.off_id and m.receipt_status=1 and c.account_id={1} and c.receipt_status=1 order by c.cg_id ", _sab_fs_id, _account_id);
                    }
                    #endregion
                    break;
                }

                case xoff_type.singleSabbathCombined:
                {
                    fGrid.Cols["rpt_no"].Visible   = true;
                    fGrid.Cols["sab_date"].Visible = true;
                    #region single_sabbath_combined
                    var    _accounts = accn.GetChildAccounts("COMBINED_OFFERING", em.account_typeS.ActualAccount).Select(l => l.account_id).ToList();
                    string _in_str   = "(";
                    foreach (var k in _accounts)
                    {
                        _in_str += (_in_str.Length == 1) ? string.Format("{0}", k) : string.Format(",{0}", k);
                    }
                    _in_str += ")";
                    _str     = string.Format("select m.off_id,m.source_name,m.source_id,m.source_type_id,m.sab_date,m.receipt_status,c.amount,c.cg_id,c.account_id from off_main_tb as m,off_accounts_tb as c" +
                                             " where m.sab_fs_id={0} and m.off_id=c.off_id and m.receipt_status=1 and c.account_id in {1} and c.receipt_status=1 order by c.account_id ", _sab_fs_id, _in_str);
                    #endregion
                    break;
                }

                case xoff_type.monthSingle:
                {
                    fGrid.Cols["rpt_no"].Visible   = true;
                    fGrid.Cols["sab_date"].Visible = true;
                    var _fs_ids = fn.GetFsIDMonth(_month, _year);
                    #region month_single_sabbath
                    if (m_source_type != em.off_source_typeS.none)
                    {
                        if (_cg_id > -1)
                        {
                            _str = string.Format("select m.off_id,m.source_name,m.source_id,m.source_type_id,m.sab_date,m.receipt_status,c.amount,c.cg_id, c.account_id from off_main_tb as m,off_accounts_tb as c" +
                                                 " where m.sab_fs_id between {0} and {1} and m.off_id=c.off_id and m.receipt_status=1 and c.account_id={2} and c.cg_id={3} and m.source_type_id={4}", _fs_ids[0], _fs_ids[1], _account_id, _cg_id, m_source_type.ToInt32());
                        }
                        else
                        {
                            _str = string.Format("select m.off_id,m.source_name,m.source_id,m.source_type_id,m.sab_date,m.receipt_status,c.amount,c.cg_id,c.account_id from off_main_tb as m,off_accounts_tb as c" +
                                                 " where m.sab_fs_id between {0} and {1}  and m.off_id=c.off_id and m.receipt_status=1 and c.account_id={2} and c.source_type_id={3}", _fs_ids[0], _fs_ids[1], _account_id, m_source_type.ToInt32());
                        }
                    }
                    else
                    {
                        if (_cg_id > -1)
                        {
                            _str = string.Format("select m.off_id,m.source_name,m.source_id,m.source_type_id,m.sab_date,m.receipt_status,c.amount, c.cg_id,c.account_id from off_main_tb as m,off_accounts_tb as c" +
                                                 " where m.sab_fs_id between {0} and {1} and m.off_id=c.off_id and m.receipt_status=1 and c.account_id={2} and c.cg_id={3}", _fs_ids[0], _fs_ids[1], _account_id, _cg_id);
                        }
                        else
                        {
                            _str = string.Format("select m.off_id,m.source_name,m.source_id,m.source_type_id,m.sab_date,m.receipt_status,c.amount,c.cg_id,c.account_id from off_main_tb as m,off_accounts_tb as c" +
                                                 " where m.sab_fs_id between {0} and {1}  and m.off_id=c.off_id and m.receipt_status=1 and c.account_id={2}", _fs_ids[0], _fs_ids[1], _account_id);
                        }
                    }
                    #endregion
                    break;
                }

                case xoff_type.range:
                {
                    fGrid.Cols["rpt_no"].Visible   = true;
                    fGrid.Cols["sab_date"].Visible = true;
                    var _fs_ids = (this.Owner as OfferingYearMemberActivity).GetRangeFsIds();
                    #region range
                    if (m_source_type != em.off_source_typeS.none)
                    {
                        if (_cg_id > -1)
                        {
                            _str = string.Format("select m.off_id,m.source_name,m.source_id,m.source_type_id,m.sab_date,m.receipt_status,c.amount, c.cg_id,c.account_id from off_main_tb as m,off_accounts_tb as c" +
                                                 " where m.sab_fs_id between {0} and {1} and m.off_id=c.off_id and m.receipt_status=1 and c.account_id={2} and c.cg_id={3} and m.source_type_id={4}", _fs_ids[0], _fs_ids[1], _account_id, _cg_id, m_source_type.ToInt32());
                        }
                        else
                        {
                            _str = string.Format("select m.off_id,m.source_name,m.source_id,m.source_type_id,m.sab_date,m.receipt_status,c.amount,c.cg_id,c.account_id from off_main_tb as m,off_accounts_tb as c" +
                                                 " where m.sab_fs_id between {0} and {1}  and m.off_id=c.off_id and m.receipt_status=1 and c.account_id={2} and c.source_type_id={3}", _fs_ids[0], _fs_ids[1], _account_id, m_source_type.ToInt32());
                        }
                    }
                    else
                    {
                        if (_cg_id > -1)
                        {
                            _str = string.Format("select m.off_id,m.source_name,m.source_id,m.source_type_id,m.sab_date,m.receipt_status,c.amount, c.cg_id,c.account_id from off_main_tb as m,off_accounts_tb as c" +
                                                 " where m.sab_fs_id between {0} and {1} and m.off_id=c.off_id and m.receipt_status=1 and c.account_id={2} and c.cg_id={3}", _fs_ids[0], _fs_ids[1], _account_id, _cg_id);
                        }
                        else
                        {
                            _str = string.Format("select m.off_id,m.source_name,m.source_id,m.source_type_id,m.sab_date,m.receipt_status,c.amount,c.cg_id,c.account_id from off_main_tb as m,off_accounts_tb as c" +
                                                 " where m.sab_fs_id between {0} and {1}  and m.off_id=c.off_id and m.receipt_status=1 and c.account_id={2}", _fs_ids[0], _fs_ids[1], _account_id);
                        }
                    }
                    #endregion
                    break;
                }

                case xoff_type.monthSingleCombined:
                {
                    #region month_single_combined
                    fGrid.Cols["rpt_no"].Visible   = true;
                    fGrid.Cols["sab_date"].Visible = true;
                    var    _fs_ids   = fn.GetFsIDMonth(_month, _year);
                    var    _accounts = accn.GetChildAccounts("COMBINED_OFFERING", em.account_typeS.ActualAccount).Select(l => l.account_id).ToList();
                    string _in_str   = "(";
                    foreach (var k in _accounts)
                    {
                        _in_str += (_in_str.Length == 1) ? string.Format("{0}", k) : string.Format(",{0}", k);
                    }
                    _in_str += ")";
                    _str     = string.Format("select m.off_id,m.source_name,m.source_id,m.source_type_id,m.sab_date,m.receipt_status,c.amount,c.cg_id,c.account_id from off_main_tb as m,off_accounts_tb as c" +
                                             " where m.sab_fs_id between {0} and {1} and m.off_id=c.off_id and m.receipt_status=1 and c.account_id in {2} and  c.receipt_status=1 order by m.sab_fs_id, c.source_type_id,c.source_id,c.account_id ", _fs_ids[0], _fs_ids[1], _in_str);
                    #endregion
                    break;
                }
                }
            }
            datam.ShowWaitForm("Loading Data, Please Wait");
            Application.DoEvents();
            fGrid.BeginUpdate();
            fGrid.Rows.Clear();

            using (var xd = new xing())
            {
                using (var _dr = xd.SelectCommand(_str))
                {
                    iGRow               _row          = null;
                    DateTime?           _date         = null;
                    int                 cg_id         = 0;
                    int                 _total        = 0;
                    int                 _acc_id       = 0;
                    int                 _source_id    = 0;
                    int                 _gender_id    = 0;
                    em.off_source_typeS m_source_type = em.off_source_typeS.none;
                    while (_dr.Read())
                    {
                        _row          = fGrid.Rows.Add();
                        m_source_type = (em.off_source_typeS)_dr["source_type_id"].ToInt32();
                        _source_id    = _dr["source_id"].ToInt32();
                        if (m_source_type == em.off_source_typeS.church_member)
                        {
                            if (datam.DATA_MEMBER.IndexOfKey(_source_id) > -1)
                            {
                                _gender_id = datam.DATA_MEMBER[_source_id].gender_id;
                                _row.Cells["gender"].AuxValue = _gender_id;
                                _row.Cells["gender"].Value    = ((em.xgender)_gender_id) == em.xgender.Male ? "M" : "F";
                            }
                        }
                        _row.Font                = new Font("georgia", 12, FontStyle.Regular);
                        _row.ReadOnly            = iGBool.True;
                        _row.Cells["no"].Value   = fGrid.Rows.Count;
                        _row.Cells["name"].Value = _dr["source_name"].ToStringNullable();
                        if (!switchButton1.Value)
                        {
                            _row.Cells["amount"].Value = _dr["_sum"].ToInt32();
                            _row.Cells["freq"].Value   = _dr["_freq"].ToInt32();
                        }
                        else
                        {
                            _row.Cells["amount"].Value = _dr["amount"].ToInt32();
                            _date = _dr.GetDateTime("sab_date");
                            _row.Cells["sab_date"].Value    = _date.Value.ToMyLongDate();
                            _row.Cells["sab_date"].AuxValue = fn.GetFSID(_date.Value);
                            _row.Cells["rpt_no"].Value      = "R-" + _dr["off_id"].ToStringNullable();
                        }

                        _total += _row.Cells["amount"].Value.ToInt32();
                        //

                        cg_id   = _dr["cg_id"].ToInt32();
                        _acc_id = _dr["account_id"].ToInt32();
                        if (cg_id > 0)
                        {
                            _row.Cells["cg"].Value      = datam.DATA_CHURCH_GROUPS[cg_id].cg_name;
                            _row.Cells["account"].Value = string.Format("{0} :: {1}", datam.DATA_ACCOUNTS[_acc_id].account_name, datam.DATA_CHURCH_GROUPS[cg_id].cg_name);
                            if (!_row.Cells["cg"].Col.Visible)
                            {
                                try
                                {
                                    _row.Cells["cg"].Col.Text    = datam.DATA_CG_TYPES[datam.DATA_CHURCH_GROUPS[cg_id].cg_type_id].cg_type_name;
                                    _row.Cells["cg"].Col.Visible = true;
                                }
                                catch (Exception)
                                {
                                }
                            }
                        }
                        else
                        {
                            try
                            {
                                _row.Cells["account"].Value = datam.DATA_ACCOUNTS[_acc_id].account_name;
                            }
                            catch (Exception)
                            {
                                MessageBox.Show("Halla");
                            }
                        }
                        _row.TextAlign = iGContentAlignment.MiddleCenter;
                        _row.AutoHeight();
                        _row.Height += 1;
                    }
                    switch (m_xOffType)
                    {
                    case xoff_type.singleSabbath:
                    {
                        if (_cg_id == 0)
                        {
                            labelTopName.Text = string.Format("{0} General Report for  {1}  :::  {2}", datam.DATA_ACCOUNTS[_account_id].account_name, _date.Value.ToMyShortDate(), _total.ToNumberDisplayFormat());
                            //
                            labelTopName.Tag = string.Format("{0} General Report for  {1}  :::  #total", datam.DATA_ACCOUNTS[_account_id].account_name, _date.Value.ToMyShortDate());
                            break;
                        }
                        if (_cg_id < 0)
                        {
                            labelTopName.Text = string.Format("{0}  Report for  {1}  :::  {2}", datam.DATA_ACCOUNTS[_account_id].account_name, _date.Value.ToMyShortDate(), _total.ToNumberDisplayFormat());
                            //
                            labelTopName.Tag = string.Format("{0}  Report for  {1}  :::  #total", datam.DATA_ACCOUNTS[_account_id].account_name, _date.Value.ToMyShortDate());
                            break;
                        }
                        if (_cg_id > 0)
                        {
                            labelTopName.Text = string.Format("{0}  Report for  {1}  :::  {2}", string.Format("{0} :: {1}", datam.DATA_ACCOUNTS[_account_id].account_name, datam.DATA_CHURCH_GROUPS[_cg_id].cg_name), _date.Value.ToMyShortDate(), _total.ToNumberDisplayFormat());
                            //
                            labelTopName.Tag = string.Format("{0}  Report for  {1}  :::  {2}", string.Format("{0} :: #total", datam.DATA_ACCOUNTS[_account_id].account_name, datam.DATA_CHURCH_GROUPS[_cg_id].cg_name), _date.Value.ToMyShortDate());
                        }
                        break;
                    }

                    case xoff_type.singleSabbathCombined:
                    {
                        labelTopName.Text = string.Format("Combined Offerings  Report for  {0}  :::  {1}", _date.Value.ToMyShortDate(), _total.ToNumberDisplayFormat());
                        //
                        labelTopName.Tag = string.Format("Combined Offerings  Report for  {0}  :::  #total", _date.Value.ToMyShortDate());
                        break;
                    }

                    case xoff_type.monthSingle:
                    {
                        m_ReportPeriod      = string.Format("{0} {1}", datam.MONTHS[_month - 1], _year);
                        m_ReportTotal       = _total.ToNumberDisplayFormat();
                        m_ReportMemberCount = fGrid.Rows.Count.ToStringNullable();
                        if (_cg_id == 0)
                        {
                            m_ReportName      = string.Format("{0} General Report", datam.DATA_ACCOUNTS[_account_id].account_name);
                            labelTopName.Text = string.Format("{0} General Report for  {1}  :::  {2}", datam.DATA_ACCOUNTS[_account_id].account_name, string.Format("{0} {1}", datam.MONTHS[_month - 1], _year), _total.ToNumberDisplayFormat());
                            //
                            labelTopName.Tag = string.Format("{0} General Report for  {1}  :::  #total", datam.DATA_ACCOUNTS[_account_id].account_name, string.Format("{0} {1}", datam.MONTHS[_month - 1], _year));
                            break;
                        }
                        if (_cg_id < 0)
                        {
                            m_ReportName      = string.Format("{0} Report", datam.DATA_ACCOUNTS[_account_id].account_name);
                            labelTopName.Text = string.Format("{0} Report for  {1}  :::  {2}", datam.DATA_ACCOUNTS[_account_id].account_name, string.Format("{0} {1}", datam.MONTHS[_month - 1], _year), _total.ToNumberDisplayFormat());
                            //
                            labelTopName.Tag = string.Format("{0} Report for  {1}  :::  #total", datam.DATA_ACCOUNTS[_account_id].account_name, string.Format("{0} {1}", datam.MONTHS[_month - 1], _year));
                            break;
                        }
                        if (_cg_id > 0)
                        {
                            m_ReportName      = string.Format("{0} Report  ::: {1}", datam.DATA_ACCOUNTS[_account_id].account_name, datam.DATA_CHURCH_GROUPS[_cg_id].cg_name);
                            labelTopName.Text = string.Format("{0}  Report for  {1}  :::  {2}", string.Format("{0} :: {1}", datam.DATA_ACCOUNTS[_account_id].account_name, datam.DATA_CHURCH_GROUPS[_cg_id].cg_name), string.Format("{0} {1}", datam.MONTHS[_month - 1], _year), _total.ToNumberDisplayFormat());
                            //
                            labelTopName.Tag = string.Format("{0}  Report for  {1}  :::  {2}", string.Format("{0} :: #total", datam.DATA_ACCOUNTS[_account_id].account_name, datam.DATA_CHURCH_GROUPS[_cg_id].cg_name), string.Format("{0} {1}", datam.MONTHS[_month - 1], _year));
                        }

                        break;
                    }

                    case xoff_type.range:
                    {
                        var _dates = (this.Owner as OfferingYearMemberActivity).GetRangeFsDates();
                        if (_dates[1] == null)
                        {
                            m_ReportPeriod = string.Format("{0}", System.Convert.ToDateTime(_dates[0]).ToShortDateString());
                        }
                        else
                        {
                            m_ReportPeriod = string.Format("{0}  to  {1}", System.Convert.ToDateTime(_dates[0]).ToShortDateString(), System.Convert.ToDateTime(_dates[1]).ToShortDateString());
                        }
                        m_ReportTotal       = _total.ToNumberDisplayFormat();
                        m_ReportMemberCount = fGrid.Rows.Count.ToStringNullable();
                        var _alias = string.Format("{0} to {1}", System.Convert.ToDateTime(_dates[0]).ToShortDateString(), System.Convert.ToDateTime(_dates[1]).ToShortDateString());
                        if (_cg_id == 0)
                        {
                            m_ReportName      = string.Format("{0} General Report", datam.DATA_ACCOUNTS[_account_id].account_name);
                            labelTopName.Text = string.Format("{0} General Report from  {1}  :::  {2}", datam.DATA_ACCOUNTS[_account_id].account_name, _alias, _total.ToNumberDisplayFormat());
                            //
                            labelTopName.Tag = string.Format("{0} General Report from  {1}  :::  #total", datam.DATA_ACCOUNTS[_account_id].account_name, _alias);
                            break;
                        }
                        if (_cg_id < 0)
                        {
                            m_ReportName      = string.Format("{0} Report", datam.DATA_ACCOUNTS[_account_id].account_name);
                            labelTopName.Text = string.Format("{0} Report from  {1}  :::  {2}", datam.DATA_ACCOUNTS[_account_id].account_name, _alias, _total.ToNumberDisplayFormat());
                            //
                            labelTopName.Tag = string.Format("{0} Report from  {1}  :::  #total", datam.DATA_ACCOUNTS[_account_id].account_name, _alias);
                            break;
                        }
                        if (_cg_id > 0)
                        {
                            m_ReportName      = string.Format("{0} Report  ::: {1}", datam.DATA_ACCOUNTS[_account_id].account_name, datam.DATA_CHURCH_GROUPS[_cg_id].cg_name);
                            labelTopName.Text = string.Format("{0}  Report from  {1}  :::  {2}", string.Format("{0} :: {1}", datam.DATA_ACCOUNTS[_account_id].account_name, datam.DATA_CHURCH_GROUPS[_cg_id].cg_name), _alias, _total.ToNumberDisplayFormat());
                            //
                            labelTopName.Tag = string.Format("{0}  Report from  {1}  :::  #total", string.Format("{0} :: {1}", datam.DATA_ACCOUNTS[_account_id].account_name, datam.DATA_CHURCH_GROUPS[_cg_id].cg_name), _alias);
                        }

                        break;
                    }

                    case xoff_type.monthSingleCombined:
                    {
                        labelTopName.Text = string.Format("Combined Offerings  Report for  {0}  :::  #total", string.Format("{0} {1}", datam.MONTHS[_month - 1], _date.Value.Year));
                        break;
                    }
                    }
                    if (!string.IsNullOrEmpty(m_SourceTypeName))
                    {
                        m_ReportName += " for " + m_SourceTypeName;
                    }
                    label1.Text = fGrid.Rows.Count.ToStringNullable();
                }
            }
            fGrid.SortObject.Clear();

            if (switchButton1.Value)
            {
                fGrid.SortObject.Add("sab_date", iGSortOrder.Ascending);
                fGrid.Sort();
            }
            else
            {
                fGrid.SortObject.Add("amount", iGSortOrder.Descending);
                fGrid.Sort();
            }
            fGrid.Cols.AutoWidth();
            fGrid.AutoResizeCols = false;
            fGrid.EndUpdate();
            datam.HideWaitForm();
        }
示例#19
0
        private void LoadData()
        {
            iGRow _row    = null;
            iGRow _parent = null;

            fGrid.BeginUpdate();
            fGrid.Rows.Clear();
            var gp_nlist = from k in datam.DATA_BATCH_NO_SETTINGS[m_sabbath.fs_id].Values
                           group k by k.entrant_id into nw_gp
                           select new
            {
                entrant_id = nw_gp.Key,
                gp_data    = nw_gp
            };

            foreach (var _obj in gp_nlist)
            {
                if (!sdata.HasMenuRight(7, false))
                {
                    if (_obj.entrant_id != sdata.PC_US_ID)
                    {
                        continue;
                    }
                }
                _row          = fGrid.Rows.Add();
                _row.Font     = new Font("georgia", 12, FontStyle.Bold);
                _row.ReadOnly = iGBool.True;
                try
                {
                    _row.Cells["batch_no"].Value = sdata.GetUserName(_obj.entrant_id);
                }
                catch (Exception)
                {
                    _row.Cells["batch_no"].Value = null;
                }
                _row.Cells["batch_no"].ForeColor = Color.DarkBlue;
                _row.AutoHeight();
                //
                _parent = _row;
                //
                _parent.Level = 0;

                foreach (var k in _obj.gp_data)
                {
                    #region

                    _row           = fGrid.Rows.Add();
                    _row.Font      = new Font("georgia", 12, FontStyle.Regular);
                    _row.ReadOnly  = iGBool.True;
                    _row.ForeColor = Color.Purple;
                    //
                    _row.Cells["batch_no"].Value           = k.batch_no;
                    _row.Cells["batch_count"].Value        = k.batch_count;
                    _row.Cells["batch_count"].TextAlign    = iGContentAlignment.MiddleCenter;
                    _row.Cells["batch_total"].Value        = k.batch_total;
                    _row.Cells["batch_total"].FormatString = "{0:N0}";
                    _row.Cells["batch_total"].ValueType    = typeof(int);
                    _row.Cells["batch_total"].TextAlign    = iGContentAlignment.MiddleCenter;
                    //
                    _row.Cells["entrant_count"].Value        = k.entrant_count;
                    _row.Cells["entrant_count"].TextAlign    = iGContentAlignment.MiddleCenter;
                    _row.Cells["entrant_count"].ForeColor    = Color.Black;
                    _row.Cells["entrant_total"].Value        = k.entrant_total;
                    _row.Cells["entrant_total"].FormatString = "{0:N0}";
                    _row.Cells["entrant_total"].ValueType    = typeof(int);
                    _row.Cells["entrant_total"].ForeColor    = Color.Black;
                    _row.Cells["entrant_total"].TextAlign    = iGContentAlignment.MiddleCenter;
                    //
                    _row.Tag = k;
                    _row.Key = k.un_id.ToStringNullable();
                    _row.AutoHeight();
                    _row.Height    += 2;
                    _row.TreeButton = iGTreeButtonState.Hidden;
                    _row.Level      = 1;
                    #endregion
                }
                _parent.TreeButton = iGTreeButtonState.Visible;
            }
            fGrid.Cols.AutoWidth();
            fGrid.AutoResizeCols = false;
            fGrid.EndUpdate();
        }
        private void CreateDefaultRowsDepartment()
        {
            iGRow _row          = null;
            iGRow _parent_row   = null;
            bool  _has_children = false;

            foreach (var _grid in new iGrid[] { fGrid, fGridnormal })
            {
                _grid.BeginUpdate();
                _grid.Rows.Clear();
                _row            = _grid.Rows.Add();
                _row.Selectable = false;
                _row.Height     = 5;
                _row.BackColor  = Color.Lavender;
                _row.Key        = "div11";
                var elist = (from k in datam.DATA_EXPENSE_ACCOUNTS.Values
                             where k.objDepartment.level == 1
                             select k.objDepartment).Distinct();
                foreach (var d in elist)
                {
                    _row          = _grid.Rows.Add();
                    _row.Font     = new Font("arial narrow", 13, FontStyle.Bold);
                    _row.ReadOnly = iGBool.True;
                    _row.Cells["Description"].Value = d.dept_name;
                    _row.Key = d.dept_id.ToStringNullable();
                    _row.Cells["SValue"].Value = 1;
                    //
                    var clist = (from c in datam.DATA_EXPENSE_ACCOUNTS.Values
                                 where c.objDepartment.parent_id == d.dept_id
                                 select c.objDepartment).Distinct();
                    _parent_row   = _row;
                    _has_children = false;
                    _row.AutoHeight();
                    foreach (var c in clist)
                    {
                        _has_children = true;
                        _row          = _grid.Rows.Add();
                        _row.ReadOnly = iGBool.True;
                        _row.Level    = 1;
                        _row.ReadOnly = iGBool.True;
                        _row.Cells["Description"].Value = c.dept_name;
                        _row.Key                      = c.dept_id.ToStringNullable();
                        _row.TreeButton               = iGTreeButtonState.Hidden;
                        _row.Font                     = new Font("arial narrow", 12, FontStyle.Bold);
                        _row.ForeColor                = Color.Blue;
                        _row.Cells["SValue"].Value    = 2;
                        _row.Cells["parent_id"].Value = _parent_row.Key;
                        _row.Expanded                 = false;
                        _row.AutoHeight();
                    }
                    if (_has_children)
                    {
                        _parent_row.TreeButton = iGTreeButtonState.Visible;
                        _parent_row.Expanded   = false;
                        _parent_row.Cells["has_children"].Value = 1;
                    }
                }

                _row            = _grid.Rows.Add();
                _row.Selectable = false;
                _row.Height     = 5;
                _row.BackColor  = Color.Lavender;
                _row.Key        = "div4";
                //
                _row          = _grid.Rows.Add();
                _row.Font     = new Font("arial narrow", 13, FontStyle.Bold);
                _row.ReadOnly = iGBool.True;
                if (_grid == fGrid)
                {
                    _row.Cells["Description"].Value = "Month Total";
                }
                else
                {
                    _row.Cells["Description"].Value = "Quarter Total";
                }

                _row.Cells["Description"].TextAlign = iGContentAlignment.MiddleCenter;
                _row.ForeColor = Color.Yellow;
                _row.BackColor = Color.FromArgb(64, 64, 64);
                _row.Key       = "gt";
                _row.AutoHeight();
                _row.Height += 3;
                //add the sum row
                _grid.TreeLines.Visible = true;
                _grid.Cols.AutoWidth();
                _grid.AutoResizeCols = false;
                var plist = from c in _grid.Cols["Description"].Cells.Cast <iGCell>()
                            where c.Value != null
                            select c;
                foreach (var k in plist)
                {
                    k.TextAlign = iGContentAlignment.BottomLeft;
                    //if (k.Row.Level == 0)
                    //{
                    //    k.Font = new Font("verdana", 9, FontStyle.Bold);
                    //}
                    //else
                    //{
                    //    k.Font = new Font("verdana", 9, FontStyle.Regular);
                    //}
                }
                _grid.Rows["gt"].Cells["description"].TextAlign = iGContentAlignment.BottomRight;
                _grid.EndUpdate();
            }
        }
        private void LoadList()
        {
            Application.DoEvents();
            iGrid1.BeginUpdate();
            iGrid1.Rows.Clear();
            iGRow _row  = null;
            var   nlist = from k in datam.DATA_CURRENT_PLEDGE_SETTINGS.Values
                          where k.status != em.pledge_setting_statusS.deleted
                          orderby k.pls_id
                          select k;
            float _total     = 0f;
            float _paid      = 0f;
            float _percent   = 0f;
            iGRow parent_row = null;

            foreach (var k in nlist)
            {
                _row                            = iGrid1.Rows.Add();
                _row.Font                       = new Font("georgia", 12, FontStyle.Regular);
                _row.ReadOnly                   = iGBool.True;
                _row.Cells["no"].Value          = iGrid1.Rows.Count;
                _row.Cells["pledge_name"].Value = k.pledge_name;
                _row.Cells["pledge"].Value      = datam.DATA_ACCOUNTS[k.account_id].account_name;
                _row.Cells["pledge"].ForeColor  = Color.Gray;
                if (k.status == em.pledge_setting_statusS.expired)
                {
                    _row.Font = new Font("georgia", 12, FontStyle.Italic | FontStyle.Regular);
                }
                if (string.IsNullOrEmpty(k.pledge_name))
                {
                    _row.Cells["pledge_name"].Value = _row.Cells["pledge"].Value;
                }
                _row.Cells["pledge_amount"].Value = k.pledged_amount;
                _row.Cells["paid"].Value          = k.paid_amount;
                if (k.start_date != null)
                {
                    _row.Cells["start_date"].Value = k.start_date.Value.ToMyShortDate();
                }
                if (k.end_date != null)
                {
                    _row.Cells["end_date"].Value = k.end_date.Value.ToMyShortDate();
                }
                if (k.balance > 0)
                {
                    _row.Cells["balance"].Value = k.balance;
                }
                if (k.paid_amount > 0)
                {
                    _total   = k.pledged_amount;
                    _paid    = k.paid_amount;
                    _percent = ((_paid / _total) * 100);
                    _row.Cells["p_comp"].Value = string.Format(" {0} %", Math.Round(_percent, 1));
                }
                else
                {
                    _row.Cells["p_comp"].Value = string.Format(" {0} %", 0);
                }
                _row.Key     = string.Format("{0}", k.pls_id);
                _row.Tag     = k;
                _row.Visible = true;
                _row.AutoHeight();
                _row.Height += 2;

                var plist = (from c in datam.DATA_CURRENT_PLEDGES.Values
                             where c.pls_id == k.pls_id & c.pledge_status != em.pledge_statusS.deleted
                             group c by c.cg_id into nw_gp
                             select new
                {
                    cg_id = nw_gp.Key,
                    plegde_amount = nw_gp.Sum(p => p.amount_pledged),
                    paid_amount = nw_gp.Sum(p => p.amount_paid),
                    balance = nw_gp.Sum(p => p.balance),
                    mem_count = nw_gp.Select(u => new { _id = string.Format("{0}-{1}", u.source_type.ToByte(), u.source_id) }).Distinct().Count()
                }).ToList();
                parent_row            = _row;
                parent_row.TreeButton = iGTreeButtonState.Hidden;
                parent_row.Cells["mem_count"].Value = plist.Sum(h => h.mem_count);
            }
            iGrid1.Cols.AutoWidth();
            iGrid1.AutoResizeCols = false;
            iGrid1.EndUpdate();
        }
        private void LoadMainGrid(IEnumerable <ic.expense_transC> _list)
        {
            fGrid.BeginUpdate();
            fGrid.Rows.Clear();
            if (_list == null)
            {
                fGrid.EndUpdate(); return;
            }
            iGRow _row = null;

            foreach (var n in _list)
            {
                _row          = fGrid.Rows.Add();
                _row.ReadOnly = iGBool.True;
                _row.Font     = new Font("georgia", 12, FontStyle.Regular);
                // _row.Cells["sys_no"].Value = "V-" + n.voucher_id;
                _row.Cells["date"].Value               = n.exp_date.Value.ToMyShortDate();
                _row.Cells["fs_id"].Value              = fn.GetFSID(n.exp_date.Value);
                _row.Cells["voucher_no"].Value         = n.voucher_no;
                _row.Cells["expense_amount"].Value     = n.exp_amount;
                _row.Cells["expense_amount"].TextAlign = iGContentAlignment.MiddleCenter;
                _row.Cells["expense_amount"].ForeColor = Color.DarkBlue;
                _row.Cells["expense"].Value            = n.objExpenseAccount.exp_acc_name;
                _row.Cells["details"].Value            = n.exp_details;
                _row.Cells["dept"].Value               = datam.DATA_DEPARTMENT[n.dept_id].dept_name;
                _row.Cells["pay_mode"].Value           = fnn.GetExpensePayModeString(n.pay_mode);
                switch (n.source_type)
                {
                case em.exp_inc_src_typeS.bank:
                {
                    _row.Cells["source"].Value = "Bank";
                    break;
                }

                case em.exp_inc_src_typeS.petty_cash_cheque:
                {
                    _row.Cells["source"].Value = "Petty Cash";
                    break;
                }

                case em.exp_inc_src_typeS.unbanked_cash:
                {
                    _row.Cells["source"].Value = "Source";
                    _row.ForeColor             = Color.Red;
                    break;
                }
                }
                _row.Cells["received_by"].Value = n.received_by;
                _row.Key = n.un_id.ToStringNullable();
                _row.Tag = n;
                _row.AutoHeight();

                n.is_updated = false;
            }

            using (var xd = new xing())
            {
                string _str = string.Format("select * from acc_cash_transfer_tb where (source_id={0} or destination_id={0}) and status={1} and source_type_id={2} and destination_type_id={3}",
                                            m_WithDraw.sys_account_id, em.cashTransferStatus.valid.ToInt16(), em.CashTransferSourceType.account.ToInt16(), em.CashTransferDestinationType.account.ToInt16());
                using (var _dr = xd.SelectCommand(_str))
                {
                    while (_dr.Read())
                    {
                        _row                                   = fGrid.Rows.Add();
                        _row.ReadOnly                          = iGBool.True;
                        _row.Font                              = new Font("georgia", 12, FontStyle.Regular);
                        _row.ForeColor                         = _dr["source_id"].ToInt32() == m_WithDraw.sys_account_id ? Color.Maroon : Color.Green;
                        _row.Cells["date"].Value               = _dr.GetDateTime("fs_date").ToMyShortDate();
                        _row.Cells["fs_id"].Value              = fn.GetFSID(_dr.GetDateTime("fs_date"));
                        _row.Cells["expense_amount"].Value     = _dr["amount"].ToInt32();
                        _row.Cells["expense_amount"].TextAlign = iGContentAlignment.MiddleCenter;
                        _row.Cells["expense_amount"].ForeColor = _row.ForeColor;
                        _row.Cells["expense"].Value            = "TRANSFER";
                        _row.Cells["expense"].TextAlign        = iGContentAlignment.MiddleCenter;
                        if (_dr["source_id"].ToInt32() == m_WithDraw.sys_account_id)
                        {
                            _row.Cells["details"].Value = string.Format(" Cash Transfer To {0}", datam.DATA_ACCOUNTS[_dr["destination_id"].ToInt32()].account_name);
                        }
                        else
                        {
                            _row.Cells["expense"].Value            = "Extra INCOME";
                            _row.Cells["expense_amount"].ForeColor = Color.Green;
                            _row.Cells["details"].Value            = string.Format("Cash Received From {0}", datam.DATA_ACCOUNTS[_dr["source_id"].ToInt32()].account_name);
                            _row.Cells["details"].AuxValue         = 1;
                        }
                        _row.AutoHeight();
                    }
                }
                xd.CommitTransaction();
            }

            fGrid.Cols.AutoWidth();
            fGrid.AutoResizeCols = false;
            fGrid.EndUpdate();
        }
        private void LoadGrid()
        {
            var nlist = from k in datam.DATA_ACCOUNTS_PAYABLE.Values
                        where k.balance != 0 & k.objAccount.account_type == em.account_typeS.ActualAccount
                        orderby k.balance descending
                        select k;
            iGRow _row = null;

            fGrid.BeginUpdate();
            ic.accountC _acc = null;
            foreach (var r in nlist)
            {
                _row          = fGrid.Rows.Add();
                _row.Font     = new Font("georgia", 12, FontStyle.Regular);
                _row.ReadOnly = iGBool.True;
                _acc          = datam.DATA_ACCOUNTS[r.account_id];
                if (r.account_id < 0)
                {
                    _row.Cells["owner"].Value  = "CUC";
                    _row.Cells["svalue"].Value = _row.Cells["owner"].Value;
                }
                _row.Cells["account"].Value      = _acc.account_name;
                _row.Cells["balance"].Value      = r.balance;
                _row.Cells["balance"].Font       = new Font("verdana", 11, FontStyle.Regular);
                _row.Cells["balance"].ForeColor  = Color.DarkBlue;
                _row.Cells["acc_category"].Value = datam.DATA_ACCOUNTS[_acc.p_account_id].account_name;
                // _row.Cells["owner"].Value = _acc.owner_name;
                switch (_acc.owner_type)
                {
                case em.AccountOwnerTypeS.CUC:
                {
                    _row.Cells["owner"].Value  = "CUC";
                    _row.Cells["svalue"].Value = _row.Cells["owner"].Value;
                    _row.Cells["s_id"].Value   = 1;
                    break;
                }

                case em.AccountOwnerTypeS.CHURCH:
                {
                    _row.Cells["owner"].Value  = "Church";
                    _row.Cells["svalue"].Value = _row.Cells["owner"].Value;
                    _row.Cells["s_id"].Value   = 3;
                    break;
                }

                case em.AccountOwnerTypeS.CHURCH_GROUP:
                {
                    try
                    {
                        _row.Cells["owner"].Value = datam.DATA_CHURCH_GROUPS[_acc.owner_id].cg_name;
                    }
                    catch (Exception)
                    {
                        _row.Cells["owner"].Value = "Church Group";
                    }
                    _row.Cells["svalue"].Value = _row.Cells["owner"].Value;
                    _row.Cells["s_id"].Value   = 5;
                    break;
                }

                case em.AccountOwnerTypeS.CHURCH_MEMBER:
                {
                    try
                    {
                        _row.Cells["owner"].Value = datam.DATA_MEMBER[_acc.owner_id].mem_name;
                    }
                    catch (Exception)
                    {
                        _row.Cells["owner"].Value = "Church Member";
                    }
                    _row.Cells["svalue"].Value = "Church Members";
                    _row.Cells["s_id"].Value   = 7;
                    break;
                }

                case em.AccountOwnerTypeS.DEPARTMENT:
                {
                    try
                    {
                        _row.Cells["owner"].Value = datam.DATA_DEPARTMENT[_acc.owner_id].dept_name;
                        if (_row.Cells["owner"].Text.IndexOf("department") == -1)
                        {
                            _row.Cells["owner"].Value = _row.Cells["owner"].Text + " Department";
                        }
                    }
                    catch (Exception)
                    {
                        _row.Cells["owner"].Value = "Department";
                    }
                    _row.Cells["svalue"].Value = _row.Cells["owner"].Value;
                    _row.Cells["s_id"].Value   = 4;

                    break;
                }

                case em.AccountOwnerTypeS.DISTRICT:
                {
                    _row.Cells["owner"].Value  = "District";
                    _row.Cells["svalue"].Value = _row.Cells["owner"].Value;
                    _row.Cells["s_id"].Value   = 2;
                    break;
                }

                case em.AccountOwnerTypeS.OTHER:
                {
                    _row.Cells["owner"].Value  = _acc.owner_name;
                    _row.Cells["svalue"].Value = "Others";
                    _row.Cells["s_id"].Value   = 6;
                    break;
                }
                }
                if (r.objAccount.owner_id > 0)
                {
                    try
                    {
                        var _cg = datam.DATA_CHURCH_GROUPS[r.objAccount.owner_id];
                        if (_cg != null)
                        {
                            _row.Cells["account"].Value = string.Format("{0} :: {1}", _acc.account_name, _cg.cg_name);
                            _row.Cells["owner"].Value   = _cg.cg_name;
                            _row.Cells["svalue"].Value  = _row.Cells["owner"].Value;
                            _row.Cells["s_id"].Value    = 5;
                        }
                    }
                    catch (Exception ex)
                    {
                    }
                }
                _row.AutoHeight();
                _row.Key     = string.Format("{0}{1}", r.account_id.ToString(), r.objAccount.owner_id);
                _row.Tag     = r;
                r.is_updated = false;
            }
            ShowTotalCreditors();
            fGrid.Cols.AutoWidth();
            fGrid.AutoResizeCols = false;
            var Gtotal = from k in fGrid.Rows.Cast <iGRow>()
                         group k by k.Cells["svalue"].Text
                         into nw_gp
                         select new
            {
                gp_name  = nw_gp.Key,
                gp_total = nw_gp.Sum(p => p.Cells["balance"].Value.ToInt32())
            };

            m_GroupTotal.Clear();
            foreach (var t in Gtotal)
            {
                m_GroupTotal.Add(t.gp_name, t.gp_total);
            }
            if (fGrid.GroupObject.Count == 0)
            {
                fGrid.GroupObject.Add("svalue");
            }
            fGrid.Group();
            fGrid.PerformAction(iGActions.CollapseAll);
            fGrid.EndUpdate();
        }
示例#24
0
        void UpdateGrid()
        {
            IEnumerable <ic.bankWithDrawC> _withdraws = null;
            bool load_all = false;

            if (fGrid.Rows.Count == 0)
            {
                _withdraws = from n in datam.DATA_PENDING_WITHDRAWN_CHEQUES.Values
                             where n.status == em.account_trans_Status.Normal & n.cheque_balance > 0
                             orderby n.fs_id descending
                             select n;
                load_all = true;
            }
            else
            {
                _withdraws = from n in datam.DATA_PENDING_WITHDRAWN_CHEQUES.Values
                             where n.is_updated
                             orderby n.fs_id descending
                             select n;
            }
            fGrid.Enabled = false;
            fGrid.BeginUpdate();
            iGRow         _row      = null;
            List <string> To_Delete = new List <string>();
            bool          _update   = false;

            foreach (var n in _withdraws)
            {
                _update      = false;
                n.is_updated = false;

                if (load_all)
                {
                    _row = fGrid.Rows.Add();
                }
                else
                {
                    try
                    {
                        _row    = fGrid.Rows[n.wdr_id.ToString()];
                        _update = true;
                        if (n.status == em.account_trans_Status.Cancelled)
                        {
                            if (To_Delete.IndexOf(n.wdr_id.ToString()) == -1)
                            {
                                To_Delete.Add(n.wdr_id.ToString());
                            }
                            continue;
                        }
                    }
                    catch (Exception ex)
                    {
                        if (n.status == em.account_trans_Status.Cancelled)
                        {
                            continue;
                        }
                        _row    = fGrid.Rows.Add();
                        _update = false;
                    }
                }
                if (!_update)
                {
                    _row.Key      = n.wdr_id.ToStringNullable();
                    _row.Font     = new Font("georgia", 12, FontStyle.Regular);
                    _row.ReadOnly = iGBool.True;
                    _row.Tag      = n;
                }
                _row.Cells["date"].Value                 = n.fs_date.ToMyShortDate();
                _row.Cells["cheque_no"].Value            = n.cheque_no;
                _row.Cells["alias"].Value                = n.cheque_alias;
                _row.Cells["cheque_amount"].Value        = n.WithDrawnAmount;
                _row.Cells["cheque_amount"].FormatString = "{0:N0}";
                _row.Cells["spent_amount"].Value         = (n.WithDrawnAmount - n.cheque_balance);
                _row.Cells["spent_amount"].FormatString  = "{0:N0}";
                _row.Cells["balance"].Value              = n.cheque_balance;
                _row.Cells["balance"].FormatString       = "{0:N0}";
                ///
                _row.Cells["colsearch"].Value = string.Format("{0}", _row.Cells["cheque_no"].Text.ToString()).ToLower();
                _row.AutoHeight();
                _row.Height += 2;
            }
            if (To_Delete.Count > 0)
            {
                foreach (var k in To_Delete)
                {
                    fGrid.Rows.RemoveAt(fGrid.Rows[k].Index);
                }
            }
            fGrid.Cols.AutoWidth();
            fGrid.AutoResizeCols = false;
            fGrid.EndUpdate();
            fGrid.Enabled = true;
            if (!timer1.Enabled)
            {
                timer1.Enabled = true;
            }
        }
        public void NewRecord(ic.pledgeSettingC k)
        {
            Application.DoEvents();
            iGrid1.BeginUpdate();

            iGRow _row = null;

            float _total     = 0f;
            float _paid      = 0f;
            float _percent   = 0f;
            iGRow parent_row = null;

            _row                            = iGrid1.Rows.Add();
            _row.Font                       = new Font("georgia", 12, FontStyle.Regular);
            _row.ReadOnly                   = iGBool.True;
            _row.Cells["no"].Value          = iGrid1.Rows.Count;
            _row.Cells["pledge_name"].Value = k.pledge_name;
            _row.Cells["pledge"].Value      = datam.DATA_ACCOUNTS[k.account_id].account_name;
            _row.Cells["pledge"].ForeColor  = Color.Gray;
            if (string.IsNullOrEmpty(k.pledge_name))
            {
                _row.Cells["pledge_name"].Value = _row.Cells["pledge"].Value;
            }
            _row.Cells["pledge_amount"].Value = k.pledged_amount;
            _row.Cells["paid"].Value          = k.paid_amount;
            if (k.start_date != null)
            {
                _row.Cells["start_date"].Value = k.start_date.Value.ToMyShortDate();
            }
            if (k.end_date != null)
            {
                _row.Cells["end_date"].Value = k.end_date.Value.ToMyShortDate();
            }
            if (k.balance > 0)
            {
                _row.Cells["balance"].Value = k.balance;
            }
            if (k.paid_amount > 0)
            {
                _total   = k.pledged_amount;
                _paid    = k.paid_amount;
                _percent = ((_paid / _total) * 100);
                _row.Cells["p_comp"].Value = string.Format(" {0} %", Math.Round(_percent, 1));
            }
            else
            {
                _row.Cells["p_comp"].Value = string.Format(" {0} %", 0);
            }
            _row.Key     = string.Format("{0}", k.pls_id);
            _row.Tag     = k;
            _row.Visible = true;
            _row.AutoHeight();
            _row.Height += 2;


            parent_row            = _row;
            parent_row.TreeButton = iGTreeButtonState.Hidden;
            parent_row.Cells["mem_count"].Value = null;



            iGrid1.Cols.AutoWidth();
            iGrid1.AutoResizeCols = false;
            iGrid1.EndUpdate();
        }
        private void LoadGrid()
        {
            if (accn.DATA_ASSET_LIABILITY_STATEMENT == null)
            {
                return;
            }
            var nlist = from k in accn.DATA_ASSET_LIABILITY_STATEMENT
                        orderby k.fs_id
                        select k;

            iGrid1.BeginUpdate();
            iGRow _row     = null;
            int   _balance = 0;

            //
            _row                         = iGrid1.Rows.Add();
            _row.ReadOnly                = iGBool.True;
            _row.Font                    = new Font("verdana", 11, FontStyle.Regular);
            _row.Cells["date"].Value     = dateTimePicker1.Value.ToMyShortDate();
            _row.Cells["desc"].Value     = "Balance B/F";
            _row.Cells["desc"].Font      = new Font("verdana", 11, FontStyle.Bold);
            _row.Cells["desc"].Col.Width = 200;
            _row.Cells["desc"].TextAlign = iGContentAlignment.MiddleCenter;
            _row.TextAlign               = iGContentAlignment.MiddleCenter;

            if (m_BF >= 0)
            {
                _row.Cells["dr"].Value = m_BF;
            }
            else
            {
                _row.Cells["cr"].Value = (m_BF * -1);
            }

            _balance += m_BF;

            _row.Cells["balance"].Value     = _balance;
            _row.Cells["balance"].ForeColor = Color.Blue;
            _row.Cells["balance"].TextAlign = iGContentAlignment.MiddleCenter;
            _row.Cells["balance"].BackColor = Color.AntiqueWhite;
            _row.Cells["balance"].ForeColor = Color.Blue;
            _row.AutoHeight();
            //
            _row            = iGrid1.Rows.Add();
            _row.Height     = 5;
            _row.BackColor  = Color.FromArgb(64, 64, 64);
            _row.Selectable = false;
            _row.Key        = "fixed_row";

            foreach (var k in nlist)
            {
                _row                             = iGrid1.Rows.Add();
                _row.ReadOnly                    = iGBool.True;
                _row.Font                        = new Font("verdana", 11, FontStyle.Regular);
                _row.Cells["date"].Value         = k.fs_date.ToMyLongDate();
                _row.Cells["desc"].Value         = k.description;
                _row.Cells["desc"].Col.Width     = 200;
                _row.Cells["ref_type"].Value     = GetReferenceTypeName(k.reference_type);
                _row.Cells["ref_type"].ForeColor = Color.Gray;
                _row.Cells["ref_no"].Value       = k.reference_no;
                _row.Cells["account"].Value      = k.account_name;
                _row.TextAlign                   = iGContentAlignment.MiddleCenter;
                _row.Cells["ref_no"].ForeColor   = Color.Gray;
                if (k.dr_amount > 0)
                {
                    _row.Cells["dr"].Value = k.dr_amount;
                    _balance += k.dr_amount;
                }
                if (k.cr_amount > 0)
                {
                    _row.Cells["cr"].Value = k.cr_amount;
                    _row.ForeColor         = Color.Maroon;
                    _balance -= k.cr_amount;
                }
                _row.Cells["balance"].Value     = _balance;
                _row.Cells["balance"].ForeColor = Color.Blue;
                _row.Cells["balance"].TextAlign = iGContentAlignment.MiddleCenter;
                _row.Cells["balance"].BackColor = Color.AntiqueWhite;
                _row.Cells["balance"].ForeColor = Color.Blue;
                _row.Tag = k;
                _row.AutoHeight();
            }
            iGrid1.AutoResizeCols = false;
            iGrid1.Cols.AutoWidth();
            //
            iGrid1.Cols["desc"].Width = 300;
            iGrid1.Rows.AutoHeight();
            iGrid1.Rows["fixed_row"].Height = 5;
            iGrid1.EndUpdate();
        }
        private void DrawLeftTree()
        {
            if (labelCalender.Tag == null)
            {
                return;
            }

            Application.DoEvents();
            var _dt = Convert.ToDateTime(labelCalender.Tag);

            m_YEAR  = _dt.Year;
            m_MONTH = _dt.Month;
            int new_val = string.Format("{0}{1}", m_YEAR, m_MONTH).ToInt32();

            iGrid1.BeginUpdate();
            iGrid1.Rows.Clear();
            fGrid.Rows.Clear();
            if (!datam.GetMonthBankReconcilition(new_val))
            {
            }
            var   _days = DateTime.DaysInMonth(m_YEAR, m_MONTH);
            iGRow _row  = null;

            #region draw_month header
            _row                = iGrid1.Rows.Add();
            _row.Font           = new Font("georgia", 13, FontStyle.Regular);
            _row.ForeColor      = Color.Blue;
            _row.Cells[0].Value = datam.MONTHS[m_MONTH - 1];
            _row.TreeButton     = iGTreeButtonState.Visible;
            _row.Level          = 0;
            _row.ReadOnly       = iGBool.True;
            _row.Height        += 2;
            _row.Key            = m_MONTH.ToStringNullable();
            _row.AutoHeight();
            #endregion
            #region draw month details
            DateTime?_last_date  = new DateTime(m_YEAR, m_MONTH, _days);
            int      start_fs_id = fn.GetFSID(_last_date.Value);
            for (int j = _days; j > 0; j--)
            {
                _row                   = iGrid1.Rows.Add();
                _row.ReadOnly          = iGBool.True;
                _row.Level             = 1;
                _row.TreeButton        = iGTreeButtonState.Hidden;
                _row.Font              = new Font("georgia", 12, FontStyle.Regular);
                _row.ForeColor         = Color.Maroon;
                _row.Cells[0].Value    = j.ToNthDay();
                _row.Cells[0].AuxValue = j;
                _row.AutoHeight();
                _row.Height += 2;
                _row.Key     = start_fs_id.ToStringNullable();
                _row.Visible = false;
                _row.Tag     = new DateTime(m_YEAR, m_MONTH, j).ToMyLongDate();
                start_fs_id--;
            }
            #endregion
            if (datam.DATA_MONTH_BANK_RECONCILIATION[new_val].Keys.Count > 0)
            {
                var nlist = from n in datam.DATA_MONTH_BANK_RECONCILIATION[new_val]
                            where n.Value.status == em.voucher_statusS.valid
                            orderby n.Value.fs_id descending
                            group n by n.Value.fs_id
                            into new_group
                            select new
                {
                    fs_id          = new_group.Key,
                    total_deduct   = new_group.Where(y => y.Value.br_acc_type == em.bank_reconc_typeS.deduction).Sum(h => h.Value.amount),
                    total_addition = new_group.Where(y => y.Value.br_acc_type == em.bank_reconc_typeS.addition).Sum(h => h.Value.amount),
                };
                if (nlist.Count() > 0)
                {
                    iGrid1.Rows[m_MONTH.ToString()].Cells["reconc_add"].Value    = nlist.Sum(k => k.total_addition);
                    iGrid1.Rows[m_MONTH.ToString()].Cells["reconc_deduct"].Value = nlist.Sum(k => k.total_deduct);
                    if ((nlist.Max(j => j.fs_id) != sdata.CURR_FS.fs_id) & new_val == string.Format("{0}{1}", sdata.CURR_DATE.Year, sdata.CURR_DATE.Month).ToInt32())
                    {
                        iGrid1.Rows[sdata.CURR_FS.fs_id.ToString()].Cells["reconc_add"].Value    = null;
                        iGrid1.Rows[sdata.CURR_FS.fs_id.ToString()].Cells["reconc_deduct"].Value = null;
                        iGrid1.Rows[sdata.CURR_FS.fs_id.ToString()].Visible = true;
                    }
                    foreach (var d in nlist)
                    {
                        iGrid1.Rows[d.fs_id.ToString()].Cells["reconc_add"].Value    = d.total_addition;
                        iGrid1.Rows[d.fs_id.ToString()].Cells["reconc_deduct"].Value = d.total_deduct;
                        iGrid1.Rows[d.fs_id.ToString()].Visible = true;
                    }
                    if (new_val == string.Format("{0}{1}", sdata.CURR_DATE.Year, sdata.CURR_DATE.Month).ToInt32())
                    {
                        iGrid1.SetCurCell(sdata.CURR_FS.fs_id.ToString(), 0);
                    }
                }
            }
            else
            {
                iGrid1.Rows[m_MONTH.ToString()].Cells["reconc_add"].Value    = null;
                iGrid1.Rows[m_MONTH.ToString()].Cells["reconc_deduct"].Value = null;
                if (m_YEAR == sdata.CURR_DATE.Year & m_MONTH == sdata.CURR_DATE.Month)
                {
                    iGrid1.Rows[sdata.CURR_FS.fs_id.ToString()].Cells["reconc_add"].Value    = null;
                    iGrid1.Rows[sdata.CURR_FS.fs_id.ToString()].Cells["reconc_deduct"].Value = null;
                    iGrid1.Rows[sdata.CURR_FS.fs_id.ToString()].Visible = true;
                }
            }
            iGrid1.EndUpdate();
            iGrid1.Cols.AutoWidth();
            iGrid1.AutoResizeCols = false;
        }
        private void CheckUpdates()
        {
            using (var _xd = new xing())
            {
                datam.InitAccount(_xd);
                _xd.CommitTransaction();
            }
            wdata.TABLE_STAMP["accounts_current_balance_tb"] = m_LastStamp;
            if (datam.GetAccountsPayable(null))
            {
                m_LastStamp = wdata.TABLE_STAMP["accounts_current_balance_tb"];
                var nlist = from k in datam.DATA_ACCOUNTS_PAYABLE.Values
                            where k.is_updated & k.objAccount.account_type == em.account_typeS.ActualAccount
                            select k;
                if (nlist.Count() == 0)
                {
                    return;
                }
                var   _selected_cell = fGrid.CurCell;
                var   ex_list        = fGrid.Rows.Cast <iGRow>().Where(t => t.Type == iGRowType.AutoGroupRow & t.Expanded).Select(p => p.Key).ToList();
                iGRow _row           = null;
                fGrid.BeginUpdate();
                fGrid.GroupObject.Clear();
                fGrid.Group();
                ic.accountC _acc = null;
                foreach (var r in nlist)
                {
                    try
                    {
                        _row = fGrid.Rows[string.Format("{0}{1}", r.account_id.ToString(), r.objAccount.owner_id)];
                        _acc = datam.DATA_ACCOUNTS[r.account_id];
                        _row.Cells["balance"].Value = r.balance;
                    }
                    catch (Exception ex)
                    {
                        #region new_row
                        _row          = fGrid.Rows.Add();
                        _row.Font     = new Font("georgia", 12, FontStyle.Regular);
                        _row.ReadOnly = iGBool.True;
                        _acc          = datam.DATA_ACCOUNTS[r.account_id];
                        if (r.account_id < 0)
                        {
                            _row.Cells["owner"].Value  = "CUC";
                            _row.Cells["svalue"].Value = _row.Cells["owner"].Value;
                        }
                        _row.Cells["account"].Value      = _acc.account_name;
                        _row.Cells["balance"].Value      = r.balance;
                        _row.Cells["balance"].Font       = new Font("verdana", 11, FontStyle.Regular);
                        _row.Cells["balance"].ForeColor  = Color.DarkBlue;
                        _row.Cells["acc_category"].Value = datam.DATA_ACCOUNTS[_acc.p_account_id].account_name;
                        // _row.Cells["owner"].Value = _acc.owner_name;
                        switch (_acc.owner_type)
                        {
                        case em.AccountOwnerTypeS.CUC:
                        {
                            _row.Cells["owner"].Value  = "CUC";
                            _row.Cells["svalue"].Value = _row.Cells["owner"].Value;
                            _row.Cells["s_id"].Value   = 1;
                            break;
                        }

                        case em.AccountOwnerTypeS.CHURCH:
                        {
                            _row.Cells["owner"].Value  = "Church";
                            _row.Cells["svalue"].Value = _row.Cells["owner"].Value;
                            _row.Cells["s_id"].Value   = 3;
                            break;
                        }

                        case em.AccountOwnerTypeS.CHURCH_GROUP:
                        {
                            try
                            {
                                _row.Cells["owner"].Value = datam.DATA_CHURCH_GROUPS[_acc.owner_id].cg_name;
                            }
                            catch (Exception)
                            {
                                _row.Cells["owner"].Value = "Church Group";
                            }
                            _row.Cells["svalue"].Value = _row.Cells["owner"].Value;
                            _row.Cells["s_id"].Value   = 5;
                            break;
                        }

                        case em.AccountOwnerTypeS.CHURCH_MEMBER:
                        {
                            try
                            {
                                _row.Cells["owner"].Value = datam.DATA_MEMBER[_acc.owner_id].mem_name;
                            }
                            catch (Exception)
                            {
                                _row.Cells["owner"].Value = "Church Member";
                            }
                            _row.Cells["svalue"].Value = "Church Members";
                            _row.Cells["s_id"].Value   = 7;
                            break;
                        }

                        case em.AccountOwnerTypeS.DEPARTMENT:
                        {
                            try
                            {
                                _row.Cells["owner"].Value = datam.DATA_DEPARTMENT[_acc.owner_id].dept_name;
                                if (_row.Cells["owner"].Text.IndexOf("department") == -1)
                                {
                                    _row.Cells["owner"].Value = _row.Cells["owner"].Text + " Department";
                                }
                            }
                            catch (Exception)
                            {
                                _row.Cells["owner"].Value = "Department";
                            }
                            _row.Cells["svalue"].Value = _row.Cells["owner"].Value;
                            _row.Cells["s_id"].Value   = 4;

                            break;
                        }

                        case em.AccountOwnerTypeS.DISTRICT:
                        {
                            _row.Cells["owner"].Value  = "District";
                            _row.Cells["svalue"].Value = _row.Cells["owner"].Value;
                            _row.Cells["s_id"].Value   = 2;
                            break;
                        }

                        case em.AccountOwnerTypeS.OTHER:
                        {
                            _row.Cells["owner"].Value  = _acc.owner_name;
                            _row.Cells["svalue"].Value = "Others";
                            _row.Cells["s_id"].Value   = 6;
                            break;
                        }

                        case em.AccountOwnerTypeS.CHURCH_GROUP_SHARED:
                        {
                            if (r.objAccount.owner_id == 0)
                            {
                                _row.Cells["owner"].Value = "Church";
                                _row.Cells["s_id"].Value  = 3;
                            }
                            else
                            {
                                try
                                {
                                    var _cg = datam.DATA_CHURCH_GROUPS[r.objAccount.owner_id];
                                    if (_cg != null)
                                    {
                                        _row.Cells["account"].Value = string.Format("{0} :: {1}", _acc.account_name, _cg.cg_name);
                                        _row.Cells["owner"].Value   = _cg.cg_name;
                                        _row.Cells["s_id"].Value    = 5;
                                    }
                                }
                                catch (Exception er)
                                {
                                }
                            }
                            _row.Cells["svalue"].Value = _row.Cells["owner"].Value;
                            break;
                        }
                        }
                        #endregion
                        _row.AutoHeight();
                        _row.Key = string.Format("{0}{1}", r.account_id.ToString(), r.objAccount.owner_id);
                        _row.Tag = r;
                    }
                    r.is_updated = false;
                }
                ShowTotalCreditors();
                fGrid.Cols.AutoWidth();
                fGrid.AutoResizeCols = false;
                var Gtotal = from k in fGrid.Rows.Cast <iGRow>()
                             group k by k.Cells["svalue"].Text
                             into nw_gp
                             select new
                {
                    gp_name  = nw_gp.Key,
                    gp_total = nw_gp.Sum(p => p.Cells["balance"].Value.ToInt32())
                };
                m_GroupTotal.Clear();
                foreach (var t in Gtotal)
                {
                    m_GroupTotal.Add(t.gp_name, t.gp_total);
                }
                if (fGrid.GroupObject.Count == 0)
                {
                    fGrid.GroupObject.Add("svalue");
                }
                fGrid.Group();
                fGrid.PerformAction(iGActions.CollapseAll);
                foreach (var y in ex_list)
                {
                    try
                    {
                        fGrid.Rows[y].Expanded = true;
                    }
                    catch (Exception ex)
                    {
                    }
                }
                fGrid.EndUpdate();
            }
        }
        private void LoadMainGrid2(ic.church_groupC _gp)
        {
            if (m_LDATA.Keys.IndexOf(_gp.cg_id) == -1)
            {
                m_LDATA.Add(_gp.cg_id, new iGDropDownList());
                m_LDATA[_gp.cg_id] = fnn.CreateCombo();
                m_LDATA[_gp.cg_id].MaxVisibleRowCount = 5;
                var nlist = from k in datam.DATA_ROLES.Values
                            where k.gp_type == em.role_gp_typeS.church_group &
                            k.gp_id == _gp.cg_id
                            select k;
                foreach (var n in nlist)
                {
                    m_LDATA[_gp.cg_id].Items.Add(new fnn.iGComboItemEX()
                    {
                        Text  = n.role_name,
                        Value = n.role_name,
                        Tag   = n
                    });
                }
            }
            m_prev_role = null;
            fGrid2.Cols["_pic"].Width = 20;
            fGrid2.Rows.Clear();
            buttonX1.Visible = false;
            buttonX2.Visible = false;
            buttonR.Visible  = false;
            if (_gp == null)
            {
                return;
            }
            iGRow _row = null;

            _row                         = CreateNewRow2();
            _row.Key                     = "othersxxx";
            _row.ForeColor               = Color.Blue;
            _row.Cells["mem"].Value      = "Member Names";
            _row.Cells["mem"].TextAlign  = iGContentAlignment.MiddleCenter;
            _row.BackColor               = Color.Lavender;
            _row.ReadOnly                = iGBool.False;
            _row.Selectable              = false;
            _row.Cells["type"].Value     = null;
            _row.Cells["type"].TextAlign = iGContentAlignment.MiddleRight;
            //
            _row.Cells["desig"].Value     = "Member Role(s)";
            _row.Cells["desig"].TextAlign = iGContentAlignment.MiddleCenter;
            // fGrid2.Rows["othersxxx"].Cells["_pic"].TypeFlags = iGCellTypeFlags.HasEllipsisButton;

            buttonX1.Visible = true;
            buttonX2.Visible = true;
            buttonR.Visible  = true;
            if (_gp == null)
            {
                fGrid2.EndUpdate(); return;
            }
            int _cnt = 0;

            ic.RoleC _role = null;
            if (_gp.MemberCount > 0)
            {
                foreach (var r in _gp.MemberEnumerable.OrderBy(l => l.mem_name))
                {
                    _cnt++;
                    _row          = fGrid2.Rows.Add();
                    _row.ReadOnly = iGBool.True;
                    _row.Font     = new Font("verdana", 10, FontStyle.Bold);
                    _row.Cells["type"].Col.Width = 30;
                    _row.Cells["type"].Value     = _cnt;
                    _row.Cells["type"].TextAlign = iGContentAlignment.MiddleCenter;
                    _row.Cells["mem"].ValueType  = typeof(string);
                    _row.Tag = r.mem_id.ToStringNullable();
                    _row.Cells["mem"].Value      = r.mem_name;
                    _row.Cells["_pic"].TypeFlags = iGCellTypeFlags.HasEllipsisButton;
                    _row.Cells["_pic"].ReadOnly  = iGBool.False;
                    //
                    _role = r.RolesCollection.Where(k => k.Is_valid & k.objRole.gp_type == em.role_gp_typeS.church_group & k.objRole.gp_id == _gp.cg_id).Select(k => k.objRole).FirstOrDefault();
                    _row.Cells["desig"].DropDownControl = m_LDATA[_gp.cg_id];
                    _row.Cells["desig"].Value           = null;
                    if (_role != null)
                    {
                        _row.Cells["desig"].Value = _role.role_name;
                    }
                    //
                    _row.Cells["desig"].ReadOnly  = iGBool.False;
                    _row.Cells["desig"].TypeFlags = iGCellTypeFlags.HideComboButton;
                    _row.Key = r.mem_id.ToStringNullable();
                    _row.AutoHeight();
                }
            }
            fGrid2.Cols.AutoWidth();
            fGrid2.AutoResizeCols = false;
            fGrid2.EndUpdate();
            position_button_controller();
        }
        private void DrawLeftTree()
        {
            Application.DoEvents();
            iGrid1.BeginUpdate();
            iGrid1.Rows.Clear();
            fGrid.Rows.Clear();
            iGRow _row  = null;
            var   nlist = from k in datam.DATA_CURRENT_PLEDGE_SETTINGS.Values
                          where k.pledged_amount > 0
                          orderby k.pls_id
                          select k;
            float _total     = 0f;
            float _paid      = 0f;
            float _percent   = 0f;
            iGRow parent_row = null;
            int   mem_count  = 0;

            foreach (var k in nlist)
            {
                _row                              = iGrid1.Rows.Add();
                _row.Font                         = new Font("verdana", 12, FontStyle.Bold);
                _row.BackColor                    = Color.WhiteSmoke;
                _row.ReadOnly                     = iGBool.True;
                _row.Cells["pledge"].Value        = datam.DATA_ACCOUNTS[k.account_id].account_name;
                _row.Cells["pledge_amount"].Value = k.pledged_amount;
                _row.Cells["paid"].Value          = k.paid_amount;
                if (k.balance > 0)
                {
                    _row.Cells["balance"].Value = k.balance;
                }
                if (k.paid_amount > 0)
                {
                    _total   = k.pledged_amount;
                    _paid    = k.paid_amount;
                    _percent = ((_paid / _total) * 100);
                    _row.Cells["p_comp"].Value = string.Format(" {0} %", Math.Round(_percent, 1));
                }
                else
                {
                    _row.Cells["p_comp"].Value = string.Format(" {0} %", 0);
                }
                _row.Key     = string.Format("{0}", k.pls_id);
                _row.Tag     = k;
                _row.Visible = true;
                _row.AutoHeight();
                _row.Height += 2;
                mem_count    = 0;
                var plist = from c in datam.DATA_CURRENT_PLEDGES.Values
                            where c.pls_id == k.pls_id
                            group c by c.cg_id into nw_gp
                            select new
                {
                    cg_id         = nw_gp.Key,
                    plegde_amount = nw_gp.Sum(p => p.amount_pledged),
                    paid_amount   = nw_gp.Sum(p => p.amount_paid),
                    balance       = nw_gp.Sum(p => p.balance),
                    mem_count     = nw_gp.Select(u => new { _id = string.Format("{0}-{1}", u.source_type.ToByte(), u.source_id) }).Distinct().Count()
                };
                parent_row            = _row;
                parent_row.TreeButton = iGTreeButtonState.Visible;
                foreach (var p in plist)
                {
                    _row            = iGrid1.Rows.Add();
                    _row.Font       = new Font("verdana", 11, FontStyle.Regular);
                    _row.Level      = 1;
                    _row.TreeButton = iGTreeButtonState.Hidden;
                    _row.ReadOnly   = iGBool.True;
                    if (p.cg_id == 0)
                    {
                        _row.Cells["pledge"].Value     = "General";
                        _row.Cells["pledge"].ForeColor = Color.Purple;
                    }
                    else
                    {
                        _row.Cells["pledge"].Value     = datam.DATA_CHURCH_GROUPS[p.cg_id].cg_name;
                        _row.Cells["pledge"].ForeColor = Color.Purple;
                    }
                    _row.Cells["pledge_amount"].Value = p.plegde_amount;
                    _row.Cells["paid"].Value          = p.paid_amount;
                    _row.Cells["mem_count"].Value     = p.mem_count;
                    mem_count += p.mem_count;
                    if (p.balance > 0)
                    {
                        _row.Cells["balance"].Value = p.balance;
                    }
                    if (p.paid_amount > 0)
                    {
                        _total   = p.plegde_amount;
                        _paid    = p.paid_amount;
                        _percent = ((_paid / _total) * 100);
                        _row.Cells["p_comp"].Value = string.Format(" {0} %", Math.Round(_percent, 1));
                    }
                    else
                    {
                        _row.Cells["p_comp"].Value = string.Format(" {0} %", 0);
                    }
                    _row.Key     = string.Format("{0}|{1}", k.pls_id, p.cg_id);
                    _row.Tag     = k;
                    _row.Visible = true;
                    _row.AutoHeight();
                    _row.Height += 2;
                }
                parent_row.Cells["mem_count"].Value = mem_count;
                //  parent_row.Expanded = false;
                mem_count = 0;
            }
            iGrid1.Cols.AutoWidth();
            iGrid1.AutoResizeCols = false;
            iGrid1.EndUpdate();
        }