protected void btnOK_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(hidCheckFields.Value)) { litWarn.Text = "û��ѡ���ֶ�"; LoadDataBase(false); return; } string[] fieldNames = hidCheckFields.Value.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries); if (fieldNames.Length < 1) { litWarn.Text = "û��ѡ���ֶ�"; LoadDataBase(false); return; } string key = ddlDataSource.SelectedValue.Substring(0, ddlDataSource.SelectedValue.LastIndexOf('_')); DataBaseType dataBaseType = (DataBaseType)Enum.Parse(typeof(DataBaseType), ddlDataSource.SelectedValue.Substring(ddlDataSource.SelectedValue.LastIndexOf('_') + 1)); DataBase db = DataBase.Factory(BillBase.GetConnByDevKey(key)); if (db == null) { litWarn.Text = "����ʧ�ܣ���Ч���豸"; LoadDataBase(false); return; } int succCount = 0; SYS_BILL_COL cccmax = new SYS_BILL_COL(); cccmax.BILL_ID = billid; string sortStr = BLLTable<SYS_BILL_COL>.Max(SYS_BILL_COL.Attribute.SORT_NO, cccmax); int sort = 0; if (!string.IsNullOrEmpty(sortStr)) { sort = int.Parse(sortStr) + 1; } SYS_BILL billObj = BLLTable<SYS_BILL>.Factory(conn).GetRowData(SYS_BILL.Attribute.BILL_ID, billid); SYS_BILL_CTRL ctrlCond = new SYS_BILL_CTRL(); ctrlCond.OrderBy(TF_CTRL_TYPE.Attribute.SORT_NO, Order.Asc); DataTable dtCtrl = BLLTable<SYS_BILL_CTRL>.SelectForDataTable(new SYS_BILL_CTRL(), ctrlCond); DataView dv1 = new DataView(); dv1.Table = dtCtrl; dv1.RowFilter = "P_CTRL_ID='0'"; dv1.Sort = "SORT_NO asc"; int ctrlid = 0; if (dtCtrl != null && dtCtrl.Rows.Count > 1) { ctrlid = int.Parse(dv1[0]["CTRL_ID"].ToString()); } StringBuilder treeSb = new StringBuilder(); foreach (string fieldName in fieldNames) { if (string.IsNullOrEmpty(fieldName)) continue; string[] tableField = fieldName.Split('.'); if (tableField.Length != 2) continue; if (!db.DataTables.Contains(tableField[0])) continue; DataBaseTable table = db.DataTables[tableField[0]]; if (!table.DataFields.Contains(tableField[1])) continue; DataBaseField field = table.DataFields[tableField[1]]; SYS_BILL_COL valObj = new SYS_BILL_COL(); if (txtBILL_ID.Value != "") valObj.BILL_ID = Convert.ToInt32(txtBILL_ID.Value); valObj.COL_NAME = (key == "conn" ? "AIO_SYN" : key) + "_" + table.TableName + "_" + field.FieldName; if (BLLTable<SYS_BILL_COL>.Exists(valObj)) continue; #region valObj.TABLE_NAME = table.TableName; valObj.ISPK = field.IsKeyID ? "1" : "0"; valObj.COL_NOTE = ddlDataSource.SelectedItem.Text + (string.IsNullOrEmpty(field.Desc.ZhName) ? field.FieldName : field.Desc.ZhName); valObj.DATA_TYPE = field.DataType.TypeName.ToString().Replace("_", ""); valObj.DATA_LEN = field.DataType.DataLen; valObj.DATA_ACC = field.DataType.Scale; valObj.IS_AUTO = field.IsAutoIncrease ? "1" : "0"; valObj.SORT_NO = sort++; valObj.FK_SHOW = field.FieldName; valObj.DISPLAY_NAME = valObj.COL_NOTE; valObj.TITLE = valObj.COL_NOTE; valObj.DVAL = field.DefaultValue; valObj.BILL_ROW_FORMULAR = ""; valObj.BILL_COL_FORMULAR = ""; valObj.BILL_ISHEADER = "1"; valObj.BILL_HERDERWIDTH = 0; valObj.FORM_CHECKTYPE = "string"; valObj.FORM_CTRL_ID = ctrlid; valObj.FORM_SHOW = "1"; valObj.FORM_NEED = "1"; valObj.FORM_ONEROW = "1"; valObj.SEARCH_INBILL = "1"; valObj.SEARCH_TYPE = "string"; valObj.SEARCH_FORMULAR = "LikeRight"; if (billObj.TABLE_NAME != valObj.TABLE_NAME && key != "conn" && valObj.ISPK == "1") { valObj.ISFK = "1"; } else { valObj.ISFK = "0"; } valObj.FK_NAME = field.FieldName; valObj.BILL_AFTREDTL = "0"; //valObj.TABLE_EXISTS = "1"; //valObj.COL_SYN_TO = ""; //valObj.CONN_SOURCE = key == "conn" ? "AIO_SYN" : key; valObj.PK_VALCODE = ""; #endregion SYS_BILL_COL_EXD billExd = new SYS_BILL_COL_EXD(valObj); count = billExd.Add(); if (count > 0) { if (Request["tree"] != null) { StringBuilder sb = new StringBuilder("{"); sb.Append("id:'"); sb.Append(keyid).Append("',pid:'").Append(valObj.BILL_ID).Append("',no:").Append(valObj.SORT_NO).Append(",sc:0,name:'"); sb.Append(valObj.COL_NAME + "[" + valObj.COL_NOTE + "]").Append("',ntype:'col'}"); treeSb.Append(sb.ToString()); } else { #region StringBuilder sbData = new StringBuilder("{valObj:''"); List<AttributeItem> lstCol = valObj.af_AttributeItemList; for (int i = 0; i < lstCol.Count; i++) { object val = valObj.GetValue(lstCol[i]); if (val != null) { sbData.Append(",").Append(lstCol[i].FieldName).Append(":'").Append(val.ToString()).Append("'"); } } sbData.Append("}"); treeSb.Append(sbData.ToString()); #endregion } succCount++; } } if (succCount > 0) { AgileFrame.Core.ScriptHelper.ResponseScript(Page, "_FormView();", false); litWarn.Text = "�ɹ����" + succCount + "����Ŀ"; } else { litWarn.Text = "��Ŀ���ʧ��"; } LoadDataBase(false); }
protected void btnOK_Click(object sender, EventArgs e) { //try //{ SYS_BILL_COL valObj = new SYS_BILL_COL(); if (txtTABLE_NAME.Value != "") valObj.TABLE_NAME = Convert.ToString(txtTABLE_NAME.Value); if (txtCOL_NAME.Value != "") valObj.COL_NAME = Convert.ToString("U_" + txtCOL_NAME.Value); if (keyid == "") { if (BLLTable<SYS_BILL_COL>.Exists(valObj)) { litWarn.Text = "�Ѿ����ڴ��ֶΣ�"; return; } } #region valObj.ISPK = txtISPK.Value; if (txtCOL_NOTE.Value != "") valObj.COL_NOTE = Convert.ToString(txtCOL_NOTE.Value); if (txtDATA_TYPE.Value != "") valObj.DATA_TYPE = Convert.ToString(txtDATA_TYPE.Value); if (txtDATA_LEN.Value != "") valObj.DATA_LEN = Convert.ToInt32(txtDATA_LEN.Value); if (txtDATA_ACC.Value != "") valObj.DATA_ACC = Convert.ToInt32(txtDATA_ACC.Value); if (txtIS_AUTO.Value != "") valObj.IS_AUTO = Convert.ToString(txtIS_AUTO.Value); if (txtSORT_NO.Value != "") valObj.SORT_NO = Convert.ToInt32(txtSORT_NO.Value); if (txtCOL_SHOW.Value != "") valObj.FK_SHOW = Convert.ToString(txtCOL_SHOW.Value); if (txtTITLE.Value != "") valObj.TITLE = Convert.ToString(txtTITLE.Value); if (txtDVAL.Value != "") valObj.DVAL = Convert.ToString(txtDVAL.Value); if (hidTABLE_NAME.Value != txtTABLE_NAME.Value && txtCONN_SOURCE.Value != "AIO" && valObj.ISPK == "1") { valObj.ISFK = "1"; } else { valObj.ISFK = "0"; } valObj.FK_NAME = hidFK_NAME.Value; valObj.PK_VALCODE = txtPK_VALCODE.Value; #endregion string msg = ""; try { if (ViewState["txtCOL_NAME"] != null) { if (ViewState["txtCOL_NAME"].ToString().IndexOf("U_") != 0 && ViewState["txtCOL_NAME"].ToString().IndexOf("u_") != 0) { Response.Write("�Բ��������߱��༭���ֶε�Ȩ�ޡ�"); Response.End(); return; } //valObj.COL_ID = Convert.ToInt32(keyid); SYS_BILL_COL_EXD billExd = new SYS_BILL_COL_EXD(valObj); count = billExd.DB_Update(ViewState["txtCOL_NAME"].ToString(), valObj, ref msg);//.Update(ViewState["txtCOL_NAME"].ToString());// BLLTable<SYS_BILL_COL>.Factory(conn).Update(valObj, SYS_BILL_COL.Attribute.COL_ID); } else { if (ViewState["txtCOL_NAME"].ToString().IndexOf("U_") != 0 && ViewState["txtCOL_NAME"].ToString().IndexOf("u_") != 0) { Response.Write("�Բ��������߱���Ӵ��ֶε�Ȩ�ޡ�"); Response.End(); return; } SYS_BILL_COL_EXD billExd = new SYS_BILL_COL_EXD(valObj); count = billExd.DB_AddField(ref msg) == true ? 1 : 0;// BLLTable<SYS_BILL_COL>.Factory(conn).Insert(valObj, SYS_BILL_COL.Attribute.COL_ID); keyid = count.ToString(); ViewState["KEYID"] = keyid; } } catch (Exception ee) { Response.Write("����ʧ�ܣ�������ѡ��ڵ㣡"); Response.End(); } if (count > 0) { if ("31,32,33".IndexOf(valObj.FORM_CTRL_ID.ToString()) != -1) { liSetItems.Visible = true; } else { liSetItems.Visible = false; } ViewState["txtCOL_NAME"] = valObj.COL_NAME; if (Request["tree"] != null) { StringBuilder sb = new StringBuilder("{"); sb.Append("id:'").Append(valObj.COL_NAME.ToString()); sb.Append("',pid:'").Append(valObj.TABLE_NAME).Append("',no:").Append("1"); sb.Append(",sc:").Append("0,dev:'" + Request["dev"] + "',tb:'" + Request["tb"] + "'"); sb.Append(",name:'").Append(valObj.COL_NAME).Append("',note:'[" + valObj.COL_NOTE + "]'").Append(",ntype:'col'}"); if (Request["edit"] == null) { AgileFrame.Core.ScriptHelper.ResponseScript(Page, "parent.TV.showSubNodes(\"" + sb.ToString() + "\");", false); } else { AgileFrame.Core.ScriptHelper.ResponseScript(Page, "parent.TV.editNodeInfo(\"" + sb.ToString() + "\");", false); } litWarn.Text = "����ɹ�"; } else { #region StringBuilder sbData = new StringBuilder("{valObj:''"); List<AttributeItem> lstCol = valObj.af_AttributeItemList; for (int i = 0; i < lstCol.Count; i++) { object val = valObj.GetValue(lstCol[i]); if (val != null) { sbData.Append(",").Append(lstCol[i].FieldName).Append(":'").Append(val.ToString()).Append("'"); } } sbData.Append("}"); if (ViewState["sbData"] == null) { ViewState["sbData"] = sbData.ToString(); } else { ViewState["sbData"] += "," + sbData.ToString(); } Button btn = (Button)sender; if (btn.ID.IndexOf("btnOK") != -1) { if (ViewState["sbData"] == null) { string dataStr = "[" + ViewState["sbData"].ToString() + "]"; ScriptManager.RegisterStartupScript(Page, this.GetType(), "goto", "_FormView();if (window.opener){window.opener.returnValue = '" + dataStr + "';}else{window.returnValue = '" + dataStr + "';}window.close();", true); } else { ScriptManager.RegisterStartupScript(Page, this.GetType(), "goto", "_FormView();if (window.opener){window.opener.returnValue = 're';}else{window.returnValue = 're';}window.close();", true); } } else { AgileFrame.Core.ScriptHelper.ResponseScript(Page, "_FormView();", false); txtTABLE_NAME.Value = ""; txtCOL_NAME.Value = ""; hidTABLE_NAME.Value = ""; } #endregion } } else { litWarn.Text = "��ʧ�ܣ�"; } //} //catch (Exception ex) //{ // litWarn.Text = ex.Message; //} }
protected void btnOK_Click(object sender, EventArgs e) { //try //{ SYS_BILL_COL valObj = new SYS_BILL_COL(); if (txtBILL_ID.Value != "") valObj.BILL_ID = Convert.ToInt32(txtBILL_ID.Value); if (txtCOL_NAME.Value != "") valObj.COL_NAME = Convert.ToString(txtCOL_NAME.Value); if (keyid == "") { if (BLLTable<SYS_BILL_COL>.Exists(valObj)) { litWarn.Text = "�Ѿ����ڴ��ֶΣ�"; return; } } #region if (txtTABLE_NAME.Value != "") valObj.TABLE_NAME = Convert.ToString(txtTABLE_NAME.Value); if (txtCOL_ID.Value !="" ) valObj.COL_ID = Convert.ToInt32(txtCOL_ID.Value); valObj.ISPK = txtISPK.Value; if(txtCOL_NOTE.Value !="" ) valObj.COL_NOTE = Convert.ToString(txtCOL_NOTE.Value); if(txtDATA_TYPE.Value !="" ) valObj.DATA_TYPE = Convert.ToString(txtDATA_TYPE.Value); if(txtDATA_LEN.Value !="" ) valObj.DATA_LEN = Convert.ToInt32(txtDATA_LEN.Value); if(txtDATA_ACC.Value !="" ) valObj.DATA_ACC = Convert.ToInt32(txtDATA_ACC.Value); if(txtIS_AUTO.Value !="" ) valObj.IS_AUTO = Convert.ToString(txtIS_AUTO.Value); if(txtSORT_NO.Value !="" ) valObj.SORT_NO = Convert.ToInt32(txtSORT_NO.Value); if(txtCOL_SHOW.Value !="" ) valObj.FK_SHOW = Convert.ToString(txtCOL_SHOW.Value); if(txtDISPLAY_NAME.Value !="" ) valObj.DISPLAY_NAME = Convert.ToString(txtDISPLAY_NAME.Value); if(txtTITLE.Value !="" ) valObj.TITLE = Convert.ToString(txtTITLE.Value); if(txtDVAL.Value !="" ) valObj.DVAL = Convert.ToString(txtDVAL.Value); if(txtBILL_ROW_FORMULAR.Value !="" ) valObj.BILL_ROW_FORMULAR = Convert.ToString(txtBILL_ROW_FORMULAR.Value); if(txtBILL_COL_FORMULAR.Value !="" ) valObj.BILL_COL_FORMULAR = Convert.ToString(txtBILL_COL_FORMULAR.Value); if(txtBILL_ISHEADER.Value !="" ) valObj.BILL_ISHEADER = Convert.ToString(txtBILL_ISHEADER.Value); if(txtBILL_HERDERWIDTH.Value !="" ) valObj.BILL_HERDERWIDTH = Convert.ToInt32(txtBILL_HERDERWIDTH.Value); if(txtFORM_CHECKTYPE.Value !="" ) valObj.FORM_CHECKTYPE = Convert.ToString(txtFORM_CHECKTYPE.Value); // if(txtFORM_CTRL_ID.Value !="" ) valObj.FORM_CTRL_ID = int.Parse(Request["txtFORM_CTRL_ID"]); if(txtFORM_SHOW.Value !="" ) valObj.FORM_SHOW = Convert.ToString(txtFORM_SHOW.Value); if(txtFORM_NEED.Value !="" ) valObj.FORM_NEED = Convert.ToString(txtFORM_NEED.Value); if(txtFORM_MIN.Value !="" ) valObj.FORM_MIN = Convert.ToString(txtFORM_MIN.Value); if(txtFORM_MAX.Value !="" ) valObj.FORM_MAX = Convert.ToString(txtFORM_MAX.Value); if(txtFORM_ONEROW.Value !="" ) valObj.FORM_ONEROW = Convert.ToString(txtFORM_ONEROW.Value); if(txtFORM_CTRLWIDTH.Value !="" ) valObj.FORM_CTRLWIDTH = Convert.ToInt32(txtFORM_CTRLWIDTH.Value); if(txtSEARCH_INBILL.Value !="" ) valObj.SEARCH_INBILL = Convert.ToString(txtSEARCH_INBILL.Value); if(txtSEARCH_TYPE.Value !="" ) valObj.SEARCH_TYPE = Convert.ToString(txtSEARCH_TYPE.Value); if(txtSEARCH_FORMULAR.Value !="" ) valObj.SEARCH_FORMULAR = Convert.ToString(txtSEARCH_FORMULAR.Value); //valObj.ISFK = hidIsFK.Value; //if (hidTABLE_NAME.Value != txtTABLE_NAME.Value && txtCONN_SOURCE.Value != "AIO"&&valObj.ISPK=="1") //{ // valObj.ISFK = "1"; //} //else { // valObj.ISFK = "0"; //} valObj.FK_NAME = hidFK_NAME.Value; valObj.BILL_AFTREDTL = txtBILL_AFTREDTL.Value; //valObj.TABLE_EXISTS = txtTAVLE_EXISTS.Checked == true ? "1" : "0"; //valObj.COL_SYN_TO = txtCOL_SYN_TO.Value; //valObj.CONN_SOURCE = txtCONN_SOURCE.Value; valObj.PK_VALCODE = txtPK_VALCODE.Value; valObj.SEL_TB_COL = txtSEL_TBNAME.Value + "," + txtSEL_KEY.Value + "," + txtSEL_NAME.Value; #endregion if (keyid != "") { valObj.COL_ID = Convert.ToInt32(keyid); SYS_BILL_COL_EXD billExd = new SYS_BILL_COL_EXD(valObj); count = BLLTable<SYS_BILL_COL>.Factory(conn).Update(valObj, SYS_BILL_COL.Attribute.COL_ID); } else { SYS_BILL_COL_EXD billExd = new SYS_BILL_COL_EXD(valObj); count =BLLTable<SYS_BILL_COL>.Factory(conn).Insert(valObj, SYS_BILL_COL.Attribute.COL_ID); keyid = count.ToString(); ViewState["KEYID"] = keyid; } if (count > 0) { if ("31,32,33".IndexOf(valObj.FORM_CTRL_ID.ToString()) != -1) { liSetItems.Visible = true; } else { liSetItems.Visible = false; } if (Request["tree"] != null) { StringBuilder sb = new StringBuilder("{"); sb.Append("id:'"); sb.Append(keyid).Append("',pid:'").Append(valObj.BILL_ID).Append("',no:").Append(valObj.SORT_NO).Append(",sc:0,name:'"); sb.Append(valObj.COL_NAME + "[" + valObj.COL_NOTE + "]").Append("',ntype:'col'}"); if (Request["edit"] == null) { AgileFrame.Core.ScriptHelper.ResponseScript(Page, "_FormView();parent.TV.showSubNodes(\"" + sb.ToString() + "\");", false); } else { AgileFrame.Core.ScriptHelper.ResponseScript(Page, "_FormView();parent.TV.editNodeInfo(\"" + sb.ToString() + "\");", false); } litWarn.Text = "����ɹ�"; } else { #region StringBuilder sbData = new StringBuilder("{valObj:''"); List<AttributeItem> lstCol = valObj.af_AttributeItemList; for (int i = 0; i < lstCol.Count; i++) { object val = valObj.GetValue(lstCol[i]); if (val != null) { sbData.Append(",").Append(lstCol[i].FieldName).Append(":'").Append(val.ToString()).Append("'"); } } sbData.Append("}"); if (ViewState["sbData"] == null) { ViewState["sbData"] = sbData.ToString(); } else { ViewState["sbData"] += "," + sbData.ToString(); } Button btn = (Button)sender; if (btn.ID.IndexOf("btnOK") != -1) { if (ViewState["sbData"] == null) { string dataStr = "[" + ViewState["sbData"].ToString() + "]"; ScriptManager.RegisterStartupScript(Page, this.GetType(), "goto", "_FormView();if (window.opener){window.opener.returnValue = '" + dataStr + "';}else{window.returnValue = '" + dataStr + "';}window.close();", true); } else { ScriptManager.RegisterStartupScript(Page, this.GetType(), "goto", "_FormView();if (window.opener){window.opener.returnValue = 're';}else{window.returnValue = 're';}window.close();", true); } } else { AgileFrame.Core.ScriptHelper.ResponseScript(Page, "_FormView();", false); txtTABLE_NAME.Value = ""; txtCOL_NAME.Value = ""; hidTABLE_NAME.Value = ""; } #endregion } } else { litWarn.Text = "��ʧ�ܣ�"; } //} //catch (Exception ex) //{ // litWarn.Text = ex.Message; //} }
protected void btnOK_Click(object sender, EventArgs e) { //try //{ SYS_BILL_COL valObj = new SYS_BILL_COL(); if (txtTABLE_NAME.Value != "") { valObj.TABLE_NAME = Convert.ToString(txtTABLE_NAME.Value); } if (txtCOL_NAME.Value != "") { valObj.COL_NAME = Convert.ToString(txtCOL_NAME.Value); } if (keyid == "") { if (BLLTable <SYS_BILL_COL> .Exists(valObj)) { litWarn.Text = "已经存在此字段!"; return; } } #region valObj.ISPK = txtISPK.Value; if (txtCOL_NOTE.Value != "") { valObj.COL_NOTE = Convert.ToString(txtCOL_NOTE.Value); } if (txtDATA_TYPE.Value != "") { valObj.DATA_TYPE = Convert.ToString(txtDATA_TYPE.Value); } if (txtDATA_LEN.Value != "") { valObj.DATA_LEN = Convert.ToInt32(txtDATA_LEN.Value); } if (txtDATA_ACC.Value != "") { valObj.DATA_ACC = Convert.ToInt32(txtDATA_ACC.Value); } if (txtIS_AUTO.Value != "") { valObj.IS_AUTO = Convert.ToString(txtIS_AUTO.Value); } if (txtSORT_NO.Value != "") { valObj.SORT_NO = Convert.ToInt32(txtSORT_NO.Value); } if (txtCOL_SHOW.Value != "") { valObj.FK_SHOW = Convert.ToString(txtCOL_SHOW.Value); } if (txtTITLE.Value != "") { valObj.TITLE = Convert.ToString(txtTITLE.Value); } if (txtDVAL.Value != "") { valObj.DVAL = Convert.ToString(txtDVAL.Value); } if (hidTABLE_NAME.Value != txtTABLE_NAME.Value && txtCONN_SOURCE.Value != "AIO" && valObj.ISPK == "1") { valObj.ISFK = "1"; } else { valObj.ISFK = "0"; } valObj.FK_NAME = hidFK_NAME.Value; valObj.PK_VALCODE = txtPK_VALCODE.Value; #endregion string msg = ""; try { if (ViewState["txtCOL_NAME"] != null) { //valObj.COL_ID = Convert.ToInt32(keyid); SYS_BILL_COL_EXD billExd = new SYS_BILL_COL_EXD(valObj); count = billExd.DB_Update(ViewState["txtCOL_NAME"].ToString(), valObj, ref msg);//.Update(ViewState["txtCOL_NAME"].ToString());// BLLTable<SYS_BILL_COL>.Factory(conn).Update(valObj, SYS_BILL_COL.Attribute.COL_ID); } else { SYS_BILL_COL_EXD billExd = new SYS_BILL_COL_EXD(valObj); count = billExd.DB_AddField(ref msg) == true ? 1 : 0;// BLLTable<SYS_BILL_COL>.Factory(conn).Insert(valObj, SYS_BILL_COL.Attribute.COL_ID); keyid = count.ToString(); ViewState["KEYID"] = keyid; } } catch (Exception ee) { Response.Write("操作失败,请重新选择节点!"); Response.End(); } string syscolname = valObj.COL_NAME.ToLower().IndexOf("u_") == 0 ? "[客户字段]" : "[系统字段]"; if (count > 0) { if ("31,32,33".IndexOf(valObj.FORM_CTRL_ID.ToString()) != -1) { liSetItems.Visible = true; } else { liSetItems.Visible = false; } ViewState["txtCOL_NAME"] = valObj.COL_NAME; if (Request["tree"] != null) { StringBuilder sb = new StringBuilder("{"); sb.Append("id:'").Append(valObj.COL_NAME.ToString()); sb.Append("',pid:'").Append(valObj.TABLE_NAME).Append("',no:").Append("1"); sb.Append(",sc:").Append("0,dev:'" + Request["dev"] + "',tb:'" + Request["tb"] + "'"); sb.Append(",name:'").Append(valObj.COL_NAME).Append("',note:'[" + valObj.COL_NOTE + "]'").Append(",ntype:'col'}"); if (Request["edit"] == null) { AgileFrame.Core.ScriptHelper.ResponseScript(Page, "parent.TV.showSubNodes(\"" + sb.ToString() + "\");", false); } else { AgileFrame.Core.ScriptHelper.ResponseScript(Page, "parent.TV.editNodeInfo(\"" + sb.ToString() + "\");", false); } litWarn.Text = "保存" + syscolname + "成功"; } else { #region StringBuilder sbData = new StringBuilder("{valObj:''"); List <AttributeItem> lstCol = valObj.af_AttributeItemList; for (int i = 0; i < lstCol.Count; i++) { object val = valObj.GetValue(lstCol[i]); if (val != null) { sbData.Append(",").Append(lstCol[i].FieldName).Append(":'").Append(val.ToString()).Append("'"); } } sbData.Append("}"); if (ViewState["sbData"] == null) { ViewState["sbData"] = sbData.ToString(); } else { ViewState["sbData"] += "," + sbData.ToString(); } Button btn = (Button)sender; if (btn.ID.IndexOf("btnOK") != -1) { if (ViewState["sbData"] == null) { string dataStr = "[" + ViewState["sbData"].ToString() + "]"; ScriptManager.RegisterStartupScript(Page, this.GetType(), "goto", "_FormView();if (window.opener){window.opener.returnValue = '" + dataStr + "';}else{window.returnValue = '" + dataStr + "';}window.close();", true); } else { ScriptManager.RegisterStartupScript(Page, this.GetType(), "goto", "_FormView();if (window.opener){window.opener.returnValue = 're';}else{window.returnValue = 're';}window.close();", true); } } else { AgileFrame.Core.ScriptHelper.ResponseScript(Page, "_FormView();", false); txtTABLE_NAME.Value = ""; txtCOL_NAME.Value = ""; hidTABLE_NAME.Value = ""; } #endregion } } else { litWarn.Text = "修改" + syscolname + "失败!"; } //} //catch (Exception ex) //{ // litWarn.Text = ex.Message; //} }
protected void btnOK_Click(object sender, EventArgs e) { //try //{ SYS_BILL_COL valObj = new SYS_BILL_COL(); if (txtBILL_ID.Value != "") { valObj.BILL_ID = Convert.ToInt32(txtBILL_ID.Value); } if (txtCOL_NAME.Value != "") { valObj.COL_NAME = Convert.ToString(txtCOL_NAME.Value); } if (keyid == "") { if (BLLTable <SYS_BILL_COL> .Exists(valObj)) { litWarn.Text = "已经存在此字段!"; return; } } #region if (txtTABLE_NAME.Value != "") { valObj.TABLE_NAME = Convert.ToString(txtTABLE_NAME.Value); } if (txtCOL_ID.Value != "") { valObj.COL_ID = Convert.ToInt32(txtCOL_ID.Value); } valObj.ISPK = txtISPK.Value; if (txtCOL_NOTE.Value != "") { valObj.COL_NOTE = Convert.ToString(txtCOL_NOTE.Value); } if (txtDATA_TYPE.Value != "") { valObj.DATA_TYPE = Convert.ToString(txtDATA_TYPE.Value); } if (txtDATA_LEN.Value != "") { valObj.DATA_LEN = Convert.ToInt32(txtDATA_LEN.Value); } if (txtDATA_ACC.Value != "") { valObj.DATA_ACC = Convert.ToInt32(txtDATA_ACC.Value); } if (txtIS_AUTO.Value != "") { valObj.IS_AUTO = Convert.ToString(txtIS_AUTO.Value); } if (txtSORT_NO.Value != "") { valObj.SORT_NO = Convert.ToInt32(txtSORT_NO.Value); } if (txtCOL_SHOW.Value != "") { valObj.FK_SHOW = Convert.ToString(txtCOL_SHOW.Value); } if (txtDISPLAY_NAME.Value != "") { valObj.DISPLAY_NAME = Convert.ToString(txtDISPLAY_NAME.Value); } if (txtTITLE.Value != "") { valObj.TITLE = Convert.ToString(txtTITLE.Value); } if (txtDVAL.Value != "") { valObj.DVAL = Convert.ToString(txtDVAL.Value); } if (txtBILL_ROW_FORMULAR.Value != "") { valObj.BILL_ROW_FORMULAR = Convert.ToString(txtBILL_ROW_FORMULAR.Value); } if (txtBILL_COL_FORMULAR.Value != "") { valObj.BILL_COL_FORMULAR = Convert.ToString(txtBILL_COL_FORMULAR.Value); } if (txtBILL_ISHEADER.Value != "") { valObj.BILL_ISHEADER = Convert.ToString(txtBILL_ISHEADER.Value); } if (txtBILL_HERDERWIDTH.Value != "") { valObj.BILL_HERDERWIDTH = Convert.ToInt32(txtBILL_HERDERWIDTH.Value); } if (txtFORM_CHECKTYPE.Value != "") { valObj.FORM_CHECKTYPE = Convert.ToString(txtFORM_CHECKTYPE.Value); } // if(txtFORM_CTRL_ID.Value !="" ) valObj.FORM_CTRL_ID = int.Parse(Request["txtFORM_CTRL_ID"]); if (txtFORM_SHOW.Value != "") { valObj.FORM_SHOW = Convert.ToString(txtFORM_SHOW.Value); } if (txtFORM_NEED.Value != "") { valObj.FORM_NEED = Convert.ToString(txtFORM_NEED.Value); } if (txtFORM_MIN.Value != "") { valObj.FORM_MIN = Convert.ToString(txtFORM_MIN.Value); } if (txtFORM_MAX.Value != "") { valObj.FORM_MAX = Convert.ToString(txtFORM_MAX.Value); } if (txtFORM_ONEROW.Value != "") { valObj.FORM_ONEROW = Convert.ToString(txtFORM_ONEROW.Value); } if (txtFORM_CTRLWIDTH.Value != "") { valObj.FORM_CTRLWIDTH = Convert.ToInt32(txtFORM_CTRLWIDTH.Value); } if (txtSEARCH_INBILL.Value != "") { valObj.SEARCH_INBILL = Convert.ToString(txtSEARCH_INBILL.Value); } if (txtSEARCH_TYPE.Value != "") { valObj.SEARCH_TYPE = Convert.ToString(txtSEARCH_TYPE.Value); } if (txtSEARCH_FORMULAR.Value != "") { valObj.SEARCH_FORMULAR = Convert.ToString(txtSEARCH_FORMULAR.Value); } //valObj.ISFK = hidIsFK.Value; //if (hidTABLE_NAME.Value != txtTABLE_NAME.Value && txtCONN_SOURCE.Value != "AIO"&&valObj.ISPK=="1") //{ // valObj.ISFK = "1"; //} //else { // valObj.ISFK = "0"; //} valObj.FK_NAME = hidFK_NAME.Value; valObj.BILL_AFTREDTL = txtBILL_AFTREDTL.Value; //valObj.TABLE_EXISTS = txtTAVLE_EXISTS.Checked == true ? "1" : "0"; //valObj.COL_SYN_TO = txtCOL_SYN_TO.Value; //valObj.CONN_SOURCE = txtCONN_SOURCE.Value; valObj.PK_VALCODE = txtPK_VALCODE.Value; valObj.SEL_TB_COL = txtSEL_TBNAME.Value + "," + txtSEL_KEY.Value + "," + txtSEL_NAME.Value; #endregion if (keyid != "") { valObj.COL_ID = Convert.ToInt32(keyid); SYS_BILL_COL_EXD billExd = new SYS_BILL_COL_EXD(valObj); count = BLLTable <SYS_BILL_COL> .Factory(conn).Update(valObj, SYS_BILL_COL.Attribute.COL_ID); } else { SYS_BILL_COL_EXD billExd = new SYS_BILL_COL_EXD(valObj); count = BLLTable <SYS_BILL_COL> .Factory(conn).Insert(valObj, SYS_BILL_COL.Attribute.COL_ID); keyid = count.ToString(); ViewState["KEYID"] = keyid; } if (count > 0) { if ("31,32,33".IndexOf(valObj.FORM_CTRL_ID.ToString()) != -1) { liSetItems.Visible = true; } else { liSetItems.Visible = false; } if (Request["tree"] != null) { StringBuilder sb = new StringBuilder("{"); sb.Append("id:'"); sb.Append(keyid).Append("',pid:'").Append(valObj.BILL_ID).Append("',no:").Append(valObj.SORT_NO).Append(",sc:0,name:'"); sb.Append(valObj.COL_NAME + "[" + valObj.COL_NOTE + "]").Append("',ntype:'col'}"); if (Request["edit"] == null) { AgileFrame.Core.ScriptHelper.ResponseScript(Page, "_FormView();parent.TV.showSubNodes(\"" + sb.ToString() + "\");", false); } else { AgileFrame.Core.ScriptHelper.ResponseScript(Page, "_FormView();parent.TV.editNodeInfo(\"" + sb.ToString() + "\");", false); } litWarn.Text = "保存成功"; } else { #region StringBuilder sbData = new StringBuilder("{valObj:''"); List <AttributeItem> lstCol = valObj.af_AttributeItemList; for (int i = 0; i < lstCol.Count; i++) { object val = valObj.GetValue(lstCol[i]); if (val != null) { sbData.Append(",").Append(lstCol[i].FieldName).Append(":'").Append(val.ToString()).Append("'"); } } sbData.Append("}"); if (ViewState["sbData"] == null) { ViewState["sbData"] = sbData.ToString(); } else { ViewState["sbData"] += "," + sbData.ToString(); } Button btn = (Button)sender; if (btn.ID.IndexOf("btnOK") != -1) { if (ViewState["sbData"] == null) { string dataStr = "[" + ViewState["sbData"].ToString() + "]"; ScriptManager.RegisterStartupScript(Page, this.GetType(), "goto", "_FormView();if (window.opener){window.opener.returnValue = '" + dataStr + "';}else{window.returnValue = '" + dataStr + "';}window.close();", true); } else { ScriptManager.RegisterStartupScript(Page, this.GetType(), "goto", "_FormView();if (window.opener){window.opener.returnValue = 're';}else{window.returnValue = 're';}window.close();", true); } } else { AgileFrame.Core.ScriptHelper.ResponseScript(Page, "_FormView();", false); txtTABLE_NAME.Value = ""; txtCOL_NAME.Value = ""; hidTABLE_NAME.Value = ""; } #endregion } } else { litWarn.Text = "修改失败!"; } //} //catch (Exception ex) //{ // litWarn.Text = ex.Message; //} }
protected void btnOK_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(hidCheckFields.Value)) { litWarn.Text = "没有选中字段"; LoadDataBase(false); return; } string[] fieldNames = hidCheckFields.Value.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries); if (fieldNames.Length < 1) { litWarn.Text = "没有选中字段"; LoadDataBase(false); return; } string key = ddlDataSource.SelectedValue.Substring(0, ddlDataSource.SelectedValue.LastIndexOf('_')); DataBaseType dataBaseType = (DataBaseType)Enum.Parse(typeof(DataBaseType), ddlDataSource.SelectedValue.Substring(ddlDataSource.SelectedValue.LastIndexOf('_') + 1)); DataBase db = DataBase.Factory(BillBase.GetConnByDevKey(key)); if (db == null) { litWarn.Text = "操作失败,无效的设备"; LoadDataBase(false); return; } int succCount = 0; SYS_BILL_COL cccmax = new SYS_BILL_COL(); cccmax.BILL_ID = billid; string sortStr = BLLTable <SYS_BILL_COL> .Max(SYS_BILL_COL.Attribute.SORT_NO, cccmax); int sort = 0; if (!string.IsNullOrEmpty(sortStr)) { sort = int.Parse(sortStr) + 1; } SYS_BILL billObj = BLLTable <SYS_BILL> .Factory(conn).GetRowData(SYS_BILL.Attribute.BILL_ID, billid); SYS_BILL_CTRL ctrlCond = new SYS_BILL_CTRL(); ctrlCond.OrderBy(TF_CTRL_TYPE.Attribute.SORT_NO, Order.Asc); DataTable dtCtrl = BLLTable <SYS_BILL_CTRL> .SelectForDataTable(new SYS_BILL_CTRL(), ctrlCond); DataView dv1 = new DataView(); dv1.Table = dtCtrl; dv1.RowFilter = "P_CTRL_ID='0'"; dv1.Sort = "SORT_NO asc"; int ctrlid = 0; if (dtCtrl != null && dtCtrl.Rows.Count > 1) { ctrlid = int.Parse(dv1[0]["CTRL_ID"].ToString()); } StringBuilder treeSb = new StringBuilder(); foreach (string fieldName in fieldNames) { if (string.IsNullOrEmpty(fieldName)) { continue; } string[] tableField = fieldName.Split('.'); if (tableField.Length != 2) { continue; } if (!db.DataTables.Contains(tableField[0])) { continue; } DataBaseTable table = db.DataTables[tableField[0]]; if (!table.DataFields.Contains(tableField[1])) { continue; } DataBaseField field = table.DataFields[tableField[1]]; SYS_BILL_COL valObj = new SYS_BILL_COL(); if (txtBILL_ID.Value != "") { valObj.BILL_ID = Convert.ToInt32(txtBILL_ID.Value); } valObj.COL_NAME = (key == "conn" ? "AIO_SYN" : key) + "_" + table.TableName + "_" + field.FieldName; if (BLLTable <SYS_BILL_COL> .Exists(valObj)) { continue; } #region valObj.TABLE_NAME = table.TableName; valObj.ISPK = field.IsKeyID ? "1" : "0"; valObj.COL_NOTE = ddlDataSource.SelectedItem.Text + (string.IsNullOrEmpty(field.Desc.ZhName) ? field.FieldName : field.Desc.ZhName); valObj.DATA_TYPE = field.DataType.TypeName.ToString().Replace("_", ""); valObj.DATA_LEN = field.DataType.DataLen; valObj.DATA_ACC = field.DataType.Scale; valObj.IS_AUTO = field.IsAutoIncrease ? "1" : "0"; valObj.SORT_NO = sort++; valObj.FK_SHOW = field.FieldName; valObj.DISPLAY_NAME = valObj.COL_NOTE; valObj.TITLE = valObj.COL_NOTE; valObj.DVAL = field.DefaultValue; valObj.BILL_ROW_FORMULAR = ""; valObj.BILL_COL_FORMULAR = ""; valObj.BILL_ISHEADER = "1"; valObj.BILL_HERDERWIDTH = 0; valObj.FORM_CHECKTYPE = "string"; valObj.FORM_CTRL_ID = ctrlid; valObj.FORM_SHOW = "1"; valObj.FORM_NEED = "1"; valObj.FORM_ONEROW = "1"; valObj.SEARCH_INBILL = "1"; valObj.SEARCH_TYPE = "string"; valObj.SEARCH_FORMULAR = "LikeRight"; if (billObj.TABLE_NAME != valObj.TABLE_NAME && key != "conn" && valObj.ISPK == "1") { valObj.ISFK = "1"; } else { valObj.ISFK = "0"; } valObj.FK_NAME = field.FieldName; valObj.BILL_AFTREDTL = "0"; //valObj.TABLE_EXISTS = "1"; //valObj.COL_SYN_TO = ""; //valObj.CONN_SOURCE = key == "conn" ? "AIO_SYN" : key; valObj.PK_VALCODE = ""; #endregion SYS_BILL_COL_EXD billExd = new SYS_BILL_COL_EXD(valObj); count = billExd.Add(); if (count > 0) { if (Request["tree"] != null) { StringBuilder sb = new StringBuilder("{"); sb.Append("id:'"); sb.Append(keyid).Append("',pid:'").Append(valObj.BILL_ID).Append("',no:").Append(valObj.SORT_NO).Append(",sc:0,name:'"); sb.Append(valObj.COL_NAME + "[" + valObj.COL_NOTE + "]").Append("',ntype:'col'}"); treeSb.Append(sb.ToString()); } else { #region StringBuilder sbData = new StringBuilder("{valObj:''"); List <AttributeItem> lstCol = valObj.af_AttributeItemList; for (int i = 0; i < lstCol.Count; i++) { object val = valObj.GetValue(lstCol[i]); if (val != null) { sbData.Append(",").Append(lstCol[i].FieldName).Append(":'").Append(val.ToString()).Append("'"); } } sbData.Append("}"); treeSb.Append(sbData.ToString()); #endregion } succCount++; } } if (succCount > 0) { AgileFrame.Core.ScriptHelper.ResponseScript(Page, "_FormView();", false); litWarn.Text = "成功添加" + succCount + "个栏目"; } else { litWarn.Text = "栏目添加失败"; } LoadDataBase(false); }