예제 #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(tb_attachment model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update tb_attachment set ");
            strSql.Append("fileName=@fileName,");
            strSql.Append("filePath=@filePath,");
            strSql.Append("fileSize=@fileSize,");
            strSql.Append("type1=@type1,");
            strSql.Append("type2=@type2,");
            strSql.Append("tId=@tId,");
            strSql.Append("createUser=@createUser,");
            strSql.Append("createDate=@createDate,");
            strSql.Append("updateUser=@updateUser,");
            strSql.Append("updateDate=@updateDate,");
            strSql.Append("temp1=@temp1,");
            strSql.Append("temp2=@temp2");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@fileName",   SqlDbType.NVarChar,  200),
                new SqlParameter("@filePath",   SqlDbType.NVarChar,   -1),
                new SqlParameter("@fileSize",   SqlDbType.VarChar,    50),
                new SqlParameter("@type1",      SqlDbType.VarChar,    50),
                new SqlParameter("@type2",      SqlDbType.VarChar,    50),
                new SqlParameter("@tId",        SqlDbType.Int,         4),
                new SqlParameter("@createUser", SqlDbType.Int,         4),
                new SqlParameter("@createDate", SqlDbType.DateTime),
                new SqlParameter("@updateUser", SqlDbType.Int,         4),
                new SqlParameter("@updateDate", SqlDbType.DateTime),
                new SqlParameter("@temp1",      SqlDbType.NVarChar,   -1),
                new SqlParameter("@temp2",      SqlDbType.NVarChar,   -1),
                new SqlParameter("@id",         SqlDbType.Int, 4)
            };
            parameters[0].Value  = model.fileName;
            parameters[1].Value  = model.filePath;
            parameters[2].Value  = model.fileSize;
            parameters[3].Value  = model.type1;
            parameters[4].Value  = model.type2;
            parameters[5].Value  = model.tId;
            parameters[6].Value  = model.createUser;
            parameters[7].Value  = model.createDate;
            parameters[8].Value  = model.updateUser;
            parameters[9].Value  = model.updateDate;
            parameters[10].Value = model.temp1;
            parameters[11].Value = model.temp2;
            parameters[12].Value = model.id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #2
0
        public ActionResult doSanitationInfo(int _supplierId, int id)
        {
            tb_attachment model = new tb_attachment();

            ViewBag._supplierId = _supplierId;
            if (_supplierId > 0)
            {
                model = _attachmentbll.GetModel(id);
            }
            return(View(model));
        }
예제 #3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(tb_attachment model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into tb_attachment(");
            strSql.Append("fileName,filePath,fileSize,type1,type2,tId,createUser,createDate,updateUser,updateDate,temp1,temp2)");
            strSql.Append(" values (");
            strSql.Append("@fileName,@filePath,@fileSize,@type1,@type2,@tId,@createUser,@createDate,@updateUser,@updateDate,@temp1,@temp2)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@fileName",   SqlDbType.NVarChar,  200),
                new SqlParameter("@filePath",   SqlDbType.NVarChar,   -1),
                new SqlParameter("@fileSize",   SqlDbType.VarChar,    50),
                new SqlParameter("@type1",      SqlDbType.VarChar,    50),
                new SqlParameter("@type2",      SqlDbType.VarChar,    50),
                new SqlParameter("@tId",        SqlDbType.Int,         4),
                new SqlParameter("@createUser", SqlDbType.Int,         4),
                new SqlParameter("@createDate", SqlDbType.DateTime),
                new SqlParameter("@updateUser", SqlDbType.Int,         4),
                new SqlParameter("@updateDate", SqlDbType.DateTime),
                new SqlParameter("@temp1",      SqlDbType.NVarChar,   -1),
                new SqlParameter("@temp2",      SqlDbType.NVarChar, -1)
            };
            parameters[0].Value  = model.fileName;
            parameters[1].Value  = model.filePath;
            parameters[2].Value  = model.fileSize;
            parameters[3].Value  = model.type1;
            parameters[4].Value  = model.type2;
            parameters[5].Value  = model.tId;
            parameters[6].Value  = model.createUser;
            parameters[7].Value  = model.createDate;
            parameters[8].Value  = model.updateUser;
            parameters[9].Value  = model.updateDate;
            parameters[10].Value = model.temp1;
            parameters[11].Value = model.temp2;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
