Exemple #1
0
    void PostData()
    {
        string Name     = Request["Name"];
        string Code     = Request["Code"];
        string IsSystem = Request["IsSystem"];
        string GridData = Request["GridData"];

        CUser user = (CUser)Session["User"];

        if (string.IsNullOrEmpty(Name) || string.IsNullOrEmpty(Code))
        {
            Response.Write("数据不完整!");
            return;
        }
        else
        {
            if (!m_Table.Name.Equals(Name, StringComparison.OrdinalIgnoreCase) &&
                Global.GetCtx(Session["TopCompany"].ToString()).TableMgr.FindByName(Name) != null)
            {
                Response.Write("相同名称的表已经存在!");
                return;
            }
            if (!m_Table.Code.Equals(Code, StringComparison.OrdinalIgnoreCase) &&
                Global.GetCtx(Session["TopCompany"].ToString()).TableMgr.FindByCode(Code) != null)
            {
                Response.Write("相同编码的表已经存在!");
                return;
            }

            m_Table.Name     = Name;
            m_Table.Code     = Code;
            m_Table.IsSystem = Convert.ToBoolean(IsSystem);
            m_Table.IsFinish = true;
            m_Table.Updator  = user.Id;

            //自定义字段
            int      iLastIdx = 4;
            string[] arr1     = Regex.Split(GridData, ";");
            SortedList <Guid, Guid> sortColID = new SortedList <Guid, Guid>();
            foreach (string str1 in arr1)
            {
                if (str1.Length == 0)
                {
                    continue;
                }
                iLastIdx++;

                string[] arr2   = Regex.Split(str1, ",");
                Guid     guidID = new Guid(arr2[0]);
                if (sortColID.ContainsKey(guidID))
                {
                    continue;
                }

                sortColID.Add(guidID, guidID);
                CColumn col = (CColumn)m_Table.ColumnMgr.Find(guidID);
                if (col == null)
                {
                    col             = new CColumn();
                    col.Ctx         = m_Table.Ctx;
                    col.FW_Table_id = m_Table.Id;
                    col.Id          = guidID;
                    col.Creator     = user.Id;
                    m_Table.ColumnMgr.AddNew(col);
                }
                else
                {
                    col.Updator = user.Id;
                    m_Table.ColumnMgr.Update(col);
                }
                col.Name         = arr2[1];
                col.Code         = arr2[2];
                col.ColType      = CColumn.ConvertStringToColType(arr2[3]);
                col.ColLen       = Convert.ToInt32(arr2[4]);
                col.AllowNull    = (arr2[5] == "1")?true:false;
                col.IsSystem     = (arr2[6] == "1") ? true : false;
                col.IsUnique     = (arr2[17] == "1") ? true : false;
                col.IsVisible    = true;
                col.DefaultValue = arr2[7];
                col.ColDecimal   = (arr2[8] != "") ? Convert.ToInt32(arr2[8]) : 0;
                col.Formula      = arr2[9];
                if (col.ColType == ColumnType.ref_type)
                {
                    col.RefTable   = new Guid(arr2[10]);
                    col.RefCol     = new Guid(arr2[12]);
                    col.RefShowCol = new Guid(arr2[14]);
                }
                if (arr2[16].Trim() != "")
                {
                    col.ColumnEnumValMgr.RemoveAll();
                    string[] arrEnum = Regex.Split(arr2[16].Trim(), "/");
                    for (int i = 0; i < arrEnum.Length; i++)
                    {
                        string         sEnumVal = arrEnum[i];
                        CColumnEnumVal ev       = new CColumnEnumVal();
                        ev.Ctx          = col.Ctx;
                        ev.FW_Column_id = col.Id;
                        ev.Val          = sEnumVal;
                        ev.Idx          = i;
                        col.ColumnEnumValMgr.AddNew(ev);
                    }
                }
                col.Idx = iLastIdx;
            }
            //要删除的字段
            SortedList <Guid, Guid> sortOldColID = new SortedList <Guid, Guid>();
            List <CBaseObject>      lstOldCol    = m_Table.ColumnMgr.GetList();
            foreach (CBaseObject objOld in lstOldCol)
            {
                CColumn col = (CColumn)objOld;
                if (col.Code.Equals("id", StringComparison.OrdinalIgnoreCase) ||
                    col.Code.Equals("Created", StringComparison.OrdinalIgnoreCase) ||
                    col.Code.Equals("Creator", StringComparison.OrdinalIgnoreCase) ||
                    col.Code.Equals("Updated", StringComparison.OrdinalIgnoreCase) ||
                    col.Code.Equals("Updator", StringComparison.OrdinalIgnoreCase))
                {
                    continue;
                }
                sortOldColID.Add(objOld.Id, objOld.Id);
            }
            foreach (KeyValuePair <Guid, Guid> pair in sortOldColID)
            {
                if (!sortColID.ContainsKey(pair.Key))
                {
                    m_Table.ColumnMgr.Delete(pair.Key);
                }
            }
            //

            Global.GetCtx(Session["TopCompany"].ToString()).TableMgr.Update(m_Table);

            if (!CTable.CreateDataTable(m_Table))
            {
                Response.Write("创建表失败!");
                return;
            }
            if (!Global.GetCtx(Session["TopCompany"].ToString()).TableMgr.Save(true))
            {
                Response.Write("修改失败!");
                return;
            }
        }
    }
