Exemplo n.º 1
0
        protected override bool beforeUpdateInsertAction()
        {
            MapAttr attr = new MapAttr();

            attr.MyPK = this.MyPK;
            attr.RetrieveFromDBSources();

            //是否启用高级js设置.
            attr.IsEnableJS = this.GetValBooleanByKey("IsEnableJS");

            //单选按钮的展现方式.
            attr.RBShowModel = this.GetValIntByKey("RBShowModel");

            //执行保存.
            attr.Save();

            return(base.beforeUpdateInsertAction());
        }
Exemplo n.º 2
0
        public void btn_Save_Click(object sender, EventArgs e)
        {
            try
            {
                Button btn = sender as Button;
                switch (btn.ID)
                {
                case "Btn_Del":
                    MapAttr attrDel = new MapAttr();
                    attrDel.MyPK = this.RefNo;
                    attrDel.Delete();
                    this.WinClose();
                    return;

                default:
                    break;
                }

                MapAttr attr = new MapAttr();
                if (this.RefNo != null)
                {
                    attr.MyPK = this.RefNo;
                    try
                    {
                        attr.Retrieve();
                    }
                    catch
                    {
                        attr.CheckPhysicsTable();
                        attr.Retrieve();
                    }

                    attr         = (MapAttr)this.Pub1.Copy(attr);
                    attr.GroupID = this.Pub1.GetDDLByID("DDL_GroupID").SelectedItemIntVal;
                    attr.ColSpan = this.Pub1.GetDDLByID("DDL_ColSpan").SelectedItemIntVal;
                    if (attr.UIIsEnable == false && attr.MyDataType == DataType.AppString)
                    {
                        try
                        {
                            attr.IsSigan = this.Pub1.GetCBByID("CB_IsSigan").Checked;
                        }
                        catch
                        {
                        }
                    }

                    switch (this.FType)
                    {
                    case DataType.AppBoolean:
                        attr.MyDataType   = BP.DA.DataType.AppBoolean;
                        attr.DefValOfBool = this.Pub1.GetCBByID("CB_DefVal").Checked;
                        break;

                    case DataType.AppDateTime:
                    case DataType.AppDate:
                        attr.DefValReal = this.Pub1.GetTBByID("TB_DefVal").Text;
                        //if (this.Pub1.GetCBByID("CB_DefVal").Checked)
                        //    attr.DefValReal = "1";
                        //else
                        //    attr.DefValReal = "0";
                        break;

                    case DataType.AppString:
                        attr.UIBindKey = this.Pub1.GetDDLByID("DDL_TBModel").SelectedItemStringVal;
                        if (attr.TBModel == 2)
                        {
                            attr.MaxLen = 4000;
                        }
                        break;

                    default:
                        break;
                    }
                }
                else
                {
                    attr         = (MapAttr)this.Pub1.Copy(attr);
                    attr.GroupID = this.Pub1.GetDDLByID("DDL_GroupID").SelectedItemIntVal;
                    attr.ColSpan = this.Pub1.GetDDLByID("DDL_ColSpan").SelectedItemIntVal;

                    MapAttrs attrS = new MapAttrs(this.MyPK);
                    int      idx   = 0;
                    foreach (MapAttr en in attrS)
                    {
                        idx++;
                        en.Idx = idx;
                        en.Update();
                        if (en.KeyOfEn == attr.KeyOfEn)
                        {
                            throw new Exception("字段已经存在 Key=" + attr.KeyOfEn);
                        }
                    }
                    if (this.IDX == null || this.IDX == "")
                    {
                        attr.Idx = 0;
                    }
                    else
                    {
                        attr.Idx = int.Parse(this.IDX) - 1;
                    }

                    attr.MyDataType = this.FType;
                    switch (this.FType)
                    {
                    case DataType.AppBoolean:
                        attr.MyDataType    = BP.DA.DataType.AppBoolean;
                        attr.UIContralType = UIContralType.CheckBok;
                        attr.DefValOfBool  = this.Pub1.GetCBByID("CB_DefVal").Checked;
                        break;

                    case DataType.AppString:
                        attr.UIBindKey = this.Pub1.GetDDLByID("DDL_TBModel").SelectedItemStringVal;
                        break;

                    default:
                        break;
                    }
                }

                // 增加是否为空, 对数字类型的字段有效.
                try
                {
                    attr.MinLen = this.Pub1.GetDDLByID("DDL_IsNull").SelectedItemIntVal;
                }
                catch
                {
                }

                //数字签名.
                try
                {
                    //签名类型.
                    attr.SignType = (SignType)this.Pub1.GetDDLByID("DDL_SignType").SelectedItemIntVal;

                    if (attr.SignType == SignType.Pic)
                    {
                        attr.PicType = (PicType)this.Pub1.GetDDLByID("DDL_PicType").SelectedItemIntVal;//是否为自动签名
                    }
                    else if (attr.SignType == SignType.CA)
                    {
                        attr.Para_SiganField = this.Pub1.GetTBByID("TB_SiganField").Text;//数字签名字段.
                    }
                }
                catch
                {
                }

                attr.Para_FontSize = this.Pub1.GetDDLByID("DDL_FontSize").SelectedItemIntVal;

                //保存数字签名.
                Response.Buffer = true;
                attr.FK_MapData = this.MyPK;
                attr.MyPK       = this.RefNo;

                //执行一次update 处理mapdata的计算的业务逻辑.
                MapData md = new MapData();
                md.No = attr.FK_MapData;
                if (md.RetrieveFromDBSources() == 1)
                {
                    md.Update();
                }

                attr.Save();

                switch (btn.ID)
                {
                case "Btn_SaveAndClose":
                    this.WinClose();
                    return;

                case "Btn_SaveAndNew":
                    this.Response.Redirect("Do.aspx?DoType=AddF&MyPK=" + this.MyPK + "&IDX=" + this.IDX + "&GroupField=" + attr.GroupID, true);
                    return;

                default:
                    break;
                }
                this.Response.Redirect("EditF.aspx?DoType=Edit&MyPK=" + this.MyPK + "&RefNo=" + attr.MyPK + "&FType=" + this.FType + "&GroupField=" + attr.GroupID, true);
            }
            catch (Exception ex)
            {
                this.Alert(ex.Message);
            }
        }
