private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            if (cmbColumns.SelectedItem == null)
            {
                MessageBox.Show("ستون معادل انتخاب نشده است");
                return;
            }
            if (Message == null)
            {
                Message = new EntityOrganizationSecurityDirectDTO();
            }
            Message.TableDrivedEntityID = EntityID;
            Message.ColumnID            = (int)cmbColumns.SelectedValue;
            if (optDBFunction.IsChecked == true)
            {
                Message.Operator     = (EntitySecurityOperator)cmbOperator.SelectedItem;
                Message.DBFunctionID = (int)cmbDatabaseFunction.SelectedValue;
            }
            else
            {
                Message.DBFunctionID = 0;
            }

            bizOrganizationSecurity.UpdateEntityOrganizationSecurityDirect(Message);
            MessageBox.Show("اطلاعات ثبت شد");
        }
Ejemplo n.º 2
0
        public void UpdateEntityOrganizationSecurityDirect(EntityOrganizationSecurityDirectDTO message)
        {
            using (var projectContext = new DataAccess.MyProjectEntities())
            {
                var dbItem = projectContext.EntityOrganizationSecurityDirect.FirstOrDefault(x => x.ID == message.ID);
                if (dbItem == null)
                {
                    dbItem = new DataAccess.EntityOrganizationSecurityDirect();
                    projectContext.EntityOrganizationSecurityDirect.Add(dbItem);
                }
                dbItem.TableDrivedEntityID = message.TableDrivedEntityID;

                dbItem.ColumnID = message.ColumnID;
                if (message.DBFunctionID != 0)
                {
                    dbItem.DatabaseFunctionID = message.DBFunctionID;
                    dbItem.Operator           = (short)message.Operator;
                }
                else
                {
                    dbItem.DatabaseFunctionID = null;
                    dbItem.Operator           = null;
                }
                projectContext.SaveChanges();
            }
        }
 public frmEntityOrganizationSecurityDirect(int entityID)
 {
     InitializeComponent();
     EntityID = entityID;
     Message  = bizOrganizationSecurity.GetEntityOrganizationSecurityDirect(EntityID, false);
     SetOperators();
     SetDatabaseFunctions();
     SetColumns();
     ShowMessage();
 }
Ejemplo n.º 4
0
        public EntityOrganizationSecurityDirectDTO GetEntityOrganizationSecurityDirect(int entityID, bool withDetails)
        {
            EntityOrganizationSecurityDirectDTO result = new EntityOrganizationSecurityDirectDTO();

            using (var projectContext = new DataAccess.MyProjectEntities())
            {
                var item = projectContext.EntityOrganizationSecurityDirect.FirstOrDefault(x => x.TableDrivedEntityID == entityID);
                if (item != null)
                {
                    return(ToEntityOrganizationSecurityDirectDTO(item));
                }
                else
                {
                    return(null);
                }
            }
        }
Ejemplo n.º 5
0
        private EntityOrganizationSecurityDirectDTO ToEntityOrganizationSecurityDirectDTO(EntityOrganizationSecurityDirect item)
        {
            EntityOrganizationSecurityDirectDTO result = new EntityOrganizationSecurityDirectDTO();

            result.ID                  = item.ID;
            result.ColumnID            = item.ColumnID;
            result.TableDrivedEntityID = item.TableDrivedEntityID;
            result.EntityName          = item.TableDrivedEntity.Name;
            if (item.DatabaseFunctionID != null)
            {
                result.DBFunctionID = item.DatabaseFunctionID.Value;
            }
            if (item.Operator != null)
            {
                result.Operator = (EntitySecurityOperator)item.Operator;
            }
            return(result);
        }