public int SetModuleType(ModuleTypeVModel mmType) { StringBuilder strSql = new StringBuilder(); strSql.Append("select count(*) from v0_module where Ledger=@Ledger and Mm_id!=@Mm_id and ModuleType=@ModuleType"); object obj = SQLHelper.ExecuteScalar(strSql.ToString(), new { Ledger = this.Ledger, Mm_id = mmType.ModuleTypeId, ModuleType = mmType.ModuleName }); if (CommFunc.ConvertDBNullToInt32(obj) > 0) { throw new Exception("已存在此型号:" + mmType.ModuleName); } if (mmType.ModuleTypeId == 0) { strSql.Clear(); strSql.Append("select max(Mm_id)as cnt from v0_module where Ledger=@Ledger"); mmType.ModuleTypeId = CommFunc.ConvertDBNullToInt32(SQLHelper.ExecuteScalar(strSql.ToString(), new { Ledger = this.Ledger })) + 1; } object params01 = new { Ledger = this.Ledger, Mm_id = mmType.ModuleTypeId, ModuleName = mmType.ModuleName, ModuleType = mmType.ModuleName, Disabled = mmType.Disabled, Spec = "", Fty_prod = "", IsDefine = mmType.IsDefine }; strSql.Clear(); strSql.Append("insert into v0_module("); strSql.Append("Ledger,Mm_id,ModuleName,ModuleType,Disabled,ModulePwd,ModuleUid,Level,Spec,Fty_prod,IsCharg,Protocol,IsDefine)"); strSql.Append(" values ("); strSql.Append("@Ledger,@Mm_id,@ModuleName,@ModuleType,@Disabled,'','','',@Spec,@Fty_prod,0,'',@IsDefine)"); strSql.Append("ON DUPLICATE KEY UPDATE ModuleName=@ModuleName,ModuleType=@ModuleType,Disabled=@Disabled,Spec=@Spec,Fty_prod=@Fty_prod,IsDefine=@IsDefine;"); return(SQLHelper.Execute(strSql.ToString(), params01)); }
/// <summary> /// 设置设备型号信息 /// </summary> /// <returns></returns> public APIRst SetModuleType(ModuleTypeVModel mtype) { APIRst rst = new APIRst(); try { rst.data = bll.SetModuleType(mtype); } catch (Exception ex) { rst.rst = false; rst.err.code = (int)ResultCodeDefine.Error; rst.err.msg = ex.Message; FileLog.WriteLog("设置设备型号信息错误:" + ex.Message + ex.StackTrace); } return(rst); }
public APIRst SetModuleType(ModuleTypeVModel mtype) { return(infoHelper.SetModuleType(mtype)); }
public APIRst AddModuleType(ModuleTypeVModel mtype) { mtype.ModuleTypeId = 0; return(infoHelper.SetModuleType(mtype)); }
public int SetModuleType(ModuleTypeVModel mtype) { return(dal.SetModuleType(mtype)); }