protected void btn_getdetails_Click(object sender, EventArgs e) { try { vdm = new VehicleDBMgr(); DateTime fromdate = DateTime.Now; DateTime todate = DateTime.Now; string[] datestrig = txtdate.Text.Split(' '); if (datestrig.Length > 1) { if (datestrig[0].Split('-').Length > 0) { string[] dates = datestrig[0].Split('-'); string[] times = datestrig[1].Split(':'); fromdate = new DateTime(int.Parse(dates[2]), int.Parse(dates[1]), int.Parse(dates[0]), int.Parse(times[0]), int.Parse(times[1]), 0); } } string[] todatestrig = txttodate.Text.Split(' '); if (todatestrig.Length > 1) { if (todatestrig[0].Split('-').Length > 0) { string[] dates = todatestrig[0].Split('-'); string[] times = todatestrig[1].Split(':'); todate = new DateTime(int.Parse(dates[2]), int.Parse(dates[1]), int.Parse(dates[0]), int.Parse(times[0]), int.Parse(times[1]), 0); } } cmd = new MySqlCommand("SELECT dispatch.DispName,tripdata.AssignDate, tripdata.Sno AS ReturnDCno, empmanage.UserName, tripdata.VehicleNo FROM triproutes INNER JOIN dispatch ON triproutes.RouteID = dispatch.sno INNER JOIN tripdata ON triproutes.Tripdata_sno = tripdata.Sno INNER JOIN empmanage ON tripdata.EmpId = empmanage.Sno INNER JOIN branchdata ON dispatch.BranchID = branchdata.sno WHERE (tripdata.I_Date BETWEEN @d1 AND @d2) AND ((dispatch.BranchID = @BranchID) OR (branchdata.SalesOfficeID = @SOID))"); cmd.Parameters.AddWithValue("@BranchID", Session["branch"]); cmd.Parameters.AddWithValue("@SOID", Session["branch"]); cmd.Parameters.AddWithValue("@d1", GetLowDate(fromdate).AddDays(-1)); cmd.Parameters.AddWithValue("@d2", GetHighDate(todate).AddDays(-1)); dttripdata = vdm.SelectQuery(cmd).Tables[0]; if (dttripdata.Rows.Count == 0) { lbldateValidation.Text = "No DC Found Between These Dates "; } else { Gridtripdata.DataSource = dttripdata; Gridtripdata.DataBind(); } } catch (Exception ex) { lbldateValidation.Text = ex.Message; Gridtripdata.DataSource = dttripdata; Gridtripdata.DataBind(); } }
void getdet() { try { vdm = new VehicleDBMgr(); DateTime fromdate = DateTime.Now; DateTime todate = DateTime.Now; string[] datestrig = txtdate.Text.Split(' '); if (datestrig.Length > 1) { if (datestrig[0].Split('-').Length > 0) { string[] dates = datestrig[0].Split('-'); string[] times = datestrig[1].Split(':'); fromdate = new DateTime(int.Parse(dates[2]), int.Parse(dates[1]), int.Parse(dates[0]), int.Parse(times[0]), int.Parse(times[1]), 0); } } string[] todatestrig = txttodate.Text.Split(' '); if (todatestrig.Length > 1) { if (todatestrig[0].Split('-').Length > 0) { string[] dates = todatestrig[0].Split('-'); string[] times = todatestrig[1].Split(':'); todate = new DateTime(int.Parse(dates[2]), int.Parse(dates[1]), int.Parse(dates[0]), int.Parse(times[0]), int.Parse(times[1]), 0); } } cmd = new MySqlCommand("SELECT sno,gatepassno, doe, vehicleno, routename, partyname FROM gatepassdeatails WHERE (branchid = @BranchID) AND (doe BETWEEN @d1 AND @d2)"); cmd.Parameters.AddWithValue("@d1", GetLowDate(fromdate)); cmd.Parameters.AddWithValue("@d2", GetHighDate(todate)); cmd.Parameters.AddWithValue("@BranchID", Session["branch"]); DataTable dtGatePass = vdm.SelectQuery(cmd).Tables[0]; Gridtripdata.DataSource = dtGatePass; Gridtripdata.DataBind(); } catch { } }