Пример #1
0
        public bool Insert(menulevel1Data datmenulevel1)
        {
            int  iRel = -1;
            bool bRel = false;

            DataAccess.CommonDB objDB = new DataAccess.CommonDB();
            try
            {
                objDB.OpenConnection();
                string strSql = " insert into menulevel1 (menuname,nums)  values (@menuname,@nums) ";
                objDB.Command.CommandType = System.Data.CommandType.Text;
                objDB.Command.CommandText = strSql;
                objDB.Command.Parameters.AddWithValue("@menuname", datmenulevel1.menuname);
                objDB.Command.Parameters.AddWithValue("@nums", datmenulevel1.nums);
                iRel = objDB.Command.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                iRel = -1;
            }
            objDB.CloseConnection();
            objDB.Dispose();
            objDB = null;
            bRel  = (iRel.Equals(1) ? true : false);
            return(bRel);
        }
Пример #2
0
        public menulevel1Data[] Select(string Id)
        {
            int iRel = -1;

            DataAccess.CommonDB objDB         = new DataAccess.CommonDB();
            menulevel1Data[]    datmenulevel1 = new menulevel1Data[1];
            string sql = "select * from menulevel1 where Id= " + Id + " ";

            try
            {
                objDB.OpenConnection();
                DataSet ds = objDB.QueryData(sql, "departmentinfo");
                if (ds.Tables.Count > 0)
                {
                    long nRow = ds.Tables[0].Rows.Count;
                    if (nRow > 0)
                    {
                        datmenulevel1 = new menulevel1Data[nRow];
                        for (int i = 0; i < nRow; i++)
                        {
                            datmenulevel1[i]          = new menulevel1Data();
                            datmenulevel1[i].menuname = ds.Tables[0].Rows[i]["menuname"].ToString();
                            datmenulevel1[i].nums     = ds.Tables[0].Rows[i]["nums"].ToString();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                iRel = -1;
            }
            objDB.CloseConnection();
            objDB.Dispose();
            objDB = null;
            return(datmenulevel1);
        }