Tuesday 17 December 2013

look up values



using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Linq;
using Ipreo.Orion.Own.DataAccessLayer;
using System.Configuration;

namespace Ipreo.Orion.Own.LinqQuery
{
    public class lookUpVal : IDisposable
    {
        private LookUpValuesDataContext m_dbEdd;
        private iprFundEntryDataContext m_dbStg;
        private noisysEdgarDataContext m_dbNoisys;

         // Track whether Dispose has been called.
        private bool disposed = false;

        public lookUpVal ()
        {
            m_dbEdd = new LookUpValuesDataContext(ConfigurationSettings.AppSettings["ConnectionString"]);
            m_dbStg = new iprFundEntryDataContext(ConfigurationSettings.AppSettings["DevStageConnectionString"]);
            m_dbNoisys = new noisysEdgarDataContext(ConfigurationSettings.AppSettings["noisysEdgarConnectionString"]);
        }

         // Implement IDisposable.
        // Do not make this method virtual.
        // A derived class should not be able to override this method.
        public void Dispose()
        {
            Dispose(true);
            // This object will be cleaned up by the Dispose method.
            // Therefore, you should call GC.SupressFinalize to
            // take this object off the finalization queue
            // and prevent finalization code for this object
            // from executing a second time.
            GC.SuppressFinalize(this);
        }

        // Dispose(bool disposing) executes in two distinct scenarios.
        // If disposing equals true, the method has been called directly
        // or indirectly by a user's code. Managed and unmanaged resources
        // can be disposed.
        // If disposing equals false, the method has been called by the
        // runtime from inside the finalizer and you should not reference
        // other objects. Only unmanaged resources can be disposed.
        private void Dispose(bool disposing)
        {
            // Check to see if Dispose has already been called.
            if (!this.disposed)
            {
                // If disposing equals true, dispose all managed
                // and unmanaged resources.
                if (disposing)
                {
                    m_dbEdd.Dispose();
                    m_dbEdd = null;

                    m_dbStg.Dispose();
                    m_dbStg = null;

                }

                // Call the appropriate methods to clean up
                // unmanaged resources here.
                // If disposing is false,
                // only the following code is executed.

                //NO unmanaged Resource
            }
            disposed = true;
        }

         // Use interop to call the method necessary
        // to clean up the unmanaged resource.
        [System.Runtime.InteropServices.DllImport("Kernel32")]
        private extern static Boolean CloseHandle(IntPtr handle);

        // Use C# destructor syntax for finalization code.
        // This destructor will run only if the Dispose method
        // does not get called.
        // It gives your base class the opportunity to finalize.
        // Do not provide destructors in types derived from this class.
        ~lookUpVal()    
        {
            // Do not re-create Dispose clean-up code here.
            // Calling Dispose(false) is optimal in terms of
            // readability and maintainability.
            Dispose(false);
        }

        public IEnumerable<tblCurrencyLookup> getCurrency()
        {
            IQueryable<tblCurrencyLookup> tblCurrencies = from hc in m_dbEdd.tblCurrencyLookups
                                                          join hs in m_dbEdd.tbl_com_s_currencies
                                                        on hc.h_currency_id equals hs.h_currency_id
                                                       where hc.last_effective_dt == hs.effective_dt
                                                      orderby hs.sort_key, hc.currency_nm
                            select hc;
            return tblCurrencies;
        }

        public IEnumerable<tblFndReportType> getRptType()
        {
            IQueryable<tblFndReportType> tblCurrencies = from hc in m_dbEdd.tblFndReportTypes
                                                         where hc.scope_flg == 'F'
                                                            && hc.holding_type_id != 5
                                                          select hc;
            return tblCurrencies;
        }

        public IEnumerable<tblColCustomization> getCustomColmn(string ui_view_cd)
        {
            IEnumerable<tblColCustomization> tblColCustomizations = from colCust in m_dbStg.tblColCustomizations
                                                                    where colCust.ui_view_cd == ui_view_cd
                                                   select colCust;

            return tblColCustomizations;
        }

