/// <summary> /// 得到一个对象实体 /// </summary> public XHD.Model.crm_contact_bill_check DataRowToModel(DataRow row) { XHD.Model.crm_contact_bill_check model = new XHD.Model.crm_contact_bill_check(); if (row != null) { if (row["id"] != null && row["id"].ToString() != "") { model.id = int.Parse(row["id"].ToString()); } if (row["tax_code"] != null) { model.tax_code = row["tax_code"].ToString(); } if (row["new_tax_code"] != null) { model.new_tax_code = row["new_tax_code"].ToString(); } if (row["id_list"] != null) { model.id_list = row["id_list"].ToString(); } if (row["check_id"] != null) { model.check_id = row["check_id"].ToString(); } if (row["check_code"] != null) { model.check_code = row["check_code"].ToString(); } if (row["check_name"] != null) { model.check_name = row["check_name"].ToString(); } if (row["check_date"] != null && row["check_date"].ToString() != "") { model.check_date = DateTime.Parse(row["check_date"].ToString()); } if (row["sub_id"] != null && row["sub_id"].ToString() != "") { model.sub_id = int.Parse(row["sub_id"].ToString()); } if (row["sub_code"] != null) { model.sub_code = row["sub_code"].ToString(); } if (row["sub_name"] != null) { model.sub_name = row["sub_name"].ToString(); } if (row["sub_date"] != null && row["sub_date"].ToString() != "") { model.sub_date = DateTime.Parse(row["sub_date"].ToString()); } if (row["status"] != null && row["status"].ToString() != "") { model.status = int.Parse(row["status"].ToString()); } } return(model); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(XHD.Model.crm_contact_bill_check model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update crm_contact_bill_check set "); strSql.Append("tax_code=@tax_code,"); strSql.Append("new_tax_code=@new_tax_code,"); strSql.Append("id_list=@id_list,"); strSql.Append("check_id=@check_id,"); strSql.Append("check_code=@check_code,"); strSql.Append("check_name=@check_name,"); strSql.Append("check_date=@check_date,"); strSql.Append("sub_id=@sub_id,"); strSql.Append("sub_code=@sub_code,"); strSql.Append("sub_name=@sub_name,"); strSql.Append("sub_date=@sub_date,"); strSql.Append("status=@status"); strSql.Append(" where id=@id "); MySqlParameter[] parameters = { new MySqlParameter("@tax_code", MySqlDbType.VarChar, 50), new MySqlParameter("@new_tax_code", MySqlDbType.VarChar, 255), new MySqlParameter("@id_list", MySqlDbType.VarChar, 255), new MySqlParameter("@check_id", MySqlDbType.VarChar, 50), new MySqlParameter("@check_code", MySqlDbType.VarChar, 50), new MySqlParameter("@check_name", MySqlDbType.VarChar, 50), new MySqlParameter("@check_date", MySqlDbType.DateTime), new MySqlParameter("@sub_id", MySqlDbType.Int32, 11), new MySqlParameter("@sub_code", MySqlDbType.VarChar, 255), new MySqlParameter("@sub_name", MySqlDbType.VarChar, 50), new MySqlParameter("@sub_date", MySqlDbType.DateTime), new MySqlParameter("@status", MySqlDbType.Int32, 2), new MySqlParameter("@id", MySqlDbType.Int32, 11) }; parameters[0].Value = model.tax_code; parameters[1].Value = model.new_tax_code; parameters[2].Value = model.id_list; parameters[3].Value = model.check_id; parameters[4].Value = model.check_code; parameters[5].Value = model.check_name; parameters[6].Value = model.check_date; parameters[7].Value = model.sub_id; parameters[8].Value = model.sub_code; parameters[9].Value = model.sub_name; parameters[10].Value = model.sub_date; parameters[11].Value = model.status; parameters[12].Value = model.id; int rows = DbHelperMySQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(XHD.Model.crm_contact_bill_check model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into crm_contact_bill_check("); strSql.Append("id,tax_code,new_tax_code,id_list,check_id,check_code,check_name,check_date,sub_id,sub_code,sub_name,sub_date,status)"); strSql.Append(" values ("); strSql.Append("@id,@tax_code,@new_tax_code,@id_list,@check_id,@check_code,@check_name,@check_date,@sub_id,@sub_code,@sub_name,@sub_date,@status)"); MySqlParameter[] parameters = { new MySqlParameter("@id", MySqlDbType.Int32, 11), new MySqlParameter("@tax_code", MySqlDbType.VarChar, 50), new MySqlParameter("@new_tax_code", MySqlDbType.VarChar, 255), new MySqlParameter("@id_list", MySqlDbType.VarChar, 255), new MySqlParameter("@check_id", MySqlDbType.VarChar, 50), new MySqlParameter("@check_code", MySqlDbType.VarChar, 50), new MySqlParameter("@check_name", MySqlDbType.VarChar, 50), new MySqlParameter("@check_date", MySqlDbType.DateTime), new MySqlParameter("@sub_id", MySqlDbType.Int32, 11), new MySqlParameter("@sub_code", MySqlDbType.VarChar, 255), new MySqlParameter("@sub_name", MySqlDbType.VarChar, 50), new MySqlParameter("@sub_date", MySqlDbType.DateTime), new MySqlParameter("@status", MySqlDbType.Int32, 2) }; parameters[0].Value = model.id; parameters[1].Value = model.tax_code; parameters[2].Value = model.new_tax_code; parameters[3].Value = model.id_list; parameters[4].Value = model.check_id; parameters[5].Value = model.check_code; parameters[6].Value = model.check_name; parameters[7].Value = model.check_date; parameters[8].Value = model.sub_id; parameters[9].Value = model.sub_code; parameters[10].Value = model.sub_name; parameters[11].Value = model.sub_date; parameters[12].Value = model.status; int rows = DbHelperMySQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public XHD.Model.crm_contact_bill_check GetModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select id,tax_code,new_tax_code,id_list,check_id,check_code,check_name,check_date,sub_id,sub_code,sub_name,sub_date,status from crm_contact_bill_check "); strSql.Append(" where id=@id "); MySqlParameter[] parameters = { new MySqlParameter("@id", MySqlDbType.Int32, 11) }; parameters[0].Value = id; XHD.Model.crm_contact_bill_check model = new XHD.Model.crm_contact_bill_check(); DataSet ds = DbHelperMySQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }