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); } }
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); } }