Exemplo n.º 1
0
        private void showSelectedCompanyData(object sender, DataGridViewCellEventArgs e)
        {
            int             idnex = companiesData.CurrentCell.RowIndex;
            SupplierProfile obj   = new SupplierProfile(this.home, (Company)companiesList[idnex]);

            home.openChildForm(obj);
        }
Exemplo n.º 2
0
 /// <summary>
 /// This method is used for insert new supplier profile in database. - JJ
 /// </summary>
 /// <param name="supplierProfile"> object of SupplierProfileAC</param>
 /// <param name="companyId"></param>
 /// <returns>object of SupplierProfileAC</returns>
 public SupplierProfileAC SaveSupplierProfile(SupplierProfileAC supplierProfile, int companyId)
 {
     try
     {
         if (CheckSupplierCodeIdExist(supplierProfile.Code, supplierProfile.Id, companyId))
         {
             supplierProfile.Code = "";
             return(supplierProfile);
         }
         else if (CheckSupplierPhoneIdExist(supplierProfile.Phone, supplierProfile.Id))
         {
             supplierProfile.Phone = "";
             return(supplierProfile);
         }
         else if (CheckSupplierEmailIdExist(supplierProfile.Email, supplierProfile.Id))
         {
             supplierProfile.Email = "";
             return(supplierProfile);
         }
         var supplierProfiles = new SupplierProfile
         {
             Code           = supplierProfile.Code,
             CompanyId      = companyId,
             NameEn         = supplierProfile.NameEn,
             NameSl         = supplierProfile.NameSl,
             AddressEn      = supplierProfile.AddressEn,
             AddressSl      = supplierProfile.AddressSl,
             Phone          = supplierProfile.Phone,
             Fax            = supplierProfile.Fax,
             Email          = supplierProfile.Email,
             ZipCode        = supplierProfile.ZipCode,
             TotalDaysLimit = supplierProfile.TotalDaysLimit,
             POBox          = supplierProfile.POBox,
             SupplierTypeId = supplierProfile.SupplierTypeId,
             IsDeleted      = supplierProfile.IsDeleted,
             IsActive       = true,
             IsAcceptReturnForExpiredItem = supplierProfile.IsAcceptReturnForExpiredItem,
             CreatedDateTime = DateTime.UtcNow
         };
         _supplierProfileContext.Add(supplierProfiles);
         _supplierProfileContext.SaveChanges();
         supplierProfile.Id = supplierProfiles.Id;
         var creditTypeId = _paramTypeContext.FirstOrDefault(x => x.Param.Value == StringConstants.SupplierType && x.ValueEn == StringConstants.Credit).Id;
         if (supplierProfiles.SupplierTypeId == creditTypeId && supplierProfile.TotalDaysLimit > 0)
         {
             AddDaysLimit(supplierProfile.DiscountDays, supplierProfiles.Id, supplierProfile.Discount, supplierProfile.Days);
         }
         return(supplierProfile);
     }
     catch (Exception ex)
     {
         _errorLog.LogException(ex);
         throw;
     }
 }