/// <summary> /// Populates the fields for multiple objects from the columns found in an open reader. /// </summary> /// /// <param name="rdr" type="IDataReader">An object that implements the IDataReader interface</param> /// /// <returns>Object of AdvanceListContactMasters</returns> /// /// <remarks> /// /// <RevisionHistory> /// Author Date Description /// DLGenerator 7/28/2012 02:17:32 PM Created function /// /// </RevisionHistory> /// /// </remarks> /// internal static AdvanceListContactMasters PopulateObjectsFromReaderWithCheckingReader(IDataReader rdr, DatabaseHelper oDatabaseHelper,String ConnectionString) { AdvanceListContactMasters list = new AdvanceListContactMasters(); if (rdr.Read()) { AdvanceListContactMaster obj = new AdvanceListContactMaster(ConnectionString); PopulateObjectFromReader(obj, rdr); list.Add(obj); while (rdr.Read()) { obj = new AdvanceListContactMaster(ConnectionString); PopulateObjectFromReader(obj, rdr); list.Add(obj); } oDatabaseHelper.Dispose(); return list; } else { oDatabaseHelper.Dispose(); return null; } }
/// <summary> /// This method will return an object representing the record matching the primary key information specified. /// </summary> /// /// <param name="pk" type="AdvanceListContactMasterPrimaryKey">Primary Key information based on which data is to be fetched.</param> /// /// <returns>object of class AdvanceListContactMaster</returns> /// /// <remarks> /// /// <RevisionHistory> /// Author Date Description /// DLGenerator 7/28/2012 02:17:32 PM Created function /// /// </RevisionHistory> /// /// </remarks> /// public static AdvanceListContactMaster SelectOne(AdvanceListContactMasterPrimaryKey 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_AdvanceListContactMaster_SelectbyPrimaryKey", ref ExecutionState); if (dr.Read()) { AdvanceListContactMaster obj = new AdvanceListContactMaster(ConnectionString); PopulateObjectFromReader(obj,dr); dr.Close(); oDatabaseHelper.Dispose(); return obj; } else { dr.Close(); oDatabaseHelper.Dispose(); return null; } }
/// <summary> /// Populates the fields for multiple objects from the columns found in an open reader. /// </summary> /// /// <param name="rdr" type="IDataReader">An object that implements the IDataReader interface</param> /// /// <returns>Object of AdvanceListContactMasters</returns> /// /// <remarks> /// /// <RevisionHistory> /// Author Date Description /// DLGenerator 7/28/2012 02:17:32 PM Created function /// /// </RevisionHistory> /// /// </remarks> /// internal static AdvanceListContactMasters PopulateObjectsFromReader(IDataReader rdr, string ConnectionString) { AdvanceListContactMasters list = new AdvanceListContactMasters(); while (rdr.Read()) { AdvanceListContactMaster obj = new AdvanceListContactMaster(ConnectionString); PopulateObjectFromReader(obj,rdr); list.Add(obj); } return list; }
private void createSegemnt(string SegmentType) { try { lblMainMsg.Text = string.Empty; AdvanceListMasterBase listMaster = new AdvanceListMasterBase(ConnectionString); AdvanceSegmentMasterBase segmentMaster = new AdvanceSegmentMasterBase(ConnectionString); AdvanceListContactMaster objListContactMaster = new AdvanceListContactMaster(ConnectionString); DataTable dtListContactMaster = new DataTable(); dtListContactMaster.Columns.Add(new DataColumn("ListMasterID", typeof(string))); dtListContactMaster.Columns.Add(new DataColumn("ContactId", typeof(string))); dtListContactMaster.Columns.Add(new DataColumn("CreatedDate", typeof(string))); dtListContactMaster.Columns.Add(new DataColumn("ModifiedDate", typeof(string))); dtListContactMaster.Columns.Add(new DataColumn("IsSegment", typeof(bool))); dtListContactMaster.Columns.Add(new DataColumn("IsActive", typeof(bool))); List<string> contactids = new List<string>(); contactids = (List<string>)Session["ContactId"]; if (hdfListId.Value != "") { bool isDeleted = objListContactMaster.DeleteAllContactsFromList(Convert.ToInt64(hdfListId.Value)); if (isDeleted) { foreach (string contactID in contactids) { DataRow rowListContactMaster = dtListContactMaster.NewRow(); rowListContactMaster["ListMasterID"] = hdfListId.Value; rowListContactMaster["ContactId"] = contactID; //rowListContactMaster["CreatedDate"] = DateTime.Now.ToString(); rowListContactMaster["ModifiedDate"] = DateTime.Now.ToString(); rowListContactMaster["IsActive"] = true; dtListContactMaster.Rows.Add(rowListContactMaster); } string[] SourceColumn = new[] { "ListMasterID", "ContactId", "CreatedDate", "ModifiedDate", "IsActive" }; string[] DestinationColumn = new[] { "ListMasterID", "ContactId", "CreatedDate", "ModifiedDate", "IsActive" }; AdvanceListContactMaster.BulkCopy(dtListContactMaster, "AdvanceListContactMaster", SourceColumn, DestinationColumn, ConnectionString); AdvanceListMasterPrimaryKey pk = new AdvanceListMasterPrimaryKey(Convert.ToInt64(hdfListId.Value));//hiddenEditID.Value)); AdvanceListMaster listMasterNew = AdvanceListMaster.SelectOne(pk, ConnectionString); listMaster.ListMasterID = Convert.ToInt64(hdfListId.Value); listMaster.ListName = txtSegmentName.Text; listMaster.ListDesc = txtDescription.Text; listMaster.CreatedDate = listMasterNew.CreatedDate; listMaster.ModifiedDate = System.DateTime.Now; listMaster.IsSegment = true; listMaster.Update(); segmentMaster.ListMasterID = Convert.ToInt64(hdfListId.Value); segmentMaster.SegmentName = txtSegmentName.Text; segmentMaster.SelectCondition = SelectedIds.Value.Substring(0, SelectedIds.Value.Length); if (rbSegCamRecOnly.Checked) HtmlContent.Value = HtmlContent.Value.Replace("\"ddlContactFieldName\"", "\"ddlContactField\" onChange='QueryBuild(this);'"); else HtmlContent.Value = HtmlContent.Value.Replace("\"ddlContactFieldName\"", "\"ddlContactField\" onChange='ListQueryBuild(this);'"); HtmlContent.Value = HtmlContent.Value.Replace("\"ddlOperatorName\"", "\"ddlOperator\" onChange='getSearchKeys(this);'"); HtmlContent.Value = HtmlContent.Value.Replace("\"ddlOperatorDefault\"", "\"ddlOperatorCommon\" onChange='displayDefaultValues(this);'"); segmentMaster.SegmentFilter = HtmlContent.Value; segmentMaster.Type = SegmentType; segmentMaster.Update(); } Response.Redirect("~/pages/Segments.aspx?name=" + txtSegmentName.Text + "&mode=update"); } else { if (rgdContacts.MasterTableView.Items.Count > 0) { listMaster.ListName = txtSegmentName.Text; listMaster.ListDesc = txtDescription.Text; listMaster.CreatedDate = System.DateTime.Now; listMaster.IsSegment = true; listMaster.InsertWithDefaultValues(true); Int64 listid = Convert.ToInt64(listMaster.ListMasterID); segmentMaster.ListMasterID = listid; segmentMaster.SegmentName = txtSegmentName.Text; segmentMaster.SelectCondition = SelectedIds.Value.Substring(0, SelectedIds.Value.Length); if (rbSegCamRecOnly.Checked) HtmlContent.Value = HtmlContent.Value.Replace("\"ddlContactFieldName\"", "\"ddlContactField\" onChange='QueryBuild(this);'"); else HtmlContent.Value = HtmlContent.Value.Replace("\"ddlContactFieldName\"", "\"ddlContactField\" onChange='ListQueryBuild(this);'"); HtmlContent.Value = HtmlContent.Value.Replace("\"ddlOperatorName\"", "\"ddlOperator\" onChange='getSearchKeys(this);'"); HtmlContent.Value = HtmlContent.Value.Replace("\"ddlOperatorDefault\"", "\"ddlOperatorCommon\" onChange='displayDefaultValues(this);'"); segmentMaster.SegmentFilter = HtmlContent.Value; segmentMaster.Type = SegmentType; segmentMaster.Insert(); foreach (string contactID in contactids) { DataRow rowListContactMaster = dtListContactMaster.NewRow(); rowListContactMaster["ListMasterID"] = listid; rowListContactMaster["ContactId"] = contactID; rowListContactMaster["CreatedDate"] = DateTime.Now.ToString(); rowListContactMaster["ModifiedDate"] = DateTime.Now.ToString(); rowListContactMaster["IsActive"] = true; dtListContactMaster.Rows.Add(rowListContactMaster); } string[] SourceColumn = new[] { "ListMasterID", "ContactId", "CreatedDate", "ModifiedDate", "IsActive" }; string[] DestinationColumn = new[] { "ListMasterID", "ContactId", "CreatedDate", "ModifiedDate", "IsActive" }; AdvanceListContactMaster.BulkCopy(dtListContactMaster, "AdvanceListContactMaster", SourceColumn, DestinationColumn, ConnectionString); } } Response.Redirect("~/pages/Segments.aspx?name=" + txtSegmentName.Text + "&mode=create"); } catch (Exception ex) { lblMainMsg.Text = "Error: " + ex.Message; //lblMainMsg.Visible = true; rtsAddSegment.SelectedIndex = 0; rtsAddSegment.MultiPage.SelectedIndex = 0; } }