public void BindGrid(string id) { Demo.BLL.tb_JC_Employee bll = new Demo.BLL.tb_JC_Employee(); Demo.Model.tb_JC_Employee model = new Demo.Model.tb_JC_Employee(); model = bll.GetModel(id); employeeno.Text = model.EmployeeName.ToString(); employeename.Text = model.EmployeeName.ToString(); emid.Text = model.ID.ToString(); DropDownList2.SelectedValue = model.PositionNO.ToString(); DropDownList1.SelectedValue = model.DepartmentNO.ToString(); sex.SelectedValue = model.Sex.ToString(); age.Text = model.Age.ToString(); email.Text = model.Email.ToString(); phone.Text = model.MobileNumber.ToString(); entrydate.Text = model.EntryDate.ToString(); leavedate.Text = model.LeaveDate.ToString(); nation.Text = model.Nation.ToString(); nativeplace.Text = model.NativePlace.ToString(); politicalstatus.SelectedValue = model.PoliticalStatus.ToString(); Maritialstatus.SelectedValue = model.MaritialStatus.ToString(); // deptno.SelectedValue = deptbll.GetModelList("where DeptmentNo = "+ model.DepartmentNO)[0].DepartmentName; }
protected void ttbSearch3_Trigger2Click(object sender, EventArgs e) { //search Demo.BLL.tb_JC_Employee bll = new Demo.BLL.tb_JC_Employee(); Demo.Model.tb_JC_Employee model = new Demo.Model.tb_JC_Employee(); string name = ttbSearch3.Text.Trim(); model = bll.GetModelList("EmployeeName = '" + name + "'")[0]; if (model.DepartmentNO == null) { Alert.ShowInTop("未找到该员工!"); } else { PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("~/Web/JC/deptment/listemployeemodify.aspx?id={0}&employeename={1}", model.ID, model.EmployeeNO), "编辑")); } }
protected void btnDelete3_Click(object sender, EventArgs e) { if (Grid3.SelectedRowIndexArray.Length == 0) { Alert.ShowInTop("请至少选择一条记录!"); return; } Demo.BLL.tb_JC_Employee bll = new Demo.BLL.tb_JC_Employee(); foreach (int n in Grid3.SelectedRowIndexArray) { object[] keys = Grid3.DataKeys[n]; string id = keys[0].ToString(); bll.Delete(id); } BindGrid3(); Alert.ShowInTop("删除选中的 " + Grid3.SelectedRowIndexArray.Length + " 项纪录!"); }
/// <summary> /// 模拟数据库分页 /// </summary> /// <returns></returns> private DataTable GetPagedDataTable3(int pageIndex, int pageSize) { Demo.BLL.tb_JC_Employee bll = new Demo.BLL.tb_JC_Employee(); DataTable source = bll.GetList("").Tables[0]; DataTable paged = source.Clone(); int rowbegin = pageIndex * pageSize; int rowend = (pageIndex + 1) * pageSize; if (rowend > source.Rows.Count) { rowend = source.Rows.Count; } for (int i = rowbegin; i < rowend; i++) { paged.ImportRow(source.Rows[i]); } return(paged); }
protected void btnSaveRefresh_Click(object sender, EventArgs e) { // 1. 这里放置保存窗体中数据的逻辑 Demo.BLL.tb_JC_Employee bll = new Demo.BLL.tb_JC_Employee(); Demo.Model.tb_JC_Employee model = new Demo.Model.tb_JC_Employee(); model.EmployeeNO = employeeno.Text.Trim(); model.EmployeeName = employeename.Text.Trim(); model.ID = Guid.NewGuid().ToString(); model.PositionNO = DropDownList2.SelectedValue; model.DepartmentNO = DropDownList1.SelectedValue; model.Sex = sex.SelectedText;; model.Age = Convert.ToInt16(age.Text.Trim()); model.Email = email.Text.Trim(); model.MobileNumber = phone.Text.Trim(); model.EntryDate = Convert.ToDateTime(entrydate.SelectedDate); model.LeaveDate = Convert.ToDateTime(leavedate.SelectedDate.HasValue ? entrydate.SelectedDate.Value.ToString("yyyy-MM-dd") : ""); model.Nation = nation.Text; model.NativePlace = nativeplace.Text; model.PoliticalStatus = politicalstatus.SelectedValue; model.MaritialStatus = Maritialstatus.SelectedValue; if (bll.Add(model)) { Alert.ShowInTop("添加成功"); } else { Alert.ShowInTop("添加失败"); } PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); }