Example #1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Model.InvoiceAttachments model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into InvoiceAttachments(");
            strSql.Append("Invoiceurl,ProjectId,PaymentapplicationformId)");
            strSql.Append(" values (");
            strSql.Append("@Invoiceurl,@ProjectId,@PaymentapplicationformId)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Invoiceurl",               SqlDbType.NVarChar, 500),
                new SqlParameter("@ProjectId",                SqlDbType.Int,        4),
                new SqlParameter("@PaymentapplicationformId", SqlDbType.Int, 4)
            };
            parameters[0].Value = model.Invoiceurl;
            parameters[1].Value = model.ProjectId;
            parameters[2].Value = model.PaymentapplicationformId;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Example #2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Model.InvoiceAttachments model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update InvoiceAttachments set ");
            strSql.Append("Invoiceurl=@Invoiceurl,");
            strSql.Append("ProjectId=@ProjectId,");
            strSql.Append("PaymentapplicationformId=@PaymentapplicationformId");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Invoiceurl",               SqlDbType.NVarChar, 500),
                new SqlParameter("@ProjectId",                SqlDbType.Int,        4),
                new SqlParameter("@PaymentapplicationformId", SqlDbType.Int,        4),
                new SqlParameter("@Id",                       SqlDbType.Int, 4)
            };
            parameters[0].Value = model.Invoiceurl;
            parameters[1].Value = model.ProjectId;
            parameters[2].Value = model.PaymentapplicationformId;
            parameters[3].Value = model.Id;
            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #3
0
        public JsonResult Fileds3()
        {
            var msg       = "";
            var bianliang = System.Web.HttpContext.Current;

            bianliang.Response.ContentType = "text/plain";
            HttpPostedFile filePost = bianliang.Request.Files["fileds"]; // 获取上传的文件

            string filePath = SaveFileds3(filePost);                     // 保存文件并获取文件路径

            Model.Paymentapplicationform formmodel = formbll.GetModelsss();
            if (formmodel != null)
            {
                Model.InvoiceAttachments invoicemodel = new Model.InvoiceAttachments();
                invoicemodel.Invoiceurl = filePath;
                invoicemodel.PaymentapplicationformId = formmodel.Id;
                if (invoicemodel != null)
                {
                    invoicebll.Add(invoicemodel);
                }
                return(Json(filePath, JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json(msg = "上传失败请选择项目!", JsonRequestBehavior.AllowGet));
            }
        }
Example #4
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Model.InvoiceAttachments DataRowToModel(DataRow row)
 {
     Model.InvoiceAttachments model = new  Model.InvoiceAttachments();
     if (row != null)
     {
         if (row["Id"] != null && row["Id"].ToString() != "")
         {
             model.Id = int.Parse(row["Id"].ToString());
         }
         if (row["Invoiceurl"] != null)
         {
             model.Invoiceurl = row["Invoiceurl"].ToString();
         }
         if (row["ProjectId"] != null && row["ProjectId"].ToString() != "")
         {
             model.ProjectId = int.Parse(row["ProjectId"].ToString());
         }
         if (row["PaymentapplicationformId"] != null && row["PaymentapplicationformId"].ToString() != "")
         {
             model.PaymentapplicationformId = int.Parse(row["PaymentapplicationformId"].ToString());
         }
     }
     return(model);
 }
Example #5
0
        public Model.InvoiceAttachments GetModels(int Id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 Id,Invoiceurl,ProjectId,PaymentapplicationformId from InvoiceAttachments ");
            strSql.Append(" where PaymentapplicationformId=@Id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Id", SqlDbType.Int, 4)
            };
            parameters[0].Value = Id;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Example #6
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(Model.InvoiceAttachments model)
 {
     return(dal.Update(model));
 }
Example #7
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(Model.InvoiceAttachments model)
 {
     return(dal.Add(model));
 }