Ejemplo n.º 1
0
        public List <CheckListItemAndData> GetCheckListData(string Type, string WardID, string UserID, string ShiftID)
        {
            DataSet objDS = new DataSet();

            objDS = adminDL.GetCheckListData(Type, WardID, UserID, ShiftID);
            List <CheckListItemAndData> chkItemDataList = new List <CheckListItemAndData>();
            CheckListItemAndData        chkItemData     = null;
            int prevItemId = 0;

            if (objDS.Tables.Count > 0)
            {
                foreach (DataRow row in objDS.Tables[0].Rows)
                {
                    if (prevItemId != Convert.ToInt32(row[0]))
                    {
                        chkItemData                   = new CheckListItemAndData();
                        chkItemData.Options           = new List <CheckListOptions>();
                        prevItemId                    = Convert.ToInt32(row[0]);
                        chkItemData.CheckListItemId   = Convert.ToInt32(row[0]);
                        chkItemData.CheckListItemName = row[1].ToString();
                        chkItemData.ChecklistType     = row[2].ToString();
                        chkItemData.ControlType       = row[3].ToString();
                        if (objDS.Tables.Count > 1)
                        {
                            chkItemData.CheckListData = objDS.Tables[1].AsEnumerable().Where(f => f.Field <int>("CheckListItemId") == prevItemId).Select(m => new KeyValuePair()
                            {
                                Key   = m.Field <string>("CheckListDataID"),
                                Value = m.Field <string>("CheckListData")
                            }).ToList();
                        }



                        if (Convert.ToString(row[4]) != string.Empty)
                        {
                            chkItemData.Options = objDS.Tables[0].AsEnumerable().Where(f => f.Field <int>("CheckListItemId") == prevItemId).Select(m => new CheckListOptions()
                            {
                                CheckListOptionsID    = m.Field <int>("OptionsItemID").ToString(),
                                CheckListOptionsValue = m.Field <string>("OptionValue")
                            }).ToList();
                            // chkItemData.Options.Add(new KeyValuePair() { Key = Convert.ToString(row[4]), Value = Convert.ToString(row[5]) });
                        }

                        chkItemDataList.Add(chkItemData);
                    }
                }
            }
            return(chkItemDataList);
        }