private void InitialData() { Session["lstOrderDetail"] = null; var cmdStore = new StoreService(); //DataSouce = cmdStore.GetALL(); DataSouce = new List<STORE>(); USER user = Session["user"] as USER; if (user == null) Response.Redirect("MainAdmin.aspx"); var cmdZone = new ZoneDetailService(); foreach (ZONE_DETAIL zoneId in cmdZone.GetALLByUser(user.EMPLOYEE_ID)) { List<STORE> tmp = cmdStore.GetALL().Where(x => x.ZONE_ID == zoneId.ZONE_ID).ToList(); DataSouce.AddRange(tmp); } var cmd = new SectorService(); var list = cmd.GetALL(); foreach (var item in list) { ddlSector.Items.Add(new ListItem(item.SECTOR_NAME, item.SECTOR_ID.ToString())); } var cmdPro = new ProvinceService(); ViewState["listProvince"] = cmdPro.GetALL(); foreach (var item in (List<PROVINCE>)ViewState["listProvince"]) { ddlProvince.Items.Add(new ListItem(item.PROVINCE_NAME, item.PROVINCE_ID.ToString())); } var cmdRoad = new RoadService(); ViewState["listRoad"] = cmdRoad.GetALL(); foreach (var item in (List<ROAD>)ViewState["listRoad"]) { ddlRoad.Items.Add(new ListItem(item.ROAD_NAME, item.ROAD_ID.ToString())); } gridStore.DataSource = null; gridStore.DataBind(); }
private void InitialDataPopup() { var cmd = new DepartmentService(); var list = cmd.GetALL(); foreach (var item in list) { ddlDepartment.Items.Add(new ListItem(item.DEPARTMENT_NAME, item.DEPARTMENT_ID.ToString())); } if (ViewState["empId"] != null) { var cmdEmp = new EmployeeService(); _employee = cmdEmp.Select(Convert.ToInt32(ViewState["empId"].ToString())); if (_employee != null) { popTxtEmployeeCode.Text = _employee.EMPLOYEE_CODE; txtName.Text = _employee.EMPLOYEE_NAME; txtLastName.Text = _employee.EMPLOYEE_SURNAME; ddlDepartment.SelectedValue = _employee.DEPARTMENT_ID.ToString(); flag.Text = "Edit"; } var cmdFunc = new ZoneDetailService(); DataSouceRoleFunction = cmdFunc.GetALLInclude(_employee.EMPLOYEE_ID); } else { DataSouceRoleFunction = new List<ZONE_DETAIL>(); } DataSouceRoleFunction.AddRange(DataSouceNewRoleFunction); gridZone.DataSource = DataSouceRoleFunction; gridZone.DataBind(); }
protected void btnAddZone_Click(object sender, EventArgs e) { var cmdZone = new ZoneService(); List<ZONE_DETAIL> list = new List<ZONE_DETAIL>(); for (int i = 0; i < gridSelectZone.Rows.Count; i++) { if (((CheckBox)gridSelectZone.Rows[i].Cells[0].FindControl("check")).Checked) { if (ViewState["empId"] != null && DataSouceRoleFunction.Where(x => x.ZONE_ID == Convert.ToInt32(gridSelectZone.DataKeys[i].Value.ToString())).FirstOrDefault() == null) { ZONE_DETAIL obj = new ZONE_DETAIL(); obj.Action = ActionEnum.Create; obj.EMPLOYEE_ID = Convert.ToInt32(ViewState["empId"].ToString()); obj.ZONE_ID = Convert.ToInt32(gridSelectZone.DataKeys[i].Value.ToString()); obj.CREATE_DATE = DateTime.Now; obj.CREATE_EMPLOYEE_ID = 0; obj.UPDATE_DATE = DateTime.Now; obj.UPDATE_EMPLOYEE_ID = 0; obj.SYE_DEL = true; list.Add(obj); } else if (DataSouceNewRoleFunction.Where(x => x.ZONE_ID == Convert.ToInt32(gridSelectZone.DataKeys[i].Value.ToString())).FirstOrDefault() == null) { ZONE_DETAIL obj = new ZONE_DETAIL(); obj.Action = ActionEnum.Create; obj.EMPLOYEE_ID = 0; obj.ZONE_ID = Convert.ToInt32(gridSelectZone.DataKeys[i].Value.ToString()); obj.CREATE_DATE = DateTime.Now; obj.CREATE_EMPLOYEE_ID = 0; obj.UPDATE_DATE = DateTime.Now; obj.UPDATE_EMPLOYEE_ID = 0; obj.SYE_DEL = true; DataSouceNewRoleFunction.Add(obj); } } } if (list.Count > 0) { var cmd = new ZoneDetailService(list); cmd.AddList(); } InitialDataPopup(); this.popup.Show(); }
protected void gridZone_RowDeleting(object sender, GridViewDeleteEventArgs e) { var cmd = new ZoneDetailService(); cmd.Delete(Convert.ToInt32(gridZone.DataKeys[e.RowIndex].Values[0].ToString())); InitialDataPopup(); this.popup.Show(); }