Example #1
0
        private int SaveData()
        {
            if (VerificationText())
            {
                return(0);
            }
            if (GeneralHelpler.ConfirmQuestionOperate("确定保存修改?") == DialogResult.Cancel)
            {
                return(0);
            }
            var drow = bindingSource1.Current;

            if (drow != null)
            {
                var row = ((DataRowView)drow).Row;
                row.EndEdit();
                var entity = row.ToObjectSafe <AzMetaCustomCloumEntity>();
                int result = 0;
                if (IsNew)
                {
                    result = AzMetaCustomCloumHandle.Handle().Insert(entity).Id;
                    IsNew  = false;
                }
                else
                {
                    result = AzMetaCustomCloumHandle.Handle().Update(entity);
                }
                if (result > 0)
                {
                    row.AcceptChanges();
                    return(1);
                }
            }
            return(1);
        }
        private void tspBtnSave_Click(object sender, System.EventArgs e)
        {
            if (GeneralHelpler.ConfirmQuestionOperate("确定保存当前所有修改吗?") == DialogResult.Cancel)
            {
                return;
            }

            azMetaCustomCloumListEntityBindingSource.EndEdit();
            dataGridView1.EndEdit();
            var vlist = (azMetaCustomCloumListEntityBindingSource.DataSource as DataTable).GetChanges();

            if (vlist == null)
            {
                return;
            }

            foreach (DataRow item in vlist.Rows)
            {
                var entity = item.ToObjectSafe <AzMetaCustomCloumEntity>();
                AzMetaCustomCloumHandle.Handle().UpdateBatch(entity);
            }
            vlist.AcceptChanges();
            (azMetaCustomCloumListEntityBindingSource.DataSource as DataTable).AcceptChanges();
            ButtonAction();
        }
