private void UpdateEmployeeAddress() { int employeeID = Int32.Parse(lblEmployeeID.Text); if (employeeID < 1) { return; } Cursor.Current = Cursors.WaitCursor; Employee employee = new Employee(); Address address = new Address(); int cur_row = EmployeeGrid.CurrentRow.Index; int address_id = 0; try { address_id = Int32.Parse(EmployeeGrid.Rows[cur_row].Cells["AddressID"].Value.ToString()); employee.AddressID = address_id; employee.FirstName = txtFirstName.Text.Trim(); employee.MiddleName = txtMiddleName.Text.Trim(); employee.LastName = txtLastName.Text.Trim(); employee.Login = txtUserName.Text.Trim(); employee.WorkPhone = txtWorkPhone.Text.Trim(); employee.HomePhone = txtHomePhone.Text.Trim(); employee.CellPhone = txtCellPhone.Text.Trim(); //employee.AddressID = addressid; employee.EmployeeID = Int32.Parse(lblEmployeeID.Text); //employee = employee.GetEmployee(employee.EmployeeID); employee.UpdateEmployee(employee); address.AddressLine1 = txtAddressLine1.Text.Trim(); address.AddressLine2 = txtAddressLine2.Text.Trim(); address.City = txtCity.Text.Trim(); address.StateProvince = txtState.Text.Trim(); address.PostalCode = txtZipcode.Text.Trim(); address.AddressID = employee.AddressID; if (address.AddressID < 1) { employee.AddressID = address.AddAddress(address); employee.UpdateEmployee(employee); } else { address.UpdateAddress(address); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Employee/Address", MessageBoxButtons.OK, MessageBoxIcon.Error); Cursor.Current = Cursors.Default; } finally { address = null; employee = null; } Cursor.Current = Cursors.Default; }
private void btnAdd_Click(object sender, EventArgs e) { Address add = new Address(); add.AddressLine1 = "3255 Sexton Drive"; add.AddressLine2 = ""; add.City = "Green Cove Springs"; add.StateProvince = "FL"; add.PostalCode = "32043"; add.AddAddress(add); }
public static void Initialize(StudentManagementContext context) { context.Database.EnsureCreated(); // Look for any students. if (context.Students.Any()) { return; // DB has been seeded } var address = Address.AddAddress("Khayyam", "Tehran", "Tehran", "Iran", "1234567890"); var student = Student.AddStudent("Majid Parsa", address, "00989122112567"); context.Students.Add(student); context.SaveChanges(); }
private void button2_Click(object sender, EventArgs e) { Address add = new Address(); Customer cust = new Customer(); Cursor.Current = Cursors.WaitCursor; try { for (int i = 0; i < dataGridView1.Rows.Count; i++) { add.AddressLine1 = dataGridView1.Rows[i].Cells["Addressline1"].Value.ToString(); add.AddressLine2 = ""; add.City = dataGridView1.Rows[i].Cells["city"].Value.ToString(); add.StateProvince = dataGridView1.Rows[i].Cells["state"].Value.ToString(); add.PostalCode = dataGridView1.Rows[i].Cells["zip"].Value.ToString(); int addid = add.AddAddress(add); cust.AddressID = addid; cust.AccountNumber = ""; cust.TerritoryID = 0; cust.DeliveryDay = 1; cust.CustomerType = "A"; cust.CreditLimit = 100.00m; cust.Email = ""; cust.ContactName = dataGridView1.Rows[i].Cells["contactname"].Value.ToString(); cust.Fax = dataGridView1.Rows[i].Cells["fax"].Value.ToString(); cust.Phone = dataGridView1.Rows[i].Cells["phone"].Value.ToString(); cust.SecondPhone = dataGridView1.Rows[i].Cells["secondphone"].Value.ToString(); cust.Name = dataGridView1.Rows[i].Cells["name"].Value.ToString(); cust.ModifiedDate = DateTime.Now; cust.AddCustomer(cust); } } catch (Exception ex) { MessageBox.Show(ex.Message); Cursor.Current = Cursors.Default; } finally { add = null; cust = null; Cursor.Current = Cursors.Default; MessageBox.Show("done", "Tools", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void btnSaveVendor_Click(object sender, EventArgs e) { int addressid = 0; Cursor.Current = Cursors.WaitCursor; try { for (int i = 0; i < dataGridView1.Rows.Count; i++) { Address add = new Address(); Vendor vend = new Vendor(); add.AddressLine1 = dataGridView1.Rows[i].Cells["address 2"].Value.ToString(); add.AddressLine2 = dataGridView1.Rows[i].Cells["addresline2"].Value.ToString(); add.City = dataGridView1.Rows[i].Cells["city"].Value.ToString(); add.StateProvince = dataGridView1.Rows[i].Cells["state"].Value.ToString(); add.PostalCode = dataGridView1.Rows[i].Cells["zip"].Value.ToString(); addressid = add.AddAddress(add); vend.AccountNumber = ""; vend.AddressID = addressid; vend.ActiveFlag = true; //vend.ContactName = dataGridView1.Rows[i].Cells["FirstName"].Value.ToString(); vend.CreditRating = 100; vend.Email = dataGridView1.Rows[i].Cells["alt phone"].Value.ToString(); vend.Phone = dataGridView1.Rows[i].Cells["contact"].Value.ToString(); vend.Fax = dataGridView1.Rows[i].Cells["phone"].Value.ToString(); vend.ModifiedDate = DateTime.Now; vend.Name = dataGridView1.Rows[i].Cells["vendor"].Value.ToString(); vend.ContactName = dataGridView1.Rows[i].Cells["firstname"].Value.ToString() + " " + dataGridView1.Rows[i].Cells["MI"].Value.ToString() + " " + dataGridView1.Rows[i].Cells["lastname"].Value.ToString(); vend.PreferredVendorStatus = true; vend.AddVendor(vend); add = null; vend = null; } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void AddEmployeeAddress() { Cursor.Current = Cursors.WaitCursor; Employee employee = new Employee(); Address address = new Address(); try { address.AddressLine1 = txtAddressLine1.Text.Trim(); address.AddressLine2 = txtAddressLine2.Text.Trim(); address.City = txtCity.Text.Trim(); address.StateProvince = txtState.Text.Trim(); address.PostalCode = txtZipcode.Text.Trim(); int addressid = address.AddAddress(address); employee.FirstName = txtFirstName.Text.Trim(); employee.MiddleName = txtMiddleName.Text.Trim(); employee.LastName = txtLastName.Text.Trim(); employee.Login = txtUserName.Text.Trim(); employee.AddressID = addressid; employee.WorkPhone = txtWorkPhone.Text.Trim(); employee.HomePhone = txtHomePhone.Text.Trim(); employee.CellPhone = txtCellPhone.Text.Trim(); employee.AddEmployee(employee); } catch (Exception ex) { MessageBox.Show(ex.Message, "Employee/Address", MessageBoxButtons.OK, MessageBoxIcon.Error); Cursor.Current = Cursors.Default; } finally { address = null; employee = null; } Cursor.Current = Cursors.Default; }
private void SaveCustomer() { Customer cus = new Customer(); Address add = new Address(); Address billing_add = new Address(); try { if (txtCustomerID.Text != string.Empty) { cus.CustomerID = Int32.Parse(txtCustomerID.Text); } cus.AccountNumber = txtAccountNumber.Text; cus.ActiveFlag = chkActiveFlag.Checked; cus.Name = txtCustomerName.Text; cus.Phone = txtTelephone.Text; cus.SecondPhone = txtSecondaryTelephone.Text; cus.Fax = txtFax.Text; cus.Email = txtEmail.Text; cus.CustomerType = m_strDeliveryFreq[cmbOrderFrequency.SelectedIndex, 0]; //cmbOrderFrequency.SelectedValue.ToString(); if (cmbTerritory.SelectedIndex > 0) { cus.TerritoryID = Int32.Parse(cmbTerritory.SelectedValue.ToString()); } cus.ContactName = txtContactName.Text; if (txtCreditLimit.Text != string.Empty) { cus.CreditLimit = decimal.Parse(txtCreditLimit.Text); } if (cmbDeliveryDay.SelectedIndex > 0) { cus.DeliveryDay = short.Parse(cmbDeliveryDay.SelectedIndex.ToString()); } //address info add.AddressID = m_AddressID; add.AddressLine1 = txtStreetAddress.Text; add.AddressLine2 = ""; add.City = txtCity.Text; add.StateProvince = txtState.Text; add.PostalCode = txtZip.Text; //billing address billing_add.AddressID = m_BillingAddressID; billing_add.AddressLine1 = txtBillingStreetAddress.Text; billing_add.AddressLine2 = ""; billing_add.City = txtBillingCity.Text; billing_add.StateProvince = txtBillingState.Text; billing_add.PostalCode = txtBillingZip.Text; if (cus.CustomerID == 0) { //This is a new customer, add row to customer and address table cus.AddressID = add.AddAddress(add); if (cus.AddressID > 0) { cus.BillingAddressID = billing_add.AddAddress(billing_add); if (cus.Exists(cus.Name) > 0) { DialogResult result = MessageBox.Show("The Customer " + cus.Name + " already exists\nWould you like to update it?", "MICS", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { cus.UpdateCustomer(cus); MessageBox.Show("Record saved successfully", "MICS", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Record is not saved", "MICS", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { cus.CustomerID = cus.AddCustomer(cus); if (cus.CustomerID > 0) { MessageBox.Show("Record saved successfully", "MICS", MessageBoxButtons.OK, MessageBoxIcon.Information); RefreshForm(cus.CustomerID); } else { ShowError("Failed to add new customer"); } } } } else if (cus.CustomerID > 0) { //This is an existing customer, do and update to the address and customer tables. if (m_AddressID == 0) { m_AddressID = add.AddAddress(add); } else { add.Update(add); } if (m_BillingAddressID == 0) { m_BillingAddressID = billing_add.AddAddress(billing_add); } else { billing_add.Update(billing_add); } cus.AddressID = m_AddressID; cus.BillingAddressID = m_BillingAddressID; cus.UpdateCustomer(cus); MessageBox.Show("Record saved successfully", "MICS", MessageBoxButtons.OK, MessageBoxIcon.Information); RefreshForm(cus.CustomerID); } } catch (Exception ex) { ShowError(ex.Message); } finally { cus = null; add = null; } }
private void btnSave_Click(object sender, EventArgs e) { if (IsInvalidControl()) { return; } Cursor.Current = Cursors.WaitCursor; Vendor v = new Vendor(); Vendor vendor = new Vendor(); Address add = new Address(); try { v.Name = txtName.Text.Trim(); v.ContactName = txtContactName.Text.Trim(); v.AccountNumber = txtAccountNumber.Text.Trim(); if (txtCreditRating.Text.Trim().Length > 0) { v.CreditRating = Byte.Parse(txtCreditRating.Text.Trim()); } else { v.CreditRating = 0; } v.ActiveFlag = chkActive.Checked; v.Phone = txtPhone.Text.Trim(); v.AltPhone = txtPhone.Text; v.Terms = txtTerms.Text; v.Fax = txtFax.Text.Trim(); v.Email = txtEmail.Text.Trim(); v.PreferredVendorStatus = chkPrefered.Checked; v.ModifiedDate = DateTime.Now; add.AddressLine1 = txtStreetAddress.Text; add.City = txtCity.Text; add.StateProvince = txtState.Text; add.PostalCode = txtZip.Text; int vendid = v.Exists(v.Name); if (vendid > 0) { DialogResult result = MessageBox.Show("Vendor: " + v.Name + " already exists\nWould you like to update it?", "MICS", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { v.VendorID = vendid; v.UpdateVendor(v); int vendAddressId = v.AddressID; add.UpdateAddress(add); PopulateGrid(v.VendorID); MessageBox.Show("Record updated successfully", "MICS", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Record is not saved", "MICS", MessageBoxButtons.OK, MessageBoxIcon.Warning); } return; } v.AddressID = add.AddAddress(add); vendor.VendorID = vendor.AddVendor(v); PopulateGrid(vendor.VendorID); } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { vendor = null; v = null; } Cursor.Current = Cursors.Default; }
public string AddAddress([FromBody] Address a) { return(a.AddAddress()); }