Esempio n. 1
0
        public InvestorEntity GetOne(int userId)
        {
            try
            {
                using (Database db = new Database(GlobalObjects.CONNECTION_STRING))
                {
                    db.Open();
                    string    sql;
                    int       ret    = 0;
                    DataTable oTable = new DataTable();
                    sql = "GetInvestment";
                    db.ExecuteCommandReader(sql,
                                            new string[] { "@id" },
                                            new DbType[] { DbType.Int32 },
                                            new object[] { userId },
                                            out ret, ref oTable, CommandTypeEnum.StoredProcedure);

                    InvestorEntity user = new InvestorEntity();
                    if (oTable.Rows.Count > 0)
                    {
                        DataRow oRow = oTable.Rows[0];
                        user = SetData(oRow);
                    }

                    return(user);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 2
0
        public void Save(ActionType type, InvestorEntity ent)
        {
            try
            {
                using (Database db = new Database(GlobalObjects.CONNECTION_STRING))
                {
                    db.Open();
                    int      ret = 0;
                    int      typ = (int)type;
                    string   sql = "SaveInvestment";
                    string[] asParams;
                    DbType[] atParamTypes;
                    object[] aoValues;


                    asParams = new string[] { "@actiontype",
                                              "@id",
                                              "@userid",
                                              "@amount",
                                              "@notes",
                                              "@createdby",
                                              "@createddate",
                                              "@updatedby",
                                              "@updateddate" };

                    atParamTypes = new DbType[] {
                        DbType.Int16,
                        DbType.Int32,
                        DbType.Int32,
                        DbType.Decimal,
                        DbType.String,
                        DbType.String,
                        DbType.DateTime,
                        DbType.String,
                        DbType.DateTime
                    };

                    aoValues = new object[] {
                        typ,
                        ent.ID,
                        ent.UserId,
                        ent.Amount,
                        ent.Notes,
                        appUsr.UserName,
                        DateTime.Now,
                        appUsr.UserName,
                        DateTime.Now
                    };



                    db.ExecuteCommandNonQuery(sql, asParams, atParamTypes, aoValues, out ret, CommandTypeEnum.StoredProcedure);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 3
0
        private void Update()
        {
            newEntity        = new InvestorEntity();
            newEntity.ID     = id;
            newEntity.Notes  = txtNotes.Text;
            newEntity.Amount = Convert.ToDecimal(txtAmount.Text);

            newService.Save(ActionType.Update, newEntity);

            Response.Redirect("ManageInvestors.aspx");
        }
Esempio n. 4
0
        private void Create()
        {
            newEntity        = new InvestorEntity();
            newEntity.UserId = Convert.ToInt32(ddlUser.SelectedValue);
            newEntity.Notes  = txtNotes.Text;
            newEntity.Amount = Convert.ToDecimal(txtAmount.Text);

            newService.Save(ActionType.Create, newEntity);

            Response.Redirect("ManageInvestors.aspx");
        }
Esempio n. 5
0
        private void PopulateFields(int id)
        {
            newEntity = new InvestorEntity();
            newEntity = newService.GetOne(id);

            UserEntity  usrEnt = new UserEntity();
            UserService usrSrv = new UserService();

            usrEnt = usrSrv.GetOne(newEntity.UserId);

            txtAmount.Text        = newEntity.Amount.ToString();
            txtNotes.Text         = newEntity.Notes;
            ddlUser.SelectedValue = newEntity.UserId.ToString();
        }
        private InvestorEntity SetData(DataRow oRow)
        {
            try
            {
                InvestorEntity ent = new InvestorEntity();
                ent.ID     = Convert.ToInt32(oRow["id"]);
                ent.UserId = Convert.ToInt32(oRow["user_id"]);
                ent.Amount = Convert.ToDecimal(oRow["amount"]);
                ent.Notes  = oRow["notes"].ToString();
                ent.Status = Convert.ToInt32(oRow["status"]);

                return(ent);
            }
            catch (Exception ex) { throw ex; }
        }