Exemple #2
0
    void PostData()
    {
        string id       = Request["id"];
        string Name     = Request["Name"];
        string Code     = Request["Code"];
        string IsSystem = Request["IsSystem"];
        string GridData = Request["GridData"];

        CUser user = (CUser)Session["User"];

        if (string.IsNullOrEmpty(id) || string.IsNullOrEmpty(Name) || string.IsNullOrEmpty(Code))
        {
            Response.Write("数据不完整!");
            return;
        }
        else
        {
            if (Global.GetCtx(Session["TopCompany"].ToString()).TableMgr.FindByName(Name) != null)
            {
                Response.Write("相同名称的表已经存在!");
                return;
            }
            if (Global.GetCtx(Session["TopCompany"].ToString()).TableMgr.FindByCode(Code) != null)
            {
                Response.Write("相同编码的表已经存在!");
                return;
            }

            CTable table = new CTable();
            table.Ctx      = Global.GetCtx(Session["TopCompany"].ToString());
            table.Id       = new Guid(id);
            table.Name     = Name;
            table.Code     = Code;
            table.IsSystem = Convert.ToBoolean(IsSystem);
            table.IsFinish = true;
            table.Creator  = user.Id;
            //系统字段
            {
                CColumn col = new CColumn();
                col.Ctx         = table.Ctx;
                col.FW_Table_id = table.Id;
                col.Name        = "id";
                col.Code        = "id";
                col.ColType     = ColumnType.guid_type;
                col.ColLen      = 16;
                col.AllowNull   = false;
                col.IsSystem    = true;
                col.IsUnique    = true;
                col.IsVisible   = false;
                col.Idx         = 0;
                col.Creator     = user.Id;
                table.ColumnMgr.AddNew(col);

                col             = new CColumn();
                col.Ctx         = table.Ctx;
                col.FW_Table_id = table.Id;
                col.Name        = "创建时间";
                col.Code        = "Created";
                col.ColType     = ColumnType.datetime_type;
                col.ColLen      = 8;
                //col.DefaultValue = "getdate()";
                col.AllowNull = true;
                col.IsSystem  = true;
                col.IsUnique  = false;
                col.IsVisible = false;
                col.Idx       = 1;
                col.Creator   = user.Id;
                table.ColumnMgr.AddNew(col);

                col             = new CColumn();
                col.Ctx         = table.Ctx;
                col.FW_Table_id = table.Id;
                col.Name        = "创建者";
                col.Code        = "Creator";
                col.ColType     = ColumnType.ref_type;
                CTable tableUser = (CTable)Global.GetCtx(Session["TopCompany"].ToString()).TableMgr.FindByCode("B_User");
                Guid   guidUid   = Guid.Empty;
                Guid   guidUname = Guid.Empty;
                if (tableUser != null)
                {
                    col.RefTable = tableUser.Id;
                    CColumn colUid = tableUser.ColumnMgr.FindByCode("id");
                    col.RefCol = colUid.Id;
                    guidUid    = col.RefCol;
                    CColumn colUname = tableUser.ColumnMgr.FindByCode("name");
                    col.RefShowCol = colUname.Id;
                    guidUname      = col.RefShowCol;
                }
                col.ColLen = 16;
                //col.DefaultValue = "0";
                col.AllowNull = true;
                col.IsSystem  = true;
                col.IsUnique  = false;
                col.IsVisible = false;
                col.Idx       = 2;
                col.Creator   = user.Id;
                table.ColumnMgr.AddNew(col);

                col             = new CColumn();
                col.Ctx         = table.Ctx;
                col.FW_Table_id = table.Id;
                col.Name        = "修改时间";
                col.Code        = "Updated";
                col.ColType     = ColumnType.datetime_type;
                col.ColLen      = 8;
                //col.DefaultValue = "getdate()";
                col.AllowNull = true;
                col.IsSystem  = true;
                col.IsUnique  = false;
                col.IsVisible = false;
                col.Idx       = 3;
                col.Creator   = user.Id;
                table.ColumnMgr.AddNew(col);

                col             = new CColumn();
                col.Ctx         = table.Ctx;
                col.FW_Table_id = table.Id;
                col.Name        = "修改者";
                col.Code        = "Updator";
                col.ColType     = ColumnType.ref_type;
                if (tableUser != null)
                {
                    col.RefTable   = tableUser.Id;
                    col.RefCol     = guidUid;
                    col.RefShowCol = guidUname;
                }
                col.ColLen = 16;
                //col.DefaultValue = "0";
                col.AllowNull = true;
                col.IsSystem  = true;
                col.IsUnique  = false;
                col.IsVisible = false;
                col.Idx       = 4;
                col.Creator   = user.Id;
                table.ColumnMgr.AddNew(col);
            }
            //自定义字段
            int      iLastIdx = 4;
            string[] arr1     = Regex.Split(GridData, ";");
            foreach (string str1 in arr1)
            {
                if (str1.Length == 0)
                {
                    continue;
                }
                iLastIdx++;

                string[] arr2 = Regex.Split(str1, ",");
                CColumn  col  = new CColumn();
                col.Ctx          = table.Ctx;
                col.FW_Table_id  = table.Id;
                col.Id           = new Guid(arr2[0]);
                col.Name         = arr2[1];
                col.Code         = arr2[2];
                col.ColType      = CColumn.ConvertStringToColType(arr2[3]);
                col.ColLen       = Convert.ToInt32(arr2[4]);
                col.AllowNull    = (arr2[5] == "1")?true:false;
                col.IsSystem     = (arr2[6] == "1") ? true : false;
                col.IsUnique     = (arr2[17] == "1") ? true : false;
                col.IsVisible    = true;
                col.DefaultValue = arr2[7];
                col.ColDecimal   = (arr2[8] != "") ? Convert.ToInt32(arr2[8]) : 0;
                col.Formula      = arr2[9];
                if (col.ColType == ColumnType.ref_type)
                {
                    col.RefTable   = new Guid(arr2[10]);
                    col.RefCol     = new Guid(arr2[12]);
                    col.RefShowCol = new Guid(arr2[14]);
                }
                if (arr2[16].Trim() != "")
                {
                    col.ColumnEnumValMgr.RemoveAll();
                    string[] arrEnum = Regex.Split(arr2[16].Trim(), "/");
                    for (int i = 0; i < arrEnum.Length; i++)
                    {
                        string         sEnumVal = arrEnum[i];
                        CColumnEnumVal ev       = new CColumnEnumVal();
                        ev.Ctx          = col.Ctx;
                        ev.FW_Column_id = col.Id;
                        ev.Val          = sEnumVal;
                        ev.Idx          = i;
                        col.ColumnEnumValMgr.AddNew(ev);
                    }
                }
                col.Idx     = iLastIdx;
                col.Creator = user.Id;
                table.ColumnMgr.AddNew(col);
            }

            Global.GetCtx(Session["TopCompany"].ToString()).TableMgr.AddNew(table);

            if (!CTable.CreateDataTable(table))
            {
                Response.Write("创建表失败!");
                return;
            }
            if (!Global.GetCtx(Session["TopCompany"].ToString()).TableMgr.Save(true))
            {
                Response.Write("添加失败!");
                return;
            }
        }
    }
