/// <summary> /// 保存或者修改下一步 /// </summary> /// <param name="isSaveFileSize"></param> /// <param name="strAction"></param> /// <param name="modelFiled"></param> /// <param name="page"></param> /// <param name="strTableName"></param> /// <param name="strPageParams"></param> public string[] SavaOrUpdateNext(bool isSaveFileSize, string strAction, Model.Content.ModelField modelFiled, string strTableName) { string strColumnType = GetControlsColumnType(modelFiled.Controls, modelFiled.BasicField, modelFiled.DataColumnLength); //获取字段类型 return(dal.SavaOrUpdateNext(isSaveFileSize, strAction, modelFiled, strColumnType, strTableName)); }
/// <summary> /// 模型操作 /// </summary> /// <param Name="isSaveFileSize"></param> /// <param Name="strAction"></param> /// <param Name="modelFiled"></param> /// <param Name="page"></param> /// <param Name="strColumnType"></param> /// <param Name="strTableName"></param> /// <param Name="strPageParams"></param> public string[] SavaOrUpdateNext(bool isSaveFileSize, string strAction, Model.Content.ModelField modelFiled, string strColumnType, string strTableName) { //事务开启(以后优化) SqlConnection sqlConn = new SqlConnection(KingTop.Common.SQLHelper.ConnectionStringLocalTransaction); sqlConn.Open(); SqlTransaction sqlTran = sqlConn.BeginTransaction(); string[] strMessage = new string[2]; if (isSaveFileSize && strAction != "EDIT" && modelFiled.SaveFileName == "") { strMessage[0] = "0"; strMessage[1] = Utils.GetResourcesValue("Model", "AddFiledErrorMessage"); } string strSaveMessage = Save(sqlTran, strAction, modelFiled); if (strSaveMessage == "1") //如果数据插入成功,则要更新模型表 { if (strAction != "EDIT") //如果操作不为更新, 则还要在相应的模板表中插入字段 { string strIsNull = ""; //是否必填 if (modelFiled.IsRequired) //如果选择必填,则插入不为空 { strIsNull = ""; } string strDefaultValue = ""; //默认值 if (modelFiled.DefaultValue != "") { if (Public.IsNumber(modelFiled.DefaultValue)) { strDefaultValue = "default(" + modelFiled.DefaultValue + ")"; } else { strDefaultValue = " default('" + modelFiled.DefaultValue + "')"; } } string strAddMessage = AddModelColumn(sqlTran, strTableName, Utils.GetFilterKeyword(modelFiled.Name), strColumnType, strIsNull, strDefaultValue); //新加列 if (strAddMessage == "1") { if (isSaveFileSize) //如果保存文件大小字段,则还要插入在表中插入一个字段 { strAddMessage = AddModelColumn(sqlTran, strTableName, Utils.GetFilterKeyword(modelFiled.SaveFileName), "int", "", ""); //新加列 if (strAddMessage == "1") { sqlTran.Commit(); //事务提交 strMessage[0] = "1"; strMessage[1] = Utils.GetResourcesValue("Model", "AddSucess"); } else { sqlTran.Rollback(); //事务回滚 strMessage[0] = "0"; strMessage[1] = Utils.GetResourcesValue("Model", "AddDataBaseMessage"); } } else { sqlTran.Commit();//事务提交 strMessage[0] = "1"; strMessage[1] = Utils.GetResourcesValue("Model", "AddSucess"); } // bllModelField.CommitTran(); } else { sqlTran.Rollback();//事务回滚 strMessage[0] = "0"; strMessage[1] = Utils.GetResourcesValue("Model", "AddDataBaseFiledMessage"); } } else { sqlTran.Commit();//事务提交 strMessage[0] = "1"; strMessage[1] = Utils.GetResourcesValue("Model", "AddSucess"); } } else { sqlTran.Rollback(); //事务回滚 if (strAction != "EDIT") { strMessage[0] = "0"; strMessage[1] = Utils.GetResourcesValue("Model", "AddFiledMessage"); } else { strMessage[0] = "0"; strMessage[1] = Utils.GetResourcesValue("Model", "UpdateError"); } } sqlConn.Close(); sqlTran.Dispose(); sqlConn.Dispose(); return(strMessage); }