public void UpdateCompanyReference(string companyName, string xeroReference)
        {
            companyName   = companyName.Trim();
            xeroReference = xeroReference.Trim();
            String        strConnectionString = ConfigurationManager.ConnectionStrings["ConnStringDeltoneCRM"].ConnectionString;
            ContactDAL    cdal        = new ContactDAL(strConnectionString);
            var           comId       = 0;
            DeltoneCRMDAL dal         = new DeltoneCRMDAL();
            var           comIdByName = dal.GetCompanyIdByCompanyName(companyName);

            if (!string.IsNullOrEmpty(comIdByName))
            {
                comId = Convert.ToInt32(comIdByName);
                if (comId > 0)
                {
                    cdal.UpdateWithXeroDetails(comId, xeroReference);
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            contactdal = new ContactDAL(CONNSTRING);
            xero       = new XeroIntergration();

            int    CompID          = Int32.Parse(Request.Form["CompID"].ToString());
            String FirstName       = Request.Form["NewFirstName"].ToString();
            String LastName        = Request.Form["NewLastName"].ToString();
            String DefaultAreaCode = Request.Form["NewDefaultAreaCode"].ToString();
            String DefaultNumber   = Request.Form["NewDefaultNumber"].ToString();
            String MobileNumber    = Request.Form["NewMobileNumber"].ToString();
            String EmailAddy       = Request.Form["NewEmailAddy"].ToString();
            String ShipLine1       = Request.Form["NewShipLine1"].ToString();
            String ShipLine2       = Request.Form["NewShipLine2"].ToString();
            String ShipCity        = Request.Form["NewShipCity"].ToString();
            String ShipState       = Request.Form["NewShipState"].ToString();
            String ShipPostcode    = Request.Form["NewShipPostcode"].ToString();
            String BillLine1       = Request.Form["NewBillLine1"].ToString();
            String BillLine2       = Request.Form["NewBillLine2"].ToString();
            String BillCity        = Request.Form["NewBillCity"].ToString();
            String BillState       = Request.Form["NewBillState"].ToString();
            String BillPostcode    = Request.Form["NewBillPostcode"].ToString();
            String PrimaryContact  = Request.Form["PrimaryContact"].ToString();


            String finalPrimaryContact = "";

            if (PrimaryContact == "true")
            {
                finalPrimaryContact = "Y";
            }
            else
            {
                finalPrimaryContact = "N";
            }

            DeltoneCRMDAL dal = new DeltoneCRMDAL();
            // Response.Write(dal.AddNewContact(CompID, FirstName, LastName, DefaultAreaCode, DefaultNumber, MobileNumber, EmailAddy, ShipLine1, ShipLine2, ShipCity, ShipState, ShipPostcode, BillLine1, BillLine2, BillCity, BillState, BillPostcode, finalPrimaryContact));
            var    loggedInUserId = Convert.ToInt32(Session["LoggedUserID"].ToString());
            String str            = dal.AddNewContact(CompID, FirstName, LastName, DefaultAreaCode, DefaultNumber, MobileNumber, EmailAddy, ShipLine1, ShipLine2,
                                                      ShipCity, ShipState, ShipPostcode, BillLine1, BillLine2, BillCity, BillState, BillPostcode, finalPrimaryContact, loggedInUserId);

            if (!String.IsNullOrEmpty(str))
            {
                String[] arr            = str.Split(':');
                String   contactID      = arr[1].ToString();
                String   companyname    = arr[2].ToString();
                String   companywebsite = arr[3].ToString();

                String strDefaultCountryCode = "+61";       //Should have entries in AddContactUI
                String strDefaultCountry     = "Australia"; //Should have entries in AddContactUI

                //Create the Repository

                Repository            res        = xero.CreateRepository();
                XeroApi.Model.Contact delContact = xero.CreateContact(res, companyname, FirstName, LastName, DefaultAreaCode, strDefaultCountryCode, DefaultNumber, String.Empty, String.Empty, String.Empty, String.Empty, strDefaultCountryCode, MobileNumber, EmailAddy, ShipLine1, ShipCity, strDefaultCountry, ShipPostcode, ShipState, BillLine1, BillCity, strDefaultCountry, BillPostcode, BillState);
                if (delContact != null)
                {
                    //Update the ContactGuid in the DataBase Table
                    contactdal.UpdateWithXeroDetails(CompID, delContact.ContactID.ToString());
                }
                else
                {
                }

                Response.Write(str);
            }
        }