Beispiel #1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public void Add(CCT.Model.BARCODESETTINGModel model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into BARCODESETTING(");
            strSql.Append("BARCODEID,DEPTCODE,ASSETCLASSIFY,FIXEDBARCODE,MAXCODE,COMMENTS)");
            strSql.Append(" values (");
            strSql.Append("@BARCODEID,@DEPTCODE,@ASSETCLASSIFY,@FIXEDBARCODE,@MAXCODE,@COMMENTS)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@BARCODEID",     SqlDbType.Int,        4),
                new SqlParameter("@DEPTCODE",      SqlDbType.NVarChar,  50),
                new SqlParameter("@ASSETCLASSIFY", SqlDbType.NVarChar),
                new SqlParameter("@FIXEDBARCODE",  SqlDbType.NVarChar,  10),
                new SqlParameter("@MAXCODE",       SqlDbType.Int,        4),
                new SqlParameter("@COMMENTS",      SqlDbType.NVarChar)
            };
            parameters[0].Value = model.BARCODEID;
            parameters[1].Value = model.DEPTCODE;
            parameters[2].Value = model.ASSETCLASSIFY;
            parameters[3].Value = model.FIXEDBARCODE;
            parameters[4].Value = model.MAXCODE;
            parameters[5].Value = model.COMMENTS;

            DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
        }
Beispiel #2
0
        /// <summary>
        /// 根据固定条码 得到一个对象实体
        /// </summary>
        public CCT.Model.BARCODESETTINGModel GetModelDueCode(string fixedCode)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 BARCODEID,DEPTCODE,ASSETCLASSIFY,FIXEDBARCODE,MAXCODE,COMMENTS from BARCODESETTING ");
            strSql.Append(" where FIXEDBARCODE=@FIXEDBARCODE ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@FIXEDBARCODE", SqlDbType.VarChar, 10)
            };
            parameters[0].Value = fixedCode;

            CCT.Model.BARCODESETTINGModel model = new CCT.Model.BARCODESETTINGModel();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["BARCODEID"] != null && ds.Tables[0].Rows[0]["BARCODEID"].ToString() != "")
                {
                    model.BARCODEID = int.Parse(ds.Tables[0].Rows[0]["BARCODEID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["DEPTCODE"] != null && ds.Tables[0].Rows[0]["DEPTCODE"].ToString() != "")
                {
                    model.DEPTCODE = ds.Tables[0].Rows[0]["DEPTCODE"].ToString();
                }
                if (ds.Tables[0].Rows[0]["ASSETCLASSIFY"] != null && ds.Tables[0].Rows[0]["ASSETCLASSIFY"].ToString() != "")
                {
                    model.ASSETCLASSIFY = ds.Tables[0].Rows[0]["ASSETCLASSIFY"].ToString();
                }
                if (ds.Tables[0].Rows[0]["FIXEDBARCODE"] != null && ds.Tables[0].Rows[0]["FIXEDBARCODE"].ToString() != "")
                {
                    model.FIXEDBARCODE = ds.Tables[0].Rows[0]["FIXEDBARCODE"].ToString();
                }
                if (ds.Tables[0].Rows[0]["MAXCODE"] != null && ds.Tables[0].Rows[0]["MAXCODE"].ToString() != "")
                {
                    model.MAXCODE = int.Parse(ds.Tables[0].Rows[0]["MAXCODE"].ToString());
                }
                if (ds.Tables[0].Rows[0]["COMMENTS"] != null && ds.Tables[0].Rows[0]["COMMENTS"].ToString() != "")
                {
                    model.COMMENTS = ds.Tables[0].Rows[0]["COMMENTS"].ToString();
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
Beispiel #3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(CCT.Model.BARCODESETTINGModel model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update BARCODESETTING set ");
            strSql.Append("BARCODEID=@BARCODEID,");
            strSql.Append("DEPTCODE=@DEPTCODE,");
            strSql.Append("ASSETCLASSIFY=@ASSETCLASSIFY,");
            strSql.Append("FIXEDBARCODE=@FIXEDBARCODE,");
            strSql.Append("MAXCODE=@MAXCODE,");
            strSql.Append("COMMENTS=@COMMENTS,");
            strSql.Append("plantid=@plantid,");
            strSql.Append("employeeid=@employeeid");
            strSql.Append(" where BARCODEID=@BARCODEID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@BARCODEID",     SqlDbType.Int,        4),
                new SqlParameter("@DEPTCODE",      SqlDbType.NVarChar,  50),
                new SqlParameter("@ASSETCLASSIFY", SqlDbType.NVarChar),
                new SqlParameter("@FIXEDBARCODE",  SqlDbType.NVarChar,  10),
                new SqlParameter("@MAXCODE",       SqlDbType.Int,        4),
                new SqlParameter("@COMMENTS",      SqlDbType.NVarChar),
                new SqlParameter("@plantid",       SqlDbType.NVarChar,   2),
                new SqlParameter("@employeeid",    SqlDbType.NVarChar, 50)
            };
            parameters[0].Value = model.BARCODEID;
            parameters[1].Value = model.DEPTCODE;
            parameters[2].Value = model.ASSETCLASSIFY;
            parameters[3].Value = model.FIXEDBARCODE;
            parameters[4].Value = model.MAXCODE;
            parameters[5].Value = model.COMMENTS;
            parameters[6].Value = model.PlantID;
            parameters[7].Value = model.EmployeeID;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

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