Example #1
0
 public void DeleteAddressContext(sp_VendorAddr_DM InputAddress)
 {
     using (VolTeerEntities context = new VolTeerEntities())
     {
         var VendorAddrsToRemove = (from n in context.tblVendorAddrs where n.VendorID == InputAddress.VendorID select n).FirstOrDefault();
         context.tblVendorAddrs.Remove(VendorAddrsToRemove);
         context.SaveChanges();
     }
 }
Example #2
0
 public void TestVendorAddrDelete()
 {
     DataTable dt = cExcel.ReadExcelFile("Sheet1", Path.Combine(cExcel.GetHelperFilesDir(), "VendorAddr.xlsx"));
     foreach (DataRow row in dt.Rows) // Loop over the rows.
     {
         Guid vendorID = new Guid(row["VendorID"].ToString());
         sp_VendorAddr_DM data = new sp_VendorAddr_DM();
         data.VendorID = vendorID;
         sp_VendorAddr_BLL vendor = new sp_VendorAddr_BLL();
         vendor.DeleteAddressContext(data);
         var newdata = vendor.ListAddresses(vendorID);
         Assert.IsNull(newdata);
     }
 }
Example #3
0
 public int InsertAddressContext(sp_VendorAddr_DM InputAddress)
 {
     using (VolTeerEntities context = new VolTeerEntities())
     {
         var NewAddress = new tblVendorAddr
         {
             AddrID = InputAddress.AddrID,
             HQ = InputAddress.HQ
         };
         context.tblVendorAddrs.Add(NewAddress);
         context.SaveChanges();
         //Return the id of the newly created record
         return NewAddress.AddrID;
     }
 }
Example #4
0
        public void TestVendorAddrCreate()
        {
            //create a vendor
            sp_Vendor_DM data = new sp_Vendor_DM();
            data.VendorID = new Guid();
            string vendorName = "My Name";
            data.VendorName = vendorName;
            data.ActiveFlg = true;
            sp_Vendor_BLL vendor = new sp_Vendor_BLL();
            vendor.InsertVendorContext(ref data);

            //Insert Vendor Addr
            sp_VendorAddr_DM data1 = new sp_VendorAddr_DM();
            data1.VendorID = data.VendorID;
            data1.AddrID = 1;
            sp_VendorAddr_BLL vendoraddr = new sp_VendorAddr_BLL();
            vendoraddr.InsertAddressContext(data1);

            //Read Vendor Add
            var newdata = vendoraddr.ListAddresses(data1.VendorID);

            Assert.AreEqual(newdata.VendorID, data.VendorID, "VendorID Not Set As Expected");
            Assert.AreEqual(newdata.AddrID, 1, "AddrID Not Set As Expected");
        }
        /// <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.
            }
        }
Example #6
0
        public void UpdateAddressContext(sp_VendorAddr_DM InputAddress)
        {
            using (VolTeerEntities context = new VolTeerEntities())
            {
                var existingAddress = context.tblVendorAddrs.Find(InputAddress.AddrID, InputAddress.HQ);

                if (InputAddress != null)
                {
                    existingAddress.VendorID = InputAddress.VendorID;
                    existingAddress.AddrID = InputAddress.AddrID;
                    existingAddress.HQ = InputAddress.HQ;
                    context.SaveChanges();
                }
            }
        }
Example #7
0
 public void UpdateAddressContext(sp_VendorAddr_DM InputAddress)
 {
     DAL.UpdateAddressContext(InputAddress);
 }
Example #8
0
 public int InsertAddressContext(sp_VendorAddr_DM InputAddress)
 {
     return DAL.InsertAddressContext(InputAddress);
 }
Example #9
0
 public void DeleteAddressContext(sp_VendorAddr_DM InputAddress)
 {
     DAL.DeleteAddressContext(InputAddress);
 }