public static bool UpdateDev(GasCardWithCommInfo model, out string strError) { strError = ""; try { using (GLedDbEntities ent = new GLedDbEntities()) { var oldinfo = (from c in ent.GasCardWithCommInfo where c.Id == model.Id select c).FirstOrDefault(); if (oldinfo == null) { strError = ConstDefineBll.InfoCanNotFind; return(false); } oldinfo.Id = model.Id; oldinfo.DefName = model.DefName; oldinfo.DefPassword = model.DefPassword; oldinfo.Name = model.Name; oldinfo.Password = model.Password; oldinfo.CityId = model.CityId; oldinfo.Address = model.Address; oldinfo.PosLongitude = model.PosLongitude; oldinfo.PosLatitude = model.PosLatitude; oldinfo.ProjectId = model.ProjectId; oldinfo.GroupId = model.GroupId; oldinfo.OrgId = model.OrgId; oldinfo.CommType = model.CommType; oldinfo.ProtocolType = model.ProtocolType; oldinfo.CommServerIp = model.CommServerIp; oldinfo.CommServerPort = model.CommServerPort; oldinfo.CommServerSn = model.CommServerSn; oldinfo.CommSerialPort = model.CommSerialPort; oldinfo.CommSerialBaud = model.CommSerialBaud; oldinfo.CommSerialDataBit = model.CommSerialDataBit; oldinfo.CommSerialStopBit = model.CommSerialStopBit; oldinfo.CommSerialParity = model.CommSerialParity; oldinfo.CommTimeoutMs = model.CommTimeoutMs; oldinfo.CommExtConnInfo = model.CommExtConnInfo; oldinfo.BEnable = model.BEnable; oldinfo.CardBrightness = model.CardBrightness; oldinfo.CardContext = model.CardContext; oldinfo.CardIsDouble = model.CardIsDouble; oldinfo.CardModel = model.CardModel; oldinfo.CardNumberCount = model.CardNumberCount; oldinfo.CardPointCount = model.CardPointCount; oldinfo.CardScreenCount = model.CardScreenCount; oldinfo.IsDel = model.IsDel; oldinfo.Comment = model.Comment; oldinfo.UpdateDt = DateTime.Now; ent.SaveChanges(); } return(true); } catch (System.Exception ex) { strError = ex.Message; return(false); } }
public static bool AddDev(ref GasCardWithCommInfo model, out string strError) { strError = ""; try { using (GLedDbEntities ent = new GLedDbEntities()) { GasCardWithCommInfo newinfo = new GasCardWithCommInfo() { Id = model.Id, DefName = model.DefName, DefPassword = model.DefPassword, Name = model.Name, Password = model.Password, CityId = model.CityId, Address = model.Address, PosLongitude = model.PosLongitude, PosLatitude = model.PosLatitude, ProjectId = model.ProjectId, GroupId = model.GroupId, OrgId = model.OrgId, CommType = model.CommType, ProtocolType = model.ProtocolType, CommServerIp = model.CommServerIp, CommServerPort = model.CommServerPort, CommServerSn = model.CommServerSn, CommSerialPort = model.CommSerialPort, CommSerialBaud = model.CommSerialBaud, CommSerialDataBit = model.CommSerialDataBit, CommSerialStopBit = model.CommSerialStopBit, CommSerialParity = model.CommSerialParity, CommTimeoutMs = model.CommTimeoutMs, CommExtConnInfo = model.CommExtConnInfo, BEnable = model.BEnable, CardBrightness = model.CardBrightness, CardContext = model.CardContext, CardIsDouble = model.CardIsDouble, CardModel = model.CardModel, CardNumberCount = model.CardNumberCount, CardPointCount = model.CardPointCount, CardScreenCount = model.CardScreenCount, IsDel = 0, ScreenNams = model.ScreenNams, Comment = model.Comment, UpdateDt = DateTime.Now, CreateDt = DateTime.Now }; ent.GasCardWithCommInfo.Add(newinfo); ent.SaveChanges(); model.Id = newinfo.Id; return(true); } } catch (System.Exception ex) { strError = ex.Message; return(false); } }
/// <summary> /// Save配置 /// </summary> /// <param name="id"></param> /// <param name="IsDouble"></param> /// <param name="ScreenCount"></param> /// <param name="CardModel"></param> /// <param name="CardPointCount"></param> public void SaveDev(int id, int IsDouble, int ScreenCount, string CardModel, int CardPointCount) { using (LedDb db = new LedDb()) { GasCardWithCommInfo aDev = db.GasCardWithCommInfo.Where(p => p.Id == id && p.IsDel != 1).FirstOrDefault(); if (aDev != null) { aDev.CardIsDouble = IsDouble; aDev.CardScreenCount = ScreenCount; aDev.CardModel = CardModel; aDev.CardPointCount = CardPointCount; db.SaveChanges(); } } }
public ActionResult GetGasCardInfo(int id) { object objResult = null; if (!string.IsNullOrWhiteSpace(id.ToString())) { using (LedDb db = new LedDb()) { GasCardWithCommInfo aGasCardInfo = db.GasCardWithCommInfo.Where(p => p.Id == id && p.IsDel != 1).FirstOrDefault(); if (aGasCardInfo != null) { objResult = new ResultHelper() { Desc = " Station Information Get Success", Msg = " Station Information Get Success", Obj = aGasCardInfo, Ret = 1, Status = true }; } else { objResult = new ResultHelper() { Status = false, Ret = -1, Obj = null, Msg = "No such record exists", Desc = "No such record exists" }; } } } else { objResult = new ResultHelper() { Status = false, Ret = -1, Obj = null, Msg = "id is null,Please try again later", Desc = "id is null,Please try again later" }; } return(Json(objResult)); }
public string UpdateADev(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.UpdateDev(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 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; } }
private void button19_Click(object sender, EventArgs e) { GasCardWithCommInfo mod = new GasCardWithCommInfo() { Id = 0, Name = "CardName", Address = "", BEnable = 1, CardBrightness = 1, CardIsDouble = 1, CardNumberCount = 1, CardPointCount = 1, CardScreenCount = 6, CityId = "", Comment = "", CommExtConnInfo = "", CommSerialBaud = 0, CommSerialDataBit = 0, CommSerialParity = 0, CommSerialPort = "", CommSerialStopBit = 0, CommServerIp = "", CommServerPort = 0, CommServerSn = "sn00006", CommTimeoutMs = 2000, CommType = 1, DefName = "defname003", DefPassword = "******", IsDel = 0, Password = "******", PosLatitude = "", PosLongitude = "", ProtocolType = 0, CardModel = "GL-88888-910", ProjectId = 1, GroupId = 1, OrgId = 1, CardContext = "1111-1111-111-111-11-11-11-11-11-11-11-11-11", ScreenNams = "94#-dic95-00-00-00-00-00-00-00-00-00", CreateDt = DateTime.Now, UpdateDt = DateTime.Now, }; RequestModelString obj = new RequestModelString() { Info = JsonStrObjConver.Obj2JsonStr(mod, typeof(GasCardWithCommInfo)), reqDt = DateTime.Now, TockId = ConstDefineTestWebapi.TockIdEnableTest }; string strParmaInfo = JsonStrObjConver.Obj2JsonStr(obj, typeof(RequestModelString)); GlareLedServices2.GLSysMgrSoapClient cl = new GlareLedServices2.GLSysMgrSoapClient(); string strResult = cl.AddCard(strParmaInfo); MessageBox.Show(strResult); }
public ActionResult Modify(GasCardWithCommInfo subject) { ResultHelper objResult = null; try { using (LedDb db = new LedDb()) { if (ModelState.IsValid) { GasCardWithCommInfo aSubject = db.GasCardWithCommInfo.Where(p => p.Id == subject.Id).FirstOrDefault(); //aSubject.CardName = subject.CardName; //aSubject.CardModel = subject.CardModel; //aSubject.ScreenCount = subject.ScreenCount; //aSubject.ScreenNams = subject.ScreenNams; aSubject = subject; aSubject.UpdateDt = DateTime.Now; if (db.SaveChanges() > 0) { objResult = new ResultHelper() { Status = true, Ret = 0, Obj = subject, Msg = "Edit Success!", Desc = "Edit Success!" }; } else { objResult = new ResultHelper() { Desc = "Edit Faile,please try again.", Msg = "Edit Faile,please try again.", Obj = null, Ret = -1, Status = false }; } } else { objResult = new ResultHelper() { Desc = " Faile,please try again", Msg = " Faile,please try again", Obj = null, Ret = -1, Status = false }; } } } catch (Exception ex) { objResult = new ResultHelper() { Desc = ex.Message, Msg = ex.Message, Obj = null, Ret = -1, Status = false }; } return(Json(objResult)); }
public ActionResult Add(GasCardWithCommInfo subject) { ResultHelper objResult = null; try { using (LedDb db = new LedDb()) { if (ModelState.IsValid) { subject.UpdateDt = DateTime.Now; subject.CreateDt = DateTime.Now; subject.IsDel = 0; db.GasCardWithCommInfo.Add(subject); if (db.SaveChanges() > 0) { objResult = new ResultHelper() { Status = true, Ret = 0, Obj = subject, Msg = "Add Success!", Desc = "Add Success!" }; } else { objResult = new ResultHelper() { Desc = "Add Faile,please try again.", Msg = "Add Faile,please try again.", Obj = null, Ret = -1, Status = false }; } } else { objResult = new ResultHelper() { Desc = " Faile,please try again", Msg = " Faile,please try again", Obj = null, Ret = -1, Status = false }; } } } catch (Exception ex) { objResult = new ResultHelper() { Desc = ex.Message, Msg = ex.Message, Obj = null, Ret = -1, Status = false }; } return(Json(objResult)); }
/// <summary> /// /// </summary> /// <param name="iProject">如果工程小于等于0,全文查找(插入时已经确保不同工程下名字也不能相同)</param> /// <param name="userName"></param> /// <param name="userPassword"></param> /// <returns></returns> public static CommDevLoginedUserModel CommDevLogin(int iProject, string userName, string userPassword) { using (GLedDbEntities ent = new GLedDbEntities()) { ddCommDevUser userinfo = null; if (iProject <= 0) { GasCardWithCommInfo dev = (from c in ent.GasCardWithCommInfo where c.Name == userName && c.Password == userPassword select c).FirstOrDefault(); if (dev != null) { userinfo = new ddCommDevUser() { CreateDt = DateTime.Now, Id = -1, IsDel = 0, MgrCommDevId = dev.Id, Name = dev.Name, Password = dev.Password, RefGroupId = -1, RefOrgId = -1, RefProjectId = -1, UpdateDt = DateTime.Now }; } } else { GasCardWithCommInfo dev = (from c in ent.GasCardWithCommInfo where c.Name == userName && c.Password == userPassword select c).FirstOrDefault(); if (dev != null) { userinfo = new ddCommDevUser() { CreateDt = DateTime.Now, Id = -1, IsDel = 0, MgrCommDevId = dev.Id, Name = dev.Name, Password = dev.Password, RefGroupId = -1, RefOrgId = -1, RefProjectId = -1, UpdateDt = DateTime.Now }; } } if (userinfo == null) { return(null); } string iTockId = LoginUserEnableMgr.Get().InsertANewLogined(); CommDevLoginedUserModel mod = new CommDevLoginedUserModel() { LoginDt = DateTime.Now, LoginIdByCenter = iTockId, UserInfo = userinfo }; return(mod); } }