当前位置: 首页>>代码示例>>C#>>正文


C# DataRow.Where方法代码示例

本文整理汇总了C#中DataRow.Where方法的典型用法代码示例。如果您正苦于以下问题:C# DataRow.Where方法的具体用法?C# DataRow.Where怎么用?C# DataRow.Where使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DataRow的用法示例。


在下文中一共展示了DataRow.Where方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetSeatLayout


//.........这里部分代码省略.........

                                //check if bus has different seat layouts. If so, do not float seats right
                                if (maxLength == 2 && maxWidth == 2)
                                    sbSeatLayout.Append("<tr><td>");
                                else
                                    sbSeatLayout.Append("<tr><td style=\"float: right\">");

                                sbSeatLayout.Append("<ul class=\"seat_map\">");

                                #region loop array and add seats

                                foreach (DataRow dr in drArray)
                                {
                                    #region Set seat type seat/sleeper_v/sleeper_h

                                    /******* HARD CODED SEATTYPE FOR TESTING *********/
                                    if (dr["Seat"].ToString() != String.Empty)
                                    {

                                        if (seatType.ToString().ToLower().Contains("sleeper") && !seatType.ToString().ToLower().Contains("semi"))
                                        {
                                            strSeatType = "Sleeper";
                                            strSeatCssSuffix = "sleeper";
                                        }
                                        else
                                        {
                                            strSeatType = "Seat";
                                            strSeatCssSuffix = "seat";
                                        }

                                    }

                                    #endregion

                                    //Check if datarow has empty seats, if so add empty spaces
                                    if (dr["Seat"] != null && dr["Seat"].ToString() != String.Empty)
                                    {
                                        //set appropriate class based on seat availability
                                        if (dr["SeatStatus"].ToString().ToUpper() == "FALSE")
                                        {
                                            if (dr["IsBookedByFemale"].ToString().ToUpper() == "TRUE")
                                                sbSeatLayout.Append("<li id=\"li" + dr["Seat"].ToString().Replace("(", String.Empty).Replace(")", String.Empty).Replace(" ", String.Empty) + "\" class=\"availableladies_" + strSeatCssSuffix + "\" title=\" Booked - " + dr["Seat"].ToString() + " \"+ ");
                                            else
                                                sbSeatLayout.Append("<li id=\"li" + dr["Seat"].ToString() + "\" class=\"booked_" + strSeatCssSuffix + "\" title=\" Booked - " + dr["Seat"].ToString() + " \"+  > ");
                                        }
                                        else
                                        {
                                            if (dr["IsBookedByFemale"].ToString().ToUpper() == "TRUE")
                                                sbSeatLayout.Append("<li id=\"li" + dr["Seat"].ToString().Replace("(", String.Empty).Replace(")", String.Empty).Replace(" ", String.Empty) + "\" class=\"availableladies_" + strSeatCssSuffix + "\" ");
                                            else
                                                sbSeatLayout.Append("<li id=\"li" + dr["Seat"].ToString().Replace("(", String.Empty).Replace(")", String.Empty).Replace(" ", String.Empty) + "\" class=\"available_" + strSeatCssSuffix + "\" ");

                                            if (dr["IsReservedForFemale"].ToString().ToUpper() == "TRUE")
                                                sbSeatLayout.Append("onclick=\"doUndoSelect('" + dr["Seat"].ToString() + "', '" + dr["Fare"].ToString() + "," + strSeatType + ",1', 'available')\" ");
                                            else
                                                sbSeatLayout.Append("onclick=\"doUndoSelect('" + dr["Seat"].ToString() + "', '" + dr["Fare"].ToString() + "," + strSeatType + ",0', 'available')\" ");

                                            sbSeatLayout.Append("onmouseout=\"closePanel('seat_info');\" ");
                                            sbSeatLayout.Append("onmouseover=\"showPanel(event,'seat_info','" + dr["Seat"].ToString() + "," + dr["Fare"].ToString() + "," + strSeatType + "');\">");

                                            //sb.Append("<a href='#' id='seat" + dr["Seat"].ToString() + "'>" + dr["Seat"].ToString() + "</a></li>");
                                        }

                                        //Seat number is properly displayed in Chrome and Firefox except IE.
                                        //check with designer. If it doesn't work, uncomment below line and comment the line next to it.
                                        //sbSeatLayout.Append("<a id='seat" + dr["Seat"].ToString() + "'>"+ "&nbsp;" +"</a></li>");
                                        sbSeatLayout.Append("<a id='seat" + dr["Seat"].ToString() + "'>" + "" + "</a></li>");

                                        sbSeatLayout.Append("<input id=\"isSelected" + dr["Seat"].ToString().Replace("(", String.Empty).Replace(")", String.Empty).Replace(" ", String.Empty) + "\" type=\"hidden\" name=\"isSelected" + dr["Seat"].ToString().Replace("(", String.Empty).Replace(")", String.Empty) + "\" />");
                                        //sbSeatLayout.Append("<input id=\"isSelectedRet" + dr["Seat"].ToString().Replace("(", String.Empty).Replace(")", String.Empty).Replace(" ", String.Empty) + "\" type=\"hidden\" name=\"isSelectedRet" + dr["Seat"].ToString().Replace("(", String.Empty).Replace(")", String.Empty) + "\" />");
                                        //sbSeatLayout.Append("<input id=\"isSelected" + dr["Seat"].ToString() + "\" type=\"hidden\" name=\"isSelected\"/>");
                                    }
                                    else
                                    {
                                        //check if drArray has no seats. If so, add li element to create walking bay
                                        if (drArray.Where(p => p.RowState == DataRowState.Detached).Count() == drArray.Count())
                                            sbSeatLayout.Append("<li>&nbsp;</li>");
                                    }
                                }

                                #endregion

                                sbSeatLayout.Append("</ul>");
                                sbSeatLayout.Append("</<td></tr>");
                            }
                            sbSeatLayout.Append("</table></div>");
                        }

                        sbSeatLayout.Append("</<td></tr></table>");
                    }
                }

            }
        }
        catch (Exception)
        {
            // only for development purpose
        }
        return sbSeatLayout.ToString();
    }
