Exemplo n.º 1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(SOSOshop.Model.Qualifications model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Qualifications(");
            strSql.Append("DrugsBase_Enterprise_ID,Name,Attachment,Classify,ExpiryDate,AlertDate,IsTransition,IsYearCheck,Remark,Ceated)");

            strSql.Append(" values (");
            strSql.Append("@DrugsBase_Enterprise_ID,@Name,@Attachment,@Classify,@ExpiryDate,@AlertDate,@IsTransition,@IsYearCheck,@Remark,@Ceated)");
            strSql.Append(";select @@IDENTITY");

            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());

            db.AddInParameter(dbCommand, "DrugsBase_Enterprise_ID", DbType.Int32, model.DrugsBase_Enterprise_ID);
            db.AddInParameter(dbCommand, "Name", DbType.Int32, model.Name);
            db.AddInParameter(dbCommand, "Attachment", DbType.String, model.Attachment);
            db.AddInParameter(dbCommand, "Classify", DbType.String, model.Classify);
            db.AddInParameter(dbCommand, "ExpiryDate", DbType.Int32, model.ExpiryDate);
            db.AddInParameter(dbCommand, "AlertDate", DbType.String, model.AlertDate);
            db.AddInParameter(dbCommand, "IsTransition", DbType.Boolean, model.IsTransition);
            db.AddInParameter(dbCommand, "IsYearCheck", DbType.Boolean, model.IsYearCheck);
            db.AddInParameter(dbCommand, "Remark", DbType.String, model.Remark);
            db.AddInParameter(dbCommand, "Ceated", DbType.DateTime, model.Ceated);
            int    result;
            object obj = db.ExecuteScalar(dbCommand);

            if (!int.TryParse(obj.ToString(), out result))
            {
                return(0);
            }
            return(result);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 对象实体绑定数据
        /// </summary>
        public SOSOshop.Model.Qualifications ReaderBind(IDataReader dataReader)
        {
            SOSOshop.Model.Qualifications model = new SOSOshop.Model.Qualifications();
            object ojb;

            ojb = dataReader["ID"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.ID = (int)ojb;
            }
            ojb = dataReader["DrugsBase_Enterprise_ID"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.DrugsBase_Enterprise_ID = (int)ojb;
            }
            ojb = dataReader["Name"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Name = (int)ojb;
            }
            model.Attachment = dataReader["Attachment"].ToString();
            model.Classify   = dataReader["Classify"].ToString();
            ojb = dataReader["ExpiryDate"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.ExpiryDate = (int)ojb;
            }
            ojb = dataReader["AlertDate"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.AlertDate = (DateTime)ojb;
            }
            ojb = dataReader["IsTransition"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.IsTransition = (bool)ojb;
            }
            ojb = dataReader["IsYearCheck"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.IsYearCheck = (bool)ojb;
            }
            model.Remark = dataReader["Remark"].ToString();
            ojb          = dataReader["Ceated"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Ceated = (DateTime)ojb;
            }
            return(model);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public SOSOshop.Model.Qualifications GetModel(int ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select ID,DrugsBase_Enterprise_ID,Name,Attachment,Classify,ExpiryDate,AlertDate,IsTransition,IsYearCheck,Remark,Ceated from Qualifications ");
            strSql.Append(" where ID=@ID ");

            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());

            db.AddInParameter(dbCommand, "ID", DbType.Int32, ID);
            SOSOshop.Model.Qualifications model = null;
            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                if (dataReader.Read())
                {
                    model = ReaderBind(dataReader);
                }
            }
            return(model);
        }
Exemplo n.º 4
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(SOSOshop.Model.Qualifications model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Qualifications set ");
            strSql.Append("DrugsBase_Enterprise_ID=@DrugsBase_Enterprise_ID,");
            strSql.Append("Name=@Name,");
            strSql.Append("Attachment=@Attachment,");
            strSql.Append("Classify=@Classify,");
            strSql.Append("ExpiryDate=@ExpiryDate,");
            strSql.Append("AlertDate=@AlertDate,");
            strSql.Append("IsTransition=@IsTransition,");
            strSql.Append("IsYearCheck=@IsYearCheck,");
            strSql.Append("Remark=@Remark,");
            strSql.Append("Ceated=@Ceated");
            strSql.Append(" where ID=@ID ");

            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());

            db.AddInParameter(dbCommand, "ID", DbType.Int32, model.ID);
            db.AddInParameter(dbCommand, "DrugsBase_Enterprise_ID", DbType.Int32, model.DrugsBase_Enterprise_ID);
            db.AddInParameter(dbCommand, "Name", DbType.Int32, model.Name);
            db.AddInParameter(dbCommand, "Attachment", DbType.String, model.Attachment);
            db.AddInParameter(dbCommand, "Classify", DbType.String, model.Classify);
            db.AddInParameter(dbCommand, "ExpiryDate", DbType.Int32, model.ExpiryDate);
            db.AddInParameter(dbCommand, "AlertDate", DbType.String, model.AlertDate);
            db.AddInParameter(dbCommand, "IsTransition", DbType.Boolean, model.IsTransition);
            db.AddInParameter(dbCommand, "IsYearCheck", DbType.Boolean, model.IsYearCheck);
            db.AddInParameter(dbCommand, "Remark", DbType.String, model.Remark);
            db.AddInParameter(dbCommand, "Ceated", DbType.DateTime, model.Ceated);
            int rows = db.ExecuteNonQuery(dbCommand);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }