protected void LoadPages() { int nPageNumber = int.Parse(txtPageNumber.Text); int nPageSize = int.Parse(txtPageSize.Text); int nTotalRecord = Harvests_Data.Count(Session["EmployeeKey"].ToInt()); if (nTotalRecord > nPageSize * 5) { nTotalRecord = nPageSize * 5; } if (nTotalRecord > nPageSize) { PageNumbers.Visible = true; DataTable nTable = TNLibrary.WEB.LoadDataToToolboxWeb.LoadPageSize(nPageSize, nTotalRecord); PageNumbers.SelectedIndex = nPageNumber - 1; PageNumbers.DataSource = nTable; PageNumbers.DataBind(); } else { PageNumbers.Visible = false; } }
protected void Page_Load(object sender, EventArgs e) { SessionUserLogin nUserLogin = (SessionUserLogin)Session["UserLogin"]; if (nUserLogin != null) { nUserLogin.CheckRole("CU0006"); DataTable dt = Harvests_Data.GetAddressList(); for (int i = 0; i < dt.Rows.Count; i++) { cmm += "\"" + dt.Rows[i]["Address"].ToString() + "\","; } string nKey = this.Request["key"]; txtKey.Text = "0"; int _nKey = 0; if (nKey != null) { if (int.TryParse(nKey, out _nKey)) { txtKey.Text = nKey; } if (!IsPostBack) { LoadInfo(_nKey); LoadDataToToolboxWeb.DropDown_DDL(DDLSeeds, "SELECT SeedsKey,SeedsName FROM PUL_Seeds", false); if (!nUserLogin.Role.Edit && nKey != "0") { cmdSave.Visible = false; DDLSeeds.Enabled = false; txtCode.Enabled = false; txtDateOn.Enabled = false; txtLoss.Enabled = false; txtSlotAfter.Enabled = false; txtSlotBefor.Enabled = false; txtWeightAfter.Enabled = false; txtWeightBefor.Enabled = false; } else if (!nUserLogin.Role.Add && nKey == "0") { cmdSave.Visible = false; DDLSeeds.Enabled = false; txtCode.Enabled = false; txtDateOn.Enabled = false; txtLoss.Enabled = false; txtSlotAfter.Enabled = false; txtSlotBefor.Enabled = false; txtWeightAfter.Enabled = false; txtWeightBefor.Enabled = false; } } } } }
protected void cmdView_Click1(object sender, ImageClickEventArgs e) { int nPageNumber = int.Parse(txtPageNumber.Text); int nPageSize = int.Parse(txtPageSize.Text); SessionUserLogin nUserLogin = (SessionUserLogin)Session["UserLogin"]; DateTime dtfrom = DateTime.ParseExact(txtfromDatetime.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture); DateTime dtto = DateTime.ParseExact(txttoDatetime.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture); DataTable nTable = Harvests_Data.GetList(dtfrom, dtto, Convert.ToInt16(Session["EmployeeKey"]), nPageSize, nPageNumber); GV_Harvests.DataSource = nTable; GV_Harvests.DataBind(); LoadPages(); }
public void LoadData() { int nPageNumber = int.Parse(txtPageNumber.Text); int nPageSize = int.Parse(txtPageSize.Text); SessionUserLogin nUserLogin = (SessionUserLogin)Session["UserLogin"]; DataTable nTable = Harvests_Data.GetList(Convert.ToInt16(Session["EmployeeKey"]), nPageSize, nPageNumber); GV_Harvests.DataSource = nTable; GV_Harvests.DataBind(); DateTime dt = DateTime.Now; txtfromDatetime.Text = "01/01/2013"; txttoDatetime.Text = DateTime.Now.ToString("dd/MM/yyyy"); LoadPages(); }
protected void GrDelete(object sender, CommandEventArgs e) { int nPageNumber = int.Parse(txtPageNumber.Text); int nPageSize = int.Parse(txtPageSize.Text); SessionUserLogin nUserLogin = (SessionUserLogin)Session["UserLogin"]; nUserLogin.CheckRole("CU0006"); if (!nUserLogin.Role.Del) { Response.Write("<script >alert('Bạn không có quyền xóa danh mục này!')</script>"); } else { try { int mKey = int.Parse(e.CommandArgument.ToString()); Harvest_Info info = new Harvest_Info(mKey); if ((DateTime.Now - info.DateOn).TotalDays > 7) { Response.Write("<script >alert('Dữ liệu đã quá 7 ngày, không được phép xóa!')</script>"); } else { info.Delete(); DataTable nTable = Harvests_Data.GetList(Convert.ToInt16(Session["EmployeeKey"]), nPageSize, nPageNumber); GV_Harvests.DataSource = nTable; GV_Harvests.DataBind(); LoadPages(); } } catch { Response.Write("<script >alert('Có lỗi gì đó vui lòng thử lại!')</script>"); } } }