Exemple #1
0
        public static void ShowAzColumsEdit(BindingSource dataSource, string tablename = "", bool isNew = false)
        {
            AzColumsEdit columsEdit = new AzColumsEdit();


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

            columsEdit.bindingSource1 = dataSource;

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

            columsEdit.ShowDialog();
        }
        private void tspBtnSave_Click(object sender, EventArgs e)
        {
            if (GeneralHelpler.ConfirmQuestionOperate("确定保存当前所有修改吗?") == DialogResult.Cancel)
            {
                return;
            }

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

            if (vlist == null)
            {
                return;
            }

            foreach (DataRow item in vlist.Rows)
            {
                var entity = item.ToObjectSafe <AzMetaCloumEntity>();
                AzMetaCloumHandle.Handle().Update(entity);
            }
            vlist.AcceptChanges();
            (azMetaCloumListEntityBindingSource.DataSource as DataTable).AcceptChanges();
            tspBtnSave.Enabled = false;
        }
        private void LoadMataColum(bool look = false)
        {
            toolStrip2.Enabled = true;
            string querytable = currentObject.SchemaName;
            var    cpro       = AzCdgnClassProperty.GetItemClassCreatProperty(currentObject);

            _IsStoreQuery = cpro.ObjPresentation.ObjDataType == ObjDataTypeEnum.atk_QuerystoredProcedure;
            _LookParam    = false;
            if (cpro.ObjPresentation.ObjDataType == ObjDataTypeEnum.atk_QuerystoredProcedure && !look)
            {
                if (!string.IsNullOrWhiteSpace(cpro.ObjPresentation.StoreProcedureQuery))
                {
                    querytable = cpro.ObjPresentation.StoreProcedureQuery;
                    _LookParam = true;
                }
            }
            var       c    = AzMetaCloumHandle.Handle().Select().Where(t => t.TableName == querytable).OrderBy(t => t.ShowOrder).Go();
            DataTable data = Translator.Translate <AzMetaProfile, AzMetaCloumEntity>(c, "AtkMetaCloum");

            data.AcceptChanges();
            currentDatas         = c;
            data.ColumnChanging += new DataColumnChangeEventHandler(Column_Changing);


            azMetaCloumListEntityBindingSource.DataSource = data;
            azMetaCloumListEntityBindingSource.EndEdit();
            tspBtnSave.Enabled       = false;
            toolStripButton4.Enabled = false;
            toolStripButton5.Enabled = false;
            tspButtonSort.Enabled    = false;
            tspBtnEdit.Enabled       = false;
            tspBtnDelete.Enabled     = false;
            toolStripButton8.Enabled = true;
        }
 private void ACM_ReIniValue_Click(object sender, EventArgs e)
 {
     if (GeneralHelpler.ConfirmQuestionOperate("确定初始全部字段?") == DialogResult.Cancel)
     {
         return;
     }
     AzMetaCloumHandle.Handle().InitColumnValueSchema(currentObject.SchemaName);
     LoadMataColum();
 }
        private void ACM_CopyFiledValue_Click(object sender, EventArgs e)
        {
            string copyfrom = AzCopyColumnTableSelect.ShowAzCopyColumnTableSelect();

            if (string.IsNullOrWhiteSpace(copyfrom))
            {
                return;
            }
            AzMetaCloumHandle.Handle().UpdataDisplayFormOtherSchemaName(currentObject.SchemaName, copyfrom);
            LoadMataColum();
        }
        private void ACM_ReNameColumns_Click(object sender, EventArgs e)
        {
            if (GeneralHelpler.ConfirmQuestionOperate("确定全部更新显示字段至数据库?") == DialogResult.Cancel)
            {
                return;
            }
            var listcol = AzMetaCloumHandle.Handle().Select().Where(t => t.TableName == currentObject.SchemaName).OrderBy(t => t.ShowOrder).Go();

            foreach (var item in listcol)
            {
                AzMetaTableHandle.Handle().ReNameColumnDisplay(item.FldDisplay, currentObject.SchemaName, currentObject.DbObjType, item.FldName);
            }

            LoadMataColum();
        }
Exemple #7
0
        private void CreateCodeBath(List <string> oplist, string current)
        {
            var item = AzMetaTableHandle.Handle().Select().Where(m => m.ObjModeName == current).Go().FirstOrDefault();

            if (item == null)
            {
                return;
            }
            var itemDetails  = AzMetaCloumHandle.Handle().Select().Where(t => t.TableName == item.SchemaName).OrderBy(t => t.ShowOrder).Go();
            var itemproperty = AzCdgnClassProperty.GetItemClassCreatProperty(item);
            var list         = GetCreateList(oplist, itemproperty);

            foreach (string c in list)
            {
                CreateCodeHandle(c, item, itemproperty, itemDetails);
            }
            azCdgnDetail1.SetCodeCreateMsg(CodeHandle.GetCodeHandleMsg());
        }
Exemple #8
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 <AzMetaCloumEntity>();
                int tyid   = 1;
                if (radioButton2.Checked)
                {
                    tyid = 2;
                }
                entity.TpyeId = tyid;

                int result = 0;
                if (IsNew)
                {
                    result = AzMetaCloumHandle.Handle().Insert(entity).Id;
                    IsNew  = false;
                }
                else
                {
                    result = AzMetaCloumHandle.Handle().Update(entity);
                }
                if (result > 0)
                {
                    row.AcceptChanges();
                    return(1);
                }
            }
            return(1);
        }
        private void tspButtonSort_Click(object sender, EventArgs e)
        {
            if (GeneralHelpler.ConfirmQuestionOperate("确定生成顺序?") == DialogResult.Cancel)
            {
                return;
            }
            var listcol = AzMetaCloumHandle.Handle().Select().Where(t => t.TableName == currentObject.SchemaName).OrderBy(t => t.ShowOrder).Go();
            var odi     = 1;

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

                odi += 1;
            }

            LoadMataColum();
        }
        public static string SpParamCreates(AzMetaTableEntity azMetaTable)
        {
            if (string.IsNullOrWhiteSpace(azMetaTable.SchemaName))
            {
                return("");
            }

            IEnumerable <AzMetaCloumEntity> azMetaCloums = AzMetaCloumHandle.Handle()
                                                           .Select()
                                                           .Where(m => m.TableName == azMetaTable.SchemaName)
                                                           .Go();
            StringBuilder stringBuilder = new StringBuilder();

            foreach (var col in azMetaCloums)
            {
                stringBuilder.AppendLine(SpParamCreate(col));
            }

            return(stringBuilder.ToString());
        }
        private void tspBtnDelete_Click(object sender, EventArgs e)
        {
            if (GeneralHelpler.ConfirmQuestionOperate("确定删除当前所选行吗?") == DialogResult.Cancel)
            {
                return;
            }
            var drow = azMetaCloumListEntityBindingSource.Current;

            if (drow != null)
            {
                var row    = ((DataRowView)drow).Row;
                var entity = row.ToObjectSafe <AzMetaCloumEntity>();
                if (AzMetaCloumHandle.Handle().Delete(entity) == 1)
                {
                    azMetaCloumListEntityBindingSource.RemoveCurrent();
                    row.AcceptChanges();
                    tspBtnSave.Enabled = DataChangeAskSave();
                }
            }
        }
Exemple #12
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);
        }
Exemple #13
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 <AzMetaCloumEntity>();
                if (entity.Id == 0)
                {
                    bindingSource1.RemoveCurrent();
                    return;
                }
                var       c    = AzMetaCloumHandle.Handle().Select().Where(t => t.Id == entity.Id).Go();
                DataTable data = Translator.Translate <AzMetaProfile, AzMetaCloumEntity>(c, "AtkMetaCloum");
                row.ItemArray = data.AsEnumerable().FirstOrDefault().ItemArray;
                row.AcceptChanges();
            }
        }