private void InitializeData(CompanyTypes type) { try { Cursor = Cursors.WaitCursor; dsCore1.EnforceConstraints = false; daCompanies1.Connection = AppHelper.GetDbConnection(); daCompanies1.ClearBeforeFill = true; if (type == CompanyTypes.Customer) { daCompanies1.FillCustomer(dsCore1.Companies); } else { daCompanies1.FillVendor(dsCore1.Companies); } } catch (Exception ex) { Logger.ErrorRoutine(ex); RibbonMessageBox.Show("ERROR Loading Data!\n" + ex.Message); } finally { Cursor = Cursors.Default; } }
public async Task Create_InvalidInput_ReturnNull(string name, CompanyTypes companyType) { #region Arrange var dbContext = new ApplicationDbContext(_dbContextOptions); await dbContext.Database.EnsureDeletedAsync(); await dbContext.SaveChangesAsync(); var newCompany = new AdminCompanyModel { Name = name, Type = companyType }; var appCompany = new Company(dbContext); #endregion #region Act var actualCompany = await appCompany.Create(newCompany); #endregion #region Assert Assert.Null(actualCompany); #endregion }
public async Task Update_InvalidInput_ReturnsNull(int id, string name, CompanyTypes companyType) { #region Arrange var dbContext = new ApplicationDbContext(_dbContextOptions); await dbContext.Database.EnsureDeletedAsync(); var company = new Domain.Company { Name = "Name", Type = CompanyTypes.Producer }; dbContext.Companies.Add(company); await dbContext.SaveChangesAsync(); var newCompany = new AdminCompanyModel { ID = id, Name = name, Type = companyType }; var appCompany = new Company(dbContext); #endregion #region Act var actualCompany = await appCompany.Update(newCompany); #endregion #region Assert Assert.Null(actualCompany); #endregion }
private void InitializeData(CompanyTypes type) { try { Cursor = Cursors.WaitCursor; dsCore1.EnforceConstraints = false; daOrders1.Connection = AppHelper.GetDbConnection(); daOrders1.ClearBeforeFill = true; if (type == CompanyTypes.Customer) { daOrders1.FillOpeningBalanceCustomer(dsCore1.Orders, (DateTime)dtpBegin.Value, ((DateTime)dtpEnd.Value).AddDays(1)); } else { daOrders1.FillOpeningBalanceVendor(dsCore1.Orders, (DateTime)dtpBegin.Value, ((DateTime)dtpEnd.Value).AddDays(1)); } } catch (Exception ex) { Logger.ErrorRoutine(ex); RibbonMessageBox.Show("ERROR Loading Data!\n" + ex.Message); } finally { Cursor = Cursors.Default; } }
public async Task Create_ValidInput_ReturnsCorrectData(string name, CompanyTypes companyType) { #region Arrange var dbContext = new ApplicationDbContext(_dbContextOptions); await dbContext.Database.EnsureDeletedAsync(); var newCompany = new AdminCompanyModel { Name = name, Type = companyType }; var expectedCompany = new CompanyModel { ID = 1, Name = name, Type = companyType.ToString() }; var appCompany = new Company(dbContext); #endregion #region Act var actualCompany = await appCompany.Create(newCompany); #endregion #region Assert Assert.Equal(expectedCompany.ID, actualCompany.ID); Assert.Equal(expectedCompany.Name, actualCompany.Name); Assert.Equal(expectedCompany.Type, actualCompany.Type); #endregion }
private void InitializeData(CompanyTypes type, int id) { // main data try { dsCore1.EnforceConstraints = false; // set database connection daCurrencies1.Connection = AppHelper.GetDbConnection(); daCompanies1.Connection = AppHelper.GetDbConnection(); daOrders1.Connection = AppHelper.GetDbConnection(); // lookup table daCurrencies1.FillActive(dsCore1.Currencies); if (type == CompanyTypes.Customer) { daCompanies1.FillCustomerActive(dsCore1.Companies); } else { daCompanies1.FillVendorActive(dsCore1.Companies); } // get data if (id < 0) { // mode txMode = DataEntryModes.Add; // add new row to master table BindingContext[dsCore1, "Orders"].AddNew(); // default values for master table DataRowView dr = (DataRowView)this.BindingContext[dsCore1, "Orders"].Current; dr["OrderNo"] = DbHelper.GenerateNewOrderID(ModulePrefix, DateTime.Today.Year); dr["OrderValue"] = 0; dr["OrderType"] = ModulePrefix; dr["OrderDate"] = DateTime.Today; dr["RequiredDate"] = DateTime.Today.AddDays(30); dr["PaymentValue"] = 0; dr["PaymentType"] = 1; // credit payment } else { // mode txMode = DataEntryModes.Edit; // get data daOrders1.ClearBeforeFill = true; daOrders1.FillByID(dsCore1.Orders, id); } } catch (Exception ex) { Logger.ErrorRoutine(ex); RibbonMessageBox.Show("ERROR Loading Data: " + ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
public Company(string name, string address, string[] contacs, string taxNo, TaxOffice taxOffice, string ticaretSicilNo, string tcNo, CompanyTypes companyType, string[] taxTypes) { Name = name; Address = address; Contacs = contacs; TaxNo = taxNo; TaxOffice = taxOffice; TicaretSicilNo = ticaretSicilNo; TcNo = tcNo; CompanyType = companyType; TaxTypes = taxTypes; }
public static IEnumerable <object[]> Data_Create_InvalidInput_ReturnNull() { string name = "Name"; CompanyTypes companyType = CompanyTypes.Distributor; // name = null yield return(new object[] { null, companyType }); // name = empty yield return(new object[] { "", companyType }); // companyType = 100 (does not exists) yield return(new object[] { name, 100 }); }
private void InitializeForm(CompanyTypes type) { this.type = type; if (type == CompanyTypes.Customer) { this.Text = "Customer List"; this._grid.Caption = "Customer List"; } else { this.Text = "Vendor List"; this._grid.Caption = "Vendor List"; } }
private void InitializeData(CompanyTypes type, int id) { // main data try { dsCore1.EnforceConstraints = false; // set database connection daCurrencies1.Connection = AppHelper.GetDbConnection(); daCompanies1.Connection = AppHelper.GetDbConnection(); daOrders1.Connection = AppHelper.GetDbConnection(); // lookup table daCurrencies1.FillActive(dsCore1.Currencies); if (type == CompanyTypes.Customer) daCompanies1.FillCustomerActive(dsCore1.Companies); else daCompanies1.FillVendorActive(dsCore1.Companies); // get data if (id < 0) { // mode txMode = DataEntryModes.Add; // add new row to master table BindingContext[dsCore1, "Orders"].AddNew(); // default values for master table DataRowView dr = (DataRowView)this.BindingContext[dsCore1, "Orders"].Current; dr["OrderNo"] = DbHelper.GenerateNewOrderID(ModulePrefix, DateTime.Today.Year); dr["OrderValue"] = 0; dr["OrderType"] = ModulePrefix; dr["OrderDate"] = DateTime.Today; dr["RequiredDate"] = DateTime.Today.AddDays(30); dr["PaymentValue"] = 0; dr["PaymentType"] = 1; // credit payment } else { // mode txMode = DataEntryModes.Edit; // get data daOrders1.ClearBeforeFill = true; daOrders1.FillByID(dsCore1.Orders, id); } } catch (Exception ex) { Logger.ErrorRoutine(ex); RibbonMessageBox.Show("ERROR Loading Data: " + ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
private void InitializeForm(CompanyTypes type) { this.type = type; if (type == CompanyTypes.Customer) { this.Text = "Customer Entry"; this.label1.Text = "Customer Code"; this.label2.Text = "Customer Name"; } else { this.Text = "Vendor Entry"; this.label1.Text = "Vendor Code"; this.label2.Text = "Vendor Name"; } }
private void InitializeForm(CompanyTypes type) { this.type = type; AppHelper.ApplyVisualStyle(this.Controls); if (type == CompanyTypes.Customer) { this.Text = "Customer Opening Balance Entry"; this.label4.Text = "Customer Name"; ModulePrefix = TransactionTypes.TX_BEGINBALANCE_CUSTOMER; } else { this.Text = "Vendor Opening Balance Entry"; this.label4.Text = "Vendor Name"; ModulePrefix = TransactionTypes.TX_BEGINBALANCE_VENDOR; } }
public static IEnumerable <object[]> Data_Update_InvalidInput_ReturnsNull() { int id = 1; string name = "New Name"; CompanyTypes companyType = CompanyTypes.Distributor; // id = 2 (does not exist) yield return(new object[] { 2, name, companyType }); // name = null yield return(new object[] { id, null, companyType }); // name = empty yield return(new object[] { id, "", companyType }); // companyType = 100 (does not exist) yield return(new object[] { id, name, 100 }); }
public void frmCompanyEntry_Helper(CompanyTypes type, int id) { InitializeComponent(); InitializeForm(type); // access control id ModuleID = "ACC-01013"; // retrieve data daCompanies1.Connection = AppHelper.GetDbConnection(); daCompanies1.ClearBeforeFill = true; try { if (id < 0) { this.BindingContext[this.dsCore1, "Companies"].AddNew(); DataRowView dr = (DataRowView)this.BindingContext[this.dsCore1, "Companies"].Current; txMode = DataEntryModes.Add; // default field value dr["Active"] = 1; if (type == CompanyTypes.Customer) { dr["Type"] = "C"; dr["Code"] = DbHelper.GenerateNewCompanyID("CI"); } else { dr["Type"] = "S"; dr["Code"] = DbHelper.GenerateNewCompanyID("VI"); } } else { daCompanies1.FillByID(this.dsCore1.Companies, id); txMode = DataEntryModes.Edit; } } catch (Exception ex) { // textfile logging Logger.ErrorRoutine(ex); // screen logging RibbonMessageBox.Show("ERROR Loading Data!\n" + ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
private void InitializeData(CompanyTypes type) { try { Cursor = Cursors.WaitCursor; dsCore1.EnforceConstraints = false; daOrders1.Connection = AppHelper.GetDbConnection(); daOrders1.ClearBeforeFill = true; if (type == CompanyTypes.Customer) daOrders1.FillOpeningBalanceCustomer(dsCore1.Orders, (DateTime)dtpBegin.Value, ((DateTime)dtpEnd.Value).AddDays(1)); else daOrders1.FillOpeningBalanceVendor(dsCore1.Orders, (DateTime)dtpBegin.Value, ((DateTime)dtpEnd.Value).AddDays(1)); } catch (Exception ex) { Logger.ErrorRoutine(ex); RibbonMessageBox.Show("ERROR Loading Data!\n" + ex.Message); } finally { Cursor = Cursors.Default; } }
private void InitializeData(CompanyTypes type) { try { Cursor = Cursors.WaitCursor; dsCore1.EnforceConstraints = false; daCompanies1.Connection = AppHelper.GetDbConnection(); daCompanies1.ClearBeforeFill = true; if (type == CompanyTypes.Customer) daCompanies1.FillCustomer(dsCore1.Companies); else daCompanies1.FillVendor(dsCore1.Companies); } catch (Exception ex) { Logger.ErrorRoutine(ex); RibbonMessageBox.Show("ERROR Loading Data!\n" + ex.Message); } finally { Cursor = Cursors.Default; } }
public frmCompanyList(CompanyTypes type) { InitializeComponent(); InitializeForm(type); InitializeData(type); }
public static IEnumerable <object[]> Data_Create_InvalidRequest_ReturnsJsonResponseAndBadRequestWithErrors() { string name = "Name"; CompanyTypes companyType = CompanyTypes.Producer; // Name = null yield return(new object[] { null, companyType, new string[] { "Name" }, new string[] { "Cannot be null or empty." } }); // Name = empty yield return(new object[] { "", companyType, new string[] { "Name" }, new string[] { "Cannot be null or empty." } }); // CompanyType = 100 yield return(new object[] { name, 100, new string[] { "Type" }, new string[] { "Does not exist." } }); // Everything wrong yield return(new object[] { null, 100, new string[] { "Name", "Type" }, new string[] { "Cannot be null or empty.", "Does not exist." } }); }
public async Task Update_InvalidRequest_ReturnsJsonResponseAndBadRequestWithErrors(int id, string name, CompanyTypes companyType, IEnumerable <string> expectedErrorNames, IEnumerable <string> expectedErrorMessages) { #region Arrange await DeleteDbContent(); var client = GetHttpClient(); var dbContext = GetDbContext(); dbContext.Companies.Add(new Domain.Company { Name = "Name", Type = CompanyTypes.Distributor }); await dbContext.SaveChangesAsync(); var newCompany = new AdminCompanyModel { ID = id, Name = name, Type = companyType }; #endregion #region Act var response = await client.PutAsJsonAsync($"/api/company/{id}", newCompany); var responseBody = await response.Content.ReadAsStreamAsync(); var actualCompany = await JsonSerializer.DeserializeAsync <JsonElement>(responseBody); var errorProp = actualCompany.GetProperty("errors"); var errors = errorProp.EnumerateObject(); #endregion #region Assert Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode); Assert.Equal(expectedErrorNames.Count(), errors.Count()); Assert.All(expectedErrorNames, errorName => Assert.Contains(errorName, errors.Select(prop => prop.Name))); Assert.All(expectedErrorMessages, errorMessage => Assert.Contains(errorMessage, errors.Select(prop => prop.Value[0].ToString()))); #endregion }
public async Task Update_ValidRequest_ReturnsJsonResponseAndOk(int id, string name, CompanyTypes companyType) { #region Arrange await DeleteDbContent(); var client = GetHttpClient(); var dbContext = GetDbContext(); dbContext.Companies.Add(new Domain.Company { Name = "Name", Type = CompanyTypes.Distributor }); await dbContext.SaveChangesAsync(); var newCompany = new AdminCompanyModel { ID = id, Name = name, Type = companyType }; var expectedCompany = new CompanyModel { ID = id, Name = name, Type = companyType.ToString() }; #endregion #region Act var response = await client.PutAsJsonAsync($"/api/company/{id}", newCompany); var responseBody = await response.Content.ReadAsStreamAsync(); var actualCompany = await JsonSerializer.DeserializeAsync <CompanyModel>(responseBody); #endregion #region Assert Assert.Equal(HttpStatusCode.OK, response.StatusCode); Assert.Equal(expectedCompany.ID, actualCompany.ID); Assert.Equal(expectedCompany.Name, actualCompany.Name); Assert.Equal(expectedCompany.Type, actualCompany.Type); #endregion }
public async Task Create_ValidRequest_ReturnsJsonResponseAndCreated(string name, CompanyTypes companyType) { #region Arrange await DeleteDbContent(); var client = GetHttpClient(); var newCompany = new AdminCompanyModel { Name = name, Type = companyType }; var expectedCompany = new CompanyModel { ID = 1, Name = name, Type = companyType.ToString() }; #endregion #region Act var response = await client.PostAsJsonAsync("/api/company", newCompany); var responseBody = await response.Content.ReadAsStreamAsync(); var actualCompany = await JsonSerializer.DeserializeAsync <CompanyModel>(responseBody); #endregion #region Assert Assert.Equal(HttpStatusCode.Created, response.StatusCode); Assert.Equal(expectedCompany.ID, actualCompany.ID); Assert.Equal(expectedCompany.Name, actualCompany.Name); Assert.Equal(expectedCompany.Type, actualCompany.Type); #endregion }
public async Task Create_InvalidRequest_ReturnsJsonResponseAndBadRequestWithErrors(string name, CompanyTypes companyType, IEnumerable <string> expectedErrorNames, IEnumerable <string> expectedErrorValues) { #region Arrange await DeleteDbContent(); var client = GetHttpClient(); var newCompany = new AdminCompanyModel { Name = name, Type = companyType }; #endregion #region Act var response = await client.PostAsJsonAsync("/api/company", newCompany); var responseBody = await response.Content.ReadAsStreamAsync(); var actualCompany = await JsonSerializer.DeserializeAsync <JsonElement>(responseBody); var errorProp = actualCompany.GetProperty("errors"); var errors = errorProp.EnumerateObject(); #endregion #region Assert Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode); Assert.Equal(expectedErrorNames.Count(), errors.Count()); Assert.All(expectedErrorNames, errorName => Assert.Contains(errorName, errors.Select(prop => prop.Name))); Assert.All(expectedErrorValues, errorValue => Assert.Contains(errorValue, errors.Select(prop => prop.Value[0].ToString()))); #endregion }
public frmCompanyBalanceEntry(CompanyTypes type) { frmCompanyBalanceEntry_Helper(type, -1); }
public frmCompanyBalanceEntry(CompanyTypes type, int id) { frmCompanyBalanceEntry_Helper(type, id); }
// get company type from the DB public CompanyType GetCompanyType(CompanyTypes companyType) { return(ContextDb.CompanyTypes.FirstOrDefault(x => x.Name == companyType.ToString())); }
public void frmCompanyBalanceEntry_Helper(CompanyTypes type, int id) { InitializeComponent(); InitializeForm(type); InitializeData(type, id); }
// get company type of a company which will be added to the DB public CompanyType GetCompanyType(CompanyTypes companyType) { return(Repository.GetCompanyType(companyType)); }