Esempio n. 1
0
        public void Create(SmsinfosprModel theSpr)
        {
            DBConnection Connection = new DBConnection();

            try
            {
                Connection.Open();

                UserModel theUser = new UserModel();
                theUser.FindByID(UserModel.CurrentUserId);

                string strSQL = string.Format("INSERT INTO SMSINFOSPR(ID, NAME,  PARENT_ID, BRANCHE_ID) VALUES(s_smsinfospr.nextval, '{0}', '{1}','{2}')",
                                              theSpr.Name,
                                              theSpr.ParentID,
                                              theUser.BrancheID);

                Connection.ExecQueryInsert(strSQL);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
                Connection.Close();
            }
        }
Esempio n. 2
0
        public SmsinfosprModel FindOne(int ID)
        {
            SmsinfosprRepository _repo  = new SmsinfosprRepository();
            SmsinfosprModel      theSpr = _repo.FindAll("ID=" + ID.ToString())[0];

            this.ID       = theSpr.ID;
            this.Name     = theSpr.Name;
            this.ParentID = theSpr.ParentID;

            return(this);
        }
Esempio n. 3
0
        public List <SmsinfosprModel> FindAll(string condition = "", string order = "")
        {
            List <SmsinfosprModel> SprList = new List <SmsinfosprModel>();
            DBConnection           conn    = null;

            try
            {
                conn = new DBConnection();
                conn.Open();

                UserModel theUser = new UserModel();
                theUser.FindByID(UserModel.CurrentUserId);

                string strSQL = "SELECT * FROM SMSINFOSPR where BRANCHE_ID = " + theUser.BrancheID;

                if (condition.Length > 0)
                {
                    strSQL = strSQL + " and " + condition;
                }
                if (order.Length > 0)
                {
                    strSQL = strSQL + " order by " + order;
                }

                DataTable Table = new DataTable();

                conn.ExecQuerySelect(strSQL, ref Table);

                for (int i = 0; i < Table.Rows.Count; i++)
                {
                    SmsinfosprModel theSmsinfosprModel = new SmsinfosprModel();
                    theSmsinfosprModel.ID       = Convert.ToInt32(Table.Rows[i]["ID"].ToString());
                    theSmsinfosprModel.Name     = Table.Rows[i]["Name"].ToString();
                    theSmsinfosprModel.ParentID = Convert.ToInt32(Table.Rows[i]["PARENT_ID"].ToString());

                    SprList.Insert(i, theSmsinfosprModel);
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message.ToString());
            }
            finally
            {
                conn.Connection.Dispose();
                conn.Connection.Close();
            }
            return(SprList);
        }
Esempio n. 4
0
        public void Delete()
        {
            SmsinfosprRepository _repo = new SmsinfosprRepository();

            List <SmsinfosprModel> listResult = new List <SmsinfosprModel>();

            listResult = FindAll("PARENT_ID=" + this.ID);

            if (listResult.Count > 0)
            {
                for (int i = 0; i < listResult.Count; i++)
                {
                    SmsinfosprModel item = listResult[i];
                    item.Delete();
                }
            }

            _repo.Delete(this);
        }
Esempio n. 5
0
        public void Delete(SmsinfosprModel theSpr)
        {
            DBConnection Connection = new DBConnection();

            try
            {
                Connection.Open();
                string strSQL = string.Format("DELETE FROM SMSINFOSPR WHERE ID = {0}",
                                              theSpr.ID);

                Connection.ExecQueryInsert(strSQL);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
                Connection.Close();
            }
        }
Esempio n. 6
0
        public void Update(SmsinfosprModel theSpr)
        {
            DBConnection Connection = new DBConnection();

            try
            {
                Connection.Open();
                string strSQL = string.Format("UPDATE SMSINFOSPR SET NAME='{0}', PARENT_ID='{1}' WHERE ID = {2}",
                                              theSpr.Name,
                                              theSpr.ParentID,
                                              theSpr.ID);

                Connection.ExecQueryInsert(strSQL);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
                Connection.Close();
            }
        }