private void deleteMemberPlegdeToolStripMenuItem_Click(object sender, EventArgs e) { using (var _fm = new SdaHelperManager.ConfirmWPwd()) { _fm.ShowDialog(); if (_fm.DialogResult != DialogResult.OK) { return; } } var _obj = fGrid.SelectedRows[0].Tag as ic.pledgeC; _obj.pledge_status = em.pledge_statusS.deleted; string _str = "Are You Sure You Want To Delete This Member Pledge ??"; using (var xd = new xing()) { var _d_obj = xd.ExecuteScalarObject("select pl_status from pledge_master_tb where pl_id=" + _obj.pl_id); if (_d_obj != null) { if (_d_obj.ToInt16() == em.pledge_statusS.deleted.ToInt16()) { MessageBox.Show("You Have Already Deleted This Member Pledge", "Already Deleted"); return; } } if (!dbm.WarningMessage(_str, "Delete Warning")) { return; } // xd.SingleUpdateCommandALL("pledge_master_tb", new string[] { "pl_status", "pl_id" }, new object[] { em.pledge_statusS.deleted.ToInt16(), _obj.pl_id }, 1); // xd.SingleUpdateCommandALL("pledge_payment_mvt_tb", new string[] { "status", "pl_id" }, new object[] { 0, _obj.pl_id }, 1); // xd.SingleUpdateCommandALL("pledge_addition_tb", new string[] { "pl_status", "pl_id" }, new object[] { em.pledge_statusS.deleted.ToInt16(), _obj.pl_id }, 1); // accn.PledgeSummary(xd, (_obj.amount_pledged * -1), (_obj.amount_paid * -1), _obj.pls_id); // xd.CommitTransaction(); } fGrid.Rows.RemoveAt(fGrid.Rows[_obj.pl_id.ToString()].Index); if (this.Tag != null) { this.Tag = null; } }
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; } } }