/// <summary> /// Если 7 поколений рожденных прошло через программу, то номера генов отметаются. /// </summary> /// <returns>Генезис ID</returns> private static int bornRabbitGenesis(MySqlConnection sql, OneRabbit fml, OneRabbit ml) { int fLevel = 0, mLevel = 0; fml.RabGenoms = RabbitGenGetter.GetRabGenoms(sql, fml.ID); RabbitGen.GetFullGenLevels(fml.RabGenoms, ref fLevel); if (ml != null) { ml.RabGenoms = RabbitGenGetter.GetRabGenoms(sql, ml.ID); RabbitGen.GetFullGenLevels(ml.RabGenoms, ref mLevel); } MySqlCommand cmd = new MySqlCommand("SELECT o_value FROM options WHERE o_name='opt' AND o_subname='rab_gen_depth'", sql); object o = cmd.ExecuteScalar(); if (o != null) { int rab_gen_depth = 0; if (int.TryParse(o.ToString(), out rab_gen_depth)) { if (Math.Min(fLevel, mLevel) >= rab_gen_depth) { return(0); } } } return(RabbitGenGetter.MakeCommonGenesis(sql, fml.Genoms, (ml != null ? ml.Genoms : fml.Genoms), fml.Zone)); }
public static void SetRabbit(MySqlConnection con, OneRabbit r) { int multi = (r.Defect ? 1 : 0); String flags = String.Format("{0:D1}{1:D1}{2:D1}{3:D1}{4:D1}", r.Production ? 1 : 0, r.RealizeReady ? 1 : 0, multi, r.NoKuk ? 1 : 0, r.NoLact ? 1 : 0);//TODO возможен косяк String query = String.Format(@"UPDATE rabbits SET r_name={0:d}, r_surname={1:d}, r_secname={2:d}, r_breed={3:d}, r_zone={4:d}, r_group={5:d}, r_notes=@notes, r_flags='{6:d}', r_rate={7:d}, r_born={8:s} ", DBHelper.Nullable(r.NameID), DBHelper.Nullable(r.SurnameID), DBHelper.Nullable(r.SecnameID), r.BreedID, r.Zone, r.Group, flags, r.Rate, DBHelper.DateToSqlString(r.BirthDay) ); if (r.Sex != Rabbit.SexType.VOID) { query += String.Format(", r_status={0:d}, r_last_fuck_okrol={1:s}", r.Status, DBHelper.DateToSqlString(r.LastFuckOkrol)); } if (r.Sex == Rabbit.SexType.FEMALE) { query += String.Format(", r_event='{0:s}', r_event_date={1:s}, r_overall_babies={2:d}", Rabbit.GetEventName(r.EventType), DBHelper.DateToSqlString(r.EventDate), r.KidsOverAll); } query += String.Format(" WHERE r_id={0:d};", r.ID); MySqlCommand cmd = new MySqlCommand(query, con); cmd.Prepare(); cmd.Parameters.AddWithValue("@notes", r.Notes); cmd.ExecuteNonQuery(); int gen = RabbitGenGetter.MakeGenesis(con, r.Genoms); cmd.CommandText = String.Format("UPDATE rabbits SET r_genesis={0:d} WHERE r_id={1:d};", gen, r.ID); cmd.ExecuteNonQuery(); if (r.WasNameID != r.NameID) { ///todo проверка на используемость cmd.CommandText = String.Format("UPDATE names SET n_use = NULL, n_block_date = NULL WHERE n_id={0:d};", r.WasNameID); cmd.ExecuteNonQuery(); cmd.CommandText = String.Format("UPDATE names SET n_use = {0:d} WHERE n_id = {1:d};", r.ID, DBHelper.Nullable(r.NameID)); cmd.ExecuteNonQuery(); } }
public Dictionary <int, Color> getBreedColors() { return(RabbitGenGetter.getBreedColors(sql)); }
public RabbitGen getRabbitGen(int rid) { return(RabbitGenGetter.GetRabbitGen(sql, rid)); }
public RabTreeData rabbitGenTree(int rabbit) { return(RabbitGenGetter.GetRabbitGenTree(sql, rabbit)); }
public String GetRabGenoms(int rId) { return(RabbitGenGetter.GetRabGenoms(sql, rId)); }