private void button1_Click_1(object sender, EventArgs e) { string nameCompany = CompanyName.Text; string adress = Adress.Text; string phoneNo = Phone.Text; string city = City.Text; Entity.FaridiaIronStoreEntities db = new FaridiaIronStoreEntities(); Entity.Supplier supplierExist = db.Suppliers.Where(aa => aa.Name.Equals(nameCompany)).FirstOrDefault(); if (supplierExist == null) { if (phoneNo.Count() > 0 && phoneNo.Count() < 20) { Entity.Supplier supplier = new Entity.Supplier(); supplier.Name = nameCompany; supplier.Address = adress; supplier.Phone = phoneNo; supplier.City = city; supplier.StationSupplierId = (int)Station.StationId; db.Suppliers.Add(supplier); db.SaveChanges(); MessageBox.Show("Saved"); this.Close(); } else { MessageBox.Show("Enter Valid PhoneNo"); } } else { MessageBox.Show("Supplier Already Exists"); } }
private void Button_Click(object sender, EventArgs e) { string nameCompany = CompanyName.Text; string adress = Adress.Text; string phoneNo = Phone.Text; string city = City.Text; FaridiaIronStoreEntities db = new FaridiaIronStoreEntities(); Entity.Supplier supplier = db.Suppliers.Where(a => a.SupplierId == _id && a.StationSupplierId == _supplierStationID).FirstOrDefault(); //IronStore.EntityFramework.SupplierBankDetail supplierBank = new EntityFramework.SupplierBankDetail(); //List<IronStore.EntityFramework.SupplierBankDetail> bankList = new List<SupplierBankDetail>(); supplier.Name = nameCompany; supplier.Address = adress; supplier.Phone = phoneNo; supplier.City = city; db.SaveChanges(); MessageBox.Show("Updated"); this.Close(); }