Exemplo n.º 3
0
        protected override bool beforeUpdateInsertAction()
        {
            MapAttr attr = new MapAttr();

            attr.MyPK = this.MyPK;
            attr.RetrieveFromDBSources();

            //高度.
            //  attr.UIHeightInt = this.GetValIntByKey("ExtRows") * 23;

            attr.IsRichText   = this.GetValBooleanByKey(MapAttrAttr.IsRichText);   //是否是富文本?
            attr.IsSupperText = this.GetValBooleanByKey(MapAttrAttr.IsSupperText); //是否是大块文本?

            if (attr.IsRichText || attr.IsSupperText)
            {
                attr.MaxLen = 4000;
                this.SetValByKey(MapAttrAttr.MaxLen, 4000);
            }


            #region 自动扩展字段长度.  @杜. 需要翻译.
            if (attr.MaxLen < 4000)
            {
                string  sql = "";
                MapData md  = new MapData();
                md.No = this.FK_MapData;
                if (md.RetrieveFromDBSources() == 1)
                {
                    if (DBAccess.IsExitsTableCol(md.PTable, this.KeyOfEn) == true)
                    {
                        if (SystemConfig.AppCenterDBType == DBType.MSSQL)
                        {
                            sql = "ALTER TABLE " + md.PTable + " ALTER column " + this.KeyOfEn + " NVARCHAR(" + attr.MaxLen + ")";
                        }

                        if (SystemConfig.AppCenterDBType == DBType.MySQL)
                        {
                            sql = "alter table " + md.PTable + " modify " + attr.Field + " NVARCHAR(" + attr.MaxLen + ")";
                        }

                        if (SystemConfig.AppCenterDBType == DBType.Oracle)
                        {
                            sql = "alter table " + md.PTable + " modify " + attr.Field + " NVARCHAR2(" + attr.MaxLen + ")";
                        }

                        if (SystemConfig.AppCenterDBType == DBType.PostgreSQL)
                        {
                            sql = "alter table " + md.PTable + " modify " + attr.Field + " VARCHAR(" + attr.MaxLen + ")";
                        }

                        DBAccess.RunSQL(sql); //如果是oracle如果有nvarchar与varchar类型,就会出错.
                    }
                }
            }
            #endregion 自动扩展字段长度.


            //默认值.
            string defval = this.GetValStrByKey("ExtDefVal");
            if (defval == "" || defval == "0")
            {
                string defVal = this.GetValStrByKey("DefVal");
                if (defval.Contains("@") == true)
                {
                    this.SetValByKey("DefVal", "");
                }
            }
            else
            {
                this.SetValByKey("DefVal", this.GetValByKey("ExtDefVal"));
            }

            //执行保存.
            attr.Save();

            if (this.GetValStrByKey("GroupID") == "无")
            {
                this.SetValByKey("GroupID", "0");
            }

            return(base.beforeUpdateInsertAction());
        }
