public virtual SubjectInformationDomain CreateSubjectInformationDomain() { SubjectInformationEntity entity = new SubjectInformationEntity(); entity.SubjectInformationId = Guid.NewGuid().ToString(); return new SubjectInformationDomain(entity); }
protected void btnSave_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtSubjectName.Text.Trim())) { AlertMessage("Subject Name can not be null."); return; } bool isUpdate = false; SubjectInformationEntity entity = new SubjectInformationEntity(); if (SubjectInformationID == "") { entity.SubjectInformationId = Guid.NewGuid().ToString(); SubjectInformationID = entity.SubjectInformationId; } else { isUpdate = true; entity.SubjectInformationId = SubjectInformationID; } entity.ActionNo = txtActionNo.Text.Trim(); entity.Name = txtSubjectName.Text.Trim(); //Modify by Andy.gui on 2011/12/27 //Move to Subject_License_Vehicls table //entity.LicenseVehicls = txtLicense.Text.Trim(); //Modify by Andy.gui on 2011/12/27 //Add Subject_License_Vehicls table if (MainService.SubjectInformationService.SaveSubjectInformation(entity, SubjectAddress, SubjectOwner, Equipment, Distribution, isUpdate, LicenseVehicls)) { base.AlertMessage("Save Succeed"); //base.CloseDialogNoRefresh(); } else { base.AlertMessage("Save Failure"); } }
private void LoadData(SubjectInformationEntity entity) { //SubjectInformation 信息 SubjectInformationID = entity.SubjectInformationId; txtSubjectName.Text = entity.Name; //Modify by Andy.Gui on 2011/12/27 //txtLicense.Text = entity.LicenseVehicls; //Subject Address DataSet dsSubjectAddress = MainService.SubjectAddressService.GetBySubjectInformationID(entity.SubjectInformationId); if (dsSubjectAddress != null && dsSubjectAddress.Tables.Count > 0 && dsSubjectAddress.Tables[0] != null) { SubjectAddress = dsSubjectAddress.Tables[0]; BindSubjectAddress(); } //SubjectOwner DataSet dsSubjectOwner = MainService.SubjectOwnerService.GetBySubjectInformationID(entity.SubjectInformationId); if (dsSubjectOwner != null && dsSubjectOwner.Tables.Count > 0 && dsSubjectOwner.Tables[0] != null) { SubjectOwner = dsSubjectOwner.Tables[0]; BindSubjectOwner(); } //Equipment DataSet dsEquipment = MainService.EquipmentBLLService.Search(entity.SubjectInformationId); if (dsEquipment != null && dsEquipment.Tables.Count > 0 && dsEquipment.Tables[0] != null) { Equipment = dsEquipment.Tables[0]; BindEquipment(); } //Distribution DataSet dsDistribution = MainService.SubjectDistributionService.GetBySubjectInformationID(entity.SubjectInformationId); if (dsDistribution != null && dsDistribution.Tables.Count > 0 && dsDistribution.Tables[0] != null) { Distribution = dsDistribution.Tables[0]; BinddrDistribution(); } //LicenseVehicls Add by Andy.Gui on 2011/12/27 DataSet dsLicenseVehicls = MainService.SubjectLicenseVehiclsService.GetBySubjectInformationID(entity.SubjectInformationId); if (dsLicenseVehicls != null && dsLicenseVehicls.Tables.Count > 0 && dsLicenseVehicls.Tables[0] != null) { LicenseVehicls = dsLicenseVehicls.Tables[0]; BindLicenseVehicls(); } }
public virtual void UpdateSubjectInformationEntity(SubjectInformationEntity entity, DataAccessBroker broker) { DataAccess.Update(entity, broker); }
public virtual void InsertSubjectInformationEntity(SubjectInformationEntity entity, DataAccessBroker broker) { DataAccess.Insert(entity, broker); }
public virtual SubjectInformationEntity GetSubjectAddressEntityByActionNo(string actionNo) { SubjectInformationEntity entity = new SubjectInformationEntity(); entity.ActionNo = actionNo; return DataAccess.SelectSingle<SubjectInformationEntity>(entity); }
//public virtual List<ChkFunctionParamEntity> GetChkFunctionParasByFunctionId(string functionId) //{ // return SelectByCondition<ChkFunctionParamEntity>(adidas.DataCollection.Common.Utils.QueryCondition.Create().Equals(ChkFunctionParamTable.C_FUNCTION_ID, functionId).Order(ChkFunctionParamTable.C_SORT_ORDER)); //} //public virtual void InsertChkFUnctionParas(List<ChkFunctionParamEntity> functionParas, DataAccessBroker broker) //{ // DataAccess.Insert(functionParas, broker); //} //public virtual void DeleteChkFunctionParasByCondition(ChkFunctionParamEntity param, DataAccessBroker broker) //{ // DataAccess.DeleteEntity(param, broker); //} //Modify by Andy.gui on 2011/12/27 //Add Subject_License_Vehicls table public virtual bool SaveSubjectInformation(SubjectInformationEntity entity, DataTable dtSubjectAddress, DataTable dtSubjectOwner, DataTable dtEquipment, DataTable dtDistribution, bool isUpdate, DataTable dtLicenseVehicls) { //注释Update部分, 由于除SubjectInformation外其它只允许新增和删除,所以去掉Update using (DataAccessBroker broker = DataAccessFactory.Instance()) { broker.BeginTransaction(); try { if (isUpdate) { UpdateSubjectInformationEntity(entity, broker); } else { InsertSubjectInformationEntity(entity, broker); } //Save SubjectAddress if (dtSubjectAddress != null && dtSubjectAddress.Rows.Count > 0) { string strSql = @"delete " + SubjectAddressTable.C_TableName + " where " + SubjectAddressTable.C_Subject_Information_ID + "='" + entity.SubjectInformationId + "'"; broker.ExecuteNonQuery(strSql, null, CommandType.Text); SubjectAddressEntity objEntity; foreach (DataRow drSubjectAddress in dtSubjectAddress.Rows) { //insert objEntity = new SubjectAddressEntity(); objEntity.SubjectAddressId = drSubjectAddress["Subject_Address_ID"].ToString(); objEntity.SubjectInformationId = entity.SubjectInformationId; objEntity.ProvinceId = Convert.ToInt32(drSubjectAddress["Province_ID"].ToString()); objEntity.Province = drSubjectAddress["Province"].ToString(); objEntity.CityId = Convert.ToInt32(drSubjectAddress["City_ID"].ToString()); objEntity.City = drSubjectAddress["City"].ToString(); objEntity.SubCityId = Convert.ToInt32(drSubjectAddress["Sub_City_ID"].ToString()); objEntity.SubCity = drSubjectAddress["Sub_City"].ToString(); objEntity.Town = drSubjectAddress["Town"].ToString(); objEntity.Street = drSubjectAddress["Street"].ToString(); objEntity.Doorplate = drSubjectAddress["Doorplate"].ToString(); objEntity.Room = drSubjectAddress["Room"].ToString(); DataAccess.Insert(objEntity, broker); } } //Save dtSubjectOwner if (dtSubjectOwner != null && dtSubjectOwner.Rows.Count > 0) { string strSql = @"delete " + SubjectOwnerTable.C_TableName + " where " + SubjectOwnerTable.C_Subject_Information_ID + "='" + entity.SubjectInformationId + "'"; broker.ExecuteNonQuery(strSql, null, CommandType.Text); SubjectOwnerEntity objEntity; foreach (DataRow drSubjectOwner in dtSubjectOwner.Rows) { //insert objEntity = new SubjectOwnerEntity(); objEntity.SubjectOwnerId = drSubjectOwner["Subject_Owner_ID"].ToString(); objEntity.SubjectInformationId = entity.SubjectInformationId; objEntity.Name = drSubjectOwner["Name"].ToString(); objEntity.Id = drSubjectOwner["ID"].ToString(); objEntity.OriginalAddress = drSubjectOwner["Original_Address"].ToString(); objEntity.Description = drSubjectOwner["Description"].ToString(); DataAccess.Insert(objEntity, broker); } } //Save dtEquipment if (dtEquipment != null && dtEquipment.Rows.Count > 0) { string strSql = @"delete " + EquipmentTable.C_TableName + " where " + EquipmentTable.C_Action_NO + "='" + entity.SubjectInformationId + "'"; broker.ExecuteNonQuery(strSql, null, CommandType.Text); EquipmentEntity objEntity; foreach (DataRow drEquipment in dtEquipment.Rows) { objEntity = new EquipmentEntity(); objEntity.EquipmentId = drEquipment["Equipment_ID"].ToString(); objEntity.ActionNo = entity.SubjectInformationId; objEntity.EquipmentName = drEquipment["Equipment_Name"].ToString(); objEntity.Amount = drEquipment["Amount"].ToString(); DataAccess.Insert(objEntity, broker); } } //Save dtDistribution if (dtDistribution != null && dtDistribution.Rows.Count > 0) { string strSql = @"delete " + SubjectDistributionTable.C_TableName + " where " + SubjectDistributionTable.C_Subject_Information_ID + "='" + entity.SubjectInformationId + "'"; broker.ExecuteNonQuery(strSql, null, CommandType.Text); SubjectDistributionEntity objEntity; foreach (DataRow drDistribution in dtDistribution.Rows) { objEntity = new SubjectDistributionEntity(); objEntity.SubjectDistributionId = drDistribution["Subject_Distribution_ID"].ToString(); objEntity.SubjectInformationId = entity.SubjectInformationId; objEntity.DistributionType = drDistribution["Distribution_Type"].ToString(); objEntity.Name = drDistribution["Name"].ToString(); objEntity.Address = drDistribution["Address"].ToString(); objEntity.Phone = drDistribution["Phone"].ToString(); DataAccess.Insert(objEntity, broker); } } //Save LicenseVehicls //Add by Andy.Gui on 2011/12/27 dtLicenseVehicls if (dtLicenseVehicls != null && dtLicenseVehicls.Rows.Count > 0) { string strSql = @"delete " + SubjectLicenseVehiclsTable.C_TableName + " where " + SubjectLicenseVehiclsTable.C_Subject_Information_ID + "='" + entity.SubjectInformationId + "'"; broker.ExecuteNonQuery(strSql, null, CommandType.Text); SubjectLicenseVehiclsEntity objEntity; foreach (DataRow drLicenseVehicls in dtLicenseVehicls.Rows) { objEntity = new SubjectLicenseVehiclsEntity(); objEntity.SubjectLicenseVehiclsId = drLicenseVehicls["Subject_License_Vehicls_ID"].ToString(); objEntity.SubjectInformationId = entity.SubjectInformationId; objEntity.LicenseVehicls = drLicenseVehicls["License_Vehicls"].ToString(); DataAccess.Insert(objEntity, broker); } } broker.Commit(); return true; } catch { broker.RollBack(); return false; } } }
public SubjectInformationDomain(SubjectInformationEntity entity) : base(entity) { masterEntity = entity; }