protected void Page_Load(object sender, EventArgs e) { var db = new DCDataContext(); var res = db.ExecuteQuery(typeof(string), "SELECT FirstName + ' ' + SUBSTRING(LastName,1,1) + '. ' + SUBSTRING(Patronymic,1,1) + '.' FROM Employee", new object[0]); ListBox1.DataSource = res; ListBox1.DataBind(); }
protected void Button1_Click(object sender, EventArgs e) { var db = new DCDataContext(); var res = db.Employee.Where(a => a.Address.Contains(TextBox1.Text)); GridView1.DataSource = res; GridView1.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { var db = new DCDataContext(); var res = db.ExecuteQuery(typeof(string), "SELECT UPPER ( FirstName) FROM Employee", new object[0]); ListBox1.DataSource = res; ListBox1.DataBind(); }
protected void DeleteLB_Click(object sender, EventArgs e) { var db = new DCDataContext(); var empP = db.EmployeeProject.Single(a => a.Id == (int)DetailsView1.SelectedValue); db.EmployeeProject.DeleteOnSubmit(empP); db.SubmitChanges(); Response.Redirect("EmployeesProjects.aspx"); }
protected void Button1_Click(object sender, EventArgs e) { var db = new DCDataContext(); var arr = chars.Where(q => q >= startDDL.SelectedValue.ToCharArray()[0] && q <= endDDL.SelectedValue.ToCharArray()[0]).ToArray(); var res = db.Employee.Where(q => arr.Contains(q.FirstName.ToUpper()[0])).OrderBy(a => a.FirstName).ToArray(); GridView1.DataSource = res; GridView1.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { var query = @"SELECT Employee.FirstName, Employee.LastName, Employee.Patronymic, Employee.Id, Project.Name, EmployeeProject.OfficialSalary * EmployeeProject.CountDaysWork /22 as Result FROM Employee INNER JOIN EmployeeProject ON Employee.Id = EmployeeProject.EmployeeId INNER JOIN Project ON EmployeeProject.ProjectId = Project.Id"; var db = new DCDataContext(); db.ExecuteQuery<EmpRes>(query); GridView1.DataBind(); }
protected void Button1_Click(object sender, EventArgs e) { if(!FileUpload1.HasFile) return; var db = new DCDataContext(); db.Employee.Single(a => a.Id == int.Parse(DropDownList1.SelectedValue)).AvatarName = DropDownList1.SelectedValue + "_" + FileUpload1.FileName; db.SubmitChanges(); FileUpload1.SaveAs(Directory.GetParent(HttpContext.Current.Request.PhysicalPath).FullName + "/Avatars/" + DropDownList1.SelectedValue + "_" + FileUpload1.FileName); ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "key", "alert('Файл загружен!');", true); }
protected void Page_Load(object sender, EventArgs e) { var query = @"SELECT Employee.FirstName, Employee.LastName, Employee.Patronymic, SUM(EmployeeProject.OfficialSalary)AS SumTotal FROM Employee INNER JOIN EmployeeProject ON Employee.Id = EmployeeProject.EmployeeId group BY Employee.FirstName, Employee.LastName, Employee.Patronymic"; var db = new DCDataContext(); db.ExecuteQuery<string>(query); GridView1.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { var query = @"SELECT Project.Name, EmployeeProject.OfficialSalary FROM Employee INNER JOIN EmployeeProject ON Employee.Id = EmployeeProject.EmployeeId INNER JOIN Project ON EmployeeProject.ProjectId = Project.Id ORDER BY EmployeeProject.OfficialSalary"; var db = new DCDataContext(); db.ExecuteQuery<string>(query); GridView1.DataBind(); }
protected void UpdateB_Click(object sender, EventArgs e) { var db = new DCDataContext(); var empP = db.EmployeeProject.Single(a => a.Id == (int)DetailsView1.SelectedValue); empP.CountDaysWork = int.Parse(CountDaysWorkTB.Text); empP.OfficialSalary = int.Parse(OfficialSalaryTB.Text); empP.EmployeeId = int.Parse(EmployeesDDL.SelectedValue); empP.ProjectId = int.Parse(ProjectsDDL.SelectedValue); empP.PositionId = int.Parse(PositionsDDL.SelectedValue); db.SubmitChanges(); Response.Redirect("EmployeesProjects.aspx"); }
protected void Button1_Click(object sender, EventArgs e) { var query = @"SELECT Employee.FirstName, Employee.LastName, Employee.Patronymic, EmployeeProject.OfficialSalary, Project.Name FROM EmployeeProject INNER JOIN Employee ON EmployeeProject.EmployeeId = Employee.Id INNER JOIN Project ON EmployeeProject.ProjectId = Project.Id WHERE (EmployeeProject.OfficialSalary > {0})"; var db = new DCDataContext(); db.ExecuteQuery<EmpRes>(query, TextBox1.Text); GridView1.DataBind(); }
protected void Button1_Click(object sender, EventArgs e) { var query = @"SELECT Employee.FirstName, Employee.LastName, Employee.Patronymic, Employee.Id, Project.Name, CAST(EmployeeProject.OfficialSalary * EmployeeProject.CountDaysWork AS float(2)) / 22 / {0} AS Result, Project.Id AS Expr1 FROM Employee INNER JOIN EmployeeProject ON Employee.Id = EmployeeProject.EmployeeId INNER JOIN Project ON EmployeeProject.ProjectId = Project.Id WHERE (Project.Id = {1})"; var db = new DCDataContext(); db.ExecuteQuery<Salary.EmpRes>(query, DropDownList1.SelectedValue, TextBox1.Text); GridView1.DataBind(); }
protected void Button1_Click(object sender, EventArgs e) { var empP = new EmployeeProject() { CountDaysWork = int.Parse(CountDaysWorkTB.Text), OfficialSalary = int.Parse(OfficialSalaryTB.Text), EmployeeId = int.Parse(EmployeesDDL.SelectedValue), ProjectId = int.Parse(ProjectsDDL.SelectedValue), PositionId = int.Parse(PositionsDDL.SelectedValue), }; var db = new DCDataContext(); db.EmployeeProject.InsertOnSubmit(empP); db.SubmitChanges(); Response.Redirect("EmployeesProjects.aspx"); }
protected void UpdateLB_Click(object sender, EventArgs e) { Panel1.Visible = true; DetailsView1.Visible = false; var db = new DCDataContext(); var empP = db.EmployeeProject.Single(a => a.Id == (int)DetailsView1.SelectedValue); EmployeesDDL.DataBind(); EmployeesDDL.SelectedIndex = EmployeesDDL.Items.IndexOf(EmployeesDDL.Items.OfType<ListItem>().Single(a => a.Value == empP.EmployeeId.ToString())); PositionsDDL.DataBind(); PositionsDDL.SelectedIndex = PositionsDDL.Items.IndexOf(PositionsDDL.Items.OfType<ListItem>().Single(a => a.Value == empP.PositionId.ToString())); ProjectsDDL.DataBind(); ProjectsDDL.SelectedIndex = ProjectsDDL.Items.IndexOf(ProjectsDDL.Items.OfType<ListItem>().Single(a => a.Value == empP.ProjectId.ToString())); OfficialSalaryTB.Text = empP.OfficialSalary.ToString(); CountDaysWorkTB.Text = empP.CountDaysWork.ToString(); CreateB.Visible = false; UpdateB.Visible = true; }