private void CreateCongTy_Button_Click(object sender, RoutedEventArgs e) { try { congty cty = new congty(); cty.mack = tbCrMack.Text; cty.nhomnganh = cbCrNhomNganh.Text; cty.tencty = tbCrTenCty.Text; if (tbCrSoLuongCp.Text == "") { tbCrSoLuongCp.Text = "0"; } cty.socp = Convert.ToInt32(tbCrSoLuongCp.Text); bool result = DataBase.CreateCty(cty); if (result) { MessageBox.Show("success"); } else { MessageBox.Show("Đã có công ty này rồi"); } } catch (Exception ex) { MessageBox.Show("fail"); } }
public static bool UpdateCty(congty cty) { congty temp = dataBaseEntities.congty.First(i => i.mack == cty.mack); temp.nhomnganh = cty.nhomnganh; temp.socp = cty.socp; temp.tencty = cty.tencty; dataBaseEntities.SaveChanges(); return(true); }
public static bool DelteCty(string mack) { congty temp = dataBaseEntities.congty.First(i => i.mack == mack); if (temp == null) { return(false); } dataBaseEntities.congty.Remove(temp); return(true); }
private void Congty_Mack_TextChanged(object sender, TextChangedEventArgs e) { string mack = tbUdMack.Text; congty cty = DataBase.FindCtyByMack(mack); if (cty == null) { return; } tbUdTenCty.Text = cty.tencty; tbUdSoluongCP.Text = cty.socp.ToString(); cbUdNhomNganh.Text = cty.nhomnganh; }
public static bool CreateCty(congty cty) { List <congty> temp = dataBaseEntities.congty.ToList(); int count = temp.Count; for (int i = 0; i < count; i++) { if (temp[i].mack.Equals(cty.mack, StringComparison.InvariantCultureIgnoreCase)) { return(false); } } dataBaseEntities.congty.Add(cty); dataBaseEntities.SaveChanges(); return(true); }