void BindData1() { ClassYear y = new ClassYear(); DataTable dt = y.GetYearSearch(txtSearchTH.Text); GridView1.DataSource = dt; GridView1.DataBind(); SetViewState(dt); }
void BindData() { ClassYear y = new ClassYear(); DataTable dt = y.GetYear(""); GridView1.DataSource = dt; GridView1.DataBind(); SetViewState(dt); }
protected void btnSearchRefresh_Click(object sender, EventArgs e) { ClearData(); ClassYear y = new ClassYear(); DataTable dt = y.GetYear(""); GridView1.DataSource = dt; GridView1.DataBind(); SetViewState(dt); }
protected void modUpdateCommand(Object sender, GridViewUpdateEventArgs e) { TextBox txtYearNameEdit = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtYearNameEdit"); ClassYear y = new ClassYear(Convert.ToInt32(txtYearNameEdit.Text)); y.UpdateYear(); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('อัพเดทข้อมูลเรียบร้อย')", true); GridView1.EditIndex = -1; BindData1(); }
protected void modDeleteCommand(Object sender, GridViewDeleteEventArgs e) { int id = Convert.ToInt32(GridView1.DataKeys[e.RowIndex].Value); ClassYear y = new ClassYear(); y.YEAR_ID = id; y.DeleteYear(); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('ลบข้อมูลเรียบร้อย')", true); GridView1.EditIndex = -1; BindData1(); }
public static void MigrateGroup_Course(IServiceProvider serviceProvider) { var db = serviceProvider.GetService <ApplicationDbContext>(); Console.WriteLine("ready to migration groups (y/n)? "); if (Console.ReadLine().ToLower() != "y") { return; } int count = 0; Console.WriteLine("delete all groups"); db.ClassYears.ToList().ForEach(x => db.Remove(x)); db.SaveChanges(); db.Groups.ToList().ForEach(x => db.Remove(x)); db.SaveChanges(); var yearId = db.Years.LastOrDefault(x => x.Deleted == false).Id; string path = OldDataPathForMigrations + "courses.txt"; extractData( lines: File.ReadAllLines(path).ToList(), onExtracted: (values) => { var cy = new ClassYear { YearId = yearId, SchoolId = 1, By = "System", ClassId = db.Classes.Where(x => x.Old_ClassId == values[2]).SingleOrDefault().Id }; db.ClassYears.Add(cy); db.SaveChanges(); db.Groups.Add(new Group { Old_GroupId = values[0], Title = values[1], ClassYearId = cy.Id, By = "System", }); count++; } ); db.SaveChanges(); Console.WriteLine("total rows = " + count); Console.WriteLine("press any key to continue . . ."); Console.ReadLine(); }
protected void btnSearchYear_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtSearchTH.Text)) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('กรุณากรอก คำค้นหา')", true); return; } else { ClassYear y = new ClassYear(); DataTable dt = y.GetYearSearch(txtSearchTH.Text); GridView1.DataSource = dt; GridView1.DataBind(); SetViewState(dt); } }
protected void btnSubmitYEAR_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtYearName.Text)) { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('กรุณาใส่ ปีพุทธศักราช')", true); return; } ClassYear y = new ClassYear(); y.YEAR_ID = Convert.ToInt32(txtYearName.Text); if (y.CheckUseYearName()) { y.InsertYear(); BindData(); ClearData(); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('เพิ่มข้อมูลเรียบร้อย')", true); } else { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('มีปีพุทธศักราชนี้ อยู่ในระบบแล้ว !')", true); } }