/// <summary> /// 删除和移动顺序操作 /// </summary> protected void Operation() { string Action = Request.QueryString["Action"]; mF.Id = StringDeal.ToInt(Request.QueryString["Id"]); if (!String.IsNullOrEmpty(Action)) { if (Action == "down" || Action == "up") { bF.FieldMove(mF, Action); } else if (Action == "del") { mF = bF.GetTableAndField(mF);//字段名与表名 bF.FieldDel(mF); HXD.ModelField.BLL.Field bf = new HXD.ModelField.BLL.Field(); HXD.ModelField.Model.Field mf = new HXD.ModelField.Model.Field(); mf.TableName = mF.TableName; mf.Name = mF.Field; bf.Val = mf; bf.DeleteXml(); } Response.Redirect("Field_Manage.aspx?TableId=" + TableId + "", true); } }
/// <summary> /// ²åÈë×ֶΠ/// </summary> /// <param name="Val"></param> public void InsertField(HXD.ModelField.Model.Field Val) { string Sql = ""; switch (Val.Type) { case "SingleLine": Sql = "ALTER TABLE " + Val.TableName + " ADD [" + Val.Name + "] [NVARCHAR] (" + Val.MaxLength + ") NULL DEFAULT ('" + Val.Default + "')"; break; case "Password": Sql = "ALTER TABLE " + Val.TableName + " ADD [" + Val.Name + "] [NVARCHAR] (" + Val.MaxLength + ") NULL DEFAULT ('" + Val.Default + "')"; break; case "MultiLine": Sql = "ALTER TABLE " + Val.TableName + " ADD [" + Val.Name + "] [NTEXT] NULL DEFAULT ('" + Val.Default + "')"; break; case "Editor": Sql = "ALTER TABLE " + Val.TableName + " ADD [" + Val.Name + "] [NTEXT] NULL DEFAULT ('" + Val.Default + "')"; break; case "Select": Sql = "ALTER TABLE " + Val.TableName + " ADD [" + Val.Name + "] [NVARCHAR] (4000) NULL DEFAULT ('" + Val.Default + "')"; break; case "Number": Sql = "ALTER TABLE " + Val.TableName + " ADD [" + Val.Name + "] [DECIMAL] (18, " + Val.Bit + ") NULL DEFAULT (" + Val.Default + ")"; break; case "DateTime": Sql = "ALTER TABLE " + Val.TableName + " ADD [" + Val.Name + "] [DATETIME] NULL DEFAULT (" + Val.Default + ")"; break; case "Image": Sql = "ALTER TABLE " + Val.TableName + " ADD [" + Val.Name + "] [NVARCHAR] (1200) NULL DEFAULT ('" + Val.Default + "')"; break; case "File": Sql = "ALTER TABLE " + Val.TableName + " ADD [" + Val.Name + "] [NVARCHAR] (1200) NULL DEFAULT ('" + Val.Default + "')"; break; case "BatchImage": Sql = "ALTER TABLE " + Val.TableName + " ADD [" + Val.Name + "] [TEXT] NULL DEFAULT ('" + Val.Default + "')"; break; case "BatchFile": Sql = "ALTER TABLE " + Val.TableName + " ADD [" + Val.Name + "] [TEXT] NULL DEFAULT ('" + Val.Default + "')"; break; case "OtherMenu": Sql = "ALTER TABLE " + Val.TableName + " ADD [" + Val.Name + "] [INT] NULL DEFAULT ('" + Val.Default + "')"; break; case "Provinces": Sql = "ALTER TABLE " + Val.TableName + " ADD [" + Val.Name + "] [NVARCHAR] (200) NULL DEFAULT ('')"; SQLHelper.ExecuteNonQuery("FieldCreate", Val.TableName, Val.Name + "_City", "ALTER TABLE " + Val.TableName + " ADD [" + Val.Name + "_City] [NVARCHAR] (200) NULL DEFAULT ('')"); break; case "Increment": Sql = "ALTER TABLE " + Val.TableName + " ADD [" + Val.Name + "] [NTEXT] NULL DEFAULT ('" + Val.Default + "')"; break; } if (!String.IsNullOrEmpty(Sql)) { SQLHelper.ExecuteNonQuery("FieldCreate", Val.TableName, Val.Name, Sql); } }
/// <summary> /// ÐÞ¸Ä×ֶΠ/// </summary> /// <param name="Val"></param> public void UpdateField(HXD.ModelField.Model.Field Val) { string Sql = ""; switch (Val.Type) { case "SingleLine": Sql = "ALTER TABLE " + Val.TableName + " ALTER COLUMN [" + Val.Name + "] [NVARCHAR] (" + Val.MaxLength + ") NULL"; Sql += " ALTER TABLE " + Val.TableName + " ADD CONSTRAINT DF_" + Val.TableName + "_" + Val.Name + " DEFAULT ('" + Val.Default + "') FOR [" + Val.Name + "]"; break; case "Password": Sql = "ALTER TABLE " + Val.TableName + " ALTER COLUMN [" + Val.Name + "] [NVARCHAR] (" + Val.MaxLength + ") NULL"; Sql += " ALTER TABLE " + Val.TableName + " ADD CONSTRAINT DF_" + Val.TableName + "_" + Val.Name + " DEFAULT ('" + Val.Default + "') FOR [" + Val.Name + "]"; break; case "MultiLine": Sql = "ALTER TABLE " + Val.TableName + " ADD CONSTRAINT DF_" + Val.TableName + "_" + Val.Name + " DEFAULT ('" + Val.Default + "') FOR [" + Val.Name + "]"; break; case "Editor": Sql = "ALTER TABLE " + Val.TableName + " ADD CONSTRAINT DF_" + Val.TableName + "_" + Val.Name + " DEFAULT ('" + Val.Default + "') FOR [" + Val.Name + "]"; break; case "Select": Sql = "ALTER TABLE " + Val.TableName + " ADD CONSTRAINT DF_" + Val.TableName + "_" + Val.Name + " DEFAULT ('" + Val.Default + "') FOR [" + Val.Name + "]"; break; case "Number": Sql = "ALTER TABLE " + Val.TableName + " ALTER COLUMN [" + Val.Name + "] [DECIMAL] (18, " + Val.Bit + ") NULL"; Sql += " ALTER TABLE " + Val.TableName + " ADD CONSTRAINT DF_" + Val.TableName + "_" + Val.Name + " DEFAULT (" + Val.Default + ") FOR [" + Val.Name + "]"; break; case "DateTime": Sql = "ALTER TABLE " + Val.TableName + " ADD CONSTRAINT DF_" + Val.TableName + "_" + Val.Name + " DEFAULT (" + Val.Default + ") FOR [" + Val.Name + "]"; break; case "Image": Sql = "ALTER TABLE " + Val.TableName + " ADD CONSTRAINT DF_" + Val.TableName + "_" + Val.Name + " DEFAULT ('" + Val.Default + "') FOR [" + Val.Name + "]"; break; case "File": Sql = "ALTER TABLE " + Val.TableName + " ADD CONSTRAINT DF_" + Val.TableName + "_" + Val.Name + " DEFAULT ('" + Val.Default + "') FOR [" + Val.Name + "]"; break; case "BatchImage": Sql = "ALTER TABLE " + Val.TableName + " ADD CONSTRAINT DF_" + Val.TableName + "_" + Val.Name + " DEFAULT ('" + Val.Default + "') FOR [" + Val.Name + "]"; break; case "BatchFile": Sql = "ALTER TABLE " + Val.TableName + " ADD CONSTRAINT DF_" + Val.TableName + "_" + Val.Name + " DEFAULT ('" + Val.Default + "') FOR [" + Val.Name + "]"; break; case "OtherMenu": Sql = "ALTER TABLE " + Val.TableName + " ADD CONSTRAINT DF_" + Val.TableName + "_" + Val.Name + " DEFAULT ('" + Val.Default + "') FOR [" + Val.Name + "]"; break; case "Provinces": Sql = "ALTER TABLE " + Val.TableName + " ADD CONSTRAINT DF_" + Val.TableName + "_" + Val.Name + " DEFAULT ('') FOR [" + Val.Name + "]"; SQLHelper.ExecuteNonQuery("FieldCreate", Val.TableName, Val.Name + "_City", "ALTER TABLE " + Val.TableName + " ADD CONSTRAINT DF_" + Val.TableName + "_" + Val.Name + "_City DEFAULT ('') FOR [" + Val.Name + "_City]"); break; case "Increment": Sql = "ALTER TABLE " + Val.TableName + " ADD CONSTRAINT DF_" + Val.TableName + "_" + Val.Name + " DEFAULT ('" + Val.Default + "') FOR [" + Val.Name + "]"; break; } if (!String.IsNullOrEmpty(Sql)) { SQLHelper.ExecuteNonQuery("FieldCreate", Val.TableName, Val.Name, Sql); } }
/// <summary> /// 字段信息保存 /// </summary> protected void FieldSave() { //获取入库的信息 mF.Field = this.Field.Text; mF.Title = this.Title.Text; mF.Note = this.Note.Text; mF.Prompt = this.Prompt.Text; mF.Type = this.Type.SelectedValue; #region 获取要生成表及XML字段所有属性 HXD.ModelField.Model.Field mf = new HXD.ModelField.Model.Field(); mf.TableName = this.TableName.Text; mf.Type = this.Type.SelectedValue; mf.Name = this.Field.Text; mf.Title = this.Title.Text; mf.Note = this.Note.Text; mf.Prompt = this.Prompt.Text; mf.MaxLength = StringDeal.ToInt(Request.Form["MaxLength"]); mf.Size = StringDeal.ToInt(Request.Form["Size"]); mf.Default = Request.Form["Default"]; mf.Width = StringDeal.ToInt(Request.Form["Width"]); mf.Height = StringDeal.ToInt(Request.Form["Height"]); mf.PwdMode = Request.Form["PwdMode"]; mf.EditorType = StringDeal.ToInt(Request.Form["EditorType"]); mf.Options = Request.Form["Options"]; mf.OptionsType = Request.Form["OptionsType"]; mf.Bit = StringDeal.ToInt(Request.Form["Bit"]); mf.DateTime = Request.Form["DateTime"]; mf.IsUploadPhoto = StringDeal.ToBool(Request.Form["IsUploadPhoto"]); mf.UploadPhotoSize = StringDeal.ToInt(Request.Form["UploadPhotoSize"]); mf.UploadPhotoType = Request.Form["UploadPhotoType"]; mf.IsSelect = StringDeal.ToBool(Request.Form["IsSelect"]); mf.IsMark = StringDeal.ToBool(Request.Form["IsMark"]); mf.MarkImage = Request.Form["MarkImage"]; mf.IsThumb = StringDeal.ToBool(Request.Form["IsThumb"]); mf.ThumbSize = Request.Form["ThumbSize"]; mf.IsUploadFile = StringDeal.ToBool(Request.Form["IsUploadFile"]); mf.UploadFileSize = StringDeal.ToInt(Request.Form["UploadFileSize"]); mf.UploadFileType = Request.Form["UploadFileType"]; mf.Validator = Request.Form["Validator"]; #endregion if (mF.Id == 0) { if (bF.FieldInsert(mF)) { StringDeal.Alter("此字段名已经存在,请更换其他名称!"); } else { HXD.ModelField.BLL.Field bf = new HXD.ModelField.BLL.Field(); bf.Val = mf; bf.InsertXml(); bf.InsertField(); Response.Redirect("Field_Manage.aspx?TableId=" + TableId + ""); } } else { if (bF.FieldUpdate(mF)) { StringDeal.Alter("此字段名已经存在,请更换其他名称!"); } else { HXD.ModelField.BLL.Field bf = new HXD.ModelField.BLL.Field(); bf.Val = mf; bf.UpdateXml(); bf.UpdateField(); Response.Redirect("Field_Manage.aspx?TableId=" + TableId + ""); } } }