/// <summary> /// 更新一条数据 /// </summary> public bool Update(Library.Model.ProjectCost model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update T_ProjectCost set "); strSql.Append("F_ProjectID=@F_ProjectID,"); strSql.Append("F_IsProjectCost=@F_IsProjectCost,"); strSql.Append("F_CostType=@F_CostType,"); strSql.Append("F_CostAmount=@F_CostAmount,"); strSql.Append("F_OtherCost=@F_OtherCost,"); strSql.Append("F_CostDate=@F_CostDate,"); strSql.Append("F_OperatorID=@F_OperatorID,"); strSql.Append("F_OperateTime=@F_OperateTime,"); strSql.Append("F_IsDelete=@F_IsDelete,"); strSql.Append("F_CostDescription=@F_CostDescription,"); strSql.Append("F_ApplyID=@F_ApplyID"); strSql.Append(" where F_ID=@F_ID"); SqlParameter[] parameters = { new SqlParameter("@F_ProjectID", SqlDbType.Int, 4), new SqlParameter("@F_IsProjectCost", SqlDbType.Bit, 1), new SqlParameter("@F_CostType", SqlDbType.Int, 4), new SqlParameter("@F_CostAmount", SqlDbType.Money, 8), new SqlParameter("@F_OtherCost", SqlDbType.NVarChar, 500), new SqlParameter("@F_CostDate", SqlDbType.Date, 3), new SqlParameter("@F_OperatorID", SqlDbType.Int, 4), new SqlParameter("@F_OperateTime", SqlDbType.DateTime), new SqlParameter("@F_IsDelete", SqlDbType.Bit, 1), new SqlParameter("@F_CostDescription", SqlDbType.NVarChar, 500), new SqlParameter("@F_ApplyID", SqlDbType.Int, 4), new SqlParameter("@F_ID", SqlDbType.Int, 4) }; parameters[0].Value = model.F_ProjectID; parameters[1].Value = model.F_IsProjectCost; parameters[2].Value = model.F_CostType; parameters[3].Value = model.F_CostAmount; parameters[4].Value = model.F_OtherCost; parameters[5].Value = model.F_CostDate; parameters[6].Value = model.F_OperatorID; parameters[7].Value = model.F_OperateTime; parameters[8].Value = model.F_IsDelete; parameters[9].Value = model.F_CostDescription; parameters[10].Value = model.F_ApplyID; parameters[11].Value = model.F_ID; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Library.Model.ProjectCost model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into T_ProjectCost("); strSql.Append("F_ProjectID,F_IsProjectCost,F_CostType,F_CostAmount,F_OtherCost,F_CostDate,F_OperatorID,F_OperateTime,F_IsDelete,F_CostDescription,F_ApplyID)"); strSql.Append(" values ("); strSql.Append("@F_ProjectID,@F_IsProjectCost,@F_CostType,@F_CostAmount,@F_OtherCost,@F_CostDate,@F_OperatorID,@F_OperateTime,@F_IsDelete,@F_CostDescription,@F_ApplyID)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@F_ProjectID", SqlDbType.Int, 4), new SqlParameter("@F_IsProjectCost", SqlDbType.Bit, 1), new SqlParameter("@F_CostType", SqlDbType.Int, 4), new SqlParameter("@F_CostAmount", SqlDbType.Money, 8), new SqlParameter("@F_OtherCost", SqlDbType.NVarChar, 500), new SqlParameter("@F_CostDate", SqlDbType.Date, 3), new SqlParameter("@F_OperatorID", SqlDbType.Int, 4), new SqlParameter("@F_OperateTime", SqlDbType.DateTime), new SqlParameter("@F_IsDelete", SqlDbType.Bit, 1), new SqlParameter("@F_CostDescription", SqlDbType.NVarChar, 500), new SqlParameter("@F_ApplyID", SqlDbType.Int, 4) }; parameters[0].Value = model.F_ProjectID; parameters[1].Value = model.F_IsProjectCost; parameters[2].Value = model.F_CostType; parameters[3].Value = model.F_CostAmount; parameters[4].Value = model.F_OtherCost; parameters[5].Value = model.F_CostDate; parameters[6].Value = model.F_OperatorID; parameters[7].Value = model.F_OperateTime; parameters[8].Value = model.F_IsDelete; parameters[9].Value = model.F_CostDescription; parameters[10].Value = model.F_ApplyID; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Library.Model.ProjectCost GetModel(int F_ID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 F_ID,F_ProjectID,F_IsProjectCost,F_CostType,F_CostAmount,F_OtherCost,F_CostDate,F_OperatorID,F_OperateTime,F_IsDelete,F_CostDescription,F_ApplyID from T_ProjectCost "); strSql.Append(" where F_ID=@F_ID"); SqlParameter[] parameters = { new SqlParameter("@F_ID", SqlDbType.Int, 4) }; parameters[0].Value = F_ID; Library.Model.ProjectCost model = new Library.Model.ProjectCost(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Library.Model.ProjectCost DataRowToModel(DataRow row) { Library.Model.ProjectCost model = new Library.Model.ProjectCost(); if (row != null) { if (row["F_ID"] != null && row["F_ID"].ToString() != "") { model.F_ID = int.Parse(row["F_ID"].ToString()); } if (row["F_ProjectID"] != null && row["F_ProjectID"].ToString() != "") { model.F_ProjectID = int.Parse(row["F_ProjectID"].ToString()); } if (row["F_IsProjectCost"] != null && row["F_IsProjectCost"].ToString() != "") { if ((row["F_IsProjectCost"].ToString() == "1") || (row["F_IsProjectCost"].ToString().ToLower() == "true")) { model.F_IsProjectCost = true; } else { model.F_IsProjectCost = false; } } if (row["F_CostType"] != null && row["F_CostType"].ToString() != "") { model.F_CostType = int.Parse(row["F_CostType"].ToString()); } if (row["F_CostAmount"] != null && row["F_CostAmount"].ToString() != "") { model.F_CostAmount = decimal.Parse(row["F_CostAmount"].ToString()); } if (row["F_OtherCost"] != null) { model.F_OtherCost = row["F_OtherCost"].ToString(); } if (row["F_CostDate"] != null && row["F_CostDate"].ToString() != "") { model.F_CostDate = DateTime.Parse(row["F_CostDate"].ToString()); } if (row["F_OperatorID"] != null && row["F_OperatorID"].ToString() != "") { model.F_OperatorID = int.Parse(row["F_OperatorID"].ToString()); } if (row["F_OperateTime"] != null && row["F_OperateTime"].ToString() != "") { model.F_OperateTime = DateTime.Parse(row["F_OperateTime"].ToString()); } if (row["F_IsDelete"] != null && row["F_IsDelete"].ToString() != "") { if ((row["F_IsDelete"].ToString() == "1") || (row["F_IsDelete"].ToString().ToLower() == "true")) { model.F_IsDelete = true; } else { model.F_IsDelete = false; } } if (row["F_CostDescription"] != null) { model.F_CostDescription = row["F_CostDescription"].ToString(); } if (row["F_ApplyID"] != null && row["F_ApplyID"].ToString() != "") { model.F_ApplyID = int.Parse(row["F_ApplyID"].ToString()); } } return(model); }