public void addAttribute(AttributeShape att) { attributes.Add(att); att.Disposed += new EventHandler(att_Disposed); if (attributes.Count >= 1) { if (this.cardinalities.Count > 1) { if (this.cardinalities[0].MaxCardinality == -1 && this.cardinalities[1].MaxCardinality == -1) { this.type = RelationshipType.AssociativeEntity; this.sName = this.sName.ToUpper(); Invalidate(); } } } }
public override ShapeBase Clone() { AttributeShape att = new AttributeShape(); att.sName = sName; att.type = type; att.isComposite = isComposite; att.Size = this.Size; att.Location = Location; if (isComposite) { foreach (AttributeShape attchild in attributeChilds) { att.addAttribute((AttributeShape)attchild.Clone()); } } return((ShapeBase)att); }
private void checkDuplicateName(TextBox txtName) { Regex testName = new Regex("^[A-z][0-9A-z]*$"); if (!testName.Match(txtName.Text).Success) { DevExpress.XtraEditors.XtraMessageBox.Show("Please enter valid name for this object\nThe name must be alphanumeric", "Warning"); txtName.Focus(); txtName.SelectAll(); return; } bool isDuplicate = false; foreach (Control c in parentPanel.Controls) { //Kiểm tra tên đối với những Notation cùng loại if (c.GetType().Name == namingShape.GetType().Name&& c != namingShape) { if (((ShapeBase)c).sName.ToLower() == txtName.Text.ToLower()) { isDuplicate = true; break; } } } if (!isDuplicate) { //nếu nó là attribute (viết tạm ở đây) if (this is AttributeShape) { AttributeShape att = this as AttributeShape; if (att.attributeChilds.Count == 0) { att.dataType = ucDataDescription.cboDataType.SelectedItem.ToString(); if (ucDataDescription.txtLength.Text != "") { try { int length = int.Parse(ucDataDescription.txtLength.Text); //if ((att.dataType == "nvarchar" || att.dataType == "nchar") && (length < 1 || length > 4000)) //{ // DevExpress.XtraEditors.XtraMessageBox.Show("Please enter Length between 1 and 4000.", "Warning"); // return; //} //if (length < 1 || length > 8000) //{ // DevExpress.XtraEditors.XtraMessageBox.Show("Please enter Length between 1 and 8000.", "Warning"); // return; //} if (length < 1) { DevExpress.XtraEditors.XtraMessageBox.Show("Please enter Length greater than 0", "Warning"); return; } att.dataLength = length; } catch { DevExpress.XtraEditors.XtraMessageBox.Show("Please enter Length as positive number.", "Warning"); return; } } else { att.dataLength = 0; } att.allowNull = ucDataDescription.chkNull.Checked; att.description = ucDataDescription.txtDescription.Text; ucDataDescription.Dispose(); } } this.sName = txtName.Text; //auto size to bound name Graphics g = CreateGraphics(); SizeF nameSize = g.MeasureString(sName, ThongSo.JFont); if (nameSize.Width + 30 > ThongSo.ShapeW) { this.Width = (int)nameSize.Width + 30; } txtName.Dispose(); parentPanel.isNaming = false; parentPanel.Refresh(); this.Invalidate(); } else { DevExpress.XtraEditors.XtraMessageBox.Show("Object " + txtName.Text + " already exist", "Warning"); txtName.Focus(); txtName.SelectAll(); } }
public void addAttribute(AttributeShape att) { attributeChilds.Add(att); att.Disposed += new EventHandler(att_Disposed); }
public void addAttribute(AttributeShape att) { attributes.Add(att); att.Entity = this; att.Disposed += new EventHandler(att_Disposed); }