/// <summary> /// Create a new CustomerInformation object. /// </summary> /// <param name="autoInc">Initial value of the AutoInc property.</param> /// <param name="customerName">Initial value of the CustomerName property.</param> /// <param name="dueAmount">Initial value of the DueAmount property.</param> /// <param name="createDate">Initial value of the CreateDate property.</param> public static CustomerInformation CreateCustomerInformation(global::System.Int64 autoInc, global::System.String customerName, global::System.Decimal dueAmount, global::System.DateTime createDate) { CustomerInformation customerInformation = new CustomerInformation(); customerInformation.AutoInc = autoInc; customerInformation.CustomerName = customerName; customerInformation.DueAmount = dueAmount; customerInformation.CreateDate = createDate; return customerInformation; }
/// <summary> /// Update or Insert Customer information /// </summary> /// <param name="obj"></param> private void updateCustomerClick(object obj) { this.newCustomerUpdate.IsEnabled = false; Mouse.OverrideCursor = Cursors.Wait; try { this.newCustomerName.GetBindingExpression(TextBox.TextProperty); this.getValidationError(this.newCustomerName); using (DueManagementEntity dmDatabase = new DueManagementEntity()) { ModelCustomerIno selectedCustomer = obj as ModelCustomerIno; var custometIsExist = dmDatabase.CustomerInformations.FirstOrDefault(x => x.AutoInc== selectedCustomer.ID); if (custometIsExist!=null) { Mouse.OverrideCursor = null; if (MessageBox.Show(CommandData.ERROR_MESSAGE[0],CommandData.SOFTWARE_NAME,MessageBoxButton.YesNo,MessageBoxImage.Question)==MessageBoxResult.Yes) { Mouse.OverrideCursor = Cursors.Wait; custometIsExist.Address = selectedCustomer.Address; custometIsExist.CustomerName = selectedCustomer.CustomerName; custometIsExist.DueAmount = selectedCustomer.DueAmount; custometIsExist.Mobile = selectedCustomer.Mobile; custometIsExist.Remark = selectedCustomer.Remark; custometIsExist.ShopName = selectedCustomer.ShopName; dmDatabase.SaveChanges(); Mouse.OverrideCursor = null; MessageBox.Show(CommandData.ERROR_MESSAGE[1], CommandData.SOFTWARE_NAME, MessageBoxButton.OK, MessageBoxImage.Information); } else { return; } } else { CustomerInformation newCustomerInformation = new CustomerInformation { Address = selectedCustomer.Address, AutoInc = default(long), CreateDate = DateTime.Today, CustomerName = selectedCustomer.CustomerName, DueAmount = selectedCustomer.DueAmount, Mobile = selectedCustomer.Mobile, Remark = selectedCustomer.Remark, ShopName = selectedCustomer.ShopName }; dmDatabase.CustomerInformations.AddObject(newCustomerInformation); dmDatabase.SaveChanges(); selectedCustomer.ID = newCustomerInformation.AutoInc; Mouse.OverrideCursor = null; MessageBox.Show(CommandData.ERROR_MESSAGE[2], CommandData.SOFTWARE_NAME, MessageBoxButton.OK, MessageBoxImage.Information); } } } catch (NullReferenceException) { Mouse.OverrideCursor = null; MessageBox.Show(CommandData.ERROR_MESSAGE[5], CommandData.SOFTWARE_NAME, MessageBoxButton.OK, MessageBoxImage.Stop); } catch (Exception errorException) { Mouse.OverrideCursor = null; MessageBox.Show(errorException.Message, CommandData.SOFTWARE_NAME, MessageBoxButton.OK, MessageBoxImage.Error); } finally { Mouse.OverrideCursor = null; } }
/// <summary> /// Deprecated Method for adding a new object to the CustomerInformations EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToCustomerInformations(CustomerInformation customerInformation) { base.AddObject("CustomerInformations", customerInformation); }