Example #1
0
        public bool DeleteCompany(CompanyEntity entityObject)
        {
            string sqlStatement = "UPDATE Company SET Deleted=1 WHERE CompanyId=@CompanyId  " + Environment.NewLine;

            //execute
            Connection.Execute(sqlStatement, new { CompanyId = entityObject.CompanyId }, Transaction);
            return true;
        }
Example #2
0
 public List<VinaGerman.Entity.BusinessEntity.ContactEntity> GetContactForCompany(CompanyEntity Object)
 {
     //execute
     using (var db = VinaGerman.Database.VinagermanDatabase.GetDatabaseInstance())
     {
         try
         {
             db.OpenConnection();
             return db.Resolve<IContactDB>().GetContactForCompany(Object);
         }
         finally
         {
             db.CloseConnection();
         }
     }
 }
Example #3
0
 public bool DeleteCompany(CompanyEntity entityObject)
 {
     //execute
     using (var db = VinaGerman.Database.VinagermanDatabase.GetDatabaseInstance())
     {
         try
         {
             db.OpenConnection();
             return db.Resolve<ICompanyDB>().DeleteCompany(entityObject);
         }
         finally
         {
             db.CloseConnection();
         }
     }
 }
Example #4
0
        public CompanyEntity AddOrUpdateCompany(CompanyEntity entityObject)
        {
            string sqlStatement = "";
            //if insert
            if (entityObject.CompanyId > 0)
            {
                sqlStatement += "UPDATE Company SET  " + Environment.NewLine +
                "CompanyOwner=@CompanyOwner," + Environment.NewLine +
                "Description=@Description," + Environment.NewLine +
                "Deleted=@Deleted," + Environment.NewLine +
                "Address=@Address," + Environment.NewLine +
                "CompanyCode=@CompanyCode," + Environment.NewLine +
                "TaxCode=@TaxCode," + Environment.NewLine +
                "Website=@Website," + Environment.NewLine +
                "Phone=@Phone," + Environment.NewLine +
                "IsSupplier=@IsSupplier," + Environment.NewLine +
                "IsCustomer=@IsCustomer" + Environment.NewLine +
                "WHERE CompanyId=@CompanyId " + Environment.NewLine +
                "SELECT @CompanyId AS CompanyId " + Environment.NewLine;
            }
            else
            {
                sqlStatement += "INSERT INTO Company(  " + Environment.NewLine +
                "CompanyOwner," + Environment.NewLine +
                "Description," + Environment.NewLine +
                "Deleted," + Environment.NewLine +
                "Address," + Environment.NewLine +
                "CompanyCode," + Environment.NewLine +
                "TaxCode," + Environment.NewLine +
                "Website," + Environment.NewLine +
                "Phone," + Environment.NewLine +
                "IsSupplier," + Environment.NewLine +
                "IsCustomer)" + Environment.NewLine +
                "VALUES (" + Environment.NewLine +
                "@CompanyOwner," + Environment.NewLine +
                "@Description," + Environment.NewLine +
                "@Deleted," + Environment.NewLine +
                "@Address," + Environment.NewLine +
                "@CompanyCode," + Environment.NewLine +
                "@TaxCode," + Environment.NewLine +
                "@Website," + Environment.NewLine +
                "@Phone," + Environment.NewLine +
                "@IsSupplier," + Environment.NewLine +
                "@IsCustomer)" + Environment.NewLine +
                "SELECT SCOPE_IDENTITY() AS CompanyId" + Environment.NewLine;
            }

            //execute
            entityObject.CompanyId = Connection.ExecuteScalar<int>(sqlStatement, new
            {
                Address = entityObject.Address,
                CompanyCode = entityObject.CompanyCode,
                CompanyId = entityObject.CompanyId,
                CompanyOwner = entityObject.CompanyOwner,
                Description = entityObject.Description,
                IsCustomer = (entityObject.IsCustomer ? 1 : 0),
                IsSupplier = (entityObject.IsSupplier ? 1 : 0),
                Deleted = (entityObject.Deleted ? 1 : 0),
                Phone = entityObject.Phone,
                TaxCode = entityObject.TaxCode,
                Website = entityObject.Website
            }, Transaction);
            return entityObject;
        }
