خرید بک لینک

Vote count: 0

i use this code check date availability from the database and so i use one textbox which is linked to a datepicker ui and a dropdownlist to select time. the problem is if i select a date and fullday and if it is in database table already it shows date unavailable as its supposed to same for afteooon or forenoon for the same date. but when i select a date where either afteoon or forenoon is already booked it only blocks afteoon or forenoon respectively and if i select fullday for the same date it says date available and i tried to use if condition inside if condition to solve this but i dont know where im doing wrong please someone help me. thanks in advance. Sincerely

the front end code is as below

 <form id="form1" runat="server">
     <asp:ScriptManager ID="scriptmanager1" runat="server">
     </asp:ScriptManager>
     <div>
         <asp:UpdatePanel ID="PnlUsrDetails" runat="server">
             <ContentTemplate>
                 <table>
                     <tr>
                         <td>UserName:
                         </td>
                         <td>


                             <asp:TextBox ID="txtFunctionDate" runat="server" AutoPostBack="true" />
                             <asp:DropDownList AutoPostBack="true" ID="ddlFunctionTime" runat="server" OnSelectedIndexChanged="txtUseame_TextChanged">
                                 <asp:ListItem>--Select--</asp:ListItem>
                                 <asp:ListItem Value="Forenoon">Forenoon</asp:ListItem>
                                 <asp:ListItem Value="Afteoon">Afteoon</asp:ListItem>
                                 <asp:ListItem Value="FullDay">Full Day</asp:ListItem>

                             </asp:DropDownList>
                         </td>
                         <td>
                             <div id="checkdate" runat="server" visible="false">
                                 <asp:Image ID="imgstatus" runat="server" Width="17px" Height="17px" />
                                 <asp:Label ID="lblStatus" runat="server"></asp:Label>
                             </div>
                         </td>
                     </tr>
                 </table>
             </ContentTemplate>
         </asp:UpdatePanel>
     </div>
 </form>

the back end code is below

protected void txtUseame_TextChanged(object sender, EventArgs e)
    {

        if (!string.IsNullOrEmpty(ddlFunctionTime.Text))
        {
            string coString = ConfigurationManager.CoectionStrings["MandapamDatabase"].CoectionString;
            OleDbCoection coection = new OleDbCoection(coString)
            string selectQuery = "SELECT FunctionTime FROM function WHERE FunctionDate=@FunctionDate AND FunctionTime='FullDay'";
            coection.Open();
            OleDbCommand command = new OleDbCommand(selectQuery, coection);
            command.Coection = coection;
            command.CommandText = selectQuery;
            command.CommandType = CommandType.Text;
            command.Parameters.AddWithValue("@FunctionDate", txtFunctionDate.Text);
            command.Parameters.AddWithValue("@FunctionTime", ddlFunctionTime.Text);

            OleDbDataReader dr = command.ExecuteReader();
            if (dr.HasRows)
            {
                checkdate.Visible = true;
                imgstatus.ImageUrl = "NotAvailable.jpg";
                lblStatus.Text = "Date Unavailable";
                lblStatus.ForeColor = System.Drawing.Color.Red;
            }

            else if (!string.IsNullOrEmpty(ddlFunctionTime.Text))
            {
                string conString = ConfigurationManager.CoectionStrings["MandapamDatabase"].CoectionString;
                OleDbCoection co = new OleDbCoection(conString);
                string selectQuery1 = "SELECT FunctionTime FROM function WHERE FunctionDate=@FunctionDate AND FunctionTime=@FunctionTime";
                co.Open();
                OleDbCommand cmd = new OleDbCommand(selectQuery1, co);
                cmd.Coection = coection;
                cmd.CommandText = selectQuery1;
                cmd.CommandType = CommandType.Text;
                cmd.Parameters.AddWithValue("@FunctionDate", txtFunctionDate.Text);
                cmd.Parameters.AddWithValue("@FunctionTime", ddlFunctionTime.Text);
                OleDbDataReader dr1 = cmd.ExecuteReader();
                if (dr1.HasRows)
                {
                    if(ddlFunctionTime.SelectedItem.Value == "FullDay")
                    {
                        checkdate.Visible = true;
                        imgstatus.ImageUrl = "NotAvailable.jpg";
                        lblStatus.Text = "Date Unavailable";
                    }
                    else
                    {
                        checkdate.Visible = true;
                        imgstatus.ImageUrl = "NotAvailable.jpg";
                        lblStatus.Text = "Date Unavailable";
                    }
                }

                else
                {
                    checkdate.Visible = true;
                    imgstatus.ImageUrl = "Icon_Available.gif";
                    lblStatus.Text = "Date Available";
                }
            }
            else
            {
                checkdate.Visible = false;
            }
        }


    }

asked 40 secs ago

برچسب: نویسنده: استخدام کار تاريخ: جمعه 1 مرداد 1395 ساعت: 15:03

صفحه بندی