private void LoadData() { if ((cmbDay.Text == "" || cmbDay.Text == "-Select-") && cmbYear.Text == "-Select-" && cmbMonth.Text != "-Select-" && lblGetAssemblyTypeId.Text != null) // search from month { DataSet ds = VehicleOrderRepository.GetVPCStorageByMonth(Convert.ToInt32(cmbMonth.Value), Convert.ToInt32(lblGetAssemblyTypeId.Value)); grid.DataSource = null; grid.DataSourceID = null; grid.DataSource = ds.Tables[0]; Session["GridData"] = ds.Tables[0]; grid.DataBind(); } else if ((cmbDay.Text == "" || cmbDay.Text == "-Select-") && cmbYear.Text != "-Select-" && cmbMonth.Text != "-Select-" && lblGetAssemblyTypeId.Text != null) // search from month and year { DataSet ds = VehicleOrderRepository.GetVPCStorageByMonthYear(Convert.ToInt32(cmbYear.Text), Convert.ToInt32(cmbMonth.Value), Convert.ToInt32(lblGetAssemblyTypeId.Value)); grid.DataSource = null; grid.DataSourceID = null; grid.DataSource = ds.Tables[0]; Session["GridData"] = ds.Tables[0]; grid.DataBind(); } else if ((cmbDay.Text == "" || cmbDay.Text == "-Select-") && cmbYear.Text != "-Select-" && cmbMonth.Text == "-Select-" && lblGetAssemblyTypeId.Text != null) // search from year { DataSet ds = VehicleOrderRepository.GetVPCStorageByYear(Convert.ToInt32(cmbYear.Text), Convert.ToInt32(lblGetAssemblyTypeId.Value)); grid.DataSource = null; grid.DataSourceID = null; grid.DataSource = ds.Tables[0]; Session["GridData"] = ds.Tables[0]; grid.DataBind(); } else if (!string.IsNullOrEmpty(cmbDay.Text) || cmbDay.Text != "-Select-" && lblGetAssemblyTypeId.Text != null) // search from date { if (cmbDay.Text == "") { DataSet ds = VehicleOrderRepository.GetVPCStorageForLoadGrid(Convert.ToInt32(lblGetAssemblyTypeId.Value)); grid.DataSource = null; grid.DataSourceID = null; grid.DataSource = ds.Tables[0]; Session["GridData"] = ds.Tables[0]; grid.DataBind(); } else { if (cmbYear.Text == "-Select-" && lblGetAssemblyTypeId.Text != null) { DataSet ds = VehicleOrderRepository.GetVPCStorageByDay(cmbDay.Text, Convert.ToInt32(lblGetAssemblyTypeId.Value)); grid.DataSource = null; grid.DataSourceID = null; grid.DataSource = ds.Tables[0]; Session["GridData"] = ds.Tables[0]; grid.DataBind(); } else { DataSet ds = VehicleOrderRepository.GetVPCStorageByDayYear(Convert.ToInt32(cmbYear.Text), cmbDay.Text, Convert.ToInt32(lblGetAssemblyTypeId.Value)); grid.DataSource = null; grid.DataSourceID = null; grid.DataSource = ds.Tables[0]; Session["GridData"] = ds.Tables[0]; grid.DataBind(); } } } else { grid.DataSourceID = null; grid.DataSource = SqlDataSource1; Session["GridData"] = SqlDataSource1; grid.DataBind(); } if (Session["cmbMonth"] != null) { cmbMonth.Value = Session["cmbMonth"].ToString(); } if (Session["cmbYear"] != null) { cmbYear.Text = Session["cmbYear"].ToString(); } if (Session["cmbDay"] != null) { cmbDay.Text = Session["cmbDay"].ToString(); } }
protected void Page_Load(object sender, EventArgs e) { lblGetAssemblyTypeId.Value = Session["assemblyType"].ToInt32(0); int assemblyTypeId = Session["assemblyType"].ToInt32(0); string month = DateTime.Today.Month.ToString(); if (month.Count() == 1) { month = "0" + month; } string earlymonth = DateTime.Today.Year.ToString() + "-" + month + "-01"; if (!IsCallback && !IsPostBack) { int start = grid.PageIndex * grid.SettingsPager.PageSize; int end = (grid.PageIndex + 1) * grid.SettingsPager.PageSize; GridViewDataColumn column1 = grid.Columns["CategoryName"] as GridViewDataColumn; GridViewDataColumn column2 = grid.Columns["Description"] as GridViewDataColumn; for (int i = start; i < end; i++) { ASPxTextBox txtBox1 = (ASPxTextBox)grid.FindRowCellTemplateControl(i, column1, "txtBox"); ASPxTextBox txtBox2 = (ASPxTextBox)grid.FindRowCellTemplateControl(i, column2, "txtBox"); if (txtBox1 == null || txtBox2 == null) { continue; } int id = Convert.ToInt32(grid.GetRowValues(i, grid.KeyFieldName)); } GetYear(); GetMonth(); Session["OriSqlCommand"] = SqlDataSource1.SelectCommand; BindGrid(" Where A.ProdOutDate BETWEEN '" + earlymonth + "' and EOMONTH('" + earlymonth + "') and A.AssemblyTypeId = " + assemblyTypeId + " and A.isCKD = 1 order by ProdOutDate asc"); } else { if ((cmbDay.Text == "" || cmbDay.Text == "-Select-") && cmbYear.Text == "-Select-" && cmbMonth.Text != "-Select-" && lblGetAssemblyTypeId.Text != null) // search from month { DataSet ds = VehicleOrderRepository.GetVPCStorageByMonth(Convert.ToInt32(cmbMonth.Value), Convert.ToInt32(lblGetAssemblyTypeId.Value)); grid.DataSource = null; grid.DataSourceID = null; grid.DataSource = ds.Tables[0]; Session["GridData"] = ds.Tables[0]; grid.DataBind(); } else if ((cmbDay.Text == "" || cmbDay.Text == "-Select-") && cmbYear.Text != "-Select-" && cmbMonth.Text != "-Select-" && lblGetAssemblyTypeId.Text != null) // search from month and year { DataSet ds = VehicleOrderRepository.GetVPCStorageByMonthYear(Convert.ToInt32(cmbYear.Text), Convert.ToInt32(cmbMonth.Value), Convert.ToInt32(lblGetAssemblyTypeId.Value)); grid.DataSource = null; grid.DataSourceID = null; grid.DataSource = ds.Tables[0]; Session["GridData"] = ds.Tables[0]; grid.DataBind(); } else if ((cmbDay.Text == "" || cmbDay.Text == "-Select-") && cmbYear.Text != "-Select-" && cmbMonth.Text == "-Select-" && lblGetAssemblyTypeId.Text != null) // search from year { DataSet ds = VehicleOrderRepository.GetVPCStorageByYear(Convert.ToInt32(cmbYear.Text), Convert.ToInt32(lblGetAssemblyTypeId.Value)); grid.DataSource = null; grid.DataSourceID = null; grid.DataSource = ds.Tables[0]; Session["GridData"] = ds.Tables[0]; grid.DataBind(); } else if (!string.IsNullOrEmpty(cmbDay.Text) || cmbDay.Text != "-Select-" && lblGetAssemblyTypeId.Text != null) // search from date { if (cmbDay.Text == "") { DataSet ds = VehicleOrderRepository.GetVPCStorageForLoadGrid(Convert.ToInt32(lblGetAssemblyTypeId.Value)); grid.DataSource = null; grid.DataSourceID = null; grid.DataSource = ds.Tables[0]; Session["GridData"] = ds.Tables[0]; grid.DataBind(); } else { if (cmbYear.Text == "-Select-" && lblGetAssemblyTypeId.Text != null) { DataSet ds = VehicleOrderRepository.GetVPCStorageByDay(cmbDay.Text, Convert.ToInt32(lblGetAssemblyTypeId.Value)); grid.DataSource = null; grid.DataSourceID = null; grid.DataSource = ds.Tables[0]; Session["GridData"] = ds.Tables[0]; grid.DataBind(); } else { DataSet ds = VehicleOrderRepository.GetVPCStorageByDayYear(Convert.ToInt32(cmbYear.Text), cmbDay.Text, Convert.ToInt32(lblGetAssemblyTypeId.Value)); grid.DataSource = null; grid.DataSourceID = null; grid.DataSource = ds.Tables[0]; Session["GridData"] = ds.Tables[0]; grid.DataBind(); } } } else { Session["OriSqlCommand"] = SqlDataSource1.SelectCommand; BindGrid(" Where A.ProdOutDate BETWEEN '" + earlymonth + "' and EOMONTH('" + earlymonth + "') and A.AssemblyTypeId = " + assemblyTypeId + " and A.isCKD = 1 order by ProdOutDate asc"); } } }
protected void btnRefresh_Click(object sender, EventArgs e) { if ((cmbDay.Text == "" || cmbDay.Text == "-Select-") && cmbYear.Text == "-Select-" && cmbMonth.Text != "-Select-" && lblGetAssemblyTypeId.Text != null) // search from month { DataSet ds = VehicleOrderRepository.GetVPCStorageByMonth(Convert.ToInt32(cmbMonth.Value), Convert.ToInt32(lblGetAssemblyTypeId.Value)); grid.DataSource = null; grid.DataSourceID = null; grid.DataSource = ds.Tables[0]; Session["GridData"] = ds.Tables[0]; grid.DataBind(); } else if ((cmbDay.Text == "" || cmbDay.Text == "-Select-") && cmbYear.Text != "-Select-" && cmbMonth.Text != "-Select-" && lblGetAssemblyTypeId.Text != null) // search from month and year { DataSet ds = VehicleOrderRepository.GetVPCStorageByMonthYear(Convert.ToInt32(cmbYear.Text), Convert.ToInt32(cmbMonth.Value), Convert.ToInt32(lblGetAssemblyTypeId.Value)); grid.DataSource = null; grid.DataSourceID = null; grid.DataSource = ds.Tables[0]; Session["GridData"] = ds.Tables[0]; grid.DataBind(); } else if ((cmbDay.Text == "" || cmbDay.Text == "-Select-") && cmbYear.Text != "-Select-" && cmbMonth.Text == "-Select-" && lblGetAssemblyTypeId.Text != null) // search from year { DataSet ds = VehicleOrderRepository.GetVPCStorageByYear(Convert.ToInt32(cmbYear.Text), Convert.ToInt32(lblGetAssemblyTypeId.Value)); grid.DataSource = null; grid.DataSourceID = null; grid.DataSource = ds.Tables[0]; Session["GridData"] = ds.Tables[0]; grid.DataBind(); } else if (!string.IsNullOrEmpty(cmbDay.Text) || cmbDay.Text != "-Select-" && lblGetAssemblyTypeId.Text != null) // search from date { if (cmbDay.Text == "") { grid.DataSourceID = null; grid.DataSource = SqlDataSource1; Session["GridData"] = SqlDataSource1; grid.DataBind(); } else { if (cmbYear.Text == "-Select-" && lblGetAssemblyTypeId.Text != null) { DataSet ds = VehicleOrderRepository.GetVPCStorageByDay(cmbDay.Text, Convert.ToInt32(lblGetAssemblyTypeId.Value)); grid.DataSource = null; grid.DataSourceID = null; grid.DataSource = ds.Tables[0]; Session["GridData"] = ds.Tables[0]; grid.DataBind(); } else { DataSet ds = VehicleOrderRepository.GetVPCStorageByDayYear(Convert.ToInt32(cmbYear.Text), cmbDay.Text, Convert.ToInt32(lblGetAssemblyTypeId.Value)); grid.DataSource = null; grid.DataSourceID = null; grid.DataSource = ds.Tables[0]; Session["GridData"] = ds.Tables[0]; grid.DataBind(); } } } else { grid.DataSourceID = null; grid.DataSource = SqlDataSource1; Session["GridData"] = SqlDataSource1; grid.DataBind(); } }