Exemplo n.º 4
0
        public void btn_Save_Click(object sender, EventArgs e)
        {
            try
            {
                Button btn = sender as Button;
                switch (btn.ID)
                {
                case "Btn_Del":
                    this.Response.Redirect("Do.aspx?DoType=Del&MyPK=" + this.MyPK + "&RefNo=" + this.RefNo + "&GroupField = " + this.GroupField, true);
                    return;

                default:
                    break;
                }

                MapAttr attr = new MapAttr();
                if (this.RefNo != null)
                {
                    attr.MyPK = this.RefNo;
                    try
                    {
                        attr.Retrieve();
                    }
                    catch
                    {
                        attr.CheckPhysicsTable();
                        attr.Retrieve();
                    }

                    attr         = (MapAttr)this.Pub1.Copy(attr);
                    attr.GroupID = this.Pub1.GetDDLByID("DDL_GroupID").SelectedItemIntVal;
                    if (attr.UIIsEnable == false && attr.MyDataType == DataType.AppString)
                    {
                        try
                        {
                            attr.IsSigan = this.Pub1.GetCBByID("CB_IsSigan").Checked;
                        }
                        catch
                        {
                        }
                    }

                    switch (this.FType)
                    {
                    case DataType.AppBoolean:
                        attr.MyDataType   = BP.DA.DataType.AppBoolean;
                        attr.DefValOfBool = this.Pub1.GetCBByID("CB_DefVal").Checked;
                        break;

                    case DataType.AppDateTime:
                    case DataType.AppDate:
                        attr.DefValReal = this.Pub1.GetTBByID("TB_DefVal").Text;
                        //if (this.Pub1.GetCBByID("CB_DefVal").Checked)
                        //    attr.DefValReal = "1";
                        //else
                        //    attr.DefValReal = "0";
                        break;

                    case DataType.AppString:
                        attr.UIBindKey = this.Pub1.GetDDLByID("DDL_TBModel").SelectedItemStringVal;
                        break;

                    default:
                        break;
                    }
                }
                else
                {
                    attr         = (MapAttr)this.Pub1.Copy(attr);
                    attr.GroupID = this.Pub1.GetDDLByID("DDL_GroupID").SelectedItemIntVal;
                    MapAttrs attrS = new MapAttrs(this.MyPK);
                    int      idx   = 0;
                    foreach (MapAttr en in attrS)
                    {
                        idx++;
                        en.IDX = idx;
                        en.Update();
                        if (en.KeyOfEn == attr.KeyOfEn)
                        {
                            throw new Exception("字段已经存在 Key=" + attr.KeyOfEn);
                        }
                    }
                    if (this.IDX == null || this.IDX == "")
                    {
                        attr.IDX = 0;
                    }
                    else
                    {
                        attr.IDX = int.Parse(this.IDX) - 1;
                    }

                    attr.MyDataType = this.FType;
                    switch (this.FType)
                    {
                    case DataType.AppBoolean:
                        attr.MyDataType    = BP.DA.DataType.AppBoolean;
                        attr.UIContralType = UIContralType.CheckBok;
                        attr.DefValOfBool  = this.Pub1.GetCBByID("CB_DefVal").Checked;
                        break;

                    case DataType.AppString:
                        attr.UIBindKey = this.Pub1.GetDDLByID("DDL_TBModel").SelectedItemStringVal;
                        break;

                    default:
                        break;
                    }
                }

                Response.Buffer = true;
                attr.FK_MapData = this.MyPK;
                attr.MyPK       = this.RefNo;
                attr.Save();
                switch (btn.ID)
                {
                case "Btn_SaveAndClose":
                    this.WinClose();
                    return;

                case "Btn_SaveAndNew":
                    this.Response.Redirect("Do.aspx?DoType=AddF&MyPK=" + this.MyPK + "&IDX=" + this.IDX + "&GroupField=" + attr.GroupID, true);
                    return;

                default:
                    break;
                }
                this.Response.Redirect("EditF.aspx?DoType=Edit&MyPK=" + this.MyPK + "&RefNo=" + attr.MyPK + "&FType=" + this.FType + "&GroupField=" + attr.GroupID, true);
            }
            catch (Exception ex)
            {
                this.Alert(ex.Message);
            }
        }