Example #3
0
        public static void ShowAzCustomColumsEdit(BindingSource dataSource, string tablename = "", bool isNew = false)
        {
            AzCustomColumsEdit customColumsEdit = new AzCustomColumsEdit();


            if (isNew)
            {
                var       row  = (dataSource.DataSource as DataTable).NewRow();
                var       c    = AzMetaCustomCloumHandle.Handle().NewAdd(tablename);
                DataTable data = Translator.Translate <AzMetaProfile, AzMetaCustomCloumEntity>(c, "AtkMetaCustomCloum");
                row.ItemArray = data.AsEnumerable().FirstOrDefault().ItemArray;
                (dataSource.DataSource as DataTable).Rows.Add(row);
                dataSource.MoveLast();
                customColumsEdit.IsNew = true;
            }

            customColumsEdit.bindingSource1 = dataSource;

            customColumsEdit.textFldName.DataBindings.Add("Text", dataSource, "FldName", true);
            customColumsEdit.cboBoxFldCodeType.DataBindings.Add("Text", dataSource, "FldCodeType", true);
            customColumsEdit.cboBoxFldType.DataBindings.Add("Text", dataSource, "FldType", true);
            customColumsEdit.textFldDisplay.DataBindings.Add("Text", dataSource, "FldDisplay", true);
            customColumsEdit.textFldLen.DataBindings.Add("Text", dataSource, "FldLen", true);
            customColumsEdit.ckBoxIsIdentity.DataBindings.Add("Checked", dataSource, "IsIdentity", true);
            customColumsEdit.ckBoxIsKeyField.DataBindings.Add("Checked", dataSource, "IsKeyField", true);
            customColumsEdit.ckBoxIsNullable.DataBindings.Add("Checked", dataSource, "IsNullable", true);

            customColumsEdit.ShowDialog();
        }
 private void tspClearAll_Click(object sender, System.EventArgs e)
 {
     if (GeneralHelpler.ConfirmQuestionOperate("确定清除所有行吗?") == DialogResult.Cancel)
     {
         return;
     }
     AzMetaCustomCloumHandle.Handle().DeleteAll(currentSelectObjModeName);
     LoadMataColum(currentschemaFrom);
 }
        private void tspButtonImport_Click(object sender, System.EventArgs e)
        {
            if (GeneralHelpler.ConfirmQuestionOperate("确定导入元数据吗?") == DialogResult.Cancel)
            {
                return;
            }
            var azMetaTable = azMetaTableEntities.AsQueryable().Where(m => m.ObjModeName == currentSelectObjModeName).FirstOrDefault();

            if (azMetaTable != null)
            {
                var listcol = AzMetaCustomCloumHandle.Handle().Select().Where(m => m.TableName == azMetaTable.SchemaFrom).Go();
                MetadataOperate.ImportCustomMetaData(azMetaTable.SchemaFrom, azMetaTable.SchemaName, listcol.Count() == 0);
                LoadMataColum(azMetaTable.SchemaFrom);
                //  tspButtonImport.Enabled = false;
            }
        }
        private void tspMenuItemTurn_Click(object sender, EventArgs e)
        {
            if (GeneralHelpler.ConfirmQuestionOperate("确定根据DB数据类型初始代码数据类型吗?") == DialogResult.Cancel)
            {
                return;
            }
            var listcol = AzMetaCustomCloumHandle.Handle().Select().Where(t => t.TableName == currentObject.SchemaName).Go();

            foreach (var item in listcol)
            {
                var entitype = MetaDataTypeHandle.GetMetaDataType(item.FldType);
                item.FldCodeType = entitype.CodeType;
                AzMetaCustomCloumHandle.Handle().Update(item);
            }
            LoadMataColum();
        }
        private void tspBtnDelete_Click(object sender, System.EventArgs e)
        {
            if (GeneralHelpler.ConfirmQuestionOperate("确定删除当前所选行吗?") == DialogResult.Cancel)
            {
                return;
            }
            var drow = azMetaCustomCloumListEntityBindingSource.Current;

            if (drow != null)
            {
                var row    = ((DataRowView)drow).Row;
                var entity = row.ToObjectSafe <AzMetaCustomCloumEntity>();
                if (AzMetaCustomCloumHandle.Handle().Delete(entity) == 1)
                {
                    azMetaCustomCloumListEntityBindingSource.RemoveCurrent();
                }
            }
        }
        private void LoadMataColum(string schemaFrom)
        {
            toolStrip2.Enabled = true;
            var       c    = AzMetaCustomCloumHandle.Handle().Select().Where(t => t.TableName == currentSelectObjModeName).OrderBy(t => t.ShowOrder).Go();
            DataTable data = Translator.Translate <AzMetaProfile, AzMetaCustomCloumEntity>(c, "AtkMetaCustomCloum");

            data.AcceptChanges();
            azMetaCustomCloumListEntityBindingSource.DataSource = data;
            azMetaCustomCloumListEntityBindingSource.EndEdit();
            if (string.IsNullOrWhiteSpace(schemaFrom))
            {
                tspButtonImport.Enabled = false;
            }
            else
            {
                tspButtonImport.Enabled = c.Where(m => m.SchemaFrom == schemaFrom).Count() == 0;
            }
        }
        private int CreateDBTabeOp(string objModeName)
        {
            AzMetaTableEntity azMetaTable = AzMetaTableHandle.Handle().Select()
                                            .Where(t => t.ObjModeName == objModeName)
                                            .Go().FirstOrDefault();
            IEnumerable <AzMetaCustomCloumEntity> cloumListEntities = AzMetaCustomCloumHandle.Handle().Select()
                                                                      .Where(t => t.TableName == azMetaTable.SchemaName)
                                                                      .Go();
            string strcreate = DataOperate.CreateDBObject(azMetaTable, cloumListEntities);
            int    result    = MetadataOperate.ExecuteCmd(strcreate);

            if (result > 0)
            {
                azMetaTable.ObjModeType = 0;
                azMetaTable.ObjDataType = 0;
                AzMetaTableHandle.Handle().Updata(azMetaTable);
            }
            return(result);
        }
        private void tspMenuItemDisplay_Click(object sender, System.EventArgs e)
        {
            if (GeneralHelpler.ConfirmQuestionOperate("确定生成显示名(已经有显示名的不合更改)?") == DialogResult.Cancel)
            {
                return;
            }
            var listcol = AzMetaCustomCloumHandle.Handle().Select().Where(t => t.TableName == currentSelectObjModeName).OrderBy(t => t.ShowOrder).Go();

            foreach (var item in listcol)
            {
                if (string.IsNullOrWhiteSpace(item.FldDisplay))
                {
                    item.FldDisplay = item.FldName;
                    AzMetaCustomCloumHandle.Handle().Update(item);
                }
            }

            LoadMataColum(currentschemaFrom);
        }
        private void tspButtonSort_Click(object sender, System.EventArgs e)
        {
            if (GeneralHelpler.ConfirmQuestionOperate("确定生成顺序?") == DialogResult.Cancel)
            {
                return;
            }
            var listcol = AzMetaCustomCloumHandle.Handle().Select().Where(t => t.TableName == currentSelectObjModeName).OrderBy(t => t.ShowOrder).Go();
            var odi     = 1;

            foreach (var item in listcol)
            {
                item.ShowOrder = odi;
                AzMetaCustomCloumHandle.Handle().Update(item);

                odi += 1;
            }

            LoadMataColum(currentschemaFrom);
        }
        private void tspCancelEdit_Click(object sender, System.EventArgs e)
        {
            if (GeneralHelpler.ConfirmQuestionOperate("确定取消当前修改吗?") == DialogResult.Cancel)
            {
                return;
            }
            var drow = azMetaCustomCloumListEntityBindingSource.Current;

            if (drow != null)
            {
                var       row    = ((DataRowView)drow).Row;
                var       entity = row.ToObject <AzMetaCustomCloumEntity>();
                var       c      = AzMetaCustomCloumHandle.Handle().Select().Where(t => t.Id == entity.Id).Go();
                DataTable data   = Translator.Translate <AzMetaProfile, AzMetaCustomCloumEntity>(c, "AtkMetaCustomCloum");
                row.ItemArray = data.AsEnumerable().FirstOrDefault().ItemArray;
                row.AcceptChanges();
                tspBtnSave.Enabled    = DataChangeAskSave();
                tspButtonSort.Enabled = !tspBtnSave.Enabled && tspBtnEdit.Enabled;
            }
        }
