private void suppliersList_SelectionChanged(object sender, SelectionChangedEventArgs e) { this.supplier = suppliersList.SelectedItem as Supplier; this.northwindContext.LoadProperty<Supplier>(this.supplier, s => s.Products); this.productsInfo = ((IListSource)supplier.Products).GetList(); productsList.DataContext = this.productsInfo; }
private void btnAdd_Click(object sender, EventArgs e) { Supplier newSup = new Supplier(); newSup.SupplierID = -1; newSup.CompanyName = this.txtCompName.Text; newSup.Contactname = this.txtContname.Text; newSup.ContactTitle = this.txtContTitle.Text; newSup.Address = this.txtAddr.Text; newSup.City = this.txtCity.Text; newSup.Region = this.txtRegion.Text; newSup.Postalcode = this.txtPos.Text; newSup.Country = this.cbCountry.Text; newSup.Phone = this.txtPhone.Text; newSup.Fax = this.txtFax.Text; int check = newSup.isValid(); if (check < 0) { MessageBox.Show(newSup.getErrorMessage(check)); } else { this.dataModel.insertNewRow(newSup); MessageBox.Show("Completed"); clearAll(); } }
protected void btnSave_Click(object sender, EventArgs e) { Supplier dataObj = new Supplier(); dataObj.SupplierID = -1; dataObj.CompanyName = this.txtCompanyName.Text; dataObj.Contactname = this.txtContactName.Text; dataObj.ContactTitle = this.txtTitle.Text; dataObj.Address = this.txtAddress.Text; dataObj.City = this.txtCity.Text; dataObj.Region = this.txtRegion.Text; dataObj.Postalcode = this.txtPostalCode.Text; dataObj.Country = this.txtCountry.Text; dataObj.Phone = this.txtPhone.Text; dataObj.Fax = this.txtFax.Text; try { int check = dataObj.isValid(); if (check < 0) { //MessageBox.Show(newEmp.getErrorMessage(check)); this.script.Text = "<script>alert(\""+dataObj.getErrorMessage(check)+"\");</script>"; return; } else { if (this.newEmpMode == true) this.dataModel.insertNewRow(dataObj); else { dataObj.SupplierID = this.suppID; this.dataModel.updateRow(dataObj); } //Server.Transfer("Suppliers.aspx", true); } } catch (Exception ex) { Session["current_error"] = ex.Message; Response.Redirect("serverError.aspx"); } Response.Redirect("Suppliers.aspx"); }
private void doSave_Update() { this.errorProvider.Clear(); Supplier dataObj = new Supplier(); dataObj.SupplierID = -1; dataObj.CompanyName = this.txtCompName.Text; dataObj.Contactname = this.txtContname.Text; dataObj.ContactTitle = this.txtContTitle.Text; dataObj.Address = this.txtAddr.Text; dataObj.City = this.txtCity.Text; dataObj.Region = this.txtRegion.Text; dataObj.Postalcode = this.txtPos.Text; dataObj.Country = this.cbCountry.Text; dataObj.Phone = this.txtPhone.Text; dataObj.Fax = this.txtFax.Text; int check = dataObj.isValid(); if (check < 0) { showErrors(dataObj, check); } else { try { if (this.AddNewMode == true) this.dataModel.insertNewRow(dataObj); else { dataObj.SupplierID = int.Parse(this.txtSupID.Text); this.dataModel.updateRow(dataObj); } this.clearForm(); this.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); this.Close(); } } }
/// <summary> /// Create a new Supplier object. /// </summary> /// <param name="supplierID">Initial value of the SupplierID property.</param> /// <param name="companyName">Initial value of the CompanyName property.</param> public static Supplier CreateSupplier(global::System.Int32 supplierID, global::System.String companyName) { Supplier supplier = new Supplier(); supplier.SupplierID = supplierID; supplier.CompanyName = companyName; return supplier; }
/// <summary> /// Deprecated Method for adding a new object to the Suppliers EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToSuppliers(Supplier supplier) { base.AddObject("Suppliers", supplier); }
private void showErrors(Supplier supp, int code) { if (code == -2) { if (this.txtCompName.Text.Equals("")) this.errorProvider.SetError(txtCompName, supp.getErrorMessage(code)); if (this.txtContname.Text.Equals("")) this.errorProvider.SetError(txtContname, supp.getErrorMessage(code)); if (this.txtContTitle.Text.Equals("")) this.errorProvider.SetError(txtContTitle, supp.getErrorMessage(code)); if (this.txtAddr.Text.Equals("")) this.errorProvider.SetError(txtAddr, supp.getErrorMessage(code)); if (this.txtCity.Text.Equals("")) this.errorProvider.SetError(txtCity, supp.getErrorMessage(code)); if (this.cbCountry.Text.Equals("")) this.errorProvider.SetError(cbCountry, supp.getErrorMessage(code)); if (this.txtPhone.Text.Equals("")) this.errorProvider.SetError(txtPhone, supp.getErrorMessage(code)); } }
private void btnUpdate_Click(object sender, EventArgs e) { if (this.txtSupID.Text.Equals("")) { MessageBox.Show("You must select a Supplier first"); return; } try { Supplier updateData = new Supplier(); updateData.SupplierID = int.Parse(this.txtSupID.Text.Trim()); updateData.CompanyName = this.txtCompName.Text; updateData.Contactname = this.txtContname.Text; updateData.ContactTitle = this.txtContTitle.Text; updateData.Address = this.txtAddr.Text; updateData.City = this.txtCity.Text; updateData.Region = this.txtRegion.Text; updateData.Postalcode = this.txtPos.Text; updateData.Country = this.cbCountry.Text; updateData.Phone = this.txtPhone.Text; updateData.Fax = this.txtFax.Text; this.dataModel.updateRow(updateData); MessageBox.Show("Updated"); clearAll(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }