Exemple #1
0
        public void TestVendAddressCreate()
        {
            //Test Our Read
            sp_VendAddress_DM data = new sp_VendAddress_DM();
            string AddrLine1 = "Add1";
            string AddrLine2 = "Add2";
            string AddrLine3 = "Add3";
            string City = "City";
            string St = "St";
            int Zip = 11111;
            int Zip4 = 1111;

            data.AddrLine1 = AddrLine1;
            data.AddrLine2 = AddrLine2;
            data.AddrLine3 = AddrLine3;
            data.City = City;
            data.St = St;
            data.Zip = Zip;
            data.Zip4 = Zip4;
            data.ActiveFlg = true;
            sp_VendAddress_BLL vend = new sp_VendAddress_BLL();
            vend.InsertAddressContext(data);
            Assert.AreEqual(AddrLine1, data.AddrLine1, "AddrLine1 Not Set As Expected");
            Assert.AreEqual(AddrLine2, data.AddrLine2, "AddrLine2 Not Set As Expected");
            Assert.AreEqual(AddrLine3, data.AddrLine3, "AddrLine3 Not Set As Expected");
            Assert.AreEqual(City, data.City, "City Not Set As Expected");
            Assert.AreEqual(St, data.St, "St Not Set As Expected");
            Assert.AreEqual(Zip, data.Zip, "Zip Not Set As Expected");
            Assert.AreEqual(Zip4, data.Zip4, "Zip Not Set As Expected");
        }
 public void DeleteAddressContext(sp_VendAddress_DM InputAddress)
 {
     using (VolTeerEntities context = new VolTeerEntities())
     {
         var VendAddressToRemove = (from n in context.tblVendAddresses where n.AddrID == InputAddress.AddrID select n).FirstOrDefault();
         context.tblVendAddresses.Remove(VendAddressToRemove);
         context.SaveChanges();
     }
 }
Exemple #3
0
 public void TestVendAddressDelete()
 {
     DataTable dt = cExcel.ReadExcelFile("Sheet1", Path.Combine(cExcel.GetHelperFilesDir(), "VendAddress.xlsx"));
     foreach (DataRow row in dt.Rows) // Loop over the rows.
     {
         int AddrID = Convert.ToInt32(row["AddrID"].ToString());
         sp_VendAddress_DM data = new sp_VendAddress_DM();
         sp_VendAddress_BLL vend = new sp_VendAddress_BLL();
         data.AddrID = AddrID;
         vend.DeleteAddressContext(data);
         data = vend.ListAddresses(AddrID);
         Assert.AreEqual(false, data.ActiveFlg, "ActiveFlag not set as expected");
     }
 }
        public void UpdateAddressContext(sp_VendAddress_DM InputAddress)
        {
            using (VolTeerEntities context = new VolTeerEntities())
            {
                var existingAddress = context.tblVendAddresses.Find(InputAddress.AddrID);

                if (InputAddress != null)
                {
                    existingAddress.AddrLine1 = InputAddress.AddrLine1;
                    existingAddress.AddrLine2 = InputAddress.AddrLine2;
                    existingAddress.AddrLine3 = InputAddress.AddrLine3;
                    existingAddress.City = InputAddress.City;
                    existingAddress.St = InputAddress.St;
                    existingAddress.Zip = InputAddress.Zip;
                    existingAddress.Zip4 = InputAddress.Zip4;
                    existingAddress.ActiveFlg = InputAddress.ActiveFlg;
                    context.SaveChanges();
                }
            }
        }
 public int InsertAddressContext(sp_VendAddress_DM InputAddress)
 {
     using (VolTeerEntities context = new VolTeerEntities())
     {
         var NewAddress = new tblVendAddress
         {
             AddrLine1 = InputAddress.AddrLine1,
             AddrLine2 = InputAddress.AddrLine2,
             AddrLine3 = InputAddress.AddrLine3,
             City = InputAddress.City,
             St = InputAddress.St,
             Zip = InputAddress.Zip,
             Zip4 = InputAddress.Zip4,
             ActiveFlg = InputAddress.ActiveFlg
         };
         context.tblVendAddresses.Add(NewAddress);
         context.SaveChanges();
         //Return the id of the newly created record
         return NewAddress.AddrID;
     }
 }
        /// <summary>
        /// SetPrimaryValues - Paint the screen with default values (use non-telerik controls)
        /// </summary>
        protected void SetPrimaryValues()
        {
            sp_VendAddress_DM VendDM = new sp_VendAddress_DM();
            sp_Vol_Address_DM VolDM = new sp_Vol_Address_DM();
            StringBuilder sb = new StringBuilder();

            try
            {
                VolDM.VolID = (Guid)currentUser.ProviderUserKey;
                VolDM = VolAddrCash.ListPrimaryAddress(VolDM);

                lblAddr1.Text = VolDM.AddrLine1;
                lblAddr2.Text = VolDM.AddrLine2;
                if (string.IsNullOrEmpty(lblAddr2.Text))
                {
                    rowAddr2.Visible = false;
                }
                else
                {
                    rowAddr2.Visible = true;
                }

                lblAddr3.Text = VolDM.AddrLine3;
                if (string.IsNullOrEmpty(lblAddr3.Text))
                {
                    rowAddr3.Visible = false;
                }
                else
                {
                    rowAddr3.Visible = true;
                }

                sb.Clear();
                sb.Append(VolDM.City.ToString());
                sb.Append(", ");
                sb.Append(VolDM.St.ToString());
                sb.Append("   ");
                sb.Append(VolDM.Zip.ToString());
                if (!string.IsNullOrEmpty(VolDM.Zip4.ToString()))
                {
                    sb.Append('-');
                    sb.Append(VolDM.Zip4.ToString());
                }

                lblCityStZip.Text = sb.ToString();
            }
            catch (Exception ex)
            {
                StackTrace st = new StackTrace();
                StackFrame sf = st.GetFrame(0);
                string errMethod = sf.GetMethod().Name.ToString();  // Get the current method name
                string errMsg = "600";                              // Gotta pass something, we're retro-fitting an existing method
                Session["LastException"] = ex;                      // Throw the exception in the session variable, will be used in error page
                string url = string.Format(ConfigurationManager.AppSettings["ErrorPageURL"], errMethod, errMsg); //Set the URL
                Response.Redirect(url);                             // Go to the error page.
            }
        }
        /// <summary>
        /// rGridAdress_UpdIns - Handle update/insert in a common procedure
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <param name="iAction"></param>
        protected void rGridAdress_UpdIns(object sender, GridCommandEventArgs e, int iAction)
        {
            try
            {
                GridEditableItem eeditedItem = e.Item as GridEditableItem;

                sp_VendAddress_DM VendAddressDM = new sp_VendAddress_DM();
                sp_VendorAddr_DM VendAddrDM = new sp_VendorAddr_DM();

                VendAddrDM.AddrID = (int)currentUser.ProviderUserKey; ;

                VendAddressDM.AddrID = (int)currentUser.ProviderUserKey;
                if (iAction == (int)RecordAction.Update)
                {
                    VendAddressDM.AddrID = Convert.ToInt32(eeditedItem.OwnerTableView.DataKeyValues[eeditedItem.ItemIndex]["AddrID"]);
                    pre_ID = Convert.ToInt32(eeditedItem.OwnerTableView.DataKeyValues[eeditedItem.ItemIndex]["AddrID"]);
                    VendAddrDM.AddrID = Convert.ToInt32(eeditedItem.OwnerTableView.DataKeyValues[eeditedItem.ItemIndex]["AddrID"]);
                }
                VendAddressDM.ActiveFlg = (eeditedItem.FindControl("chkActive") as CheckBox).Checked;
                VendAddressDM.AddrLine1 = (eeditedItem.FindControl("rTBAddr1") as RadTextBox).Text.ToString();
                VendAddressDM.AddrLine2 = (eeditedItem.FindControl("rTBAddr2") as RadTextBox).Text.ToString();
                VendAddressDM.AddrLine3 = (eeditedItem.FindControl("rTBAddr3") as RadTextBox).Text.ToString();
                VendAddressDM.City = (eeditedItem.FindControl("rTBCity") as RadTextBox).Text.ToString();
                VendAddressDM.St = (eeditedItem.FindControl("rDDSt") as RadDropDownList).SelectedValue.ToString();
                VendAddressDM.Zip = Convert.ToInt32((eeditedItem.FindControl("rNTBZip") as RadNumericTextBox).Text);
                string strZip4 = ((eeditedItem.FindControl("rNTBZip4") as RadNumericTextBox).Text).ToString();
                if (strZip4 == string.Empty)
                {
                    VendAddressDM.Zip4 = null;
                }
                else
                {
                    VendAddressDM.Zip4 = Convert.ToInt32(strZip4.ToString());
                }
                //TODO - Test to see if GeoCode works without USA at end
                //   VolAddressDM.GeoCodeGetSet = GetGeoCode(VolAddressDM);

                if (iAction == (int)RecordAction.Update)
                {

                }
                else if (iAction == (int)RecordAction.Insert)
                {

                }
            }
            catch (Exception ex)
            {
                StackTrace st = new StackTrace();
                StackFrame sf = st.GetFrame(0);
                string errMethod = sf.GetMethod().Name.ToString();  // Get the current method name
                string errMsg = "600";                              // Gotta pass something, we're retro-fitting an existing method
                Session["LastException"] = ex;                      // Throw the exception in the session variable, will be used in error page
                string url = string.Format(ConfigurationManager.AppSettings["ErrorPageURL"], errMethod, errMsg); //Set the URL
                Response.Redirect(url);                             // Go to the error page.
            }

            try
            {
                HandleScreenLoad();
            }
            catch (Exception ex)
            {
                StackTrace st = new StackTrace();
                StackFrame sf = st.GetFrame(0);
                string errMethod = sf.GetMethod().Name.ToString();  // Get the current method name
                string errMsg = "600";                              // Gotta pass something, we're retro-fitting an existing method
                Session["LastException"] = ex;                      // Throw the exception in the session variable, will be used in error page
                string url = string.Format(ConfigurationManager.AppSettings["ErrorPageURL"], errMethod, errMsg); //Set the URL
                Response.Redirect(url);                             // Go to the error page.
            }
        }
        protected void HandleScreenLoad()
        {
            currentUser = Membership.GetUser();

            pnlSingleAddress.Visible = false;
            pnlAddressGrid.Visible = true;
            sp_Vol_Address_DM VolDM = new sp_Vol_Address_DM();
            sp_VendAddress_DM VendDM = new sp_VendAddress_DM();
            //VendDM.AddrID = (int)currentUser.ProviderUserKey;
            VolDM.VolID = (Guid)currentUser.ProviderUserKey;
            //rGridAddress.DataSource = VolAddrBLL.ListAddresses(VolDM);

            rGridAddress.DataSource = VolAddrCash.ListAddresses(VolDM);
            rGridAddress.DataBind();
        }
        protected string GetGeoCode(sp_VendAddress_DM VendAddr)
        {
            GoogleAddress googleAddress = new GoogleAddress();
            googleAddress.FormattedAddress = VendAddr.AddrLine1 + ", " +
               VendAddr.City + ", " + VendAddr.St + " " + VendAddr.Zip;
            //Assume we want to send the request to Google using SSL
            IGeocoder geoCoder = new GoogleGeocoder(true);
            String geoCoderXML = geoCoder.GetLatLongFromAddress(googleAddress);
            String latitude;
            String longitude;

            using (XmlReader reader = XmlReader.Create(new StringReader(geoCoderXML)))
            {
                reader.ReadToFollowing("lat");
                reader.MoveToFirstAttribute();
                latitude = reader.Value;

                reader.ReadToFollowing("lon");
                longitude = reader.Value;
            }

            String gcReturn;
            if (latitude.Contains("unknown") || longitude.Contains("unknown"))
            {
                gcReturn = null;
            }
            else
            {
                gcReturn = "'POINT(" + longitude + " " + latitude + ")'";
            }

            return gcReturn;
        }
 public void UpdateAddressContext(sp_VendAddress_DM InputAddress)
 {
     DAL.UpdateAddressContext(InputAddress);
 }
 public int InsertAddressContext(sp_VendAddress_DM InputAddress)
 {
     return DAL.InsertAddressContext(InputAddress);
 }
 public void DeleteAddressContext(sp_VendAddress_DM InputAddress)
 {
     DAL.DeleteAddressContext(InputAddress);
 }
Exemple #13
0
        public void TestVendAddressUpdate()
        {
            //Test Our Read
            DataTable dt = cExcel.ReadExcelFile("Sheet1", Path.Combine(cExcel.GetHelperFilesDir(), "VendAddress.xlsx"));
            foreach (DataRow row in dt.Rows) // Loop over the rows.
            {
                string AddrLine1 = "TestAddrLine1";
                string AddrLine2 = "TestAddrLine2";
                string AddrLine3 = "TestAddrLine3";
                string City = "TestCity";
                string St = "TestSt";
                int Zip = 11111;
                int Zip4 = 1111;

                int AddrID = Convert.ToInt32(row["AddrID"].ToString());
                sp_VendAddress_DM data = new sp_VendAddress_DM();
                data.AddrID = AddrID;
                data.AddrLine1 = AddrLine1;
                data.AddrLine2 = AddrLine2;
                data.AddrLine3 = AddrLine3;
                data.City = City;
                data.St = St;
                data.Zip = Zip;
                data.Zip4 = Zip4;
                sp_VendAddress_BLL vend = new sp_VendAddress_BLL();
                vend.UpdateAddressContext(data);
                data = vend.ListAddresses(AddrID);
                Assert.AreEqual(AddrLine1, data.AddrLine1, "AddrLine1 Not Set As Expected");
                Assert.AreEqual(AddrLine2, data.AddrLine2, "AddrLine2 Not Set As Expected");
                Assert.AreEqual(AddrLine3, data.AddrLine3, "AddrLine3 Not Set As Expected");
                Assert.AreEqual(City, data.City, "City Not Set As Expected");
                Assert.AreEqual(St, data.St, "St Not Set As Expected");
                Assert.AreEqual(Zip, data.Zip, "Zip Not Set As Expected");
                Assert.AreEqual(Zip4, data.Zip4, "Zip4 Not Set As Expected");

            }
        }