        public IEnumerable<tblColCustomization> getCustomColmn(int ui_selection_id)
        {
            IEnumerable<tblColCustomization> tblColCustomizations = from colCust in m_dbStg.tblColCustomizations
                                                                    where colCust.ui_selection_id==ui_selection_id
                                                                    select colCust;

            return tblColCustomizations;
        }
        public IEnumerable<NewCols> getRpts(int iFundID)
        {
            IEnumerable<NewCols> tblFundReport = from hc in m_dbStg.tblIprFundReports
                                                 where hc.h_Fund_id == iFundID
                                                 orderby hc.report_dt descending
                                                 select new NewCols
                                                 {
                                                     ID = hc.ipr_fund_report_id,
                                                     Name = hc.report_dt.ToString().Replace("12:00AM", "").Trim()
                                                 };

            NewCols objIprFundReport = new NewCols();
            objIprFundReport.ID = 0;
            objIprFundReport.Name = "New";

            List<NewCols> l_NewCols = tblFundReport.ToList();
            l_NewCols.Add(objIprFundReport);

            return l_NewCols.AsEnumerable();
        }

        public IEnumerable<tblColCustomization> getOwnershipCustomColmn()
        {
            IEnumerable<tblColCustomization> tblColCustomizations = from colCust in m_dbStg.tblColCustomizations
                                                                    where colCust.ui_view_cd == "o"
                                                                    select colCust;

            return tblColCustomizations;
        }
       
        public IEnumerable<NewCols> GetOwnAcquisitionSources()
        {
            IEnumerable<NewCols> tblOwnAcquisitionSources = from OwnAcquisitionSources in m_dbEdd.tbl_sys_sources
                                                            select new NewCols
                                                            {
                                                                Name = OwnAcquisitionSources.source_nm,//+ "(" + OwnAcquisitionSources.source_cd.Trim() + ")",
                                                                ID = OwnAcquisitionSources.source_id
                                                            };
            return tblOwnAcquisitionSources;
        }
        public IEnumerable<NewCols> GetOwnAcquisitionFrequency()
        {
            IEnumerable<NewCols> tblOwnAcquisitionFrequency = from AcquisitionFrequency in m_dbNoisys.tbl_com_doc_frequencies
                                                              select new NewCols
                                                              {
                                                                  Name = AcquisitionFrequency.doc_frequency_desc,
                                                                  ID = AcquisitionFrequency.doc_frequency_id
                                                              };
            return tblOwnAcquisitionFrequency;
        }
        public IEnumerable<NewCols> GetAcquisitionFormType()
        {
            IEnumerable<NewCols> tblOwnFormType = from OwnFormType in m_dbEdd.OwnHoldingTypes
                                                  select new NewCols
                                                  {
                                                      Name = OwnFormType.holding_type_nm,
                                                      ID = OwnFormType.holding_type_id
                                                  };
            return tblOwnFormType;
        }
        public IEnumerable<NewCols> GetOwnDocStatus()
        {
            IEnumerable<NewCols> OwnDocStatus = from DocStatus in m_dbNoisys.tbl_com_filing_status
                                                where DocStatus.uss_ind==true
                                                select new NewCols
                                                {
                                                    Name = DocStatus.status_desc,
                                                    ID = DocStatus.status_id
                                                }
                                                ;
            return OwnDocStatus;
        }
        public IQueryable<tbl_com_filing_status> GetWorkflowStatus()
        {
            IQueryable<tbl_com_filing_status> OwnDocStatus = from Status13f in m_dbNoisys.tbl_com_filing_status
                                                          orderby Status13f.sort_key
                                                        select Status13f;
            return OwnDocStatus;
        }
        public IQueryable<tbl13FclnRules> Get13FRules()
        {
            IQueryable<tbl13FclnRules> Rules13F = from Rule13f in m_dbNoisys.tbl13FclnRules
                                                  select Rule13f;                                                
                                                 
            return Rules13F;
        }
        public IQueryable<tbl_fnd_cln_rule> GetPensionFundRules()
        {
            IQueryable<tbl_fnd_cln_rule> fndRules = from rule in m_dbNoisys.tbl_fnd_cln_rules
                                                    select rule;

            return fndRules;
        }
        public List<tbl_noisys_queue_ui_selection> GetUISelectionTable()
        {
            List<tbl_noisys_queue_ui_selection> UISelectionIndicators = (from UISelection in m_dbNoisys.tbl_noisys_queue_ui_selections
                                                                         select UISelection).ToList < tbl_noisys_queue_ui_selection>();

            return UISelectionIndicators;
        }

