private void EnabledRemoveButton() { List <RibbonButton> listRibbonButton = CustomerObject.GetLogicalChildCollection <RibbonButton>(this); foreach (RibbonButton rbtn in listRibbonButton) { if (rbtn.Name.Contains("btnContentRemove")) { string[] tag = rbtn.Tag.ToString().SplitByDelimiter("#"); DsNhomCap itemNhomCap = lstNhomCap[Convert.ToInt32(tag[0].Replace("NhomCap", ""))]; if (Convert.ToInt32(tag[1]) == (itemNhomCap.LstCap.Count - 1)) { rbtn.IsEnabled = true; } else { rbtn.IsEnabled = false; } } else if (rbtn.Name.Contains("btnRemove")) { if (Convert.ToInt32(rbtn.Tag.ToString()) == (lstNhomCap.Count - 1)) { rbtn.IsEnabled = true; } else { rbtn.IsEnabled = false; } } } }
private string getObject() { // string strResource = "0-20(id1|ma1,id2|ma2,id3|ma3;idI|maI,idII|maII,idIII|maIII@DDU1^id1|ma1,id2|ma2,id3|ma3;idI|maI,idII|maII,idIII|maIII@DDU2) string result = ""; List <TextBox> listTextBox = CustomerObject.GetLogicalChildCollection <TextBox>(this); List <AutoCompleteTextBox> listAutoCompleteTextBox = CustomerObject.GetLogicalChildCollection <AutoCompleteTextBox>(this); foreach (DsNhomCap nhomCap in lstNhomCap) { string group = ""; int soCap = listAutoCompleteTextBox.Where(t => t.Name.Contains("txtMaCap") && t.Tag.ToString().Equals(nhomCap.MaNhomCap)).Count(); List <AutoCompleteTextBox> subListTextBox = listAutoCompleteTextBox.Where(t => t.Tag.ToString().Equals(nhomCap.MaNhomCap)).ToList(); for (int i = 0; i < soCap; i++) { if (i > 0) { group += "^"; } string strTMaCap = subListTextBox.FirstOrDefault(t => t.Name.Equals("txtMaCap" + nhomCap.MaNhomCap + "_" + i) && t.Tag.ToString().Equals(nhomCap.MaNhomCap)).Text; string strCapNhomCapNSD = subListTextBox.FirstOrDefault(t => t.Name.Equals("txtCapNhomCapNSD" + nhomCap.MaNhomCap + "_" + i)).Text; if (!strCapNhomCapNSD.IsNullOrEmptyOrSpace()) { strCapNhomCapNSD = strCapNhomCapNSD.Trim().Replace(" ", ""); strCapNhomCapNSD = strCapNhomCapNSD.Substring(0, strCapNhomCapNSD.Length); } string strCapNhomCapNNSD = subListTextBox.FirstOrDefault(t => t.Name.Equals("txtCapNhomCapNNSD" + nhomCap.MaNhomCap + "_" + i)).Text; if (!strCapNhomCapNNSD.IsNullOrEmptyOrSpace()) { strCapNhomCapNNSD = strCapNhomCapNNSD.Trim().Replace(" ", ""); strCapNhomCapNNSD = strCapNhomCapNNSD.Substring(0, strCapNhomCapNNSD.Length); } group += strCapNhomCapNSD + ";" + strCapNhomCapNNSD + "@" + strTMaCap; } string strTu = listTextBox.FirstOrDefault(t => t.Name.Contains("txtTu") && t.Tag.ToString().Equals(nhomCap.MaNhomCap)).Text; string strDen = listTextBox.FirstOrDefault(t => t.Name.Contains("txtDen") && t.Tag.ToString().Equals(nhomCap.MaNhomCap)).Text; result += strTu + "-" + strDen + "(" + group + ")"; result += "#"; } if (!result.IsNullOrEmptyOrSpace()) { result = result.Substring(0, result.Length - 1); } return(result); }
private void ShowForm(string strMain) { string strNhomCap = ""; foreach (DsNhomCap nhomCap in lstNhomCap) { string tempNhomCap = nhomCap.StrGroupBox; string strCap = ""; if (!nhomCap.LstCap.IsNullOrEmpty() && nhomCap.LstCap.Count > 0) { foreach (string temCap in nhomCap.LstCap) { strCap += temCap; } } tempNhomCap = tempNhomCap.Replace("ControlContent", strCap); strNhomCap += tempNhomCap; } strMain = strMain.Replace("GroupBoxsContent", strNhomCap); XElement ui = XElement.Parse(strMain); UserControl uc = (System.Windows.Controls.UserControl)System.Windows.Markup.XamlReader.Load(ui.CreateReader()); CntContent.Content = uc; Dispatcher.CurrentDispatcher.DelayInvoke("InitSomething", () => { List <RibbonButton> listRibbonButton = CustomerObject.GetLogicalChildCollection <RibbonButton>(this); foreach (RibbonButton rbtn in listRibbonButton) { if (rbtn.Name.Contains("btnRemove")) { rbtn.Click += btnRemove_Click; } else if (rbtn.Name.Contains("btnAddContent")) { rbtn.Click += btnAddContent_Click; } else if (rbtn.Name.Contains("btnContentRemove")) { rbtn.Click += btnContentRemove_Click; } } List <AutoCompleteTextBox> listAutoCompleteTextBox = CustomerObject.GetLogicalChildCollection <AutoCompleteTextBox>(this); List <AutoCompleteTextBox> listNSD = listAutoCompleteTextBox.Where(t => t.Name.Contains("txtCapNhomCapNSD")).ToList(); List <AutoCompleteTextBox> listNNSD = listAutoCompleteTextBox.Where(t => t.Name.Contains("txtCapNhomCapNNSD")).ToList(); List <HT_NSD> dsNSD = qtht.layNSD(ClientInformation.LoaiNguoiSuDung); List <HT_NHNSD> dsNhomNSD = qtht.layNhomNSD(ClientInformation.LoaiNguoiSuDung); if (!dsNSD.IsNullOrEmpty() && dsNSD.Count > 0) { foreach (HT_NSD NSD in dsNSD) { foreach (AutoCompleteTextBox txt in listNSD) { txt.AddItem(new AutoCompleteEntry(NSD.MA_NSD, NSD.MA_NSD, NSD.TEN_GOI, NSD.TEN_HO_DEM)); } } } if (!dsNhomNSD.IsNullOrEmpty() && dsNhomNSD.Count > 0) { foreach (HT_NHNSD NhomNSD in dsNhomNSD) { foreach (AutoCompleteTextBox txt in listNNSD) { txt.AddItem(new AutoCompleteEntry(NhomNSD.MA_NHNSD, NhomNSD.MA_NHNSD, NhomNSD.TEN_NHNSD)); } } } EnabledRemoveButton(); }, TimeSpan.FromSeconds(0)); }