//全部重排 private void reArrange_all_techs(BathDBDataContext dc) { dc.ExecuteCommand("truncate table techindex"); dc.SubmitChanges(); var job_ids = dc.Job.Where(x => x.name.Contains("技师")).Select(x => x.id); foreach (var job_id in job_ids) { var techs = dc.Employee.Where(x => x.jobId == job_id); techs = techs.Where(x => x.techStatus == null || x.techStatus == "空闲" || x.techStatus == "待钟"); var techs_male = techs.Where(x => x.gender == "男"); var techIndex = new TechIndex(); techIndex.dutyid = job_id; techIndex.gender = "男"; techIndex.ids = string.Join("%", techs_male.OrderBy(x => x.id).Select(x => x.id + "=T").ToArray()); dc.TechIndex.InsertOnSubmit(techIndex); var techs_female = techs.Where(x => x.gender == "女"); techIndex = new TechIndex(); techIndex.dutyid = job_id; techIndex.gender = "女"; techIndex.ids = string.Join("%", techs_female.OrderBy(x => x.id).Select(x => x.id + "=T").ToArray()); dc.TechIndex.InsertOnSubmit(techIndex); } dc.SubmitChanges(); }
void TechEffect() { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(((TextAsset)Resources.Load("Xml/Tech")).text); XmlElement xmlNode = xmlDoc.DocumentElement; foreach (XmlNode elements in xmlNode) { XmlElement element = elements as XmlElement; if (element == null) { continue; } if (element.LocalName == "tech") { if (element.Attributes["id"].Value == TechIndex.ToString()) { XmlElement effects = element.SelectSingleNode("effects") as XmlElement; int.TryParse(effects.Attributes["amount"].Value, out int amount); for (int a = 0; a < amount; a++) { var effect = effects.ChildNodes[a] as XmlElement; switch (effect.Attributes["type"].Value) { case "message": Debug.Log(effect.InnerText); break; case "event": int delayDay = 0; int.TryParse(effect.InnerText, out int eventIndex); if (effect.HasAttribute("delay")) { int.TryParse(effect.Attributes["delay"].Value, out delayDay); } if (Events.UnActiveEvent.Contains(eventIndex)) { if (delayDay > 0) { Events.DelayEvent.Add(eventIndex); Events.DelayDay.Add(delayDay); Events.UnActiveEvent.Remove(eventIndex); } else { Events.ActiveEvent.Add(eventIndex); Events.UnActiveEvent.Remove(eventIndex); } } break; default: break; } } } } } }
//男技师重排 private void BtnRearrangeMale_Click(object sender, EventArgs e) { var dc = new BathDBDataContext(m_con_str); string typeSelName = seatTypeTree.SelectedNode.Text; if (typeSelName == "所有技师") { return; } var job_id = dc.Job.FirstOrDefault(x => x.name == typeSelName).id; var techs = dc.Employee.Where(x => x.jobId == job_id); techs = techs.Where(x => x.techStatus == null || x.techStatus == "空闲" || x.techStatus == "待钟"); var techs_male = techs.Where(x => x.gender == "男"); var techIndex = dc.TechIndex.FirstOrDefault(x => x.dutyid == job_id && x.gender == "男"); bool new_techIndex = false; if (techIndex == null) { new_techIndex = true; techIndex = new TechIndex(); } techIndex.dutyid = job_id; techIndex.gender = "男"; techIndex.ids = string.Join("%", techs_male.OrderBy(x => x.id).Select(x => x.id + "=T").ToArray()); if (new_techIndex) { dc.TechIndex.InsertOnSubmit(techIndex); } dc.SubmitChanges(); dgv_show(dc); }