Exemple #3
0
        private void tbtSave_Click(object sender, EventArgs e)
        {
            string sName = txtTableName.Text.Trim();
            string sCode = txtTableCode.Text.Trim();

            if (sName == "")
            {
                MessageBox.Show("名称不能空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtTableName.Focus();
                return;
            }
            if (sCode == "")
            {
                MessageBox.Show("编码不能空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtTableCode.Focus();
                return;
            }
            if (!ValidateColName(sCode))
            {
                MessageBox.Show("编码只能由字母、数字、下划线组成,且数字不能在前面!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                txtTableCode.Focus();
                txtTableCode.SelectAll();
                return;
            }
            if (m_Table.m_CmdType == CmdType.AddNew)
            {
                if (Program.Ctx.TableMgr.FindByCode(sCode) != null)
                {
                    MessageBox.Show("相同编码的表已经存在!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    txtTableCode.Focus();
                    txtTableCode.SelectAll();
                    return;
                }
            }
            else if (!sCode.Equals(m_Table.Code, StringComparison.OrdinalIgnoreCase))
            {
                CTable table = Program.Ctx.TableMgr.FindByCode(sCode);
                if (table != null && table != m_Table)
                {
                    MessageBox.Show("相同编码的表已经存在!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    txtTableCode.Focus();
                    txtTableCode.SelectAll();
                    return;
                }
            }
            //检查列的合法性
            SortedList arrColName = new SortedList();

            foreach (DataGridViewRow row in dataGridView.Rows)
            {
                if (row.Cells[0].Value == null)
                {
                    continue;
                }
                string sColName = row.Cells[0].Value.ToString().Trim();
                if (sColName == "")
                {
                    MessageBox.Show(string.Format("列名不能空!"), "错误", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    return;
                }
                if (!ValidateColName(sColName))
                {
                    MessageBox.Show(string.Format("列名只能由字母、数字、下划线组成,且数字不能在前面:{0}", sColName), "错误", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    return;
                }
                if (arrColName.Contains(sColName))
                {
                    MessageBox.Show(string.Format("列名重复:{0}", sColName), "错误", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    return;
                }
                arrColName.Add(sColName, sColName);

                //
                CColumn col = (CColumn)row.Tag;
                DataGridViewComboBoxCell cbCell = (DataGridViewComboBoxCell)row.Cells[1];
                ColumnType colType = CColumn.ConvertStringToColType(cbCell.Value.ToString());
                if (colType == ColumnType.ref_type)
                {
                    ColPropertySetting prop = (ColPropertySetting)col.m_objTempData;
                    if (prop != null)
                    {
                        if (string.IsNullOrEmpty(prop.引用表))
                        {
                            MessageBox.Show(string.Format("{0}列引用表不能空!", sColName), "错误", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                            return;
                        }
                        if (string.IsNullOrEmpty(prop.引用字段))
                        {
                            MessageBox.Show(string.Format("{0}列引用字段不能空!", sColName), "错误", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                            return;
                        }
                        if (string.IsNullOrEmpty(prop.引用显示字段))
                        {
                            MessageBox.Show(string.Format("{0}列引用显示字段不能空!", sColName), "错误", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                            return;
                        }
                    }
                }
                else if (colType == ColumnType.enum_type)
                {
                    ColPropertySetting prop = (ColPropertySetting)col.m_objTempData;
                    if (prop != null)
                    {
                        if (string.IsNullOrEmpty(prop.引用显示字段) &&
                            string.IsNullOrEmpty(prop.枚举值))
                        {
                            MessageBox.Show(string.Format("{0}列至少有引用显示字段或枚举值!", sColName), "错误", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                            return;
                        }
                        if (!string.IsNullOrEmpty(prop.引用显示字段))
                        {
                            if (string.IsNullOrEmpty(prop.引用表))
                            {
                                MessageBox.Show(string.Format("{0}列引用表不能空!", sColName), "错误", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                                return;
                            }
                        }
                    }
                }
            }


            m_Table.Name     = sName;
            m_Table.Code     = sCode;
            m_Table.IsSystem = ckIsSystem.Checked;
            m_Table.IsFinish = true;
            foreach (DataGridViewRow row in dataGridView.Rows)
            {
                if (row.Cells[0].Value == null)
                {
                    continue;
                }
                string sColName = row.Cells[0].Value.ToString().Trim();
                DataGridViewComboBoxCell cbCell = (DataGridViewComboBoxCell)row.Cells[1];
                string sColLen = row.Cells[2].Value.ToString().Trim();
                DataGridViewCheckBoxCell ckCell  = (DataGridViewCheckBoxCell)row.Cells[3];
                DataGridViewCheckBoxCell ckCell2 = (DataGridViewCheckBoxCell)row.Cells[4];
                DataGridViewCheckBoxCell ckCell3 = (DataGridViewCheckBoxCell)row.Cells[5];

                CColumn col = (CColumn)row.Tag;
                col.FW_Table_id = m_Table.Id;
                col.Code        = sColName;
                col.ColType     = CColumn.ConvertStringToColType(cbCell.Value.ToString());
                col.ColLen      = Convert.ToInt32(sColLen);
                col.AllowNull   = Convert.ToBoolean(ckCell.Value);
                col.IsSystem    = Convert.ToBoolean(ckCell2.Value);
                col.IsUnique    = Convert.ToBoolean(ckCell3.Value);
                col.Idx         = row.Index;
                ColPropertySetting prop = (ColPropertySetting)col.m_objTempData;
                if (prop != null)
                {
                    col.Name         = prop.称;
                    col.DefaultValue = prop.默认值;
                    col.ColDecimal   = prop.小数位数;
                    col.Formula      = prop.公式;
                    if (col.ColType == ColumnType.ref_type)
                    {
                        CTable table = Program.Ctx.TableMgr.FindByCode(prop.引用表);
                        col.RefTable = table.Id;
                        CColumn column = table.ColumnMgr.FindByCode(prop.引用字段);
                        col.RefCol     = column.Id;
                        column         = table.ColumnMgr.FindByCode(prop.引用显示字段);
                        col.RefShowCol = column.Id;
                    }
                    else if (col.ColType == ColumnType.enum_type)
                    {
                        //引用显示字段优先
                        if (!string.IsNullOrEmpty(prop.引用显示字段))
                        {
                            CTable table = Program.Ctx.TableMgr.FindByCode(prop.引用表);
                            col.RefTable = table.Id;
                            CColumn column = table.ColumnMgr.FindByCode(prop.引用显示字段);
                            col.RefShowCol = column.Id;
                        }
                        else
                        {
                            col.ColumnEnumValMgr.RemoveAll();
                            string[] arrItem = prop.枚举值.Split("\\".ToCharArray());
                            for (int i = 0; i < arrItem.Length; i++)
                            {
                                string         sVal = arrItem[i];
                                CColumnEnumVal cev  = new CColumnEnumVal();
                                cev.Ctx          = Program.Ctx;
                                cev.FW_Column_id = col.Id;
                                cev.Val          = sVal;
                                cev.Idx          = i;

                                col.ColumnEnumValMgr.AddNew(cev);
                            }
                        }
                    }
                    col.UIControl    = prop.界面控件;
                    col.WebUIControl = prop.web界面控件;
                }
                m_Table.ColumnMgr.Update(col);
            }

            if (!CTable.CreateDataTable(m_Table))
            {
                MessageBox.Show(Program.Ctx.LastError, "错误", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                return;
            }
            //if (!m_Table.Save(true))
            if (!Program.Ctx.TableMgr.Save(true))
            {
                MessageBox.Show(Program.Ctx.LastError, "错误", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                return;
            }

            //if (m_Table.m_CmdType== CmdType.AddNew) //新建
            //{
            //    //m_Table = new CTable();
            //    m_Table.Name = sName;
            //    m_Table.Code = sCode;
            //    m_Table.IsSystem = ckIsSystem.Checked;
            //    if (Program.User != null)
            //    {
            //        m_Table.Creator = Program.User.Id;
            //        m_Table.Updator = Program.User.Id;
            //    }
            //    m_Table.Ctx = Program.Ctx;
            //    m_Table.IsFinish = true;
            //    if (!Program.Ctx.TableMgr.AddNew(m_Table))
            //    {
            //        MessageBox.Show(Program.Ctx.LastError, "错误", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            //        return;
            //    }
            //    foreach (DataGridViewRow row in dataGridView.Rows)
            //    {
            //        if (row.Cells[0].Value == null)
            //            continue;
            //        string sColName = row.Cells[0].Value.ToString().Trim();
            //        DataGridViewComboBoxCell cbCell = (DataGridViewComboBoxCell)row.Cells[1];
            //        string sColLen = row.Cells[2].Value.ToString().Trim();
            //        DataGridViewCheckBoxCell ckCell = (DataGridViewCheckBoxCell)row.Cells[3];
            //        DataGridViewCheckBoxCell ckCell2 = (DataGridViewCheckBoxCell)row.Cells[4];

            //        CColumn col = (CColumn)row.Tag;
            //        col.FW_Table_id = m_Table.Id;
            //        col.Code = sColName;
            //        col.ColType = CColumn.ConvertStringToColType(cbCell.Value.ToString());
            //        col.ColLen = Convert.ToInt32(sColLen);
            //        col.AllowNull = Convert.ToBoolean(ckCell.Value);
            //        col.IsSystem = Convert.ToBoolean(ckCell2.Value);
            //        col.Idx = row.Index;
            //        ColPropertySetting prop = (ColPropertySetting)col.m_objTempData;
            //        if (prop != null)
            //        {
            //            col.Name = prop.名称;
            //            col.DefaultValue = prop.默认值;
            //            col.ColDecimal = prop.小数位数;
            //            col.Formula = prop.公式;
            //            if (col.ColType == ColumnType.ref_type)
            //            {
            //                CTable table = Program.Ctx.TableMgr.FindByCode(prop.引用表);
            //                col.RefTable = table.Id;
            //                CColumn column = table.ColumnMgr.FindByCode(prop.引用字段);
            //                col.RefCol = column.Id;
            //                column = table.ColumnMgr.FindByCode(prop.引用显示字段);
            //                col.RefShowCol = column.Id;
            //            }
            //            col.UIControl = prop.界面控件;
            //            col.WebUIControl = prop.web界面控件;
            //        }
            //        col.Ctx = m_Table.Ctx;

            //        if (!m_Table.ColumnMgr.AddNew(col))
            //        {
            //            MessageBox.Show(Program.Ctx.LastError, "错误", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            //            return;
            //        }
            //    }

            //    if (!m_Table.Save(true))
            //    {
            //        MessageBox.Show(Program.Ctx.LastError, "错误", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            //        return;
            //    }
            //}
            //else //保存
            //{
            //    m_Table.Name = sName;
            //    m_Table.Code = sCode;
            //    m_Table.IsFinish = true;
            //    m_Table.IsSystem = ckIsSystem.Checked;
            //    if (!Program.Ctx.TableMgr.Update(m_Table))
            //    {
            //        MessageBox.Show(Program.Ctx.LastError, "错误", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            //        return;
            //    }
            //    List<CBaseObject> lstCol = m_Table.ColumnMgr.GetList();
            //    List<CColumn> lstDel = new List<CColumn>();
            //    foreach (CBaseObject obj in lstCol)
            //    {
            //        CColumn col = (CColumn)obj;
            //        bool bHas = false;
            //        foreach (DataGridViewRow row in dataGridView.Rows)
            //        {
            //            if (row.Cells[0].Value == null)
            //                continue;
            //            CColumn col2 = (CColumn)row.Tag;
            //            if (col == col2)
            //            {
            //                bHas = true;
            //                break;
            //            }
            //        }
            //        if (!bHas)
            //            lstDel.Add(col);
            //    }
            //    foreach (CColumn col in lstDel)
            //    {
            //        m_Table.ColumnMgr.Delete(col);
            //    }

            //    foreach (DataGridViewRow row in dataGridView.Rows)
            //    {
            //        if (row.Cells[0].Value == null)
            //            continue;
            //        string sColName = row.Cells[0].Value.ToString().Trim();
            //        DataGridViewComboBoxCell cbCell = (DataGridViewComboBoxCell)row.Cells[1];
            //        string sColLen = row.Cells[2].Value.ToString().Trim();
            //        DataGridViewCheckBoxCell ckCell = (DataGridViewCheckBoxCell)row.Cells[3];
            //        DataGridViewCheckBoxCell ckCell2 = (DataGridViewCheckBoxCell)row.Cells[4];

            //        CColumn col = (CColumn)row.Tag;
            //        col.FW_Table_id = m_Table.Id;
            //        col.Code = sColName;
            //        col.ColType = CColumn.ConvertStringToColType(cbCell.Value.ToString());
            //        col.ColLen = Convert.ToInt32(sColLen);
            //        col.AllowNull = Convert.ToBoolean(ckCell.Value);
            //        col.IsSystem = Convert.ToBoolean(ckCell2.Value);
            //        col.Idx = row.Index;
            //        ColPropertySetting prop = (ColPropertySetting)col.m_objTempData;
            //        if (prop != null)
            //        {
            //            col.Name = prop.名称;
            //            col.DefaultValue = prop.默认值;
            //            col.ColDecimal = prop.小数位数;
            //            col.Formula = prop.公式;
            //            if (col.ColType == ColumnType.ref_type)
            //            {
            //                CTable table = Program.Ctx.TableMgr.FindByCode(prop.引用表);
            //                col.RefTable = table.Id;
            //                CColumn column = table.ColumnMgr.FindByCode(prop.引用字段);
            //                col.RefCol = column.Id;
            //                column = table.ColumnMgr.FindByCode(prop.引用显示字段);
            //                col.RefShowCol = column.Id;
            //            }
            //            col.UIControl = prop.界面控件;
            //            col.WebUIControl = prop.web界面控件;
            //        }
            //        col.Ctx = m_Table.Ctx;

            //        if (col.m_CmdType== CmdType.AddNew)
            //        {
            //            if (!m_Table.ColumnMgr.AddNew(col))
            //            {
            //                MessageBox.Show(Program.Ctx.LastError, "错误", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            //                return;
            //            }
            //        }
            //        else if (col.m_CmdType == CmdType.Update)
            //        {
            //            if (!m_Table.ColumnMgr.Update(col))
            //            {
            //                MessageBox.Show(Program.Ctx.LastError, "错误", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            //                return;
            //            }
            //        }
            //    }
            //    if (!m_Table.Save(true))
            //    {
            //        MessageBox.Show(Program.Ctx.LastError, "错误", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            //        return;
            //    }
            //    //排列索引变化,重新加载
            //    m_Table.ColumnMgr.Load(m_Table.ColumnMgr.m_sWhere, true);
            //}
            //if (!CTable.CreateDataTable(m_Table))
            //{
            //    MessageBox.Show(Program.Ctx.LastError, "错误", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            //    return;
            //}


            DialogResult = DialogResult.OK;
        }