protected void searchButton_Click(object sender, EventArgs e) { if (fromDateTextBox.Text == "" || toDateTextBox.Text == "") { outputLabel.Text = "Please Insert both Date"; outputLabel.ForeColor = System.Drawing.Color.Red; viewSellsGridView.DataBind(); } else { if (DateTime.Compare(Convert.ToDateTime(fromDateTextBox.Text), Convert.ToDateTime(toDateTextBox.Text)) > 0) { outputLabel.Text = "Give Proper Date"; } else { DateTime formDateTime = Convert.ToDateTime((fromDateTextBox.Text)); string formdatetimeone = formDateTime.ToString("yyyy-MM-dd"); DateTime toDateTime = Convert.ToDateTime(toDateTextBox.Text); string todatetimeone = toDateTime.ToString("yyyy-MM-dd"); viewSellsGridView.DataSource = viewSellManager.SearchByDate(formdatetimeone, todatetimeone, "sell"); viewSellsGridView.DataBind(); outputLabel.Text = String.Empty; } } }
protected void CompareDate(string fromDate, string Todate) { if (fromDate == "" && Todate == "") { ClientScript.RegisterStartupScript(this.GetType(), "Alert", "alert('Textbox can not be blank!')", true); return; } else if (fromDate == "" || Todate == "") { ClientScript.RegisterStartupScript(this.GetType(), "Alert", "alert('Please input your Date')", true); return; } else { string date1Day = fromDate.Substring(8); string date2Day = Todate.Substring(8); string date1Month = fromDate.Substring(5, 2); string date2Month = Todate.Substring(5, 2); string date1Year = fromDate.Remove(4); string date2Year = Todate.Remove(4); DateTime d1 = Convert.ToDateTime(date1Year + "/" + date1Month + "/" + date1Day); DateTime d2 = Convert.ToDateTime(date2Year + "/" + date2Month + "/" + date2Day); if (d1 > d2) { ClientScript.RegisterStartupScript(this.GetType(), "Alert", "alert('From Date must be less or equal To Date')", true); } else { // Search in database sell item // ViewSellManger viewSellManger = new ViewSellManger(); ViewSellManager viewSellManager = new ViewSellManager(); List <ViewSell> aviewSell = viewSellManager.SearchByDate(fromDate, Todate); if (aviewSell.Count > 0) { ViewState["Sales"] = aviewSell; SearchSellGridViewList.DataSource = aviewSell; SearchSellGridViewList.DataBind(); // pdfbuttonid.Visible = true; } //else //{ // LabelMessage.Visible = true; // LabelMessage.Text = "Sale Quantity Is Not Available"; // SearchSellGridViewList.DataSource = aviewSell; // SearchSellGridViewList.DataBind(); //} } } }