/// <summary>
 /// rGridAddress_DeleteCommand - Is executed if the 'Delete' command is called
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void rGridAddress_DeleteCommand(object sender, GridCommandEventArgs e)
 {
     GridEditableItem eeditedItem = e.Item as GridEditableItem;
     sp_Sample_Address_Select_DM cSampleAddress = new sp_Sample_Address_Select_DM();
     cSampleAddress.AddrID = Convert.ToInt32(eeditedItem.OwnerTableView.DataKeyValues[eeditedItem.ItemIndex]["AddrID"]);
     BLL.DeleteSampleAddressContext(cSampleAddress);
 }
Ejemplo n.º 2
0
        public void DeleteSampleAddressContext(sp_Sample_Address_Select_DM lSampleAddress)
        {
            using (VolTeerEntities context = new VolTeerEntities())
            {
                //  Load the Address based on the AddrID

                var AddressToRemove = (from n in context.tblSampleAddresses where n.AddrID == lSampleAddress.AddrID select n).FirstOrDefault();
                context.tblSampleAddresses.Remove(AddressToRemove);
                context.SaveChanges();

            }
        }
Ejemplo n.º 3
0
 public void InsertSampleAddressContext(sp_Sample_Address_Select_DM lSampleAddress)
 {
     using (VolTeerEntities context = new VolTeerEntities())
     {
         var SampleAddress = new tblSampleAddress
         {
             AddrLine1 = lSampleAddress.AddrLine1,
             AddrLine2 = lSampleAddress.AddrLine2,
             AddrLine3 = lSampleAddress.AddrLine3,
             City = lSampleAddress.City,
             St = lSampleAddress.St,
             Zip = lSampleAddress.Zip,
             Zip4 = lSampleAddress.Zip4,
             ActiveFlg = lSampleAddress.ActiveFlg
         };
         context.tblSampleAddresses.Add(SampleAddress);
         context.SaveChanges();
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        /// UpdateSampleAddressContext...  pass in an object of SampleAddress...  assign the object variables to the context variables, call the update
        /// </summary>
        /// <param name="lSampleAddress"></param>
        public void UpdateSampleAddressContext(sp_Sample_Address_Select_DM lSampleAddress)
        {
            using (VolTeerEntities context = new VolTeerEntities())
            {
                //  Load the Address based on the AddrID
                var SampleAddress = context.tblSampleAddresses.Find(lSampleAddress.AddrID);

                if (SampleAddress != null)
                {
                    SampleAddress.AddrLine1 = lSampleAddress.AddrLine1;
                    SampleAddress.AddrLine2 = lSampleAddress.AddrLine2;
                    SampleAddress.AddrLine3 = lSampleAddress.AddrLine3;
                    SampleAddress.City = lSampleAddress.City;
                    SampleAddress.St = lSampleAddress.St;
                    SampleAddress.Zip = lSampleAddress.Zip;
                    SampleAddress.Zip4 = lSampleAddress.Zip4;
                    SampleAddress.ActiveFlg = lSampleAddress.ActiveFlg;
                    context.SaveChanges();
                }
            }
        }
Ejemplo n.º 5
0
 public void UpdateSampleAddressContext(sp_Sample_Address_Select_DM lSampleAddress)
 {
     DAL.UpdateSampleAddressContext(lSampleAddress);
 }
Ejemplo n.º 6
0
 public void InsertSampleAddressContext(sp_Sample_Address_Select_DM lSampleAddress)
 {
     DAL.InsertSampleAddressContext(lSampleAddress);
 }
        /// <summary>
        /// rGridAdress_UpdIns - Call this shared method if insert or update
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <param name="iAction"></param>
        protected void rGridAdress_UpdIns(object sender, GridCommandEventArgs e, int iAction)
        {
            GridEditableItem eeditedItem = e.Item as GridEditableItem;
            sp_Sample_Address_Select_DM cSampleAddress = new sp_Sample_Address_Select_DM();

            if (iAction == (int)RecordAction.Update)
            {
                cSampleAddress.AddrID = Convert.ToInt32(eeditedItem.OwnerTableView.DataKeyValues[eeditedItem.ItemIndex]["AddrID"]);
            }
            else if (iAction == (int)RecordAction.Insert)
            {
                cSampleAddress.AddrID = 0;
            }

            cSampleAddress.AddrLine1 = (eeditedItem.FindControl("rTXTAddrLine1") as RadTextBox).Text.ToString();
            cSampleAddress.AddrLine2 = (eeditedItem.FindControl("rTXTAddrLine2") as RadTextBox).Text.ToString();
            cSampleAddress.AddrLine3 = (eeditedItem.FindControl("rTXTAddrLine3") as RadTextBox).Text.ToString();
            cSampleAddress.City = (eeditedItem.FindControl("rTXTCity") as RadTextBox).Text.ToString();
            RadDropDownList rddSt = (RadDropDownList)eeditedItem.FindControl("rDDState");
            cSampleAddress.St = rddSt.SelectedValue.ToString();
            cSampleAddress.Zip = Convert.ToInt32((eeditedItem.FindControl("rMTZip") as RadMaskedTextBox).Text);
            string strZip4 = ((eeditedItem.FindControl("rMTZip4") as RadMaskedTextBox).Text).ToString();
            if (strZip4 == string.Empty)
            {
                cSampleAddress.Zip4 = null;
            }
            else
            {
                cSampleAddress.Zip4 = Convert.ToInt32(strZip4.ToString());
            }

            if (iAction == (int)RecordAction.Update)
            {
                cSampleAddress.ActiveFlg = (eeditedItem.FindControl("chkActiveUpd") as CheckBox).Checked;
                try
                {
                    BLL.UpdateSampleAddressContext(cSampleAddress);
                }
                catch (SqlException sex)
                {
                    //TODO: Implement error page to display SQL Exception errors
                }
                catch (Exception ex)
                {
                    //TODO: Implement error page to display SQL Exception errors
                }
            }
            else if (iAction == (int)RecordAction.Insert)
            {
                cSampleAddress.ActiveFlg = (eeditedItem.FindControl("chkActiveIns") as CheckBox).Checked;

                try
                {
                    BLL.InsertSampleAddressContext(cSampleAddress);
                }
                catch (SqlException sex)
                {
                    //TODO: Implement error page to display SQL Exception errors
                }
                catch (Exception ex)
                {
                    //TODO: Implement error page to display SQL Exception errors
                }

            }
        }