public bool SaveCustomers2(Customers cust) { using (var entity = new NorthwindEntities()) { List<Customers> cust = (from c in entity.Customers where c.CustomerID.equal(cust.CustomerID) and c.CustomerName.equal(cust.CustomerName) and c.CustomerPhone.equal(cust.CustomerPhone) select c).ToList(); if (cust.Count ==0 ) if (cust.Count ==0 ) { try { entity.AddToCustomers(cust); entity.SaveChanges(); } catch (Exception SaveEx) { throw new System.Exception(ex.ToString()); return false; } } else { throw new System.Exception("duplicate:" +cust.Count.ToString()); return false; } } return true; }
private void button4_Click(object sender, EventArgs e) { PetStoreServics.Customer oCustomer = new PetStoreWinForm.PetStoreServics.Customer(); oCustomer.Name = textBox1.Text; oCustomer.LastName = textBox2.Text; oCustomer.RegisteredDate = dateTimePicker1.Value; PetStoreServics.Service1Client PetStoreServics = new PetStoreWinForm.PetStoreServics.Service1Client(); { if (!PetStoreServics.SaveCustomers2(oCustomer.Name)) { try { if (oCustomer.Name == string.Empty) { MessageBox.Show(" กรุณากรอกข้อมูลด้วยค่ะ!!"); } else MessageBox.Show("Save Data Complete"); } catch (Exception) { throw; } } else { MessageBox.Show("ชื่อนี้มีอยู่ในระบบแล้ว"); } showdata(); } } }
เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง