/// <summary> /// 获得数据列表 /// </summary> public List <LPWeb.Model.ContactNotes> DataTableToList(DataTable dt) { List <LPWeb.Model.ContactNotes> modelList = new List <LPWeb.Model.ContactNotes>(); int rowsCount = dt.Rows.Count; if (rowsCount > 0) { LPWeb.Model.ContactNotes model; for (int n = 0; n < rowsCount; n++) { model = new LPWeb.Model.ContactNotes(); if (dt.Rows[n]["ContactNoteId"].ToString() != "") { model.ContactNoteId = int.Parse(dt.Rows[n]["ContactNoteId"].ToString()); } if (dt.Rows[n]["ContactId"].ToString() != "") { model.ContactId = int.Parse(dt.Rows[n]["ContactId"].ToString()); } if (dt.Rows[n]["Created"].ToString() != "") { model.Created = DateTime.Parse(dt.Rows[n]["Created"].ToString()); } if (dt.Rows[n]["CreatedBy"].ToString() != "") { model.CreatedBy = int.Parse(dt.Rows[n]["CreatedBy"].ToString()); } model.Note = dt.Rows[n]["Note"].ToString(); modelList.Add(model); } } return(modelList); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(LPWeb.Model.ContactNotes model) { return(dal.Add(model)); }
/// <summary> /// 更新一条数据 /// </summary> public void Update(LPWeb.Model.ContactNotes model) { dal.Update(model); }
protected void btnSave_Click(object sender, EventArgs e) { string err = ""; try { if (tbxNote.Text.Trim() == "") { PageCommon.AlertMsg(this, "Please input the note!"); return; } //if (tbxNote.Text.Trim().Length > 500) //{ // PageCommon.AlertMsg(this, "The note length must be less than 500 characters!"); // return; //} int contactId = int.Parse(hfdContactId.Value); var curUser = new LoginUser(); string senderName = curUser.sFirstName + " " + curUser.sLastName; var req = new AddNoteRequest { FileId = contactId, Created = DateTime.Now, Note = tbxNote.Text.Trim(), Sender = senderName, hdr = new ReqHdr { UserId = curUser.iUserID } }; ServiceManager sm = new ServiceManager(); using (LP2ServiceClient client = sm.StartServiceClient()) { //AddNoteResponse res = client.AddNote(req); //bool exported = !res.hdr.Successful ? false : true; bool exported = true; LPWeb.Model.ContactNotes model = new LPWeb.Model.ContactNotes { Note = tbxNote.Text, ContactId = contactId, Created = DateTime.Now, CreatedBy = curUser.iUserID }; ContactNotes bllContactNotes = new ContactNotes(); bllContactNotes.Add(model); //if (!exported) //{ // PageCommon.WriteJs(this, res.hdr.StatusInfo, "parent.ClosePopupWindow();"); //} //else //{ PageCommon.WriteJs(this, "Added note successfully.", "parent.ClosePopupWindow();"); //PageCommon.WriteJsEnd(this, "Add note Failed.", PageCommon.Js_RefreshSelf); //} } } catch (System.ServiceModel.EndpointNotFoundException ee) { LPLog.LogMessage(ee.Message); PageCommon.AlertMsg(this, "Failed to add note, reason: Point Manager is not running."); } catch (Exception exception) { err = "Failed to add note, reason:" + exception.Message; LPLog.LogMessage(err); PageCommon.WriteJsEnd(this, err, PageCommon.Js_RefreshSelf); } }