Exemple #1
0
        public virtual SubjectOwnerDomain CreateSubjectOwnerDomain()
        {
            SubjectOwnerEntity entity = new SubjectOwnerEntity();
            entity.SubjectOwnerId = Guid.NewGuid().ToString();

            return new SubjectOwnerDomain(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;
                }
            }
        }
Exemple #3
0
 public SubjectOwnerDomain(SubjectOwnerEntity entity)
     : base(entity)
 {
     masterEntity = entity;
 }
Exemple #4
0
 public virtual void UpdateSubjectOwnerEntity(SubjectOwnerEntity entity, DataAccessBroker broker)
 {
     DataAccess.Update(entity, broker);
 }
Exemple #5
0
 public virtual void InsertSubjectOwnerEntity(SubjectOwnerEntity entity, DataAccessBroker broker)
 {
     DataAccess.Insert(entity, broker);
 }
Exemple #6
0
        //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);
        //}


        public virtual DataSet GetBySubjectInformationID(string subjectInformationID)
        {
            SubjectOwnerEntity entity = new SubjectOwnerEntity();
            if (!string.IsNullOrEmpty(subjectInformationID))
                entity.SubjectInformationId = subjectInformationID;

            return DataAccess.SelectDataSet(entity);
        }