public string AddCard(string strJsonParam) { string strError; RequestModelString reqinfo = ServerHlper.GetRequestModelString(System.Reflection.MethodBase.GetCurrentMethod().Name, strJsonParam, out strError); if (reqinfo == null) { return(strError); } GasCardWithCommInfo mod = JsonStrObjConver.JsonStr2Obj(reqinfo.Info, typeof(GasCardWithCommInfo)) as GasCardWithCommInfo; if (mod == null) { return(ServerHlper.MakeInfoByStatus(false, ConstDefineWs.HttpParamError)); } bool bResult = CardWithCommDevBll.AddDev(ref mod, out strError); if (!bResult) { return(ServerHlper.MakeInfoByStatus(false, ConstDefineWs.LoginNameOrPassword)); } // 成功返回成功标志及新增加的ID JsonResutlModelString result = new JsonResutlModelString() { ErrorDesc = "success", Info = mod.Id.ToString(), Status = true, StatusInt = 1 }; return(JsonStrObjConver.Obj2JsonStr(result, typeof(JsonResutlModelString))); }
private void InsertNewCard(DataTable dwCard) { foreach (DataRow row in dwCard.Rows) { string strId = row["Index"].ToString(); string strName = row["CardName"].ToString(); string strPass = row["CardPassword"].ToString(); string strSn = row["CardSn"].ToString(); string strMod = row["CardModel"].ToString(); string strIsDoub = row["IsDouble"].ToString(); string strPointCount = row["PointCount"].ToString(); string strRefProject = row["RefProject"].ToString(); string strScreenCount = row["ScreenCount"].ToString(); if (CardWithCommDevBll.IsNameExist(strName)) { continue; } if (CardWithCommDevBll.IsSnExise(strSn)) { continue; } int iPointIdx = 0; int iScreenCount = 0; int.TryParse(strPointCount, out iPointIdx); int.TryParse(strScreenCount, out iScreenCount); //MemCfgInfo.MemProjectInfo prj = GlareSysDataCenter.MemCfgInfo.MemDbMgr.Get().GetMemProjectByName(strRefProject); //if (prj == null) //{ continue; } int iProjectID = DataLoader.GetProjectIDByProjectName(strRefProject); if (!string.IsNullOrWhiteSpace(iProjectID.ToString())) { int iGroupID = DataLoader.GetGroupIDByProjectID(iProjectID); int iOrgID = DataLoader.GetOrgIDByProjectID(iProjectID); GlareSysEfDbAndModels.GasCardWithCommInfo card = new GlareSysEfDbAndModels.GasCardWithCommInfo() { Address = "", BEnable = 1, CardBrightness = 9, CardContext = "", CardIsDouble = strIsDoub == "1" ? 1 : 0, CardModel = strMod, CardNumberCount = GetDigNumByModel(strMod), CardPointCount = iPointIdx, CardScreenCount = iScreenCount, CityId = "", Comment = "", CommServerSn = strSn, CommExtConnInfo = "", CommSerialBaud = 0, CommSerialDataBit = 0, CommSerialParity = 0, CommSerialPort = "", CommSerialStopBit = 0, CommServerIp = "", CommServerPort = 0, CommTimeoutMs = 2000, CommType = 0, CreateDt = DateTime.Now, DefName = strName, DefPassword = strPass, GroupId = iGroupID, Id = 0, IsDel = 0, OrgId = iOrgID, Password = strPass, PosLatitude = "", PosLongitude = "", ProjectId = iProjectID, ProtocolType = 1, ScreenNams = "1#-2#-3#-4#-5#-6#", Name = strName, UpdateDt = DateTime.Now }; string strError; CardWithCommDevBll.AddDev(ref card, out strError); } } }
private void buttonOk_Click(object sender, EventArgs e) { string strScrName = textBoxScreenName1.Text + "-" + textBoxScreenName2.Text + "-" + textBoxScreenName3.Text + "-" + textBoxScreenName4.Text + "-" + textBoxScreenName5.Text + "-" + textBoxScreenName6.Text + "-" + textBoxScreenName7.Text + "-" + textBoxScreenName8.Text + "-" + textBoxScreenName9.Text + "-" + textBoxScreenName10.Text + "-" + textBoxScreenName11.Text + "-" + textBoxScreenName12.Text; GasCardWithCommInfo mod = new GasCardWithCommInfo() { Id = 0, Name = textBoxName.Text, Address = "1", CardModel = comboBoxCardModeType.SelectedText, CardIsDouble = 1, CardBrightness = 1, CardPointCount = comboBoxPointIndex.SelectedIndex, CardNumberCount = comboBoxNumCount.SelectedIndex + 1, CardScreenCount = comboBoxScreenCount.SelectedIndex + 1, ProjectId = (int)comboBoxProject.SelectedValue, GroupId = (int)comboBoxGroup.SelectedValue, OrgId = (int)comboBoxOrg.SelectedValue, CardContext = "888888-888888-888888-888888-888888-888888-888888-888888-888888-888888-888888-888888", ScreenNams = strScrName, CreateDt = DateTime.Now, UpdateDt = DateTime.Now, BEnable = 1, CityId = "0", Comment = "", CommExtConnInfo = "", CommSerialBaud = 0, CommSerialDataBit = 0, CommSerialParity = 0, CommSerialPort = "0", CommSerialStopBit = 0, CommServerIp = "", CommServerPort = 0, CommServerSn = textBoxConnSn.Text, CommTimeoutMs = 2000, CommType = 1, DefName = textBoxName.Text, DefPassword = textBoxPassword.Text, IsDel = 0, Password = textBoxPassword.Text, PosLatitude = "0", PosLongitude = "0", ProtocolType = 0, }; string strMsg; if (!CardWithCommDevBll.AddDev(ref mod, out strMsg)) { MessageBox.Show(strMsg); DialogResult = DialogResult.None; } }