Esempio n. 1
0
        public int Add(OABooksInStorage model)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append(" ");
            builder.Append(" if not exists(select top 1 ISBN from OA_Books_InStorage where LibraryCode='" + model.LibraryCode + "' and ISBN='" + model.ISBN + "') ");
            builder.Append(" begin ");
            builder.Append(" insert into OA_Books_InStorage(");
            builder.Append(" ISBN,LibraryCode,ClassID,BookTitle,PublishingHouse,Author,Copy,UserCode,RecordDate");
            builder.Append(") ");
            builder.Append(" values (");
            builder.Append(" '" + model.ISBN + "', ");
            builder.Append(" '" + model.LibraryCode + "', ");
            builder.Append(" " + model.ClassID + ", ");
            builder.Append(" '" + model.BookTitle + "', ");
            builder.Append(" '" + model.PublishingHouse + "', ");
            builder.Append(" '" + model.Author + "', ");
            builder.Append(" " + model.Copy + ", ");
            builder.Append(" '" + model.UserCode + "',");
            builder.Append(" '" + model.RecordDate + "' ");
            builder.Append(" ) ");
            builder.Append(" if not exists(select top 1 ISBN from OA_Books_Storage where LibraryCode='" + model.LibraryCode + "' and ISBN='" + model.ISBN + "') ");
            builder.Append(" begin ");
            builder.Append(" insert into OA_Books_Storage(");
            builder.Append(" LibraryCode,ISBN,ClassID,BookTitle,PublishingHouse,Author,SumCopy,LeaveCopy");
            builder.Append(" ) ");
            builder.Append(" values (");
            builder.Append(" '" + model.LibraryCode + "',");
            builder.Append(" '" + model.ISBN + "',");
            builder.Append(" " + model.ClassID + ", ");
            builder.Append(" '" + model.BookTitle + "', ");
            builder.Append(" '" + model.PublishingHouse + "', ");
            builder.Append(" '" + model.Author + "', ");
            builder.Append(" " + model.Copy + ", ");
            builder.Append(" " + model.Copy + " ");
            builder.Append(" ) ");
            builder.Append(" end ");
            builder.Append(" else ");
            builder.Append(" begin ");
            builder.Append("update OA_Books_Storage set ");
            builder.Append("SumCopy=SumCopy+" + model.Copy + ", ");
            builder.Append("LeaveCopy=LeaveCopy+" + model.Copy + " ");
            builder.Append(" where LibraryCode='" + model.LibraryCode + "' and ISBN='" + model.ISBN + "'");
            builder.Append(" end ");
            builder.Append(" end ");
            return(publicDbOpClass.ExecSqlString(builder.ToString()));
        }
Esempio n. 2
0
        public OABooksInStorage GetModel(int RecordID)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("select *  ");
            builder.Append(" RecordID,ISBN,ClassID,BookTitle,PublishingHouse,Author,Copy,UserCode,RecordDate ");
            builder.Append(" from OA_Books_InStorage ");
            builder.Append(" where RecordID=" + RecordID);
            OABooksInStorage storage = new OABooksInStorage();
            DataSet          set     = publicDbOpClass.DataSetQuary(builder.ToString());

            if (set.Tables[0].Rows.Count <= 0)
            {
                return(null);
            }
            if (set.Tables[0].Rows[0]["RecordID"].ToString() != "")
            {
                storage.RecordID = int.Parse(set.Tables[0].Rows[0]["RecordID"].ToString());
            }
            storage.ISBN = set.Tables[0].Rows[0]["ISBN"].ToString();
            if (set.Tables[0].Rows[0]["ClassID"].ToString() != "")
            {
                storage.ClassID = int.Parse(set.Tables[0].Rows[0]["ClassID"].ToString());
            }
            storage.BookTitle       = set.Tables[0].Rows[0]["BookTitle"].ToString();
            storage.PublishingHouse = set.Tables[0].Rows[0]["PublishingHouse"].ToString();
            storage.Author          = set.Tables[0].Rows[0]["Author"].ToString();
            if (set.Tables[0].Rows[0]["Copy"].ToString() != "")
            {
                storage.Copy = int.Parse(set.Tables[0].Rows[0]["Copy"].ToString());
            }
            storage.UserCode = set.Tables[0].Rows[0]["UserCode"].ToString();
            if (set.Tables[0].Rows[0]["RecordDate"].ToString() != "")
            {
                storage.RecordDate = DateTime.Parse(set.Tables[0].Rows[0]["RecordDate"].ToString());
            }
            return(storage);
        }