protected void Page_Load(object sender, EventArgs e) { HttpCookie cookie = Request.Cookies["LoginInfo"]; if (cookie == null) { Response.Redirect("~/Default.aspx"); } else if (cookie["IsStudent"] == "1") { Response.Redirect("~/TaskGeneration.aspx"); } else { if (cookie["IsStudent"] == "0" && ViewState["FirstTime"] == null) { MenuItem item = new MenuItem(); item.Value = "Редактирование"; item.NavigateUrl = "~/CheckYourselfEdit.aspx"; MainMenu0.Items[0].ChildItems[0].ChildItems.Add(item); ViewState["FirstTime"] = 1; } List <Student> students = model.Student.ToList(); ResultGridView.DataSource = students; ResultGridView.DataBind(); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Request["ReqId"] != null) { if (Request["ReqId"] != "") { string req_id = Request["ReqId"].ToString(); ItemDal dal = new ItemDal(); DataSet ds = dal.GetRequestStockById(req_id); if (ds != null && ds.Tables[0].Rows.Count > 0) { lbReqId.Text = req_id; ResultGridView.DataSource = ds.Tables[0]; ResultGridView.DataBind(); } } } } else { } }
protected void btnLinQ_Click(object sender, EventArgs e) { RequestDAL dal = new RequestDAL(); string dt = txtDt.Text; DataSet ds = dal.GetRequest(dt, null); if (ds != null && ds.Tables[0].Rows.Count > 0) { DataTable dataTB = ds.Tables[0]; var dataRow = dataTB.AsEnumerable().Where(x => x.Field <string>("REQUEST_ID") == txtSearch.Text); DataTable result = dataRow.CopyToDataTable <DataRow>(); if (result != null && result.Rows.Count > 0) { ResultGridView.DataSource = result; ResultGridView.DataBind(); } else { ResultGridView.DataSource = null; ResultGridView.DataBind(); } } }
public void GetAllStudentResult() { EnrollCourse _EnrollCourse = new EnrollCourse(); _EnrollCourse.DepartmentId = Convert.ToInt32(DepartmentsDropDownList.SelectedValue); _EnrollCourse.StudentRegNo = StudentsRegNoDropDownList.SelectedItem.ToString(); ResultGridView.DataSource = _ResultRepository.GetAllResult(_EnrollCourse.DepartmentId, _EnrollCourse.StudentRegNo); ResultGridView.DataBind(); }
private void FillGrid() { dataTable = new DataTable(); cmd.Connection = conn; cmd.CommandText = "SELECT Name,ProductNumber,Color,SafetyStockLevel,ReorderPoint,StandardCost,ListPrice FROM Production.Product"; ad = new SqlDataAdapter(cmd); ad.Fill(dataTable); ResultGridView.DataSource = dataTable; ResultGridView.DataBind(); ViewState["dirState"] = dataTable; ViewState["sortdr"] = "Asc"; }
private void DisplayRequest(string username) { RequestDAL dal = new RequestDAL(); List <RequestData> listresult = dal.GetRequest(username); if (listresult != null && listresult.Count > 0) { ResultGridView.DataSource = listresult; ResultGridView.DataBind(); } }
protected void Page_Load(object sender, EventArgs e) { if (Doctors?.Count > 0 && Patients?.Count > 0 && Visits?.Count > 0) { if (!IsPostBack && Session.Keys.OfType <string>().Contains("year")) { int year = Convert.ToInt32(Session["year"]); var dict = new Dictionary <int, DateTime>(); foreach (var visit in Visits) { if (visit.VisitDate.Year == year) { int id = visit.DoctorId; if (!dict.ContainsKey(id) || dict[id] > Patients[visit.PatientId].BirthDate) { dict[id] = Patients[visit.PatientId].BirthDate; } } } if (dict.Count > 0) { var resultList = new List <ResultItem>(); foreach (var item in dict) { resultList.Add(new ResultItem { Name = Doctors[item.Key].Name, Age = DateTime.Today.Year - item.Value.Year }); } ResultGridView.DataSource = resultList; ResultGridView.DataBind(); } else { Response.Write(@"<script>alert('No solution')</script>"); } } else { Response.Write(@"<script>alert('Undefined year')</script>"); } } else { Response.Write("<script>alert('Data are missing')</script>"); } }
/// <summary> /// we check if out lists and dictionaries are not empty, /// after that we check if values was chosen, convert then and go through dictionary /// if we found the right id, date and price we add deliveries to the sum /// after that we set the table with found values and count average of the deliveries /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Page_Load(object sender, EventArgs e) { if (Deliveries?.Count > 0 && Goods?.Count > 0) { if (!IsPostBack && Session.Keys.OfType <string>().Contains("id") && Session.Keys.OfType <string>().Contains("price")) { int sentId = Convert.ToInt32(Session["id"]); int price = Convert.ToInt32(Session["price"]); int sum = 0; int counter = 0; foreach (var el in Deliveries) { if (el.Id == sentId && el.Date.Year == 2020 && el.Date.Month > 6 && el.Price >= price) { sum += el.SizeDeliveries; counter++; } } if (counter > 0) { var resultList = new List <ResultItem>(); resultList.Add(new ResultItem { Id = sentId, Name = Goods[sentId].Name, Average = sum / counter }); ResultGridView.DataSource = resultList; ResultGridView.DataBind(); } else { Response.Write(@"<script>alert('No solution')</script>"); } } else { Response.Write(@"<script>alert('Undefined sentId')</script>"); } } else { Response.Write("<script>alert('Data are missing')</script>"); } }
protected void btnSearch_Click(object sender, EventArgs e) { string[] data_arr = new string[3]; data_arr[0] = txtSearch.Text; data_arr[1] = txtSearcjNameSubject.Text; data_arr[2] = txtDt.Text; RequestDAL dal = new RequestDAL(); List <RequestData> listResult = dal.GetRequest(data_arr); if (listResult != null && listResult.Count > 0) { ResultGridView.DataSource = listResult; ResultGridView.DataBind(); } }
protected void GridView1_Sorting(object sender, GridViewSortEventArgs e) { DataTable dtrslt = (DataTable)ViewState["dirState"]; if (dtrslt.Rows.Count > 0) { if (Convert.ToString(ViewState["sortdr"]) == "Asc") { dtrslt.DefaultView.Sort = e.SortExpression + " Desc"; ViewState["sortdr"] = "Desc"; } else { dtrslt.DefaultView.Sort = e.SortExpression + " Asc"; ViewState["sortdr"] = "Asc"; } ResultGridView.DataSource = dtrslt; ResultGridView.DataBind(); } }
protected void showButton_Click(object sender, EventArgs e) { string FromDate = fromDateTB.Text; string ToDate = toDateTB.Text; DateTime oDate = DateTime.Parse(FromDate); DateTime oDate2 = DateTime.Parse(ToDate); int Fday = oDate.Day; int Fmonth = oDate.Month; int Fyear = oDate.Year; int Tday = oDate2.Day; int Tmonth = oDate2.Month; int Tyear = oDate2.Year; string Fdate = Fyear + "-" + Fmonth + "-" + Fday; string Tdate = Tyear + "-" + Tmonth + "-" + Tday; ReportManager aManagera = new ReportManager(); List <testWReport> alist = aManagera.TestWiseResult(Fdate, Tdate); ResultGridView.DataSource = alist; ResultGridView.DataBind(); }