/// <summary> /// Устанавливает ширину колонок компонента ListView /// </summary> /// <param name="op">enum opt_id</param> /// <param name="lv">ListViev</param> public static void load(Options.OPT_ID op, ListView lv) { if (op == Options.OPT_ID.NONE) { return; } String val = Engine.opt().getOption(op); if (val == "" || val == "0") { return; } String[] cls = val.Split(','); int i; for (i = 0; i < lv.Columns.Count && i < cls.Length; i++) { lv.Columns[i].Width = int.Parse(cls[i]); //не безопасно } if (lv.ListViewItemSorter != null && cls.Length > i) { ListViewColumnSorter cs = lv.ListViewItemSorter as ListViewColumnSorter; int sc = int.Parse(cls[i]); if (sc >= lv.Columns.Count) { cs.Order = SortOrder.None; cs.SortColumn = 0; return; } cs.SortColumn = sc; int sort = 0; if (i + 1 < cls.Length) { int.TryParse(cls[i + 1], out sort); } cs.Order = SortOrder.None; if (sort == 1) { cs.Order = SortOrder.Ascending; } else if (sort == 2) { cs.Order = SortOrder.Descending; } lv.Sort(); } }
private static void loadSize(Form frm) { Options.OPT_ID opt; if (!checkFrm(frm, out opt)) { return; } string[] sizes = Engine.opt().getOption(opt).Split(':'); if (sizes.Length < 2) { return; } int w = -1, h = -1; int.TryParse(sizes[0], out w); int.TryParse(sizes[1], out h); if (w > 0 && h > 0) { frm.Width = w; frm.Height = h; } }
/// <summary> /// Нужно для отчета Племенное свидетельство /// </summary> /// <param name="er"></param> /// <param name="or"></param> /// <param name="hasdoc"></param> /// <returns></returns> internal static XmlDocument rabToXml(OneRabbit er, OneRabbit or, XmlDocument hasdoc) { XmlDocument doc = null; if (hasdoc == null) { doc = new XmlDocument(); doc.AppendChild(doc.CreateElement("Rows")); } else { doc = hasdoc; } XmlElement rw = doc.CreateElement("Row"); doc.DocumentElement.AppendChild(rw); if (er != null) { or = Engine.db().getLiveDeadRabbit(er.ID); if (hasdoc == null) { ReportHelper.Append(rw, doc, "header", Engine.opt().getOption(Options.OPT_ID.SVID_HEAD)); ReportHelper.Append(rw, doc, "num", Engine.opt().getOption(Options.OPT_ID.NEXT_SVID)); ReportHelper.Append(rw, doc, "date", DateTime.Now.Date.ToShortDateString()); ReportHelper.Append(rw, doc, "director", Engine.opt().getOption(Options.OPT_ID.SVID_GEN_DIR)); //rw.AppendChild(doc.CreateElement("header")).AppendChild(doc.CreateTextNode(Engine.opt().getOption(Options.OPT_ID.SVID_HEAD))); //rw.AppendChild(doc.CreateElement("num")).AppendChild(doc.CreateTextNode(Engine.opt().getOption(Options.OPT_ID.NEXT_SVID))); //rw.AppendChild(doc.CreateElement("date")).AppendChild(doc.CreateTextNode(DateTime.Now.Date.ToShortDateString())); //rw.AppendChild(doc.CreateElement("director")).AppendChild(doc.CreateTextNode(Engine.opt().getOption(Options.OPT_ID.SVID_GEN_DIR))); } else { rw.AppendChild(doc.CreateElement("group")).AppendChild(doc.CreateTextNode(er.Group.ToString())); } ReportHelper.Append(rw, doc, "sex", er.Sex == Rabbit.SexType.MALE ? "male" : (er.Sex == Rabbit.SexType.FEMALE ? "female" : "void")); ReportHelper.Append(rw, doc, "class", Rabbit.GetFBon(er.Bon)); ReportHelper.Append(rw, doc, "name", er.NameFull); ReportHelper.Append(rw, doc, "breed", er.BreedName); if (er.BirthPlace != 0) { //todo по хорошему надо писать born_place кролику при рождении на данной ферме ClientsList list = Engine.db().GetClients(); foreach (Client c in list) { if (c.ID == er.BirthPlace) { ReportHelper.Append(rw, doc, "born_place", c.Name); break; } } } else { Catalog zones = Engine.db().catalogs().getZones(); ReportHelper.Append(rw, doc, "born_place", zones[er.Zone]); } ReportHelper.Append(rw, doc, "born_date", er.BirthDay.ToShortDateString()); ReportHelper.Append(rw, doc, "age", er.Age.ToString()); ReportHelper.Append(rw, doc, "address", er.AddressSmall); ReportHelper.Append(rw, doc, "weight", or.FWeight().ToString()); ReportHelper.Append(rw, doc, "weight_date", or.WeightDate.Date.ToShortDateString()); ReportHelper.Append(rw, doc, "weight_age", or.WeightAge.ToString()); ReportHelper.Append(rw, doc, "born", or.KidsOverAll.ToString());//сколько родила ReportHelper.Append(rw, doc, "okrol", or.Okrol.ToString()); ReportHelper.Append(rw, doc, "genom", er.Genoms.Replace(' ', ',')); ReportHelper.Append(rw, doc, "wclass", er.Bon_Weight); ReportHelper.Append(rw, doc, "bclass", er.Bon_Body); ReportHelper.Append(rw, doc, "hclass", er.Bon_Hair); ReportHelper.Append(rw, doc, "cclass", er.Bon_Color); } else if (or != null) { ReportHelper.Append(rw, doc, "sex", or.Sex == Rabbit.SexType.MALE ? "male" : "female"); //ReportHelper.Append(rw, doc, "age", or.Status.ToString()+(or.Zone==1?"(списан)":"")); ReportHelper.Append(rw, doc, "age", or.Age.ToString()); ReportHelper.Append(rw, doc, "weight", or.FWeight()); ReportHelper.Append(rw, doc, "class", Rabbit.GetFBon(or.Bon)); ReportHelper.Append(rw, doc, "name", or.NameFull); ReportHelper.Append(rw, doc, "wclass", Rabbit.GetFBon("" + or.Bon[1])); ReportHelper.Append(rw, doc, "bclass", Rabbit.GetFBon("" + or.Bon[1])); ReportHelper.Append(rw, doc, "hclass", Rabbit.GetFBon("" + or.Bon[3])); ReportHelper.Append(rw, doc, "cclass", Rabbit.GetFBon("" + or.Bon[4])); } else { ReportHelper.Append(rw, doc, "sex", "none"); ReportHelper.Append(rw, doc, "age", ""); ReportHelper.Append(rw, doc, "weight", ""); ReportHelper.Append(rw, doc, "class", ""); ReportHelper.Append(rw, doc, "name", ""); ReportHelper.Append(rw, doc, "wclass", ""); ReportHelper.Append(rw, doc, "bclass", ""); ReportHelper.Append(rw, doc, "hclass", ""); ReportHelper.Append(rw, doc, "cclass", ""); } return(doc); }