Example #5
0
 public List<VinaGerman.Entity.BusinessEntity.ContactEntity> GetContactForCompany(CompanyEntity hObject)
 {
     List<VinaGerman.Entity.BusinessEntity.ContactEntity> result = null;
     string sqlStatement = "SELECT " + Environment.NewLine +
         "Contact.ContactId," + Environment.NewLine +
         "Contact.FullName," + Environment.NewLine +
         "Contact.Email," + Environment.NewLine +
         "Contact.Phone," + Environment.NewLine +
         "Contact.Address," + Environment.NewLine +
         "Contact.CompanyId," + Environment.NewLine +
         "Contact.UserAccountId," + Environment.NewLine +
         "Contact.Position," + Environment.NewLine +
         "Contact.DepartmentId" + Environment.NewLine +
         "FROM Contact join Company on Contact.CompanyId= Company.CompanyId" + Environment.NewLine +
         "WHERE Contact.Deleted=0 and Contact.CompanyId=@CompanyId" + Environment.NewLine;
     //execute
     result = Connection.Query<VinaGerman.Entity.BusinessEntity.ContactEntity>(sqlStatement, new { CompanyId = hObject.CompanyId }, Transaction).ToList();
     return result;
 }
 private void LoadData()
 {
     List<CompanyEntity> list = Factory.Resolve<ICompanyDS>().SearchCompanies(new CompanySearchEntity()
     {
         SearchText = ""
     });
     if (list != null && list.Count > 0)
     {
         source.DataSource = list;
         GridCompany.DataSource = source;
     }
     else
     {
         List<CompanyEntity> lst = new List<CompanyEntity>();
         CompanyEntity it = new CompanyEntity();
         it.Description = "";
         lst.Add(it);
         source.DataSource = lst;
         GridCompany.DataSource = source;
     }
 }
 private void CopyRow()
 {
     try
     {
         List<CompanyEntity> lst = (List<CompanyEntity>)source.DataSource;
         int index = -1;
         index = this.gvCompany.FocusedRowHandle;
         CompanyEntity b = (CompanyEntity)gvCompany.GetFocusedRow();
         if (b != null)
         {
             source = (BindingSource)GridCompany.DataSource;
             List<CompanyEntity> list = (List<CompanyEntity>)source.DataSource;
             if (list != null && list.Count > 0)
             {
                 CompanyEntity a = new CompanyEntity();
                 ApplicationHelper.TranferProperiesEx(b, a);
                 a.CompanyId = 0;
                 list.Add(a);
             }
             source.DataSource = list;
             GridCompany.DataSource = source;
             gvCompany.RefreshData();
         }
     }
     catch (Exception e)
     {
         Log.WriteLog(this, System.Reflection.MethodBase.GetCurrentMethod().Name, e.Message);
     }
 }
        public void Save(CompanyEntity entityObject)
        {
            System.Threading.ThreadPool.QueueUserWorkItem(delegate
            {
                try
                {
                    ShowLoading(StringResources.captionInformation, StringResources.msgLoading);

                    var updatedEntity = Factory.Resolve<ICompanyDS>().AddOrUpdateCompany(entityObject);

                    HideLoading();

                    //display to UI
                    Application.Current.Dispatcher.Invoke(new Action(() =>
                    {
                        SelectedCompany = updatedEntity;
                        AddOrUpdateCompany(SelectedCompany);
                    }));
                }
                catch (Exception ex)
                {
                    HideLoading();
                    ShowMessageBox(StringResources.captionError, ex.ToString(), MessageBoxButton.OK);
                }
            });
        }
        public void DeleteCompany(CompanyEntity newEntity)
        {
            CompanyEntity oldEntity = CompanyList.FirstOrDefault<CompanyEntity>(p => p.CompanyId == newEntity.CompanyId);

            if (oldEntity != null)
            {
                CompanyList.Remove(oldEntity);
            }

            CompanyList = new List<CompanyEntity>(_companyList);
        }
        public void Delete(CompanyEntity entityObject)
        {
            if (ShowMessageBox(StringResources.captionConfirm, StringResources.msgConfirmDelete, MessageBoxButton.YesNo) == MessageBoxResult.Yes)
            {
                System.Threading.ThreadPool.QueueUserWorkItem(delegate
                {
                    try
                    {
                        ShowLoading(StringResources.captionInformation, StringResources.msgLoading);

                        var updatedEntity = Factory.Resolve<ICompanyDS>().DeleteCompany(entityObject);

                        HideLoading();

                        //display to UI
                        Application.Current.Dispatcher.Invoke(new Action(() =>
                        {
                            DeleteCompany(entityObject);
                            SelectedCompany = null;
                        }));
                    }
                    catch (Exception ex)
                    {
                        HideLoading();
                        ShowMessageBox(StringResources.captionError, ex.ToString(), MessageBoxButton.OK);
                    }
                });
            }
        }
        public void AddOrUpdateCompany(CompanyEntity newEntity)
        {
            CompanyEntity oldEntity = CompanyList.FirstOrDefault<CompanyEntity>(p => p.CompanyCode == newEntity.CompanyCode);

            if (oldEntity == null)
            {
                CompanyList.Insert(0, newEntity);
            }
            else
            {
                int index = CompanyList.IndexOf(oldEntity);
                CompanyList.Remove(oldEntity);
                CompanyList.Insert(index, newEntity);
            }

            CompanyList = new List<CompanyEntity>(_companyList);
        }
 public void Add()
 {
     var newEntity = new CompanyEntity() {
         CompanyId = -1,
         CompanyOwner= ApplicationHelper.CurrentUserProfile.CompanyId,
         Deleted = false,
         IsCustomer = true,
         IsSupplier = true,
         TaxCode = "",
         CompanyCode = "",
         Address = "",
         Phone = "",
         Website = ""
     };
     SelectedCompany = newEntity;
     CompanyList.Add(newEntity);
     CompanyList = new List<CompanyEntity>(_companyList);
 }
Example #13
0
 public List<VinaGerman.Entity.BusinessEntity.ContactEntity> GetContactForCompany(CompanyEntity Object)
 {
     return Factory.Resolve<IContactBL>().GetContactForCompany(Object);
 }
Example #14
0
 public bool DeleteCompany(CompanyEntity entityObject)
 {
     return Factory.Resolve<ICompanyBL>().DeleteCompany(entityObject);
 }
Example #15
0
 public CompanyEntity AddOrUpdateCompany(CompanyEntity entityObject)
 {
     return Factory.Resolve<ICompanyBL>().AddOrUpdateCompany(entityObject);
 }