        public IEnumerable<NewCols> Get13FRulesTextWithID()
        {
            IEnumerable<NewCols> Rules13F = from Rule13f in m_dbNoisys.tbl13FclnRules
                                            select new NewCols
                                                  {
                                                      ID = Rule13f.rule_id,
                                                      Name = Rule13f.rule_desc + " (" + Rule13f.rule_id + ")"

                                                  };
            return Rules13F;
        }
        public IQueryable<tbl13dclnrule> Get13DGRules()
        {
            IQueryable<tbl13dclnrule> Rules13DG = from Rule13dg in m_dbNoisys.tbl13dclnrules
                                                 select Rule13dg;

            return Rules13DG;
        }

        public IEnumerable<NewCols> Get13DGRulesTextWithID()
        {
            IEnumerable<NewCols> Rules13F = from Rule13dg in m_dbNoisys.tbl13dclnrules
                                            select new NewCols
                                            {
                                                ID = Rule13dg._13d_cln_rule_id,
                                                Name = Rule13dg.rule_desc + " (" + Rule13dg._13d_cln_rule_id + ")"
                                            };
            return Rules13F;
        }
     
    }
}
public class NewCols
{

    public String Name { get; set; }
    public int ID { get; set; }
    public int FilterID { get; set; }

}

Friday 13 December 2013

Solving problem of Line seperation from sqlqury result message in c# MessageBox

Solving problem of Line seperation from sqlqury result message in c# MessageBox

hi ,to day i am posting  how c# Message box will display messagetext   when message text coming from Database and when messagetext coming from UI

1) C# Message Box showing message of Line separation from UI;


using System;

using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void btn_Save_Click(object sender, EventArgs e)
        {
            string messsage = "Test1...  \n Test2'";
          
            MessageBox.Show(messsage);
          
        }
    }
}


Output Result:



2) When Message to display from Data Base Query:-



DECLARE @LINEBREAK AS varchar(2)
SET @LINEBREAK ='Test1' +CHAR(13) + CHAR(10)+'Test2';

Means above here  char(13),char(10) are line breaking in sqlserver 
clearly in general way char(13)+char(10)='\n'








Wednesday 8 August 2012

creating dynamic table

private void CreateDynamicTable()
    {
        PlaceHolder1.Controls.Clear();

        // Fetch the number of Rows and Columns for the table
        // using the properties
        int tblRows = Rows;
        int tblCols = Columns;
        // Create a Table and set its properties
        Table tbl = new Table();
        // Add the table to the placeholder control
        PlaceHolder1.Controls.Add(tbl);
        // Now iterate through the table and add your controls
        for (int i = 0; i < tblRows; i++)
        {
            TableRow tr = new TableRow();
            for (int j = 0; j < tblCols; j++)
            {
                TableCell tc = new TableCell();
                TextBox txtBox = new TextBox();
                txtBox.Text = "RowNo:" + i + " " + "ColumnNo:" + " " + j;
                // Add the control to the TableCell
                tc.Controls.Add(txtBox);
                // Add the TableCell to the TableRow
                tr.Cells.Add(tc);
            }
            // Add the TableRow to the Table
            tbl.Rows.Add(tr);
        }

       // This parameter helps determine in the LoadViewState event,
       // whether to recreate the dynamic controls or not

       ViewState["dynamictable"] = true;
    }===============