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("اطلاعات ثبت شد"); }
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(); }
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); } } }
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); }