示例#1
0
        private void SaveNoteForCustomer(string comment, int employeeId, int customerId, string nextCallDueText,
                                         ActivityType activityType, NoteType noteType)
        {
            if (!string.IsNullOrEmpty(comment))
            {
                //comment = comment.Replace("\n", ";"); //dbb
                comment = comment.Replace("\n", " ");
            }

            if (PermanentNoteCheckBox.Checked)
            {
                var permanentNote = new PermanentCustomerNote(comment, customerId, employeeId);
                presenter.SavePermanentNote(permanentNote);
            }
            else
            {
                if (!string.IsNullOrEmpty(nextCallDueText))
                {
                    var nextCallDueDate = new Date(DateTime.Parse(nextCallDueText));
                    UpdateNextCallDueDate(nextCallDueDate, customerId, new Calendar().Now, employeeId);
                }

                SaveCustomerNote(employeeId, comment, customerId, activityType, noteType);
            }
        }
示例#2
0
        protected void SaveButton_Click(object sender, ImageClickEventArgs e)
        {
            int          employeeId = CurrentPrincipal.CffUser.EmployeeId;
            ICffCustomer xCustomer  = (SessionWrapper.Instance.Get != null) ? SessionWrapper.Instance.Get.CustomerFromQueryString :
                                      (!string.IsNullOrWhiteSpace(QueryString.ViewIDValue)) ? SessionWrapper.Instance.GetSession(QueryString.ViewIDValue).CustomerFromQueryString : null;

            if (PermanentNoteCheckBox.Checked)
            {
                var permanentNote = new PermanentCustomerNote(CommentTextBox.EncodedText, ((xCustomer == null)?0:xCustomer.Id), employeeId);
                presenter.SavePermanentNote(permanentNote);
            }
            else
            {
                if (!string.IsNullOrEmpty(NextCallDueTextBox.EncodedText))
                {
                    var calendar        = new Calendar();
                    var nextCallDueDate = new Date(DateTime.Parse(NextCallDueTextBox.EncodedText));

                    presenter.UpdateCustomerNextCallDue(nextCallDueDate, ((xCustomer == null) ? 0 : xCustomer.Id), calendar.Now, employeeId);

                    if (NextCallDueUpdated != null)
                    {
                        NextCallDueUpdated(nextCallDueDate, new EventArgs());
                    }
                }
                ActivityType activityType = ActivityType.Parse(int.Parse(ActivityTypeDropDownList.SelectedValue));
                NoteType     noteType     = NoteType.Parse(int.Parse(NoteTypeDropDownList.SelectedValue));

                var customerNote = new CustomerNote(activityType, noteType, CommentTextBox.EncodedText, ((xCustomer == null) ? 0 : xCustomer.Id), employeeId);
                presenter.SaveCustomerNote(customerNote);
            }
        }
        public IList <PermanentCustomerNote> LoadPermanentCustomerNote(int customerId)
        {
            IList <PermanentCustomerNote> permanentNotes = new List <PermanentCustomerNote>();

            using (SqlConnection connection = CreateConnection())
            {
                using (SqlDataReader dataReader = SqlHelper.ExecuteReader(connection,
                                                                          CommandType.StoredProcedure,
                                                                          "NotesPermanent_LoadByCustomerID",
                                                                          CreateCustomerIdParameter(customerId)))
                {
                    CleverReader cleverReader = new CleverReader(dataReader);
                    while (cleverReader.Read())
                    {
                        string parsedNotes = CustomerNotesParser.Parse(cleverReader.ToString("notes"));

                        PermanentCustomerNote permanentCustomerNote =
                            new PermanentCustomerNote(cleverReader.FromBigInteger("NotesID"),
                                                      cleverReader.ToDate("Created"),
                                                      parsedNotes,
                                                      cleverReader.ToInteger("CreatedBy"),
                                                      cleverReader.ToString("EmployeeName"),
                                                      cleverReader.ToInteger("ModifiedBy"),
                                                      cleverReader.ToString("ModifiedByEmployeeName"),
                                                      cleverReader.ToDate("Modified"));
                        permanentNotes.Add(permanentCustomerNote);
                    }
                }
            }

            return(permanentNotes);
        }
示例#4
0
        public void UpdatePermanentNote(long noteId, string comment, int modifiedBy)
        {
            ArgumentChecker.ThrowIfNullOrEmpty(comment, "comment");

            PermanentCustomerNote permanentCustomerNote = new PermanentCustomerNote(noteId, comment, modifiedBy);

            repository.UpdatePermanentCustomerNote(permanentCustomerNote);
            view.DisplayFeedback();
        }
示例#5
0
        public void Show(PermanentCustomerNote selectedPermanentCustomerNote)
        {
            CommentEditTextBox.Text = EncodedText(CustomerNotesParser.RemoveBr(selectedPermanentCustomerNote.Comment));
            CommentEditTextBox.Focus();
            ViewState.Add(SelectedNote, selectedPermanentCustomerNote);
            CustomerNoteDescriptors.Visible = false;
            Visible = true;

            BlockScreen();
        }