Example #13
0
        private void azCdgnDBSchema1_Atk_ReCreateDbData(object sender, EventArgs e)
        {
            if (GeneralHelpler.ConfirmQuestionOperate("确定重新导入?如果重新导入原设置将清除!") == DialogResult.Cancel)
            {
                return;
            }

            AzMetaCloumHandle.Handle().InitColumnSchema(metaTableEntity.SchemaName);
            var listcol = AzMetaCustomCloumHandle.Handle().Select().Where(t => t.TableName == metaTableEntity.SchemaName).Go();

            foreach (var item in listcol)
            {
                var entitype = MetaDataTypeHandle.GetMetaDataType(item.FldType);
                if (entitype != null)
                {
                    item.FldCodeType = entitype.CodeType;
                    AzMetaCustomCloumHandle.Handle().Update(item);
                }
            }
            azCdgnDetail1.SetCurrentObject(metaTableEntity, 1);
        }
Example #14
0
        private void btnCancel_Click(object sender, EventArgs e)
        {
            if (GeneralHelpler.ConfirmQuestionOperate("确定取消当前修改吗?") == DialogResult.Cancel)
            {
                return;
            }
            var drow = bindingSource1.Current;

            if (drow != null)
            {
                var row = ((DataRowView)drow).Row;

                var entity = row.ToObjectSafe <AzMetaCustomCloumEntity>();
                if (entity.Id == 0)
                {
                    bindingSource1.RemoveCurrent();
                    return;
                }
                var       c    = AzMetaCustomCloumHandle.Handle().Select().Where(t => t.Id == entity.Id).Go();
                DataTable data = Translator.Translate <AzMetaProfile, AzMetaCustomCloumEntity>(c, "AtkMetaCustomCloum");
                row.ItemArray = data.AsEnumerable().FirstOrDefault().ItemArray;
                row.AcceptChanges();
            }
        }