开发者ID:srisai339,项目名称:LoveJourney_Working,代码行数:101,代码来源:ShowTrips.aspx.cs

示例2: GetSeatLayout


//.........这里部分代码省略.........
                                    strSeatType = "Seat";
                                    strSeatCssSuffix = "seat";

                                    image = "images1/desc.png";
                                }
                                else if (int.Parse(dr["width"].ToString()) == 2)
                                {
                                    strSeatType = "Sleeper_v";
                                    strSeatCssSuffix = "sleeper_v";
                                    image = "images1/desc2.png";
                                }
                                else if (int.Parse(dr["length"].ToString()) == 2)
                                {
                                    strSeatType = "Sleeper_h";
                                    strSeatCssSuffix = "sleeper_h";
                                }
                            }
                            Session["RedbusSeattype"] = strSeatType;

                            #endregion

                            //Check if datarow has empty seats, if so add empty spaces
                            if (dr["available"] != null && dr["available"].ToString() != String.Empty)
                            {
                                //set appropriate class based on seat availability
                                if (dr["available"].ToString().ToUpper() == "FALSE")
                                {
                                    // if (dr["ladiesSeat"].ToString().ToUpper() == "TRUE")
                                    //  sbSeatLayout.Append("<li id=\"li" + dr["name"].ToString().Replace("(", String.Empty).Replace(")", String.Empty).Replace(" ", String.Empty) + "\" class=\"availableladies_" + strSeatCssSuffix + "\" ");

                                    // else
                                    sbSeatLayout.Append("<li id=\"li" + dr["name"].ToString() + "\" class=\"booked_" + strSeatCssSuffix + "\" title='Booked'> ");

                                    // sbSeatLayout.Append("onclick=\"doUndoSelect('" + dr["name"].ToString() + "', '" + dr["fare"].ToString() + "," + strSeatType + ",0', 'available')\" ");
                                    // sbSeatLayout.Append("onmouseout=\"fnClosePanel('seat_info');\" ");
                                    // sbSeatLayout.Append("onmouseover=\"fnShowPanel(event,'seat_info','" + dr["name"].ToString() + "," + dr["fare"].ToString() + "," + strSeatType + "');\">");
                                }
                                else
                                {
                                    if (dr["ladiesSeat"].ToString().ToUpper() == "TRUE")
                                    {
                                        sbSeatLayout.Append("<li id=\"li" + dr["name"].ToString().Replace("(", String.Empty).Replace(")", String.Empty).Replace(" ", String.Empty) + "\" class=\"availableladies_" + strSeatCssSuffix + "\" ");
                                        string seatname = "";
                                        if (Session["RedBusSeats"] == null)
                                        {
                                            seatname = dr["name"].ToString();
                                            Session["RedBusSeats"] = seatname;
                                        }
                                        else
                                        {
                                            Session["RedBusSeats"] = Session["RedBusSeats"].ToString() + "," + dr["name"].ToString();
                                        }

                                    }
                                    else
                                    {
                                        sbSeatLayout.Append("<li id=\"li" + dr["name"].ToString().Replace("(", String.Empty).Replace(")", String.Empty).Replace(" ", String.Empty) + "\" class=\"available_" + strSeatCssSuffix + "\" ");
                                    }

                                    sbSeatLayout.Append("onclick=\"doUndoSelect('" + dr["name"].ToString() + "', '" + dr["fare"].ToString() + "," + strSeatType + ",0', 'available')\" ");
                                    sbSeatLayout.Append("onmouseout=\"fnClosePanel('seat_info');\" ");
                                    sbSeatLayout.Append("onmouseover=title='" + strSeatType + ":" + dr["name"].ToString() + ":" + dr["fare"].ToString() + "' \"fnShowPanel1(event,'seat_info','" + dr["name"].ToString() + "," + dr["fare"].ToString() + "," + strSeatType + "');\">");
                                    //sb.Append("<a href='#' id='seat" + dr["Seat"].ToString() + "'>" + dr["Seat"].ToString() + "</a></li>");
                                }

                                //Seat number is properly displayed in Chrome and Firefox except IE.
                                //check with designer. If it doesn't work, uncomment below line and comment the line next to it.
                                //sbSeatLayout.Append("<a id='seat" + dr["Seat"].ToString() + "'>"+ "&nbsp;" +"</a></li>");
                                sbSeatLayout.Append("<a id='seat" + dr["name"].ToString() + "'>" + "" + "</a></li>");

                                sbSeatLayout.Append("<input id=\"isSelected" + dr["name"].ToString().Replace("(", String.Empty).Replace(")", String.Empty).Replace(" ", String.Empty) + "\" type=\"hidden\" name=\"isSelected" + dr["name"].ToString().Replace("(", String.Empty).Replace(")", String.Empty) + "\" />");
                                sbSeatLayout.Append("<input id=\"isSelectedRet" + dr["name"].ToString().Replace("(", String.Empty).Replace(")", String.Empty).Replace(" ", String.Empty) + "\" type=\"hidden\" name=\"isSelectedRet" + dr["name"].ToString().Replace("(", String.Empty).Replace(")", String.Empty) + "\" />");
                                //sbSeatLayout.Append("<input id=\"isSelected" + dr["Seat"].ToString() + "\" type=\"hidden\" name=\"isSelected\"/>");
                            }
                            else
                            {
                                //check if drArray has no seats. If so, add li element to create walking bay
                                if (drArray.Where(p => p.RowState == DataRowState.Detached).Count() == drArray.Count())
                                    sbSeatLayout.Append("<li>&nbsp;</li>");
                            }
                        }

                        #endregion

                        sbSeatLayout.Append("</ul>");
                        sbSeatLayout.Append("</<td></tr>");

                    }
                    sbSeatLayout.Append("</table></div>");
                }

                sbSeatLayout.Append("</<td></tr></table>");
            }
        }
        catch (Exception ex)
        {
            // only for development purpose
        }
        return sbSeatLayout.ToString();
    }
开发者ID:srisai339,项目名称:LoveJourney_Working,代码行数:101,代码来源:BusService.cs


注:本文中的DataRow.Where方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。