public static string GetCheckList(CheckedListBoxControl oCheckedListBoxControl) { string SelectValues = ""; for (int i = 0; i < oCheckedListBoxControl.ItemCount; i++) { if (oCheckedListBoxControl.GetItemChecked(i)) { SelectValues += oCheckedListBoxControl.GetItemValue(i).ToString() + ","; } } return(SelectValues); }
string GetCheckedListBoxChecked(CheckedListBoxControl chkControl) { string strCollected = string.Empty; for (int i = 0; i < chkControl.Items.Count; i++) { if (chkControl.GetItemChecked(i)) { if (strCollected == string.Empty) { strCollected = chkControl.GetItemValue(i).ToString(); } else { strCollected = strCollected + "," + chkControl.GetItemValue(i); } } } return(strCollected); }
/// <summary> /// 返回选中的集合 /// </summary> /// <returns></returns> public static List <string> ToList(this CheckedListBoxControl control) { List <string> list = new List <string>(); foreach (var index in control.CheckedIndices) { var listItem = control.GetItemValue(index) as CListItem; if (listItem != null) { list.Add(listItem.Value); } } return(list); }
void SetCheckedListBoxChecked(CheckedListBoxControl chkControl, string strCollected) { if (strCollected == null) { return; } string[] array = strCollected.Split(','); for (int i = 0; i < chkControl.Items.Count; i++) { string val = chkControl.GetItemValue(i).ToString(); if (array.Contains(val)) { chkControl.SetItemChecked(i, true); } else { chkControl.SetItemChecked(i, false); } } }
private void CreateTabPageLine(string CusID = "", string CategoryID = "", string StyleID = "") { //gcCapacity.DataSource = null; tabBranch.TabPages.Clear(); if (CusID != "" && CategoryID != "") { StringBuilder sbSQL = new StringBuilder(); sbSQL.Append("SELECT DISTINCT B.Branch, B.OIDBranch AS ID "); sbSQL.Append("FROM ProductionLine AS PL INNER JOIN "); sbSQL.Append(" Branch AS B ON PL.Branch = B.OIDBranch "); sbSQL.Append("WHERE (PL.OIDCUST = '" + CusID + "') AND(PL.OIDCATEGORY = '" + CategoryID + "') "); sbSQL.Append("ORDER BY B.OIDBranch "); DataTable dtBranch = new DBQuery(sbSQL).getDataTable(); int BCount = new DBQuery(sbSQL).getCount(); foreach (DataRow drRow in dtBranch.Rows) { DevExpress.XtraTab.XtraTabPage tabPage = new DevExpress.XtraTab.XtraTabPage(); tabPage.Name = "B" + drRow["ID"].ToString(); tabPage.Text = drRow["Branch"].ToString(); CheckedListBoxControl clbLine = new CheckedListBoxControl(); clbLine.Name = "LN" + drRow["ID"].ToString(); tabPage.Controls.Add(clbLine); clbLine.Dock = DockStyle.Fill; StringBuilder sbLINE = new StringBuilder(); sbLINE.Append("SELECT LN.LINENAME AS LineName, LN.OIDLINE AS LineID, LN.Branch AS BranchID "); sbLINE.Append("FROM ProductionLine AS PL INNER JOIN "); sbLINE.Append(" LineNumber AS LN ON PL.OIDLine = LN.OIDLINE "); sbLINE.Append("WHERE (PL.OIDCUST = '" + CusID + "') AND(PL.OIDCATEGORY = '" + CategoryID + "') AND(PL.Branch = '" + drRow["ID"].ToString() + "') "); sbLINE.Append("ORDER By LN.LINENAME "); DataTable dtLINE = new DBQuery(sbLINE).getDataTable(); clbLine.ValueMember = "LineName"; clbLine.DisplayMember = "LineName"; clbLine.DataSource = dtLINE; StringBuilder sbCapacity = new StringBuilder(); sbCapacity.Append("SELECT DISTINCT LINEID AS LineName "); sbCapacity.Append("FROM ProductionCapacityLine "); sbCapacity.Append("WHERE(OIDCAP IN "); sbCapacity.Append(" (SELECT OIDPCAP "); sbCapacity.Append(" FROM ProductionCapacity "); sbCapacity.Append(" WHERE (OIDCUST = '" + CusID + "') AND (OIDGCATEGORY = '" + CategoryID + "'))) AND (OIDBranch = '" + drRow["ID"].ToString() + "') "); DataTable dtQC = new DBQuery(sbCapacity).getDataTable(); foreach (DataRow row in dtQC.Rows) { for (int i = 0; i < clbLine.ItemCount; i++) { if (row["LineName"].ToString() == clbLine.GetItemValue(i).ToString()) { clbLine.SetItemCheckState(i, CheckState.Checked); break; } } } tabBranch.TabPages.Add(tabPage); tabBranch.ResumeLayout(false); tabBranch.LayoutChanged(); } sbSQL.Clear(); sbSQL.Append("SELECT PC.OIDPCAP AS CapacityID, PC.OIDCUST AS CustomerID, CUS.ShortName AS CustomerName, PC.OIDGCATEGORY AS CategoryID, GC.CategoryName, PC.OIDSTYLE AS StyleID, PS.StyleName, PC.QTYPerHour, PC.QTYPerDay, "); sbSQL.Append(" PC.QTYPerOT, FORMAT(PC.STDTimeCUT, '###0.####') AS StandardTimeCutting, FORMAT(PC.STDTimePAD, '###0.####') AS StandardTimePadPrint, FORMAT(PC.STDTimeSEW, '###0.####') AS StandardTimeSewing, FORMAT(PC.STDTimePACK, '###0.####') AS StandardTimePacking, FORMAT(PC.STDTime, '###0.####') AS StandardTime, "); sbSQL.Append(" PC.ProductionStartDate, PC.CreatedBy, PC.CreatedDate "); sbSQL.Append("FROM ProductionCapacity AS PC INNER JOIN "); sbSQL.Append(" Customer AS CUS ON PC.OIDCUST = CUS.OIDCUST INNER JOIN "); sbSQL.Append(" ProductStyle AS PS ON PC.OIDSTYLE = PS.OIDSTYLE INNER JOIN "); sbSQL.Append(" GarmentCategory AS GC ON PC.OIDGCATEGORY = GC.OIDGCATEGORY "); sbSQL.Append("WHERE (PC.OIDCUST = '" + CusID + "') "); if (CusID != "") { sbSQL.Append("AND (PC.OIDGCATEGORY = '" + CategoryID + "') "); } if (StyleID != "") { sbSQL.Append("AND (PC.OIDSTYLE = '" + StyleID + "') "); } sbSQL.Append("ORDER BY CapacityID "); new ObjDevEx.setGridControl(gcCapacity, gvCapacity, sbSQL).getData(false, false, false, true); } }