private void btn_Register_Click(object sender, EventArgs e) { if (validate()) { //check data exit in database? string code = txt_Code.Text; var cp_building = (from bd in db.CpBuildings where bd.Code == code && bd.SchoolId == VariableGlobal.school_id select bd).SingleOrDefault(); if (cp_building == null) { CpBuilding building_obj_new = new CpBuilding(); building_obj_new.SchoolId = VariableGlobal.school_id; building_obj_new.Code = txt_Code.Text; building_obj_new.Name = txt_Name.Text; building_obj_new.Abbreviation = txt_Abbreviation.Text; db.CpBuildings.Add(building_obj_new); } else { cp_building.Code = txt_Code.Text; cp_building.Name = txt_Name.Text; cp_building.Abbreviation = txt_Abbreviation.Text; } //update or insert data into db. try { db.SaveChanges(); this.Hide(); FrmBuildingList list_building = new FrmBuildingList(); list_building.Show(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
private void ShowBuildingList() { FrmBuildingList list_building = new FrmBuildingList(); list_building.ShowDialog(); }
private void ShowBuildingList() { FrmBuildingList buildingList_Screen = new FrmBuildingList(); buildingList_Screen.ShowDialog(); }