示例#6
0
        private void UpdatePermanentNote(object orginalNote, int modifiedBy, string newComment)
        { //clean up the &amp before saving to DB
            newComment = newComment.Replace("&amp;", "&");
            PermanentCustomerNote originalPermanentCustomerNote = orginalNote as PermanentCustomerNote;

            if (originalPermanentCustomerNote != null)
            {
                presenter.UpdatePermanentNote(originalPermanentCustomerNote.NoteId, newComment, modifiedBy);
            }
        }
 public void InsertPermanentNote(PermanentCustomerNote permanentCustomerNote)
 {
     ArgumentChecker.ThrowIfNull(permanentCustomerNote, "permanentNote");
     using (SqlConnection connection = CreateConnection())
     {
         SqlHelper.ExecuteNonQuery(connection,
                                   CommandType.StoredProcedure,
                                   "NotePermanent_Save", CreateSavePermanentNoteParameters(permanentCustomerNote));
     }
 }
        private static SqlParameter[] CreateSavePermanentNoteParameters(PermanentCustomerNote permanentCustomerNote)
        {
            SqlParameter customerIdParameter = new SqlParameter("@CustomerID", SqlDbType.Int);
            SqlParameter createdByParameter  = new SqlParameter("@CreatedBy", SqlDbType.Int);
            SqlParameter noteParamter        = new SqlParameter("@Note", SqlDbType.Text);

            customerIdParameter.Value = permanentCustomerNote.CustomerId;
            createdByParameter.Value  = permanentCustomerNote.AuthorId;
            noteParamter.Value        = permanentCustomerNote.Comment;

            return(new[] { customerIdParameter, createdByParameter, noteParamter });
        }
示例#9
0
 public bool UpdatePermanentCustNote(PermanentCustomerNote permanentCustNote, ref string errMsg)
 {
     try
     {
         repository.UpdatePermanentCustomerNote(permanentCustNote);
         return(true);
     }
     catch (System.Exception exc)
     {
         errMsg = exc.Message;
         return(false);
     }
 }
        private static SqlParameter[] CreateUpdatePermanentNoteParameters(PermanentCustomerNote permanentCustomerNote)
        {
            SqlParameter noteIdParameter     = new SqlParameter("@NoteId", SqlDbType.BigInt);
            SqlParameter modifiedByParameter = new SqlParameter("@ModifiedBy", SqlDbType.Int);
            SqlParameter commentParameter    = new SqlParameter("@Comment", SqlDbType.Text);

            noteIdParameter.Value     = permanentCustomerNote.NoteId;
            modifiedByParameter.Value = permanentCustomerNote.ModifiedBy;
            commentParameter.Value    = permanentCustomerNote.Comment;

            return(new[]
            {
                noteIdParameter,
                commentParameter,
                modifiedByParameter
            });
        }
        public IList <PermanentCustomerNote> LoadPermanentCustomerNoteOnRange(int customerId, DateRange dateRange)
        {
            SqlParameter customerIdParameter = new SqlParameter("@CustomerId", SqlDbType.BigInt);

            customerIdParameter.Value = customerId;

            SqlParameter dateFromParameter = new SqlParameter("@DateFrom", SqlDbType.DateTime);

            dateFromParameter.Value = Convert.ToDateTime(dateRange.StartDate.ToShortDateString());

            SqlParameter dateToParameter = new SqlParameter("@DateTo", SqlDbType.DateTime);

            dateToParameter.Value = Convert.ToDateTime(dateRange.EndDate.ToShortDateString());

            SqlParameter[] paramObjects = new SqlParameter[] { customerIdParameter, dateFromParameter, dateToParameter };

            IList <PermanentCustomerNote> permanentNotes = new List <PermanentCustomerNote>();

            using (SqlConnection connection = CreateConnection())
            {
                using (SqlDataReader dataReader = SqlHelper.ExecuteReader(connection,
                                                                          CommandType.StoredProcedure,
                                                                          "NotesPermanent_LoadCustomerInRange",
                                                                          paramObjects
                                                                          ))
                {
                    CleverReader cleverReader = new CleverReader(dataReader);
                    while (cleverReader.Read())
                    {
                        string parsedNotes = CustomerNotesParser.Parse(cleverReader.ToString("notes"));

                        PermanentCustomerNote permanentCustomerNote =
                            new PermanentCustomerNote(cleverReader.FromBigInteger("NotesID"),
                                                      cleverReader.ToDate("Created"),
                                                      parsedNotes,
                                                      cleverReader.ToInteger("CreatedBy"),
                                                      cleverReader.ToString("EmployeeName"),
                                                      cleverReader.ToInteger("ModifiedBy"),
                                                      cleverReader.ToString("ModifiedByEmployeeName"),
                                                      cleverReader.ToDate("Modified"));
                        permanentNotes.Add(permanentCustomerNote);
                    }
                }
            }
            return(permanentNotes);
        }
 public void SavePermanentNote(PermanentCustomerNote permanentCustomerNote)
 {
     ArgumentChecker.ThrowIfNull(permanentCustomerNote, "permanentNote");
     notesRepository.InsertPermanentNote(permanentCustomerNote);
     view.DisplayFeedback();
 }