/// <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); }
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); } }); }
/// <summary> /// 更新行业信息 /// </summary> /// <param name="param"></param> /// <returns></returns> public BaseObject UpdateIndustry(IndustryEntity param) { using (IndustryLogic logic = new IndustryLogic()) { return(logic.UpdateIndustry(param)); } }
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); }
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); } }
/// <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); }
public ActionResult EditIndustryJson(IndustryEntity param) { param.UserID = User.Identity.Name.Uint(); var result = new Helpers.IndustryHelper().UpdateIndustry(param); return(Json(result)); }
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); } }
public IndustryEntity AddOrUpdateIndustry(IndustryEntity entityObject) { IBaseDataSvc channel = CreateChannel(); var result = channel.AddOrUpdateIndustry(entityObject); channel.Dispose(); return(result); }
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); }
/// <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); }
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"); }
/// <summary> /// 填充界面 /// </summary> private void SetIndustryUI() { IndustryEntity Result = m_Industry.GetIndustry(IndustryID); if (Result == null) { return; } txtIndustryName.Text = Result.IndustryName; txtValidity.Text = Result.Validity + ""; }
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 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); }
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 //}); }
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 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); }
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; } }
public IndustryEntity AddOrUpdateIndustry(IndustryEntity entityObject) { return(Factory.Resolve <IIndustryBL>().AddOrUpdateIndustry(entityObject)); }
public void SaveIndustry(IndustryEntity Industry) { DataAccess.SaveIndustry(Industry); }
public void DeleteIndustry(IndustryEntity Industry) { DataAccess.DeleteIndustry(Industry); }
public bool DeleteIndustry(IndustryEntity entityObject) { return(Factory.Resolve <IIndustryBL>().DeleteIndustry(entityObject)); }