Example #1
0
        private void fGrid_AfterCommitEdit(object sender, iGAfterCommitEditEventArgs e)
        {
            if (fGrid.Rows[e.RowIndex].Cells["desc"].DropDownControl != null && fGrid.Rows[e.RowIndex].Cells["desc"].AuxValue == null)
            {
                fGrid.Rows[e.RowIndex].Cells["desc"].Value = null;

                return;
            }

            if (e.RowIndex != fGrid.Rows.Count - 1)
            {
                if (fGrid.Rows[e.RowIndex].Cells["desc"].Value == null)
                {
                    return;
                }
                for (int k = e.RowIndex + 1; k < fGrid.Rows.Count; k++)
                {
                    if (fGrid.Rows[k].Type == iGRowType.AutoGroupRow)
                    {
                        fGrid.Rows[k].Expanded = true;
                        continue;
                    }
                    if (!fGrid.Rows[k].Visible)
                    {
                        continue;
                    }
                    if (fGrid.Rows[k].Cells[1].Enabled == iGBool.False)
                    {
                        continue;
                    }
                    if (fGrid.Rows[k].Cells[1].ReadOnly == iGBool.True)
                    {
                        continue;
                    }
                    if (string.IsNullOrEmpty(fGrid.Rows[k].Key))
                    {
                        continue;
                    }
                    if ((e.RowIndex + 3) < fGrid.Rows.Count)
                    {
                        fGrid.Rows[(e.RowIndex + 3)].EnsureVisible();
                    }
                    fGrid.SetCurCell(k, e.ColIndex);
                    break;
                }
            }
        }
 private void fGrid_AfterCommitEdit(object sender, iGAfterCommitEditEventArgs e)
 {
     switch (fGrid.Rows[e.RowIndex].Key)
     {
     case "apostacy_date":
     {
         if (fGrid.Rows[e.RowIndex].Cells["desc"].AuxValue != null)
         {
             buttonsave.Enabled = true;
             return;
         }
         else
         {
             buttonsave.Enabled = false;
             return;
         }
     }
     }
     if (e.RowIndex != fGrid.Rows.Count - 1)
     {
         if (fGrid.Rows[e.RowIndex].Cells["desc"].Value == null)
         {
             return;
         }
         for (int k = e.RowIndex + 1; k < fGrid.Rows.Count; k++)
         {
             if (fGrid.Rows[k].Type == iGRowType.AutoGroupRow)
             {
                 fGrid.Rows[k].Expanded = true;
                 continue;
             }
             if (!fGrid.Rows[k].Visible)
             {
                 continue;
             }
             fGrid.SetCurCell(k, e.ColIndex);
             break;
         }
     }
 }
        private void fGrid_AfterCommitEdit(object sender, iGAfterCommitEditEventArgs e)
        {
            string _key = fGrid.Rows[e.RowIndex].Key;

            if (fGrid.Rows[e.RowIndex].Cells["desc"].DropDownControl == null & fGrid.Rows[e.RowIndex].Cells["desc"].Value != null & fGrid.Rows[e.RowIndex].Cells["desc"].ValueType == typeof(string))
            {
                fGrid.Rows[e.RowIndex].Cells["desc"].Value = fGrid.Rows[e.RowIndex].Cells["desc"].Value.ToString().Trim().ToUpper();
            }
            if (!string.IsNullOrEmpty(_key))
            {
                switch (_key)
                {
                case "alias":
                {
                    var _alias = fGrid.Rows["alias"].Cells["desc"].Value;
                    if (datam.DATA_ACCOUNTS.Values.Where(p => p.account_id != m_account.account_id & !string.IsNullOrEmpty(p.search_alias)).Count(k => k.search_alias.ToLower() == _alias.ToString().ToLower()) > 0)
                    {
                        MessageBox.Show(string.Format("Alias {0} Already Exists", _alias));
                        return;
                    }
                    dbh.SingleUpdateCommand("accounts_tb", new string[] { "alias", "account_id" }, new object[] { fGrid.Rows[_key].Cells["desc"].Value, m_account.account_id }, 1);
                    m_account.search_alias = fGrid.Rows[_key].Cells["desc"].Value == null ? null : fGrid.Rows[_key].Cells["desc"].Value.ToStringNullable();
                    fGrid.Rows["alias"].AutoHeight();
                    break;
                }

                case "map_id":
                {
                    var _map_id = fGrid.Rows["map_id"].Cells["desc"].Value == null ? 0 : fGrid.Rows["map_id"].Cells["desc"].Value.ToInt32();
                    dbh.SingleUpdateCommand("accounts_tb", new string[] { "map_id", "account_id" }, new object[] { _map_id, m_account.account_id }, 1);

                    fGrid.Rows["map_id"].AutoHeight();
                    break;
                }
                }
            }
        }
        private void fGrid_AfterCommitEdit(object sender, iGAfterCommitEditEventArgs e)
        {
            if (fGrid.Rows[e.RowIndex].Cells[e.ColIndex].DropDownControl != null && fGrid.Rows[e.RowIndex].Cells[e.ColIndex].AuxValue == null)
            {
                fGrid.Rows[e.RowIndex].Cells[e.ColIndex].Value = null;
                fGrid.SetCurCell(e.RowIndex, 1);

                if (fGrid.Rows[e.RowIndex].Key == "exp_account")
                {
                    fGrid.Rows["category"].Cells[1].Value = null;
                }
                return;
            }


            if (fGrid.Rows[e.RowIndex].Key == "exp_account" & fGrid.Rows[e.RowIndex].Cells[1].AuxValue != null)
            {
                var _exp = (fGrid.Rows[e.RowIndex].Cells[1].AuxValue as fnn.iGComboItemEX).Tag as ic.bank_reconc_accountC;
                if (_exp != null)
                {
                    fGrid.Rows["category"].Cells[1].Value = _exp.br_acc_type == em.bank_reconc_typeS.addition ? "Income" : "Expense";
                }
                else
                {
                    fGrid.Rows["category"].Cells[1].Value = null;
                }
            }
            if (e.RowIndex != fGrid.Rows.Count - 1)
            {
                if (fGrid.Rows[e.RowIndex].Cells["desc"].Value == null)
                {
                    return;
                }
                for (int k = e.RowIndex + 1; k < fGrid.Rows.Count; k++)
                {
                    if (fGrid.Rows[k].Type == iGRowType.AutoGroupRow)
                    {
                        fGrid.Rows[k].Expanded = true;
                        continue;
                    }
                    if (!fGrid.Rows[k].Visible)
                    {
                        continue;
                    }
                    if (fGrid.Rows[k].Cells[1].Enabled == iGBool.False)
                    {
                        continue;
                    }
                    if (string.IsNullOrEmpty(fGrid.Rows[k].Key))
                    {
                        continue;
                    }
                    if ((e.RowIndex + 3) < fGrid.Rows.Count)
                    {
                        fGrid.Rows[(e.RowIndex + 3)].EnsureVisible();
                    }
                    fGrid.SetCurCell(k, e.ColIndex);
                    break;
                }
            }
        }
