Exemplo n.º 1
0
        /// <summary>
        /// This method will return an object representing the record matching the primary key information specified.
        /// </summary>
        ///
        /// <param name="pk" type="CampaignMailingPrimaryKey">Primary Key information based on which data is to be fetched.</param>
        ///
        /// <returns>object of class CampaignMailing</returns>
        ///
        /// <remarks>
        ///
        /// <RevisionHistory>
        /// Author				Date			Description
        /// DLGenerator			6/25/2012 02:05:58 PM		Created function
        /// 
        /// </RevisionHistory>
        ///
        /// </remarks>
        ///
        public static CampaignMailing SelectOne(CampaignMailingPrimaryKey pk, string ConnectionString)
        {
            DatabaseHelper oDatabaseHelper = new DatabaseHelper(ConnectionString);
            bool ExecutionState = false;

            // Pass the values of all key parameters to the stored procedure.
            System.Collections.Specialized.NameValueCollection nvc = pk.GetKeysAndValues();
            foreach (string key in nvc.Keys)
            {
                oDatabaseHelper.AddParameter("@" + key,nvc[key] );
            }
            // The parameter '@ErrorCode' will contain the status after execution of the stored procedure.
            oDatabaseHelper.AddParameter("@ErrorCode", -1, System.Data.ParameterDirection.Output);

            IDataReader dr=oDatabaseHelper.ExecuteReader("sp_CampaignMailing_SelectbyPrimaryKey", ref ExecutionState);
            if (dr.Read())
            {
                CampaignMailing obj = new CampaignMailing(ConnectionString);
                PopulateObjectFromReader(obj,dr);
                dr.Close();
                oDatabaseHelper.Dispose();
                return obj;
            }
            else
            {
                dr.Close();
                oDatabaseHelper.Dispose();
                return null;
            }
        }
Exemplo n.º 2
0
        protected void lbtnYes_Click(object sender, EventArgs e)
        {
            try
            {
                StringBuilder strbDeletedContacts = new StringBuilder();
                if (hdfDraft.Value == "0")
                    rememberContactSelection("PgrdaddchkSelectRecs", "lblDCampaignId", RGridPendingMails, "Pgrdaddselectall");
                else
                    rememberContactSelection("SgrdaddchkSelectRecs", "lblSCampaignId", RgrdSentCampaigns, "Sgrdaddselectall");
                if (ViewState["SelectedContacts"] != null)
                {
                    //adding selected contatIds to stringbuilder
                    for (int i = 0; i < contactsSelected.Count; i++)
                    {
                        strbDeletedContacts.Append(contactsSelected[i] + ", ");
                    }
                    strbDeletedContacts.Remove(strbDeletedContacts.Length - 2, 1);
                    string[] CampIds = strbDeletedContacts.ToString().Split(',');
                    for (int i = 0; i < CampIds.Length; i++)
                    {
                        CampaignMasterPrimaryKey pk = new CampaignMasterPrimaryKey(Convert.ToInt32(CampIds[i].ToString()));
                        CampaignMaster campMaster = CampaignMaster.SelectOne(pk, ConnectionString);
                        campMaster.Active = false;
                        bool status = campMaster.Update();

                        //Update Active Status in CampaignMailing Table
                        CampaignMailingPrimaryKey pkMail = new CampaignMailingPrimaryKey(Convert.ToInt64(CampIds[i].ToString()));
                        CampaignMailing objCampMail = CampaignMailing.SelectOne(pkMail, ConnectionString);
                        if (objCampMail != null)
                        {
                            objCampMail.IsActive = false;
                            bool status1 = objCampMail.Update();
                        }
                    }
                    MDelModalPopupExtender.Hide();
                    MSentDelModalPopupExtender.Hide();
                    GridPrevSortExpression = "";
                    bindGrid("sort", 0);
                    ViewState["SelectedContacts"] = null;
                    lblMainMsg.Visible = true;
                    lblMainMsg.Text = "Successfully Deleted Mailing(s) with ids: " + strbDeletedContacts.ToString();
                    lblMainMsg.Style.Add("color", "Green");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// This method will Delete one row from the database using the primary key information
        /// </summary>
        ///
        /// <param name="pk" type="CampaignMailingPrimaryKey">Primary Key information based on which data is to be fetched.</param>
        ///
        /// <returns>True if succeeded</returns>
        ///
        /// <remarks>
        ///
        /// <RevisionHistory>
        /// Author				Date			Description
        /// DLGenerator			6/25/2012 02:05:58 PM		Created function
        /// 
        /// </RevisionHistory>
        ///
        /// </remarks>
        ///
        public static bool Delete(CampaignMailingPrimaryKey pk, string ConnectionString)
        {
            DatabaseHelper oDatabaseHelper = new DatabaseHelper(ConnectionString);
            bool ExecutionState = false;

            // Pass the values of all key parameters to the stored procedure.
            System.Collections.Specialized.NameValueCollection nvc = pk.GetKeysAndValues();
            foreach (string key in nvc.Keys)
            {
                oDatabaseHelper.AddParameter("@" + key,nvc[key] );
            }
            // The parameter '@ErrorCode' will contain the status after execution of the stored procedure.
            oDatabaseHelper.AddParameter("@ErrorCode", -1, System.Data.ParameterDirection.Output);

            oDatabaseHelper.ExecuteScalar("sp_CampaignMailing_Delete", ref ExecutionState);
            oDatabaseHelper.Dispose();
            return ExecutionState;
        }