Esempio n. 1
0
    protected void fvCommunication_PhoneNumber_ItemInserting(object sender, FormViewInsertEventArgs e)
    {
        int?i     = null;
        int iCode = 0;

        TextBox tbAreaCode    = fvCommunication_PhoneNumber.FindControl("tbAreaCode") as TextBox;
        TextBox tbPhoneNumber = fvCommunication_PhoneNumber.FindControl("tbPhoneNumber") as TextBox;

        StringBuilder sb = new StringBuilder();

        using (WACDataClassesDataContext wDataContext = new WACDataClassesDataContext())
        {
            try
            {
                string sAreaCode = null;
                if (!string.IsNullOrEmpty(tbAreaCode.Text))
                {
                    sAreaCode = WACGlobal_Methods.Format_Global_PhoneNumber_StripToNumbers(tbAreaCode.Text, WACGlobal_Methods.Enum_Number_Type.AREACODE);
                }
                else
                {
                    sb.Append("Area Code is required. ");
                }
                if (string.IsNullOrEmpty(sAreaCode))
                {
                    sb.Append("Area Code not in correct format. ");
                }

                string sPhoneNumber = null;
                if (!string.IsNullOrEmpty(tbPhoneNumber.Text))
                {
                    sPhoneNumber = WACGlobal_Methods.Format_Global_PhoneNumber_StripToNumbers(tbPhoneNumber.Text, WACGlobal_Methods.Enum_Number_Type.PHONENUMBER);
                }
                else
                {
                    sb.Append("Phone Number is required. ");
                }
                if (string.IsNullOrEmpty(sPhoneNumber))
                {
                    sb.Append("Phone Number not in correct format. ");
                }

                if (string.IsNullOrEmpty(sb.ToString()))
                {
                    iCode = wDataContext.communication_add(sAreaCode, sPhoneNumber, Session["userName"].ToString(), ref i);
                    if (iCode == 0)
                    {
                        fvCommunication_PhoneNumber.ChangeMode(FormViewMode.ReadOnly);
                        BindCommunication_PhoneNumber(Convert.ToInt32(i));
                    }
                    else
                    {
                        WACAlert.Show("Error Returned from Database.", iCode);
                    }
                }
                else
                {
                    WACAlert.Show(sb.ToString(), 0);
                }
            }
            catch (Exception ex) { WACAlert.Show("Error: " + ex.Message, 0); }
        }
    }
Esempio n. 2
0
    private void Insert_Communications()
    {
        lblGlobal_Insert_Communications.ForeColor = System.Drawing.Color.ForestGreen;
        StringBuilder sb = new StringBuilder();

        try
        {
            using (WACDataClassesDataContext wac = new WACDataClassesDataContext())
            {
                string sAreaCode = null;
                if (!string.IsNullOrEmpty(tbCommunications_AreaCode.Text))
                {
                    sAreaCode = WACGlobal_Methods.Format_Global_PhoneNumber_StripToNumbers(tbCommunications_AreaCode.Text, WACGlobal_Methods.Enum_Number_Type.AREACODE);
                }
                else
                {
                    sb.Append("Area Code is required. ");
                }
                if (string.IsNullOrEmpty(sAreaCode))
                {
                    sb.Append("Area Code not in correct format. ");
                }

                string sPhoneNumber = null;
                if (!string.IsNullOrEmpty(tbCommunications_PhoneNumber.Text))
                {
                    sPhoneNumber = WACGlobal_Methods.Format_Global_PhoneNumber_StripToNumbers(tbCommunications_PhoneNumber.Text, WACGlobal_Methods.Enum_Number_Type.PHONENUMBER);
                }
                else
                {
                    sb.Append("Phone Number is required. ");
                }
                if (string.IsNullOrEmpty(sPhoneNumber))
                {
                    sb.Append("Phone Number not in correct format. ");
                }

                if (string.IsNullOrEmpty(sb.ToString()))
                {
                    int?i     = null;
                    int iCode = wac.communication_add(sAreaCode, sPhoneNumber, Session["userName"].ToString(), ref i);
                    if (iCode == 0)
                    {
                        tbCommunications_AreaCode.Text       = "";
                        tbCommunications_PhoneNumber.Text    = "";
                        lblGlobal_Insert_Communications.Text = "Successfully added Communication: " + WACGlobal_Methods.Format_Global_PhoneNumberSeparateAreaCode(sAreaCode, sPhoneNumber);
                    }
                    else
                    {
                        WACAlert.Show("Error Inserting Communication: ", iCode);
                    }
                }
                else
                {
                    WACAlert.Show(sb.ToString(), 0);
                }
            }
        }
        catch (Exception ex)
        {
            lblGlobal_Insert_Communications.ForeColor = System.Drawing.Color.Red;
            lblGlobal_Insert_Communications.Text      = "Error Inserting Communication: " + ex.Message;
        }
    }