Example #5
0
        private void fGrid_AfterCommitEdit(object sender, iGAfterCommitEditEventArgs e)
        {
            var _key = fGrid.Rows[e.RowIndex].Key;

            switch (_key)
            {
            case "date":
            {
                DateTime?_date = System.Convert.ToDateTime(fGrid.Rows[e.RowIndex].Cells[1].Value);
                fGrid.Rows["curr_amount"].Cells[1].Value    = null;
                fGrid.Rows["curr_exch_rate"].Cells[1].Value = null;
                using (var xd = new xing())
                {
                    int   _acc_id    = (fGrid.Rows["currency"].Cells[1].AuxValue as fnn.iGComboItemEX).Tag.ToInt32();
                    float _exch_rate = accn.GetFS_ConversionRate(xd, fn.GetFSID(_date.Value), _acc_id);
                    int   _acc_bal   = accn.GetFS_ForeignCurrencyBalance(xd, fn.GetFSID(_date.Value), _acc_id);
                    fGrid.Rows["curr_exch_rate"].Cells[1].Value = _exch_rate;
                    if (_acc_bal > 0)
                    {
                        fGrid.Rows["curr_amount"].Cells[1].Value = _acc_bal;
                    }
                    xd.CommitTransaction();
                }
                break;
            }

            case "currency":
            {
                if (fGrid.Rows[e.RowIndex].Cells[1].Value == null)
                {
                    fGrid.Rows["curr_amount"].Cells[1].Value    = null;
                    fGrid.Rows["curr_exch_rate"].Cells[1].Value = null;
                    //
                    fGrid.Rows["exch_amount"].Cells[1].Value = null;
                    fGrid.Rows["exch_rate"].Cells[1].Value   = null;
                    fGrid.Rows["ug_amount"].Cells[1].Value   = null;
                    fGrid.Rows["gain"].Cells[1].Value        = null;
                    fGrid.Rows["loss"].Cells[1].Value        = null;
                    fGrid.Rows["date"].Cells[1].Value        = null;
                    fGrid.Rows["date"].Cells[1].AuxValue     = null;
                    fGrid.Rows["date"].Cells[1].Enabled      = iGBool.False;
                    fGrid.Rows["exch_amount"].Cells[0].Value = "Amount Exchanged";
                }
                else
                {
                    fGrid.Rows["curr_amount"].Cells[1].Value    = null;
                    fGrid.Rows["curr_exch_rate"].Cells[1].Value = null;
                    //
                    fGrid.Rows["exch_amount"].Cells[1].Value = null;
                    fGrid.Rows["exch_rate"].Cells[1].Value   = null;
                    fGrid.Rows["ug_amount"].Cells[1].Value   = null;
                    fGrid.Rows["gain"].Cells[1].Value        = null;
                    fGrid.Rows["loss"].Cells[1].Value        = null;
                    fGrid.Rows["date"].Cells[1].Value        = null;
                    fGrid.Rows["date"].Cells[1].AuxValue     = null;
                    fGrid.Rows["date"].Cells[1].Enabled      = iGBool.True;
                    fGrid.Rows["exch_amount"].Cells[0].Value = string.Format("{0} Exchanged", fGrid.Rows["currency"].Cells[1].Text);
                    //
                    using (var xd = new xing())
                    {
                        int    _acc_id = (fGrid.Rows["currency"].Cells[1].AuxValue as fnn.iGComboItemEX).Tag.ToInt32();
                        object _obj    = xd.ExecuteScalarObject(string.Format("select last_exchange_date from acc_foreign_currency_tb where sys_account_id={0}", _acc_id));
                        if (_obj == null)
                        {
                            _obj = xd.ExecuteScalarObject(string.Format("select TOP 1 fs_date from acc_foreign_currency_mvt_tb where sys_account_id={0} order by fs_id", _acc_id));
                        }
                        DateTime?_start_date = System.Convert.ToDateTime(_obj);
                        var      _date       = new fnn.DropDownCalenderX();
                        if (_start_date != null)
                        {
                            _date.start_date    = _start_date.Value;
                            _date.end_date      = sdata.CURR_DATE;
                            _date.selected_date = sdata.CURR_DATE;
                        }
                        else
                        {
                            _date.start_date    = sdata.CURR_DATE;
                            _date.end_date      = sdata.CURR_DATE;
                            _date.selected_date = sdata.CURR_DATE;
                        }
                        fGrid.Rows["date"].Cells["desc"].DropDownControl = _date;
                    }
                }
                break;
            }

            case "exch_amount":
            case "exch_rate":
            {
                fGrid.Rows["gain"].Cells[1].Value      = null;
                fGrid.Rows["loss"].Cells[1].Value      = null;
                fGrid.Rows["ug_amount"].Cells[1].Value = null;
                if (_key == "exch_amount")
                {
                    if ((fGrid.Rows["exch_amount"].Cells[1].Value.ToInt32() > fGrid.Rows["curr_amount"].Cells[1].Value.ToInt32()) | (fGrid.Rows["exch_amount"].Cells[1].Value.ToInt32() <= 0))
                    {
                        MessageBox.Show("The Amount You Have Entered INVALID", "Invalid Value Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        fGrid.Focus();
                        fGrid.Rows[e.RowIndex].Cells[1].Value    = null;
                        fGrid.Rows[e.RowIndex].Cells[1].Selected = true;
                        fGrid.Rows["exch_rate"].Cells[1].Value   = null;
                        return;
                    }
                }
                if (_key == "exch_rate")
                {
                    int _c = (fGrid.Rows["exch_rate"].Cells[1].Value.ToFloat() - fGrid.Rows["curr_exch_rate"].Cells[1].Value.ToFloat()).ToInt32();
                    if (Math.Abs(_c) > (fGrid.Rows["curr_exch_rate"].Cells[1].Value.ToFloat() * 0.75).ToInt32())
                    {
                        MessageBox.Show("The Exchange Rate You Entered Is Probably Wrong", "Wrong Exchange Rate Error");
                        fGrid.Focus();
                        fGrid.Rows[e.RowIndex].Cells[1].Value    = null;
                        fGrid.Rows[e.RowIndex].Cells[1].Selected = true;
                        return;
                    }
                }

                if (fGrid.Rows["exch_amount"].Cells[1].Value != null & fGrid.Rows["exch_rate"].Cells[1].Value != null)
                {
                    fGrid.Rows["ug_amount"].Cells[1].Value = (fGrid.Rows["exch_amount"].Cells[1].Value.ToInt32() * fGrid.Rows["exch_rate"].Cells[1].Value.ToFloat()).ToInt32();
                    var _diff = (fGrid.Rows["ug_amount"].Cells[1].Value.ToInt32() - ((fGrid.Rows["exch_amount"].Cells[1].Value.ToInt32() * fGrid.Rows["curr_exch_rate"].Cells[1].Value.ToFloat()).ToInt32()));
                    if (_diff > 0)
                    {
                        fGrid.Rows["gain"].Cells[1].Value = _diff;
                    }
                    else
                    {
                        if (_diff != 0)
                        {
                            fGrid.Rows["loss"].Cells[1].Value = Math.Abs(_diff);
                        }
                    }
                }

                break;
            }
            }
            if (e.RowIndex != fGrid.Rows.Count - 1)
            {
                if (fGrid.Rows[e.RowIndex].Cells["desc"].Value == null)
                {
                    return;
                }
                for (int k = e.RowIndex + 1; k < fGrid.Rows.Count; k++)
                {
                    if (fGrid.Rows[k].Type == iGRowType.AutoGroupRow)
                    {
                        fGrid.Rows[k].Expanded = true;
                        continue;
                    }
                    if (!fGrid.Rows[k].Visible)
                    {
                        continue;
                    }
                    if (fGrid.Rows[k].Cells[1].Enabled == iGBool.False)
                    {
                        continue;
                    }
                    if (fGrid.Rows[k].Cells[1].ReadOnly == iGBool.True)
                    {
                        continue;
                    }
                    if (string.IsNullOrEmpty(fGrid.Rows[k].Key))
                    {
                        continue;
                    }
                    if ((e.RowIndex + 3) < fGrid.Rows.Count)
                    {
                        fGrid.Rows[(e.RowIndex + 3)].EnsureVisible();
                    }
                    fGrid.SetCurCell(k, e.ColIndex);
                    break;
                }
            }
        }
Example #6
0
        private void fGrid_AfterCommitEdit(object sender, iGAfterCommitEditEventArgs e)
        {
            iGRow _row = fGrid.Rows[e.RowIndex];

            if (_row.Cells[1].DropDownControl != null && _row.Cells[1].AuxValue == null)
            {
                if (_row.Key != "marr_church")
                {
                    _row.Cells[1].Value = null;
                    return;
                }
            }
            if (_row.Key == "household")
            {
                if (_row.Cells[1].Value != null)
                {
                    _row.Cells[1].Value = _row.Cells[1].Value.ToProperCase();
                }
            }
            if (_row.Key == "husband" | _row.Key == "wife")
            {
                if (!CheckKukoos())
                {
                    return;
                }
                if (fGrid.Rows["husband"].Cells[1].Value != null & fGrid.Rows["wife"].Cells[1].Value != null)
                {
                    var _husband = (fGrid.Rows["husband"].Cells[1].AuxValue as fnn.iGComboItemEX).Tag as ic.memberC;
                    var _wife    = (fGrid.Rows["wife"].Cells[1].AuxValue as fnn.iGComboItemEX).Tag as ic.memberC;
                    if (_husband.objSpouse != null)
                    {
                        if (_husband.objSpouse.marriage_year > 0)
                        {
                            fGrid.Rows["marr_yr"].Cells["desc"].Value = _husband.objSpouse.marriage_year;
                        }
                        if (_husband.objSpouse.marriage_date != null & fGrid.Rows["marr_yr"].Cells["desc"].Value != null)
                        {
                            int marr_yr = fGrid.Rows["marr_yr"].Cells["desc"].Value.ToInt32();
                            fGrid.Rows["marr_date"].Cells["name"].AuxValue = marr_yr;
                            fGrid.Rows["marr_date"].Cells["desc"].ReadOnly = iGBool.False;
                            fGrid.Rows["marr_date"].Cells["desc"].Value    = _husband.objSpouse.marriage_date;
                        }
                        if (!string.IsNullOrEmpty(_husband.objSpouse.church))
                        {
                            fGrid.Rows["marr_church"].Cells["desc"].Value = _husband.objSpouse.church;
                        }
                        if (!string.IsNullOrEmpty(_husband.objSpouse.pastor))
                        {
                            fGrid.Rows["marr_pastor"].Cells["desc"].Value = _husband.objSpouse.pastor;
                        }
                    }
                    if (_wife.objSpouse != null)
                    {
                        if (fGrid.Rows["marr_yr"].Cells["desc"].Value == null & _wife.objSpouse.marriage_year > 0)
                        {
                            fGrid.Rows["marr_yr"].Cells["desc"].Value = _wife.objSpouse.marriage_year;
                        }
                        if (fGrid.Rows["marr_date"].Cells["desc"].Value == null & _wife.objSpouse.marriage_date != null & fGrid.Rows["marr_yr"].Cells["desc"].Value != null)
                        {
                            int marr_yr = fGrid.Rows["marr_yr"].Cells["desc"].Value.ToInt32();
                            fGrid.Rows["marr_date"].Cells["name"].AuxValue = marr_yr;
                            fGrid.Rows["marr_date"].Cells["desc"].ReadOnly = iGBool.False;
                            fGrid.Rows["marr_date"].Cells["desc"].Value    = _wife.objSpouse.marriage_date;
                        }
                        if (fGrid.Rows["marr_church"].Cells["desc"].Value == null & !string.IsNullOrEmpty(_wife.objSpouse.church))
                        {
                            fGrid.Rows["marr_church"].Cells["desc"].Value = _wife.objSpouse.church;
                        }
                        if (fGrid.Rows["marr_pastor"].Cells["desc"].Value == null & !string.IsNullOrEmpty(_wife.objSpouse.pastor))
                        {
                            fGrid.Rows["marr_pastor"].Cells["desc"].Value = _wife.objSpouse.pastor;
                        }
                    }
                }
                else
                {
                    foreach (var t in new string[] { "marr_yr", "marr_date", "marr_church", "marr_pastor" })
                    {
                        fGrid.Rows[t].Cells[1].Value = null;
                        fGrid.Rows["marr_date"].Cells["desc"].ReadOnly = iGBool.True;
                    }
                }
            }
            if (_row.Key == "marr_yr")
            {
                #region MyRegion
                if (fGrid.Rows["marr_yr"].Cells["desc"].Value != null && (fGrid.Rows[e.RowIndex].Cells["desc"].Value.ToInt32() >= 1900 & fGrid.Rows[e.RowIndex].Cells["desc"].Value.ToInt32() <= sdata.CURR_DATE.Year))
                {
                    int marr_yr = fGrid.Rows["marr_yr"].Cells["desc"].Value.ToInt32();
                    fGrid.Rows["marr_date"].Cells["name"].AuxValue = marr_yr;
                    fGrid.Rows["marr_date"].Cells["desc"].ReadOnly = iGBool.False;
                }
                else
                {
                    fGrid.Rows["marr_yr"].Cells["desc"].Value      = null;
                    fGrid.Rows["marr_date"].Cells["desc"].Value    = null;
                    fGrid.Rows["marr_date"].Cells["desc"].ReadOnly = iGBool.True;
                    fGrid.Rows["marr_date"].Cells["name"].AuxValue = null;
                }
                #endregion
            }
            if (e.RowIndex != fGrid.Rows.Count - 1)
            {
                if (fGrid.Rows[e.RowIndex].Cells["desc"].Value == null)
                {
                    return;
                }
                for (int k = e.RowIndex + 1; k < fGrid.Rows.Count; k++)
                {
                    if (fGrid.Rows[k].Type == iGRowType.AutoGroupRow)
                    {
                        fGrid.Rows[k].Expanded = true;
                        continue;
                    }
                    if (!fGrid.Rows[k].Visible)
                    {
                        continue;
                    }
                    if (string.IsNullOrEmpty(fGrid.Rows[k].Key))
                    {
                        continue;
                    }
                    if ((e.RowIndex + 3) < fGrid.Rows.Count)
                    {
                        fGrid.Rows[(e.RowIndex + 3)].EnsureVisible();
                    }
                    fGrid.SetCurCell(k, e.ColIndex);
                    break;
                }
            }
        }
Example #7
0
        private void fGrid_AfterCommitEdit(object sender, iGAfterCommitEditEventArgs e)
        {
            if (fGrid.Rows[e.RowIndex].Cells["desc"].DropDownControl != null && fGrid.Rows[e.RowIndex].Cells["desc"].AuxValue == null)
            {
                fGrid.Rows[e.RowIndex].Cells["desc"].Value = null;
                if (fGrid.Rows[e.RowIndex].Key == "account_from")
                {
                    fGrid.Rows["account_to"].Cells[1].Value    = null;
                    fGrid.Rows["account_to"].Cells[1].AuxValue = null;
                    fGrid.Rows["account_to"].Cells[1].Enabled  = iGBool.False;
                }
                return;
            }
            if (fGrid.Rows[e.RowIndex].Key == "account_from")
            {
                fGrid.Rows["account_to"].Cells[1].Value    = null;
                fGrid.Rows["account_to"].Cells[1].AuxValue = null;
                fGrid.Rows["account_to"].Cells[1].Enabled  = iGBool.False;
                var icombo = fGrid.Rows["account_to"].Cells[1].DropDownControl as iGDropDownList;
                if (icombo == null)
                {
                    icombo = fnn.CreateCombo();
                    fGrid.Rows["account_to"].Cells[1].DropDownControl = icombo;
                }
                ic.accountC _from = (fGrid.Rows["account_from"].Cells[1].AuxValue as fnn.iGComboItemEX).Tag as ic.accountC;
                icombo.Items.Clear();
                var nlist = accn.GetChildAccounts(m_group_account.account_id, em.account_typeS.ActualAccount);

                if (nlist != null)
                {
                    foreach (var k in nlist)
                    {
                        if (k.account_status == em.account_statusS.DeActivated)
                        {
                            continue;
                        }
                        if (k.account_id == _from.account_id)
                        {
                            continue;
                        }
                        icombo.Items.Add(new fnn.iGComboItemEX()
                        {
                            Value = k.account_name,
                            Tag   = k
                        });
                    }
                }
                fGrid.Rows["account_to"].Cells[1].Enabled = iGBool.True;
            }
            if (e.RowIndex != fGrid.Rows.Count - 1)
            {
                if (fGrid.Rows[e.RowIndex].Cells["desc"].Value == null)
                {
                    return;
                }
                for (int k = e.RowIndex + 1; k < fGrid.Rows.Count; k++)
                {
                    if (fGrid.Rows[k].Type == iGRowType.AutoGroupRow)
                    {
                        fGrid.Rows[k].Expanded = true;
                        continue;
                    }
                    if (!fGrid.Rows[k].Visible)
                    {
                        continue;
                    }
                    if (fGrid.Rows[k].Cells[1].Enabled == iGBool.False)
                    {
                        continue;
                    }
                    if (fGrid.Rows[k].Cells[1].ReadOnly == iGBool.True)
                    {
                        continue;
                    }
                    if (string.IsNullOrEmpty(fGrid.Rows[k].Key))
                    {
                        continue;
                    }
                    if ((e.RowIndex + 3) < fGrid.Rows.Count)
                    {
                        fGrid.Rows[(e.RowIndex + 3)].EnsureVisible();
                    }
                    fGrid.SetCurCell(k, e.ColIndex);
                    break;
                }
            }
        }
Example #8
0
        private void fGrid_AfterCommitEdit(object sender, iGAfterCommitEditEventArgs e)
        {
            iGRow _row = fGrid.Rows[e.RowIndex];

            if (_row.Cells[1].DropDownControl != null && _row.Cells[1].AuxValue == null)
            {
                _row.Cells[1].Value = null;
                if (_row.Key == "owner_type")
                {
                    fGrid.Rows["owner"].Cells[1].AuxValue        = null;
                    fGrid.Rows["owner"].Cells[1].Value           = null;
                    fGrid.Rows["owner"].Cells[1].DropDownControl = null;
                    fGrid.Rows["owner"].Visible = false;
                }
                if (_row.Key == "account_type")
                {
                    ClearGrid();
                }
                return;
            }
            if (_row.Key == "start_date")
            {
                if (_row.Cells[1].AuxValue != null)
                {
                    buttonX1.PerformClick();
                }
            }
            if (e.RowIndex != fGrid.Rows.Count - 1)
            {
                if (fGrid.Rows[e.RowIndex].Cells["desc"].Value == null)
                {
                    return;
                }
                for (int k = e.RowIndex + 1; k < fGrid.Rows.Count; k++)
                {
                    if (fGrid.Rows[k].Type == iGRowType.AutoGroupRow)
                    {
                        fGrid.Rows[k].Expanded = true;
                        continue;
                    }
                    if (!fGrid.Rows[k].Visible)
                    {
                        continue;
                    }
                    if (fGrid.Rows[k].Cells[1].Enabled == iGBool.False)
                    {
                        continue;
                    }
                    if (string.IsNullOrEmpty(fGrid.Rows[k].Key))
                    {
                        continue;
                    }
                    if ((e.RowIndex + 3) < fGrid.Rows.Count)
                    {
                        fGrid.Rows[(e.RowIndex + 3)].EnsureVisible();
                    }
                    fGrid.SetCurCell(k, e.ColIndex);
                    break;
                }
            }
        }
Example #9
0
        void iGridCategory_AfterCommitEdit(object sender, iGAfterCommitEditEventArgs e)
        {
            iGrid _grid = sender as iGrid;

            if (_grid.Rows[e.RowIndex].Cells[0].Value != null)
            {
                _grid.Rows[e.RowIndex].Cells[0].Value = _grid.Rows[e.RowIndex].Cells[0].Value.ToProperCase();
            }
            if (sender == iGridCategory)
            {
                #region Item Category
                if (_grid.Rows[e.RowIndex].Cells[0].Value == null)
                {
                    if (_grid.Rows[e.RowIndex].Tag != null)
                    {
                        var _category = _grid.Rows[e.RowIndex].Tag as ic.expense_catC;
                        using (var xd = new xing())
                        {
                            if (xd.ExecuteScalarInt("select TOP 1 exp_acc_id from acc_expense_accounts_tb where exp_cat_id=" + _category.exp_cat_id) == 0)
                            {
                                xd.SingleDeleteCommandExp("acc_expense_cat_tb", new string[] { "exp_cat_id" }, new int[] { _category.exp_cat_id }); xd.CommitTransaction();
                            }
                            else
                            {
                                _grid.Rows[e.RowIndex].Cells[0].Value = _category.exp_cat_name;
                                dbm.ErrorMessage("There Are Some Expense Accounts Which Are Attached To This Category", "Delete Operation Will Be Cancelled");
                                return;
                            }
                        }
                        var _dp_item = (from r in (fGrid.Rows["item_cat"].Cells["desc"].DropDownControl as iGDropDownList).Items.Cast <fnn.iGComboItemEX>()
                                        where r.Tag == _category
                                        select r).FirstOrDefault();
                        if (_dp_item != null)
                        {
                            (fGrid.Rows["item_cat"].Cells["desc"].DropDownControl as iGDropDownList).Items.Remove(_dp_item);
                            fGrid.Rows["item_cat"].Cells["desc"].AuxValue = null;
                            fGrid.Rows["item_cat"].Cells["desc"].Value    = null;
                        }
                        _grid.Rows[e.RowIndex].Tag = null;
                        datam.DATA_EXPENSE_CATEGORY.Remove(_category.exp_cat_id);
                        _grid.Rows.RemoveAt(e.RowIndex);
                    }
                    return;
                }
                else
                {
                    if (_grid.Rows[e.RowIndex].Tag == null)
                    {
                        //insert
                        if (datam.DATA_EXPENSE_CATEGORY.Values.FirstOrDefault(k => k.exp_cat_name.ToLower() == _grid.Rows[e.RowIndex].Cells[0].Text.ToLower()) != null)
                        {
                            dbm.ErrorMessage("Duplicate Entry Found", "Duplicate Error");
                            _grid.Rows[e.RowIndex].Cells[0].Value = null;
                            return;
                        }
                        var _category = new ic.expense_catC();
                        using (var xd = new xing())
                        {
                            _category.exp_cat_name = _grid.Rows[e.RowIndex].Cells[0].Text.ToProperCase();
                            _category.exp_cat_id   = xd.SingleInsertCommandTSPInt("acc_expense_cat_tb", new string[] { "exp_cat_name", "exp_type", "fs_time_stamp", "lch_id" },
                                                                                  new object[] { _category.exp_cat_name, emm.export_type.insert.ToByte(), 0, datam.LCH_ID });
                            xd.CommitTransaction();
                        }
                        _grid.Rows[e.RowIndex].Tag = _category;
                        datam.DATA_EXPENSE_CATEGORY.Add(_category.exp_cat_id, _category);
                        (fGrid.Rows["item_cat"].Cells["desc"].DropDownControl as iGDropDownList).Items.Add(new fnn.iGComboItemEX {
                            Tag = _category, Text = _category.exp_cat_name, Value = _category.exp_cat_name
                        });
                    }
                    else
                    {
                        var _category = _grid.Rows[e.RowIndex].Tag as ic.expense_catC;
                        _category.exp_cat_name = _grid.Rows[e.RowIndex].Cells[0].Value.ToStringNullable();
                        using (var xd = new xing())
                        {
                            xd.SingleUpdateCommandALL("acc_expense_cat_tb", new string[] { "exp_cat_name", "exp_cat_id" }, new object[] { _category.exp_cat_name, _category.exp_cat_id }, 1);
                            xd.CommitTransaction();
                        }
                        //update
                    }
                }
                #endregion
            }
            if (((e.RowIndex + 1) == _grid.Rows.Count))
            {
                AddRowX(_grid);
            }
        }
Example #10
0
        void iGridCategory_AfterCommitEdit(object sender, iGAfterCommitEditEventArgs e)
        {
            iGrid _grid = sender as iGrid;

            if (_grid.Rows[e.RowIndex].Cells[0].Value != null)
            {
                _grid.Rows[e.RowIndex].Cells[0].Value = _grid.Rows[e.RowIndex].Cells[0].Value.ToProperCase();
            }
            if (sender == iGridCategory)
            {
                #region Item Category
                if (_grid.Rows[e.RowIndex].Cells[0].Value == null)
                {
                    if (_grid.Rows[e.RowIndex].Tag != null)
                    {
                        var _cg = _grid.Rows[e.RowIndex].Tag as ic.church_group_typeC;
                        using (var xd = new xing())
                        {
                            if (xd.ExecuteScalarInt("select TOP 1 cg_id from church_group_tb where cg_type_id=" + _cg.cg_type_id) == 0)
                            {
                                xd.SingleDeleteCommandExp("church_group_types_tb", new string[] { "cg_type_id" }, new int[] { _cg.cg_type_id }); xd.CommitTransaction();
                            }
                            else
                            {
                                _grid.Rows[e.RowIndex].Cells[0].Value = _cg.cg_type_name;
                                dbm.ErrorMessage("There Are Some Church Groups Which Are Attached To This Church Group Type", "Delete Operation Will Be Cancelled");
                                return;
                            }
                        }

                        _grid.Rows[e.RowIndex].Tag = null;
                        datam.DATA_CG_TYPES.Remove(_cg.cg_type_id);
                        _grid.Rows.RemoveAt(e.RowIndex);
                        this.Tag = 1;
                    }
                    return;
                }
                else
                {
                    if (_grid.Rows[e.RowIndex].Tag == null)
                    {
                        //insert
                        using (var xd = new xing())
                        {
                            var ret_val = xd.ExecuteScalerInt(new string[] { "cg_type_name" }, string.Format("select count(cg_type_id) as cnt from church_group_types_tb where lower(cg_type_name)=@cg_type_name"), new object[] { _grid.Rows[e.RowIndex].Cells[0].Text.ToLower() });
                            if (ret_val > 0)
                            {
                                MessageBox.Show("You Have Already Entered This Item", "Duplicate Item Entry");
                                _grid.Rows[e.RowIndex].Cells[0].Value = null;
                                return;
                            }
                        }
                        var _cg = new ic.church_group_typeC();
                        using (var xd = new xing())
                        {
                            _cg.cg_type_name = _grid.Rows[e.RowIndex].Cells[0].Text.ToProperCase();
                            _cg.cg_type_id   = xd.SingleInsertCommandTSPInt("church_group_types_tb", new string[] { "cg_type_name", "fs_time_stamp", "lch_id" },
                                                                            new object[] { _cg.cg_type_name, 0, datam.LCH_ID });
                            xd.CommitTransaction();
                        }
                        _grid.Rows[e.RowIndex].Tag = _cg;
                        datam.DATA_CG_TYPES.Add(_cg.cg_type_id, _cg);
                        this.Tag = 1;
                    }
                    else
                    {
                        var _cg = _grid.Rows[e.RowIndex].Tag as ic.church_group_typeC;
                        _cg.cg_type_name = _grid.Rows[e.RowIndex].Cells[0].Value.ToStringNullable();
                        using (var xd = new xing())
                        {
                            xd.SingleUpdateCommandALL("church_group_types_tb", new string[] { "cg_type_name", "cg_type_id" }, new object[] { _cg.cg_type_name, _cg.cg_type_id }, 1);
                            xd.CommitTransaction();
                        }
                        this.Tag = 1;
                        //update
                    }
                    Application.DoEvents();
                    using (var xd = new xing())
                    {
                        datam.fill_church_group_types(xd);
                        xd.CommitTransaction();
                    }
                }
                #endregion
            }
            if (((e.RowIndex + 1) == _grid.Rows.Count))
            {
                AddRowX(_grid);
            }
        }
Example #11
0
        private void fGrid_AfterCommitEdit(object sender, iGAfterCommitEditEventArgs e)
        {
            if (fGrid.Rows[e.RowIndex].Cells["desc"].DropDownControl != null && fGrid.Rows[e.RowIndex].Cells["desc"].AuxValue == null)
            {
                fGrid.Rows[e.RowIndex].Cells["desc"].Value = null;
                if (fGrid.Rows[e.RowIndex].Key == "owner_type")
                {
                    fGrid.Rows["owner"].Cells[1].Value    = null;
                    fGrid.Rows["owner"].Cells[1].AuxValue = null;
                    fGrid.Rows["owner"].Visible           = false;
                }
                return;
            }
            if (fGrid.Rows[e.RowIndex].Cells["desc"].DropDownControl == null && fGrid.Rows[e.RowIndex].Cells["desc"].Value != null)
            {
                if (fGrid.Rows[e.RowIndex].Cells["desc"].ValueType == typeof(string))
                {
                    fGrid.Rows[e.RowIndex].Cells["desc"].Value = fGrid.Rows[e.RowIndex].Cells["desc"].Value.ToString().ToProperCase();
                }
                if (fGrid.Rows[e.RowIndex].Key == "owner_type")
                {
                    fGrid.Rows["owner"].Cells[1].Value    = null;
                    fGrid.Rows["owner"].Cells[1].AuxValue = null;
                    fGrid.Rows["owner"].Visible           = false;
                }
            }
            if (fGrid.Rows[e.RowIndex].Key == "owner_type")
            {
                var _val = (fGrid.Rows["owner_type"].Cells[1].AuxValue as fnn.iGComboItemEX).Tag.ToStringNullable();
                fGrid.Rows["owner"].Cells[1].AuxValue        = null;
                fGrid.Rows["owner"].Cells[1].Value           = null;
                fGrid.Rows["owner"].Cells[1].DropDownControl = null;
                fGrid.Rows["owner"].Visible = true;
                fGrid.Rows["owner"].Tag     = null;

                switch (m_OWNER_Types[_val])
                {
                case em.AccountOwnerTypeS.CUC:
                case em.AccountOwnerTypeS.DISTRICT:
                case em.AccountOwnerTypeS.CHURCH:
                {
                    fGrid.Rows["owner"].Visible = false;
                    break;
                }

                case em.AccountOwnerTypeS.DEPARTMENT:
                {
                    fGrid.Rows["owner"].Visible = true;
                    fGrid.Rows["owner"].Cells[1].DropDownControl = m_Deparments;
                    fGrid.Rows["owner"].Tag = em.AccountOwnerTypeS.DEPARTMENT;
                    break;
                }

                case em.AccountOwnerTypeS.CHURCH_GROUP:
                {
                    fGrid.Rows["owner"].Visible = true;
                    fGrid.Rows["owner"].Cells[1].DropDownControl = m_church_groups;
                    fGrid.Rows["owner"].Tag = em.AccountOwnerTypeS.CHURCH_GROUP;

                    break;
                }

                case em.AccountOwnerTypeS.CHURCH_MEMBER:
                {
                    fGrid.Rows["owner"].Visible = true;
                    fGrid.Rows["owner"].Cells[1].DropDownControl = m_members;
                    fGrid.Rows["owner"].Tag = em.AccountOwnerTypeS.CHURCH_MEMBER;

                    break;
                }

                case em.AccountOwnerTypeS.CHURCH_GROUP_SHARED:
                {
                    fGrid.Rows["owner"].Visible = true;
                    fGrid.Rows["owner"].Cells[1].DropDownControl = m_CG_Shared;
                    //
                    break;
                }

                case em.AccountOwnerTypeS.OTHER:
                {
                    break;
                }
                }
            }
            //
            if (e.RowIndex != fGrid.Rows.Count - 1)
            {
                if (fGrid.Rows[e.RowIndex].Cells["desc"].Value == null)
                {
                    return;
                }
                for (int k = e.RowIndex + 1; k < fGrid.Rows.Count; k++)
                {
                    if (fGrid.Rows[k].Type == iGRowType.AutoGroupRow)
                    {
                        fGrid.Rows[k].Expanded = true;
                        continue;
                    }
                    if (!fGrid.Rows[k].Visible)
                    {
                        continue;
                    }
                    if (fGrid.Rows[k].Cells[1].Enabled == iGBool.False)
                    {
                        continue;
                    }
                    if (string.IsNullOrEmpty(fGrid.Rows[k].Key))
                    {
                        continue;
                    }
                    if ((e.RowIndex + 3) < fGrid.Rows.Count)
                    {
                        fGrid.Rows[(e.RowIndex + 3)].EnsureVisible();
                    }
                    fGrid.SetCurCell(k, e.ColIndex);
                    break;
                }
            }
        }
        private void fGrid2_AfterCommitEdit_1(object sender, iGAfterCommitEditEventArgs e)
        {
            if (string.IsNullOrEmpty(fGrid2.Rows[e.RowIndex].Key))
            {
                #region new member
                if (e.ColIndex == 1)
                {
                    if (fGrid2.Rows[e.RowIndex].Cells[1].AuxValue != null)
                    {
                        var _mem = (fGrid2.Rows[e.RowIndex].Cells[1].AuxValue as fnn.iGComboItemEX).Tag as ic.memberC;
                        _mem.ChurchGroupCollection.Add(m_cgroup);
                        fGrid2.Rows[e.RowIndex].Tag = _mem.mem_id.ToStringNullable();
                        fGrid2.Rows[e.RowIndex].Key = _mem.mem_id.ToStringNullable();
                        dbh.SingleInsertCommandTSP("church_group_members_tb", new string[]
                        {
                            "mem_id",
                            "cg_id",
                            "cg_type_id",
                            "mem_status",
                            "start_date",
                            "end_date",
                            "exp_type",
                            "lch_id",
                            "lch_type_id",
                            "fs_time_stamp"
                        },
                                                   new object[]
                        {
                            _mem.mem_id,
                            m_cgroup.cg_id,
                            m_cgroup.cg_type_id,
                            1,
                            datam.CURR_DATE.Date,
                            null, 33,
                            datam.LCH_ID,
                            datam.LCH_TYPE_ID, 0//time_stamp
                        });
                        fGrid2.Rows[e.RowIndex].ReadOnly = iGBool.True;
                        fGrid2.Rows[e.RowIndex].Cells[1].DropDownControl = null;
                        fGrid2.Rows[e.RowIndex].Cells["_pic"].TypeFlags  = iGCellTypeFlags.HasEllipsisButton;
                        fGrid2.Rows[e.RowIndex].Cells["_pic"].ReadOnly   = iGBool.False;
                        fGrid2.Rows[e.RowIndex].Tag = _mem.mem_id;
                        fGrid2.Rows[e.RowIndex].Cells["desig"].DropDownControl = m_LDATA[m_cgroup.cg_id];
                        fGrid2.Rows[e.RowIndex].Cells["desig"].ReadOnly        = iGBool.False;
                        fGrid2.Rows[e.RowIndex].Cells["desig"].TypeFlags       = iGCellTypeFlags.HideComboButton;
                        count_Rows();
                        fGrid.Rows[m_cgroup.cg_id.ToString()].Cells[1].Value = m_cgroup.MemberCount;
                        buttonX1.PerformClick();
                    }
                    else
                    {
                        fGrid2.Rows[e.RowIndex].Cells[1].AuxValue = null;
                        fGrid2.Rows[e.RowIndex].Cells[1].Value    = null;
                    }
                }

                #endregion
                return;
            }
            if (e.ColIndex == 3)
            {
                if (fGrid2.Rows[e.RowIndex].Cells[3].AuxValue != null)
                {
                    var _role = (fGrid2.Rows[e.RowIndex].Cells[3].AuxValue as fnn.iGComboItemEX).Tag as ic.RoleC;
                    var _mem  = datam.DATA_MEMBER[fGrid2.Rows[e.RowIndex].Key.ToInt32()];
                    if (_role != null & _mem != null)
                    {
                        using (var xd = new xing())
                        {
                            #region previous role
                            if (m_prev_role != null)
                            {
                                //delete previous role

                                if (_mem != null)
                                {
                                    var mem_role = (from c in _mem.RolesCollection
                                                    where c.Is_valid & c.role_id == m_prev_role.role_id
                                                    select c).FirstOrDefault();
                                    if (mem_role != null)
                                    {
                                        mem_role.Is_valid = false;

                                        if (sdata.CURR_DATE.Subtract(mem_role.start_date).Days > 30)
                                        {
                                            xd.SingleUpdateCommandETS("roles_mem_tb", new string[]
                                            {
                                                "is_valid",
                                                "end_date",
                                                "end_fs_id",
                                                "un_id",
                                            }, new object[]
                                            {
                                                0,
                                                sdata.CURR_DATE,
                                                sdata.CURR_FS.fs_id,
                                                mem_role.un_id
                                            }, 1);
                                        }
                                        else
                                        {
                                            xd.SingleDeleteCommandExp("roles_mem_tb", new string[] { "un_id", "lch_id" }, new int[] { mem_role.un_id, sdata.ChurchID });
                                            _mem.RolesCollection.Remove(mem_role);
                                        }
                                    }
                                }
                                m_prev_role = null;
                            }
                            #endregion
                            //
                            ic.MemRoleC _mem_role = new ic.MemRoleC();
                            _mem_role.start_date  = sdata.CURR_DATE;
                            _mem_role.start_fs_id = sdata.CURR_FS.fs_id;
                            _mem_role.objRole     = _role;
                            _mem_role.Is_valid    = true;
                            _mem_role.role_id     = _role.role_id;
                            _mem_role.mem_id      = _mem.mem_id;
                            _mem_role.un_id       = xd.SingleInsertCommandInt("roles_mem_tb", new string[]
                            {
                                "mem_id",
                                "role_id",
                                "start_date",
                                "end_date",
                                "start_fs_id",
                                "end_fs_id",
                                "is_valid",
                                "exp_type",
                                "lch_id",
                            }, new object[]
                            {
                                _mem_role.mem_id,
                                _mem_role.role_id,
                                _mem_role.start_date,
                                null,       //end date
                                _mem_role.start_fs_id,
                                _mem_role.end_fs_id,
                                1,
                                33, sdata.ChurchID
                            });
                            xd.CommitTransaction();
                            _mem.RolesCollection.Add(_mem_role);
                            _mem_role = null;
                        }
                    }
                    return;
                }
                if (fGrid2.Rows[e.RowIndex].Cells[3].AuxValue == null)
                {
                    using (var xd = new xing())
                    {
                        var _mem = datam.DATA_MEMBER[fGrid2.Rows[e.RowIndex].Key.ToInt32()];
                        #region previous role
                        if (m_prev_role != null & _mem != null)
                        {
                            var mem_role = (from c in _mem.RolesCollection
                                            where c.Is_valid & c.role_id == m_prev_role.role_id
                                            select c).FirstOrDefault();
                            if (mem_role != null)
                            {
                                mem_role.Is_valid = false;

                                if (sdata.CURR_DATE.Subtract(mem_role.start_date).Days > 30)
                                {
                                    xd.SingleUpdateCommandETS("roles_mem_tb", new string[]
                                    {
                                        "is_valid",
                                        "end_date",
                                        "end_fs_id",
                                        "un_id",
                                    }, new object[]
                                    {
                                        0,
                                        sdata.CURR_DATE,
                                        sdata.CURR_FS.fs_id,
                                        mem_role.un_id
                                    }, 1);
                                }
                                else
                                {
                                    xd.SingleDeleteCommandExp("roles_mem_tb", new string[] { "un_id", "lch_id" }, new int[] { mem_role.un_id, sdata.ChurchID });
                                    _mem.RolesCollection.Remove(mem_role);
                                }
                                xd.CommitTransaction();
                            }

                            m_prev_role = null;
                        }
                        #endregion
                    }
                    fGrid2.Rows[e.RowIndex].Cells[3].Value = null;
                }
            }
        }
Example #13
0
        void fGrid_AfterCommitEdit(object sender, iGAfterCommitEditEventArgs e)
        {
            var    _cell     = fGrid.Cells[e.RowIndex, e.ColIndex];
            var    _exp      = fGrid.Rows[e.RowIndex].Tag as ic.expense_accountC;
            string _edit_col = null;
            object _edit_val = null;

            switch (_cell.Col.Key)
            {
            case "exp_name":
            {
                if (!string.IsNullOrEmpty(_cell.Text))
                {
                    using (var xd = new xing())
                    {
                        var ret_val = xd.ExecuteScalerInt(new string[] { "exp_acc_name", "exp_acc_id" }, string.Format("select count(exp_acc_id) as cnt from acc_expense_accounts_tb where lower(exp_acc_name)=@exp_acc_name and exp_acc_id<>@exp_acc_id"), new object[] { _cell.Text.Trim().ToLower(), _exp.exp_acc_id });
                        if (ret_val > 0)
                        {
                            MessageBox.Show("You Have Already Entered This Expense Account Name", "Duplicate Item Entry");
                            return;
                        }
                        xd.CommitTransaction();
                    }
                }
                _exp.exp_acc_name = string.IsNullOrEmpty(_cell.Text) ? _exp.exp_acc_name : _cell.Text.ToProperCase();
                _edit_col         = "exp_acc_name";
                _edit_val         = _exp.exp_acc_name;
                break;
            }

            case "dept":
            {
                if (_cell.AuxValue != null)
                {
                    var _dept = ((_cell.AuxValue as fnn.iGComboItemEX).Tag as ic.departmentC);
                    _exp.dept_id             = _dept.dept_id;
                    _exp.dept_parent_id      = _dept.parent_id;
                    _exp.dept_sys_account_id = _dept.expense_sys_account_id;
                }
                else
                {
                    _cell.Value = _exp.objDepartment.dept_name;
                    return;
                }
                _edit_col = "dept_id";
                _edit_val = _exp.dept_id;
                break;
            }

            case "category":
            {
                _exp.exp_cat_id = (_cell.AuxValue == null) ? 0 : ((_cell.AuxValue as fnn.iGComboItemEX).Tag as ic.expense_catC).exp_cat_id;
                if (_cell.AuxValue == null)
                {
                    _cell.Value = null;
                }
                if (_exp.exp_cat_id == 0)
                {
                    _exp.objCategory = null;
                }
                else
                {
                    _exp.objCategory = datam.DATA_EXPENSE_CATEGORY[_exp.exp_cat_id];
                }
                _edit_col = "exp_cat_id";
                _edit_val = _exp.exp_cat_id;
                sdata.ClearFormCache(em.fm.lcb_periodic_statement.ToInt16());
                break;
            }
            }
            using (var xd = new xing())
            {
                if (_edit_col.ToLower() != "dept_id")
                {
                    if (_edit_col == "exp_name")
                    {
                        xd.SingleUpdateCommandALL("acc_expense_accounts_tb", new string[]
                        {
                            _edit_col, "exp_acc_id"
                        },
                                                  new object[]
                        {
                            _edit_val,
                            _exp.exp_acc_id
                        }, 1);
                        xd.SingleUpdateCommandALL("accounts_tb", new string[] { "account_name", "account_id" }, new object[] { _edit_val.ToProperCase(), _exp.sys_account_id }, 1);
                    }
                    else
                    {
                        xd.SingleUpdateCommandALL("acc_expense_accounts_tb", new string[]
                        {
                            _edit_col, "exp_acc_id"
                        },
                                                  new object[]
                        {
                            _edit_val,
                            _exp.exp_acc_id
                        }, 1);
                    }
                }
                else
                {
                    xd.SingleUpdateCommandALL("acc_expense_accounts_tb", new string[]
                    {
                        _edit_col, "dept_parent_id", "dept_sys_account_id", "exp_acc_id"
                    },
                                              new object[]
                    {
                        _edit_val,
                        _exp.dept_parent_id,
                        _exp.dept_sys_account_id,
                        _exp.exp_acc_id
                    }, 1);
                    //
                    xd.SingleUpdateCommandALL("accounts_tb", new string[] { "p_account_id", "account_id" }, new object[] { _exp.dept_sys_account_id, _exp.sys_account_id }, 1);
                }
                xd.CommitTransaction();
            }

            EditRow(_exp);
            fGrid.Cols[e.ColIndex].AutoWidth();
        }
        private void fGrid_AfterCommitEdit(object sender, iGAfterCommitEditEventArgs e)
        {
            if (fGrid.Rows[e.RowIndex].Cells["desc"].DropDownControl != null && fGrid.Rows[e.RowIndex].Cells["desc"].AuxValue == null)
            {
                fGrid.Rows[e.RowIndex].Cells["desc"].Value = null;
                for (int y = (e.RowIndex + 1); y < fGrid.Rows.Count; y++)
                {
                    fGrid.Rows[y].Cells["desc"].Value    = null;
                    fGrid.Rows[y].Cells["desc"].AuxValue = null;
                    if (fGrid.Rows[y].Cells["desc"].Selectable == iGBool.True)
                    {
                        fGrid.Rows[y].Cells["desc"].Enabled = iGBool.False;
                    }
                }
                if (fGrid.Rows[e.RowIndex].Key == "account_from")
                {
                    FilterDestinationAccounts(null);
                }
                return;
            }
            switch (fGrid.Rows[e.RowIndex].Key)
            {
            case "transfer_date":
            {
                m_SelectedDate = System.Convert.ToDateTime(fGrid.Rows["transfer_date"].Cells[1].AuxValue);
                for (int y = (e.RowIndex + 1); y < fGrid.Rows.Count; y++)
                {
                    fGrid.Rows[y].Cells["desc"].Value    = null;
                    fGrid.Rows[y].Cells["desc"].AuxValue = null;
                    if (fGrid.Rows[y].Cells["desc"].Selectable == iGBool.True)
                    {
                        fGrid.Rows[y].Cells["desc"].Enabled = iGBool.False;
                    }
                }
                FillAccountsByDate(m_SelectedDate);
                fGrid.Rows["account_from"].Cells[1].Enabled = iGBool.True;
                //
                break;
            }

            case "account_from":
            {
                ic.accountC _from = (fGrid.Rows["account_from"].Cells[1].AuxValue as fnn.iGComboItemEX).Tag as ic.accountC;

                for (int y = (e.RowIndex + 1); y < fGrid.Rows.Count; y++)
                {
                    fGrid.Rows[y].Cells["desc"].Value    = null;
                    fGrid.Rows[y].Cells["desc"].AuxValue = null;
                    if (fGrid.Rows[y].Cells["desc"].Selectable == iGBool.True)
                    {
                        fGrid.Rows[y].Cells["desc"].Enabled = iGBool.False;
                    }
                }
                using (var xd = new xing())
                {
                    fGrid.Rows["account_balance"].Cells[1].Value = accn.GetFs_AccountBalance(xd, fn.GetFSID(m_SelectedDate.Value), _from.account_id);
                }
                fGrid.Rows["account_to"].Cells[1].Enabled = iGBool.True;
                FilterDestinationAccounts(_from);
                break;
            }

            case "account_to":
            {
                for (int y = (e.RowIndex + 1); y < fGrid.Rows.Count; y++)
                {
                    fGrid.Rows[y].Cells["desc"].Value    = null;
                    fGrid.Rows[y].Cells["desc"].AuxValue = null;
                    if (fGrid.Rows[y].Cells["desc"].Selectable == iGBool.True)
                    {
                        fGrid.Rows[y].Cells["desc"].Enabled = iGBool.False;
                    }
                }
                fGrid.Rows["transfer_amount"].Cells[1].Enabled = iGBool.True;
                fGrid.Rows["reason"].Cells[1].Enabled          = iGBool.True;
                break;
            }

            case "transfer_amount":
            {
                if ((fGrid.Rows[e.RowIndex].Cells[1].Value.ToInt32() <= 0) | fGrid.Rows[e.RowIndex].Cells[1].Value.ToInt32() > fGrid.Rows["account_balance"].Cells[1].Value.ToInt32())
                {
                    MessageBox.Show("You Have Entered An Invalid Amount", "Invalid Amount", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    fGrid.Focus();
                    fGrid.Rows[e.RowIndex].Cells[1].Value = null;
                    fGrid.SetCurCell(e.RowIndex, 1);
                    return;
                }
                break;
            }
            }

            if (e.RowIndex != fGrid.Rows.Count - 1)
            {
                if (fGrid.Rows[e.RowIndex].Cells["desc"].Value == null)
                {
                    return;
                }
                for (int k = e.RowIndex + 1; k < fGrid.Rows.Count; k++)
                {
                    if (fGrid.Rows[k].Type == iGRowType.AutoGroupRow)
                    {
                        fGrid.Rows[k].Expanded = true;
                        continue;
                    }
                    if (!fGrid.Rows[k].Visible)
                    {
                        continue;
                    }
                    if (fGrid.Rows[k].Cells[1].Enabled == iGBool.False)
                    {
                        continue;
                    }
                    if (fGrid.Rows[k].Cells[1].ReadOnly == iGBool.True)
                    {
                        continue;
                    }
                    if (string.IsNullOrEmpty(fGrid.Rows[k].Key))
                    {
                        continue;
                    }
                    if ((e.RowIndex + 3) < fGrid.Rows.Count)
                    {
                        fGrid.Rows[(e.RowIndex + 3)].EnsureVisible();
                    }
                    fGrid.SetCurCell(k, e.ColIndex);
                    break;
                }
            }
        }
Example #15
0
        private void fGrid_AfterCommitEdit(object sender, iGAfterCommitEditEventArgs e)
        {
            iGRow _row = fGrid.Rows[e.RowIndex];

            if (_row.Cells[1].DropDownControl != null && _row.Cells[1].AuxValue == null)
            {
                _row.Cells[1].Value = null;

                if (_row.Key == "account")
                {
                    fGrid.Rows["end_date"].Cells[1].Value   = null;
                    fGrid.Rows["start_date"].Cells[1].Value = null;
                    //
                    fGrid.Rows["end_date"].Cells[1].Enabled   = iGBool.False;
                    fGrid.Rows["start_date"].Cells[1].Enabled = iGBool.False;
                    //
                }
                return;
            }
            if (_row.Key == "start_date")
            {
                object _date_obj = Convert.ToDateTime(fGrid.Rows["start_date"].Cells["desc"].AuxValue);
                if (_date_obj == null)
                {
                    _row.Cells["desc"].Value = sdata.CURR_DATE;
                    return;
                }
                fGrid.Rows["end_date"].Cells[1].Value    = null;
                fGrid.Rows["end_date"].Cells[1].AuxValue = null;
                var _date      = Convert.ToDateTime(_date_obj);
                var _drop_down = fGrid.Rows["end_date"].Cells[1].DropDownControl as fnn.DropDownCalenderX;
                _drop_down.start_date    = _date.AddDays(1);
                _drop_down.selected_date = _drop_down.start_date;
                _drop_down.end_date      = _date.AddDays(366);
                //
                fGrid.Rows["end_date"].Cells[1].Enabled = iGBool.True;
            }
            //
            if (_row.Key == "account")
            {
                ic.accountC _acc = (fGrid.Rows["account"].Cells[1].AuxValue as fnn.iGComboItemEX).Tag as ic.accountC;
                if (_acc != null)
                {
                    var _saccount = (from k in datam.DATA_CURRENT_PLEDGE_SETTINGS.Values
                                     where k.account_id == _acc.account_id & k.status == em.pledge_setting_statusS.valid
                                     orderby k.pls_id descending
                                     select k).FirstOrDefault();
                    var _drop_down = fGrid.Rows["start_date"].Cells[1].DropDownControl  as fnn.DropDownCalenderX;
                    fGrid.Rows["start_date"].Cells[1].Value    = null;
                    fGrid.Rows["start_date"].Cells[1].AuxValue = null;
                    if (_saccount != null)
                    {
                        _drop_down.start_date    = _saccount.end_date.Value.AddDays(1);
                        _drop_down.selected_date = _drop_down.start_date;
                        _drop_down.end_date      = _drop_down.start_date.Value.AddDays(365);
                    }
                    else
                    {
                        _drop_down.start_date    = sdata.CURR_DATE.AddDays(-365);
                        _drop_down.selected_date = sdata.CURR_DATE;
                        _drop_down.end_date      = sdata.CURR_DATE.AddDays(365);
                    }
                    fGrid.Rows["start_date"].Cells[1].Enabled = iGBool.True;
                    fGrid.Rows["end_date"].Cells[1].Value     = null;
                    fGrid.Rows["end_date"].Cells[1].AuxValue  = null;
                    //
                    fGrid.Rows["end_date"].Cells[1].Enabled = iGBool.False;
                }
            }
            if (_row.Key == "end_date")
            {
                if (_row.Cells[1].Value != null)
                {
                    buttonX1.PerformClick();
                }
            }
            if (e.RowIndex != fGrid.Rows.Count - 1)
            {
                if (fGrid.Rows[e.RowIndex].Cells["desc"].Value == null)
                {
                    return;
                }
                for (int k = e.RowIndex + 1; k < fGrid.Rows.Count; k++)
                {
                    if (fGrid.Rows[k].Type == iGRowType.AutoGroupRow)
                    {
                        fGrid.Rows[k].Expanded = true;
                        continue;
                    }
                    if (!fGrid.Rows[k].Visible)
                    {
                        continue;
                    }
                    if (fGrid.Rows[k].Cells[1].Enabled == iGBool.False)
                    {
                        continue;
                    }
                    if (string.IsNullOrEmpty(fGrid.Rows[k].Key))
                    {
                        continue;
                    }
                    if ((e.RowIndex + 3) < fGrid.Rows.Count)
                    {
                        fGrid.Rows[(e.RowIndex + 3)].EnsureVisible();
                    }
                    fGrid.SetCurCell(k, e.ColIndex);
                    break;
                }
            }
        }