protected void LoadInfo(int Key) { CompostingOrganic_Info info = new CompostingOrganic_Info(Key); if (Key == 0) { DateTime time = DateTime.Now; txtDatetime.Text = time.ToString("dd/MM/yyyy"); } else { txtDatetime.Text = info.StartDate.ToString("dd/MM/yyyy"); } txtName.Text = LoadDataToToolboxWeb.GetName("SELECT Name FROM PUL_FertilizerOrganic where FertilizerOrganicKey = " + info.FertilizerOrganicKey.ToString()); txtQuantity.Text = info.Quantity + " " + LoadDataToToolboxWeb.GetName("SELECT Name FROM PUL_Unit where ID = " + info.UnitKey.ToString()); txtMethod.Text = info.Method; txtCompostingDates.Text = info.CompostingDates.ToString() + " ngày"; }
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("CU0002"); 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()); CompostingOrganic_Info info = new CompostingOrganic_Info(mKey); if ((DateTime.Now - info.StartDate).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 = CompostingOrganic_Data.GetList(Convert.ToInt16(Session["EmployeeKey"]), nPageSize, nPageNumber); if (nTable.Rows.Count == 0) { nTable.Rows.Add(0, 0, "", 0, null, "", ""); } GV_CompostingOrganic.DataSource = nTable; GV_CompostingOrganic.DataBind(); LoadPages(); } } catch { Response.Write("<script >alert('Có lỗi gì đó vui lòng thử lại!')</script>"); } } }