Пример #1
0
        public IndustryEntity AddOrUpdateIndustry(IndustryEntity entityObject)
        {
            string sqlStatement = "";
            //if insert
            if (entityObject.IndustryId > 0)
            {
                sqlStatement += "UPDATE Industry SET  " + Environment.NewLine +
                "Description=@Description," + Environment.NewLine +
                "Deleted=@Deleted" + Environment.NewLine +
                "WHERE IndustryId=@IndustryId " + Environment.NewLine +
                "SELECT @IndustryId AS IndustryId " + Environment.NewLine;
            }
            else
            {
                sqlStatement += "INSERT INTO Industry(  " + Environment.NewLine +
                "Description," + Environment.NewLine +
                "Deleted)" + Environment.NewLine +
                "VALUES (" + Environment.NewLine +
                "@Description," + Environment.NewLine +
                "@Deleted)" + Environment.NewLine +
                "SELECT SCOPE_IDENTITY() AS IndustryId" + Environment.NewLine;
            }

            //execute
            entityObject.IndustryId = Connection.ExecuteScalar<int>(sqlStatement, new
            {
                IndustryId = entityObject.IndustryId,
                Description = entityObject.Description,
                Deleted = (entityObject.Deleted ? 1 : 0)
            }, Transaction);
            return entityObject;
        }
Пример #2
0
        public bool DeleteIndustry(IndustryEntity entityObject)
        {
            string sqlStatement = "UPDATE Industry SET Deleted=1 WHERE IndustryId=@IndustryId  " + Environment.NewLine;

            //execute
            Connection.Execute(sqlStatement, new { IndustryId = entityObject.IndustryId }, Transaction);
            return true;
        }
Пример #3
0
 public bool DeleteIndustry(IndustryEntity entityObject)
 {
     //execute
     using (var db = VinaGerman.Database.VinagermanDatabase.GetDatabaseInstance())
     {
         try
         {
             db.OpenConnection();
             return db.Resolve<IIndustryDB>().DeleteIndustry(entityObject);
         }
         finally
         {
             db.CloseConnection();
         }
     }
 }
        public void Save(IndustryEntity entityObject)
        {
            System.Threading.ThreadPool.QueueUserWorkItem(delegate
            {
                try
                {
                    ShowLoading(StringResources.captionInformation, StringResources.msgLoading);

                    var updatedEntity = Factory.Resolve<IBaseDataDS>().AddOrUpdateIndustry(entityObject);

                    HideLoading();

                    //display to UI
                    Application.Current.Dispatcher.Invoke(new Action(() =>
                    {
                        AddOrUpdateIndustry(updatedEntity);
                    }));
                }
                catch (Exception ex)
                {
                    HideLoading();
                    ShowMessageBox(StringResources.captionError, ex.ToString(), MessageBoxButton.OK);
                }
            });
        }
        public void DeleteIndustry(IndustryEntity newEntity)
        {
            IndustryEntity oldEntity = IndustryList.FirstOrDefault<IndustryEntity>(p => p.IndustryId == newEntity.IndustryId);

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

            IndustryList = new List<IndustryEntity>(_industryList);
        }
        public void AddOrUpdateIndustry(IndustryEntity newEntity)
        {
            IndustryEntity oldEntity = IndustryList.FirstOrDefault<IndustryEntity>(p => p.Description == newEntity.Description);

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

            IndustryList = new List<IndustryEntity>(_industryList);
        }
 public void Add()
 {
     var newEntity = new IndustryEntity()
     {
         Deleted = false,
         Description = "",
         IndustryId=-1
     };
     IndustryList.Add(newEntity);
     IndustryList = new List<IndustryEntity>(_industryList);
 }
Пример #8
0
 private void LoadData()
 {
     List<IndustryEntity> list = Factory.Resolve<IBaseDataDS>().SearchIndustry(new IndustrySearchEntity()
     {
         SearchText = ""
     });
     if (list != null && list.Count > 0)
     {
         source.DataSource = list;
         GridIndustry.DataSource = source;
     }
     else
     {
         List<IndustryEntity> lst = new List<IndustryEntity>();
         IndustryEntity it = new IndustryEntity();
         it.Description = "";
         lst.Add(it);
         source.DataSource = lst;
         GridIndustry.DataSource = source;
     }
 }
Пример #9
0
 private void CopyRow()
 {
     try
     {
         List<IndustryEntity> lst = (List<IndustryEntity>)source.DataSource;
         int index = -1;
         index = this.gvIndustry.FocusedRowHandle;
         IndustryEntity b = (IndustryEntity)gvIndustry.GetFocusedRow();
         if (b != null)
         {
             source = (BindingSource)GridIndustry.DataSource;
             List<IndustryEntity> list = (List<IndustryEntity>)source.DataSource;
             if (list != null && list.Count > 0)
             {
                 IndustryEntity a = new IndustryEntity();
                 ApplicationHelper.TranferProperiesEx(b, a);
                 a.IndustryId = 0;
                 list.Add(a);
             }
             source.DataSource = list;
             GridIndustry.DataSource = source;
             gvIndustry.RefreshData();
         }
     }
     catch (Exception e)
     {
         Log.WriteLog(this, System.Reflection.MethodBase.GetCurrentMethod().Name, e.Message);
     }
 }
        public void Reload()
        {
            System.Threading.ThreadPool.QueueUserWorkItem(delegate
            {
                try
                {
                    ShowLoading(StringResources.captionInformation, StringResources.msgLoading);
                    var _obusinessList = Factory.Resolve<IBaseDataDS>().SearchBusiness(new BusinessSearchEntity()
                    {
                        SearchText = ""
                    });

                    var _oindustryList = Factory.Resolve<IBaseDataDS>().SearchIndustry(new IndustrySearchEntity()
                    {
                        SearchText = ""
                    });
                    HideLoading();

                    //display to UI
                    Application.Current.Dispatcher.Invoke(new Action(() =>
                    {
                        BusinessEntity itbs = new BusinessEntity() { BusinessId = 0, Description = "" };
                        BusinessList = _obusinessList;
                        BusinessList.Insert(0, itbs);
                        SelectedBusiness = BusinessList.FirstOrDefault();
                        IndustryEntity itin = new IndustryEntity() { IndustryId = 0, Description = "" };
                        IndustryList = _oindustryList;
                        IndustryList.Insert(0, itin);
                        SelectedIndustry = IndustryList.FirstOrDefault();
                    }));
                }
                catch (Exception ex)
                {
                    HideLoading();
                    ShowMessageBox(StringResources.captionError, ex.ToString(), MessageBoxButton.OK);
                }
            });
            //ShowDialog<uvCompanyDetailViewModel>(new uvCompanyDetailViewModel() {
            //    OriginalCompany = SelectCompany
            //});
        }
Пример #11
0
 public bool DeleteIndustry(IndustryEntity entityObject)
 {
     return Factory.Resolve<IIndustryBL>().DeleteIndustry(entityObject);
 }
Пример #12
0
 public IndustryEntity AddOrUpdateIndustry(IndustryEntity entityObject)
 {
     return Factory.Resolve<IIndustryBL>().AddOrUpdateIndustry(entityObject);
 }