示例#1
0
        private void BindItemList(int itemTypeId, int subitemId, int Supplierid)
        {
            //try
            //{
            chkItemList.DataSource = null;
            IMasterList objItemlist = (IMasterList)ObjectFactory.CreateInstance("BusinessProcess.SCM.BMasterList,BusinessProcess.SCM");
            DataSet     theDS       = objItemlist.GetItemListSupplier(itemTypeId, subitemId, Supplierid);

            theItemListDT = theDS.Tables[0];
            theItemList   = theDS.Tables[1];
            BindFunctions theBind = new BindFunctions();

            //DataView theDV = new DataView(theItemList);
            //theDV.RowFilter = "ItemTypeID =" + Convert.ToInt32(ddlItemType.SelectedValue.ToString());

            theBind.Win_BindCheckListBox(chkItemList, theItemList, "ItemName", "ItemID");
            // theBind.Win_BindCheckListBox(chkItemList, theDV.ToTable(), "ItemName", "ItemID");
            //for (int i = 0; i < drglbItemList.Rows.Count; i++)
            //{
            //    if (drglbItemList.Rows[i]["MappedItem"].ToString() == "True")
            //    {
            //        this.chkItemList.SetItemChecked(i, true);
            //    }
            //}
            for (int i = 0; i < theItemListDT.Rows.Count; i++)
            {
                for (int j = 0; j < chkItemList.Items.Count; j++)
                {
                    if (Convert.ToInt32(theItemListDT.Rows[i]["ItemTypeID"]) == itemTypeId && Convert.ToInt32(theItemListDT.Rows[i]["ItemID"]) == Convert.ToInt32((((System.Data.DataRowView)(chkItemList.Items[j])).Row.ItemArray[0]).ToString()) && theItemListDT.Rows[i]["ItemName"].ToString() == chkItemList.GetItemText(chkItemList.Items[j]))
                    {
                        this.chkItemList.SetItemChecked(j, true);
                    }
                }
            }
            bool IsAllcheck = true;

            for (int i = 0; i < chkItemList.Items.Count; i++)
            {
                if (chkItemList.GetItemChecked(i) == false)
                {
                    IsAllcheck = false;
                    break;
                }
            }
            chkAll.Checked = IsAllcheck;

            if (chkItemList.Items.Count == 0)
            {
                chkAll.Checked = false;
            }
            //}
            //catch (Exception err)
            //{
            //    MsgBuilder theBuilder = new MsgBuilder();
            //    theBuilder.DataElements["MessageText"] = err.Message.ToString();
            //    IQCareWindowMsgBox.ShowWindowConfirm("#C1", theBuilder, this);
            //}
        }