예제 #4
0
        public JsonResult doattachment(int _tid, string _urls, string _names, string _size)
        {
            string flag = "0";

            try
            {
                var strfilename = _names.Split(',');
                var strfilePath = _urls.Split(',');
                var strfileSize = _size.Split(',');
                if (strfilename.Count() >= 1 && strfilePath.Count() >= 1 && strfileSize.Count() >= 1)
                {
                    tb_attachmentBLL _attachmentbll = new tb_attachmentBLL();
                    for (int i = 0; i < strfilename.Count(); i++)
                    {
                        if (!string.IsNullOrEmpty(strfilename[i]) && !string.IsNullOrEmpty(strfilename[i]))
                        {
                            tb_attachment model = new tb_attachment();
                            model.fileName   = strfilename[i];
                            model.filePath   = strfilePath[i];
                            model.fileSize   = strfileSize[i];
                            model.type1      = "计量管理";
                            model.type2      = "计量";
                            model.tId        = _tid;
                            model.createDate = DateTime.Now;
                            model.createUser = CurrentUserInfo.PersonnelID;
                            model.updateDate = DateTime.Now;
                            model.updateUser = CurrentUserInfo.PersonnelID;
                            _attachmentbll.Add(model);
                        }
                    }
                }
            }
            catch
            {
                flag = "0";
            }
            return(Json(flag, JsonRequestBehavior.AllowGet));
        }
예제 #5
0
 private void doattachment(int id, List <tb_attachment> listattachment)
 {
     foreach (var item in listattachment)
     {
         try
         {
             var strfilename = item.fileName.Split(',');
             var strfilePath = item.filePath.Split(',');
             var strfileSize = item.fileSize.Split(',');
             if (strfilename.Count() >= 1 && strfilePath.Count() >= 1 && strfileSize.Count() >= 1)
             {
                 _attachmentbll.Delete(item.type1, item.type2, id);
                 for (int i = 0; i < strfilename.Count(); i++)
                 {
                     if (!string.IsNullOrEmpty(strfilename[i]) && !string.IsNullOrEmpty(strfilename[i]))
                     {
                         tb_attachment model = new tb_attachment();
                         model.fileName   = strfilename[i];
                         model.filePath   = strfilePath[i];
                         model.fileSize   = strfileSize[i];
                         model.type1      = item.type1;
                         model.type2      = item.type2;
                         model.tId        = id;
                         model.createDate = DateTime.Now;
                         model.createUser = CurrentUserInfo.PersonnelID;
                         model.updateDate = DateTime.Now;
                         model.updateUser = CurrentUserInfo.PersonnelID;
                         _attachmentbll.Add(model);
                     }
                 }
             }
         }
         catch
         {
             continue;
         }
     }
 }
예제 #6
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public tb_attachment GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 id,fileName,filePath,fileSize,type1,type2,tId,createUser,createDate,updateUser,updateDate,temp1,temp2 from tb_attachment ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

            tb_attachment model = new tb_attachment();
            DataSet       ds    = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
예제 #7
0
        public string SaveSanitationInfo(tb_attachment _attachment)
        {
            _attachment.type1      = "供应商管理";
            _attachment.updateDate = DateTime.Now;
            _attachment.updateUser = CurrentUserInfo.PersonnelID;
            string flag = "0";

            if (_attachment.id > 0)
            {
                if (_attachmentbll.Update(_attachment))
                {
                    flag = "1";
                }
            }
            else
            {
                _attachment.createUser = CurrentUserInfo.PersonnelID;
                if (_attachmentbll.Add(_attachment) > 0)
                {
                    flag = "1";
                }
            }
            return(flag);
        }
예제 #8
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public tb_attachment DataRowToModel(DataRow row)
        {
            tb_attachment model = new tb_attachment();

            if (row != null)
            {
                if (row["id"] != null && row["id"].ToString() != "")
                {
                    model.id = int.Parse(row["id"].ToString());
                }
                if (row["fileName"] != null)
                {
                    model.fileName = row["fileName"].ToString();
                }
                if (row["filePath"] != null)
                {
                    model.filePath = row["filePath"].ToString();
                }
                if (row["fileSize"] != null)
                {
                    model.fileSize = row["fileSize"].ToString();
                }
                if (row["type1"] != null)
                {
                    model.type1 = row["type1"].ToString();
                }
                if (row["type2"] != null)
                {
                    model.type2 = row["type2"].ToString();
                }
                if (row["tId"] != null && row["tId"].ToString() != "")
                {
                    model.tId = int.Parse(row["tId"].ToString());
                }
                if (row["createUser"] != null && row["createUser"].ToString() != "")
                {
                    model.createUser = int.Parse(row["createUser"].ToString());
                }
                if (row["createDate"] != null && row["createDate"].ToString() != "")
                {
                    model.createDate = DateTime.Parse(row["createDate"].ToString());
                }
                if (row["updateUser"] != null && row["updateUser"].ToString() != "")
                {
                    model.updateUser = int.Parse(row["updateUser"].ToString());
                }
                if (row["updateDate"] != null && row["updateDate"].ToString() != "")
                {
                    model.updateDate = DateTime.Parse(row["updateDate"].ToString());
                }
                if (row["temp1"] != null)
                {
                    model.temp1 = row["temp1"].ToString();
                }
                if (row["temp2"] != null)
                {
                    model.temp2 = row["temp2"].ToString();
                }
            }
            return(model);
        }
예제 #9
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(tb_attachment model)
 {
     return(dal.Update(model));
 }
예제 #10
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(tb_attachment model)
 {
     return(dal.Add(model));
 }