Esempio n. 3
0
    protected void fvParticipant_Communication_ItemUpdating(object sender, FormViewUpdateEventArgs e)
    {
        DropDownList ddlType       = fvParticipant_Communication.FindControl("ddlType") as DropDownList;
        DropDownList ddlUsage      = fvParticipant_Communication.FindControl("ddlUsage") as DropDownList;
        TextBox      tbAreaCode    = fvParticipant_Communication.FindControl("tbAreaCode") as TextBox;
        TextBox      tbPhoneNumber = fvParticipant_Communication.FindControl("tbPhoneNumber") as TextBox;
        //DropDownList ddlPhone = fvParticipant_Communication.FindControl("UC_Communication_EditInsert_Phone").FindControl("ddlNumber") as DropDownList;
        TextBox tbExtension = fvParticipant_Communication.FindControl("tbExtension") as TextBox;
        TextBox tbNote      = fvParticipant_Communication.FindControl("tbNote") as TextBox;

        StringBuilder sb = new StringBuilder();

        using (WACDataClassesDataContext wDataContext = new WACDataClassesDataContext())
        {
            try
            {
                int?i     = null;
                int iCode = 0;
                iCode = wDataContext.communication_add(tbAreaCode.Text, tbPhoneNumber.Text, Session["userName"].ToString(), ref i);
                if (iCode != 0)
                {
                    i = null;
                }

                var a = wDataContext.participantCommunications.Where(w => w.pk_participantCommunication == Convert.ToInt32(fvParticipant_Communication.DataKey.Value)).Select(s => s).Single();

                if (!string.IsNullOrEmpty(ddlType.SelectedValue))
                {
                    a.fk_communicationType_code = ddlType.SelectedValue;
                }
                else
                {
                    sb.Append("Type was not updated. Type is required. ");
                }

                if (!string.IsNullOrEmpty(ddlUsage.SelectedValue))
                {
                    a.fk_communicationUsage_code = ddlUsage.SelectedValue;
                }
                else
                {
                    sb.Append("Usage was not updated. Usage is required. ");
                }

                if (i != null)
                {
                    a.fk_communication = Convert.ToInt32(i);
                }
                else
                {
                    sb.Append("Phone Number was not updated. Bad Phone Number. ");
                }

                //if (!string.IsNullOrEmpty(ddlPhone.SelectedValue)) a.fk_communication = Convert.ToInt32(ddlPhone.SelectedValue);
                //else sb.Append("Phone Number was not updated. Phone Number is required. ");

                a.extension = WACGlobal_Methods.Format_Global_StringLengthRestriction(tbExtension.Text, 8).Trim();

                a.note = WACGlobal_Methods.Format_Global_StringLengthRestriction(tbNote.Text, 48).Trim();

                a.modified    = DateTime.Now;
                a.modified_by = Session["userName"].ToString();

                wDataContext.SubmitChanges();
                fvParticipant_Communication.ChangeMode(FormViewMode.ReadOnly);
                Participant_Communication_BindRecord(Convert.ToInt32(fvParticipant_Communication.DataKey.Value));

                if (!string.IsNullOrEmpty(sb.ToString()))
                {
                    WACAlert.Show(sb.ToString(), 0);
                }
            }
            catch (Exception ex) { WACAlert.Show(ex.Message, 0); }
        }
    }