示例#1
0
        public bool Update(string Name, string Description)
        {
            db.SetConnection();
            string sSQL    = "";
            bool   updated = false;

            if (Unique(Name, Description))
            {
                return(false);
            }

            DataTable dt = GetRows(Name);     // must be unknown or at least one with same name because unique did not fire

            if (dt != null)
            {
                DataRow[] dr = dt.Select("description = " + SQLSpecific.QVal(Description));
                if (dr.Length < 1)     // desc changed for an existing type
                {
                    sSQL = "UPDATE " + table + " SET "
                           + "[description] = " + SQLSpecific.QVal(Description)
                           + " WHERE " + SQLSpecific.QValCompare("name", Name, true);
                    updated = db.Execute(sSQL);
                }
            }
            else      // totally new type name
            {
                sSQL = "Insert into " + table + " ([name], [description]) "
                       + " Values (" + SQLSpecific.QVal(Name) + "," + SQLSpecific.QVal(Description) + ")";
                updated = db.Execute(sSQL);
            }
            return(updated);
        }
示例#2
0
        public bool Delete(string Id)
        {
            db.SetConnection();
            string s = "DELETE FROM " + table + " where " + SQLSpecific.QValCompare("name", Id, true);

            return(db.Execute(s));
        }
示例#3
0
        private DataTable BasicSelect(string Name, string Desc)
        {
            db.SetConnection();
            string sSQL = "SELECT name "
                          + " FROM " + table
                          + " Where " + SQLSpecific.QValCompare("name", Name, true) + " AND ";

            sSQL += SQLSpecific.QValCompare("description", Desc, true);
            DataTable dt = db.DT(sSQL);

            return(dt);
        }
示例#4
0
        public DataTable GetRows(string Name)
        {
            string sSQL = "SELECT * "
                          + " FROM " + table
                          + " Where " + SQLSpecific.QValCompare("name", Name, true);
            DataTable dt = db.DT(sSQL);

            if (dt.Rows.Count > 0)
            {
                return(dt);
            }
            else
            {
                return(null);
            }
        }
示例#5
0
        public long PrimaryKey(string Id)
        {
            if (String.IsNullOrEmpty(Id))
            {
                return(-1);
            }
            db.SetConnection();
            string s = "SELECT id FROM " + table + " where " + SQLSpecific.QValCompare("name", Id, true);
            string r = db.Scalar(s);
            long   l = -1;

            if (!Int64.TryParse(r, out l))
            {
                l = -1;
            }
            return(l);
        }