protected void LoadInfo(int Key) { Fertilizer_Use_Info info = new Fertilizer_Use_Info(Key); if (Key == 0) { DateTime time = DateTime.Now; txtDatetime.Text = time.ToString("dd/MM/yyyy"); } else { txtDatetime.Text = info.DateTimeUse.ToString("dd/MM/yyyy"); } DDLUnit.Text = LoadDataToToolboxWeb.GetName("SELECT Name FROM PUL_Unit where ID = " + info.UnitKey.ToString()); //txtArea.Text = info.Area; txtParcel.Text = info.Parcel.ToString();; txtFormulaUsed.Text = info.FormulaUsed.ToString(); DDLEquipment.Text = LoadDataToToolboxWeb.GetName("SELECT EquipmentName FROM PUL_Equipment where EquipmentKey = " + info.CooperativeKey.ToString()); DDLSeeds.Text = LoadDataToToolboxWeb.GetName("SELECT SeedsName FROM PUL_Seeds where SeedsKey = (Select SeedsKey from PUL_SeedProcess where SeedProcessKey = (Select SeedKey from PUL_Fertilizer_Use where FertilizerUseKey = " + info.FertilizerUseKey.ToString() + " ))"); txtQuantity.Text = info.Quantity; txtHowtouse.Text = info.Howtouse; txtArea.Text = info.Area; txtQuarantinePeriod.Text = info.QuarantinePeriod; DDLUnit.Text = LoadDataToToolboxWeb.GetName("SELECT Name FROM PUL_Unit where ID = " + info.UnitKey.ToString()); }
protected void GrDelete(object sender, CommandEventArgs e) { SessionUserLogin nUserLogin = (SessionUserLogin)Session["UserLogin"]; int nPageNumber = int.Parse(txtPageNumber.Text); int nPageSize = int.Parse(txtPageSize.Text); nUserLogin.CheckRole("CU0003"); 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()); Fertilizer_Use_Info info = new Fertilizer_Use_Info(mKey); if ((DateTime.Now - info.DateTimeUse).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 = Fertilizer_Use_Data.GetList(Convert.ToInt16(Session["EmployeeKey"]), nPageSize, nPageNumber, DDLSeeds.SelectedValue); if (nTable.Rows.Count == 0) { nTable.Rows.Add("", 0, null, "", "", 0, "", "", "", "", "", "", 0); } GV_Fertilizer_Use.DataSource = nTable; GV_Fertilizer_Use.DataBind(); LoadPages(); } } catch { Response.Write("<script >alert('Có lỗi gì đó vui lòng thử lại!')</script>"); } } }