/// <summary> /// 更新一条数据 /// </summary> public bool Update(XHD.Model.crm_set_pubpri_count model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update crm_set_pubpri_count set "); strSql.Append("Count=@Count,"); strSql.Append("C_createDate=@C_createDate"); strSql.Append(" where factory_Id=@factory_Id"); strSql.Append(" and Customer_Id=@Customer_Id"); strSql.Append(" and C_createId=@C_createId"); MySqlParameter[] parameters = { new MySqlParameter("@Count", MySqlDbType.Int32, 11), new MySqlParameter("@C_createDate", MySqlDbType.DateTime), new MySqlParameter("@factory_Id", MySqlDbType.VarChar, 60), new MySqlParameter("@Customer_Id", MySqlDbType.Int32, 11), new MySqlParameter("@C_createId", MySqlDbType.Int32, 11) }; parameters[0].Value = model.Count; parameters[1].Value = model.C_createDate; parameters[2].Value = model.factory_Id; parameters[3].Value = model.Customer_Id; parameters[4].Value = model.C_createId; int rows = DbHelperMySQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public XHD.Model.crm_set_pubpri_count DataRowToModel(DataRow row) { XHD.Model.crm_set_pubpri_count model = new XHD.Model.crm_set_pubpri_count(); if (row != null) { if (row["Id"] != null && row["Id"].ToString() != "") { model.Id = int.Parse(row["Id"].ToString()); } if (row["factory_Id"] != null) { model.factory_Id = row["factory_Id"].ToString(); } if (row["Count"] != null && row["Count"].ToString() != "") { model.Count = int.Parse(row["Count"].ToString()); } if (row["Customer_Id"] != null && row["Customer_Id"].ToString() != "") { model.Customer_Id = int.Parse(row["Customer_Id"].ToString()); } if (row["Customer_name"] != null) { model.Customer_name = row["Customer_name"].ToString(); } if (row["C_createId"] != null && row["C_createId"].ToString() != "") { model.C_createId = int.Parse(row["C_createId"].ToString()); } if (row["C_createName"] != null) { model.C_createName = row["C_createName"].ToString(); } if (row["C_createDate"] != null && row["C_createDate"].ToString() != "") { model.C_createDate = DateTime.Parse(row["C_createDate"].ToString()); } } return(model); }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(XHD.Model.crm_set_pubpri_count model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into crm_set_pubpri_count("); strSql.Append("factory_Id,Count,Customer_Id,Customer_name,C_createId,C_createName,C_createDate)"); strSql.Append(" values ("); strSql.Append("@factory_Id,@Count,@Customer_Id,@Customer_name,@C_createId,@C_createName,@C_createDate)"); MySqlParameter[] parameters = { new MySqlParameter("@factory_Id", MySqlDbType.VarChar, 60), new MySqlParameter("@Count", MySqlDbType.Int32, 11), new MySqlParameter("@Customer_Id", MySqlDbType.Int32, 11), new MySqlParameter("@Customer_name", MySqlDbType.VarChar, 200), new MySqlParameter("@C_createId", MySqlDbType.Int32, 11), new MySqlParameter("@C_createName", MySqlDbType.VarChar, 60), new MySqlParameter("@C_createDate", MySqlDbType.DateTime) }; parameters[0].Value = model.factory_Id; parameters[1].Value = model.Count; parameters[2].Value = model.Customer_Id; parameters[3].Value = model.Customer_name; parameters[4].Value = model.C_createId; parameters[5].Value = model.C_createName; parameters[6].Value = model.C_createDate; int rows = DbHelperMySQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public XHD.Model.crm_set_pubpri_count GetModel(int Id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select Id,factory_Id,Count,Customer_Id,Customer_name,C_createId,C_createName,C_createDate from crm_set_pubpri_count "); strSql.Append(" where Id=@Id"); MySqlParameter[] parameters = { new MySqlParameter("@Id", MySqlDbType.Int32) }; parameters[0].Value = Id; XHD.Model.crm_set_pubpri_count model = new XHD.Model.crm_set_pubpri_count(); DataSet ds = DbHelperMySQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }