Ejemplo n.º 1
0
        /// <summary>
        /// 添加行业
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public BaseObject InsertIndustry(IndustryEntity param)
        {
            var obj = new BaseObject();

            try
            {
                var industry = new Industry();
                industry.AddDate      = DateTime.Now;
                industry.Description  = param.Description;
                industry.IndustryName = param.IndustryName;
                industry.UserID       = param.UserID;

                _db.Industries.Add(industry);
                _db.SaveChanges();

                obj.Tag = 1;
            }
            catch (Exception e)
            {
                obj.Tag     = -1;
                obj.Message = e.Message;
            }

            return(obj);
        }
Ejemplo n.º 2
0
        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);
                }
            });
        }
Ejemplo n.º 3
0
 /// <summary>
 /// 更新行业信息
 /// </summary>
 /// <param name="param"></param>
 /// <returns></returns>
 public BaseObject UpdateIndustry(IndustryEntity param)
 {
     using (IndustryLogic logic = new IndustryLogic())
     {
         return(logic.UpdateIndustry(param));
     }
 }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
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);
     }
 }
Ejemplo n.º 6
0
        /// <summary>
        /// 更新行业信息
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public BaseObject UpdateIndustry(IndustryEntity param)
        {
            var obj = new BaseObject();

            try
            {
                var industry = _db.Industries.FirstOrDefault(m => m.ID == param.ID);
                if (industry == null)
                {
                    obj.Tag     = -1;
                    obj.Message = "更新失败!";
                    return(obj);
                }

                industry.AddDate      = DateTime.Now;
                industry.Description  = param.Description;
                industry.IndustryName = param.IndustryName;
                industry.UserID       = param.UserID;

                _db.SaveChanges();
                obj.Tag = 1;
            }
            catch (Exception e)
            {
                obj.Tag     = -1;
                obj.Message = e.Message;
            }

            return(obj);
        }
Ejemplo n.º 7
0
        public ActionResult EditIndustryJson(IndustryEntity param)
        {
            param.UserID = User.Identity.Name.Uint();
            var result = new Helpers.IndustryHelper().UpdateIndustry(param);

            return(Json(result));
        }
Ejemplo n.º 8
0
 private void RowDeleted()
 {
     try
     {
         if (XtraMessageBox.Show("Bạn có chắc muốn xóa", "Thông báo", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK)
         {
             int index = -1;
             index = this.gvIndustry.FocusedRowHandle;
             if (index >= 0)
             {
                 source = (BindingSource)GridIndustry.DataSource;
                 List <IndustryEntity> list = (List <IndustryEntity>)source.DataSource;
                 if (list != null && list.Count > 0)
                 {
                     IndustryEntity a = (IndustryEntity)list[index];
                     listDeleteDK.Add(a);
                 }
                 gvIndustry.DeleteRow(index);
                 gvIndustry.UpdateCurrentRow();
             }
         }
     }
     catch (Exception e)
     {
         Log.WriteLog(this, System.Reflection.MethodBase.GetCurrentMethod().Name, e.Message);
     }
 }
Ejemplo n.º 9
0
        public IndustryEntity AddOrUpdateIndustry(IndustryEntity entityObject)
        {
            IBaseDataSvc channel = CreateChannel();
            var          result  = channel.AddOrUpdateIndustry(entityObject);

            channel.Dispose();
            return(result);
        }
Ejemplo n.º 10
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);
        }
Ejemplo n.º 11
0
    /// <summary>
    /// 从界面获取对象
    /// </summary>
    /// <returns></returns>
    private IndustryEntity GetIndustryUI()
    {
        IndustryEntity Result = new IndustryEntity();

        Result.IndustryID   = IndustryID;
        Result.IndustryName = txtIndustryName.Text;
        Result.Validity     = EnvConverter.ToInt32(txtValidity.Text);
        return(Result);
    }
Ejemplo n.º 12
0
    protected void btnSaveIndustry_Click(object sender, EventArgs e)
    {
        IndustryEntity Result = GetIndustryUI();

        m_Industry.SaveIndustry(Result);
        //if (Succeed > 0) ShowMessage("数据保存成功!");
        //if (Succeed < 0) ShowMessage("数据保存失败!");
        DataBind();
        SetUIState("Default");
    }
Ejemplo n.º 13
0
    /// <summary>
    /// 填充界面
    /// </summary>
    private void SetIndustryUI()
    {
        IndustryEntity Result = m_Industry.GetIndustry(IndustryID);

        if (Result == null)
        {
            return;
        }
        txtIndustryName.Text = Result.IndustryName;
        txtValidity.Text     = Result.Validity + "";
    }
Ejemplo n.º 14
0
        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);
        }
Ejemplo n.º 15
0
        public void Add()
        {
            var newEntity = new IndustryEntity()
            {
                Deleted     = false,
                Description = "",
                IndustryId  = -1
            };

            IndustryList.Add(newEntity);
            IndustryList = new List <IndustryEntity>(_industryList);
        }
        public int CreateIndustry(IndustryEntity regionEntity)
        {
            var region = new Industry
            {
                Name = regionEntity.Name
            };

            _unitOfWork.IndustryRepository.Insert(region);
            _unitOfWork.Save();

            return(region.IndustryId);
        }
Ejemplo n.º 17
0
        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
            //});
        }
Ejemplo n.º 18
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();
         }
     }
 }
Ejemplo n.º 19
0
        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 bool UpdateIndustry(int regionId, IndustryEntity regionEntity)
        {
            var success = false;

            if (regionEntity != null)
            {
                var region = _unitOfWork.IndustryRepository.GetById(regionId);
                if (region != null)
                {
                    region.Name = regionEntity.Name;
                    _unitOfWork.IndustryRepository.Update(region);
                    _unitOfWork.Save();

                    success = true;
                }
            }
            return(success);
        }
Ejemplo n.º 21
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;
            }
        }
Ejemplo n.º 22
0
 public IndustryEntity AddOrUpdateIndustry(IndustryEntity entityObject)
 {
     return(Factory.Resolve <IIndustryBL>().AddOrUpdateIndustry(entityObject));
 }
Ejemplo n.º 23
0
 public void SaveIndustry(IndustryEntity Industry)
 {
     DataAccess.SaveIndustry(Industry);
 }
Ejemplo n.º 24
0
 public void DeleteIndustry(IndustryEntity Industry)
 {
     DataAccess.DeleteIndustry(Industry);
 }
Ejemplo n.º 25
0
 public bool DeleteIndustry(IndustryEntity entityObject)
 {
     return(Factory.Resolve <IIndustryBL>().DeleteIndustry(entityObject));
 }