Example #1
0
        private void RefreshObject()
        {
            if (_ShareInvestment.SIID == 0)
            {
                _ShareInvestment            = new ShareInvestment();
                _ShareInvestment.CreatedBy  = Global.CurrentUser.UserID;
                _ShareInvestment.CreateDate = DateTime.Now;
            }
            else
            {
                _ShareInvestment.ModifiedDate = (DateTime)DateTime.Today;
                _ShareInvestment.ModifiedBy   = (int)Global.CurrentUser.UserID;
            }

            _ShareInvestment.Purpose   = txtPerName.Text;
            _ShareInvestment.Amount    = numInvAmt.Value;
            _ShareInvestment.EntryDate = dtpDate.Value;

            //if (_HeadType == EnumInvestmentType.FixedAsset || _HeadType == EnumInvestmentType.CurrentAsset)
            //{
            //    _ShareInvestment.SIHID = (int)ctlFAssets.SelectedID;
            //    _ShareInvestment.TransactionType = (int)EnumTransactionType.Receive;
            //}
            //else if ((_HeadType == EnumInvestmentType.Loan || _HeadType == EnumInvestmentType.FromOwner || _HeadType == EnumInvestmentType.Others) && _TranType == EnumTransactionType.Receive)
            //{
            //    _ShareInvestment.SIHID = (int)ctlCAsset.SelectedID;
            //    _ShareInvestment.TransactionType = (int)EnumTransactionType.Receive;
            //}
            //else if ((_HeadType == EnumInvestmentType.Loan || _HeadType == EnumInvestmentType.FromOwner || _HeadType == EnumInvestmentType.Others) && _TranType == EnumTransactionType.Pay)
            //{
            //    _ShareInvestment.SIHID = (int)ctlLiability.SelectedID;
            //    _ShareInvestment.TransactionType = (int)EnumTransactionType.Pay;
            //}

            if (_ParentID == EnumParentType.FixedAsset)
            {
                _ShareInvestment.SIHID           = (int)ctlFAssets.SelectedID;
                _ShareInvestment.TransactionType = (int)EnumTransactionType.Receive;
            }
            else if (_ParentID == EnumParentType.CurrentAsset)
            {
                _ShareInvestment.SIHID           = (int)ctlCAsset.SelectedID;
                _ShareInvestment.TransactionType = (int)EnumTransactionType.Receive;
            }
            else if (_ParentID == EnumParentType.Liability)
            {
                if (_TranType == EnumTransactionType.Pay)
                {
                    _ShareInvestment.SIHID           = (int)ctlLiability.SelectedID;
                    _ShareInvestment.TransactionType = (int)EnumTransactionType.Pay;
                }
                else
                {
                    _ShareInvestment.SIHID           = (int)ctlLiability.SelectedID;
                    _ShareInvestment.TransactionType = (int)EnumTransactionType.Receive;
                }
            }

            //_ShareInvestment.TransactionType = (int)cboTranType.SelectedValue;
        }
Example #2
0
        private void btnEditCAsset_Click(object sender, EventArgs e)
        {
            try
            {
                DEWSRMEntities db      = new DEWSRMEntities();
                int[]          selRows = ((GridView)grdCAssets.MainView).GetSelectedRows();
                DataRowView    oID     = (DataRowView)(((GridView)grdCAssets.MainView).GetRow(selRows[0]));

                int             nID = Convert.ToInt32(oID["ID"]);
                ShareInvestment oShareInvestment = db.ShareInvestments.FirstOrDefault(p => p.SIID == nID);

                if (oShareInvestment == null)
                {
                    MessageBox.Show("select an item to edit", "Item not yet selected", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                fInvestment frm = new fInvestment();
                frm.ItemChanged = RefreshCAssetList;
                frm.ShowDlg(oShareInvestment, EnumParentType.CurrentAsset, EnumTransactionType.Receive);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Example #3
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Do you want to save the information?", "Save Information", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                try
                {
                    if (!IsValid())
                    {
                        return;
                    }

                    using (DEWSRMEntities db = new DEWSRMEntities())
                    {
                        if (_ShareInvestment.SIID <= 0)
                        {
                            RefreshObject();
                            _ShareInvestment.SIID = db.ShareInvestments.Count() > 0 ? db.ShareInvestments.Max(obj => obj.SIID) + 1 : 1;
                            db.ShareInvestments.Add(_ShareInvestment);
                        }
                        else
                        {
                            _ShareInvestment = db.ShareInvestments.FirstOrDefault(obj => obj.SIID == _ShareInvestment.SIID);
                            RefreshObject();
                        }

                        db.SaveChanges();
                        MessageBox.Show("Data saved successfully.", "Save Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        if (MessageBox.Show("Do you want to create another Investment?", "Investment", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                        {
                            if (ItemChanged != null)
                            {
                                ItemChanged();
                            }
                            this.Close();
                        }
                        else
                        {
                            if (ItemChanged != null)
                            {
                                ItemChanged();
                            }
                            _ShareInvestment = new ShareInvestment();
                            RefreshValue();
                        }
                    }
                }
                catch (Exception ex)
                {
                    if (ex.InnerException == null)
                    {
                        MessageBox.Show(ex.Message, "Failed to save", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    else
                    {
                        MessageBox.Show(ex.InnerException.Message, "Failed to save", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }
Example #4
0
        public void ShowDlg(ShareInvestment oShareInvestment, EnumParentType nParaentID, EnumTransactionType nTranType)
        {
            _TranType        = nTranType;
            _ParentID        = nParaentID;
            _ShareInvestment = oShareInvestment;

            //PopulateTranTypeCbo();
            RefreshValue();
            this.ShowDialog();
        }