Load a datagridview using List<> with files in a folder

by ssi 11. November 2013 07:40
      private void LoadGridInFolder()
        {
          string  sMask = "*.*";
            string[] aExcludeExt = { ".DB",".JPG",".BMP",".PNG",".PDF",".TXT",".WMV",".MPEG",".AVI" };
            DirectoryInfo di = new DirectoryInfo(FullQualifiedDocumentFolder);
            List<PolicyDocs> DocRec = new List<PolicyDocs>();

            FileInfo[] DirFiles = di.GetFiles(sMask);
            foreach (FileInfo fi in DirFiles)
            {
                if (!aExcludeExt.Contains(fi.Extension.ToUpper()))
                {
                    PolicyDocs rcd = new PolicyDocs();
                    rcd.FileName = fi.Name;
                    rcd.Docdate = fi.LastAccessTime;
                    rcd.Length = fi.Length;
                    rcd.CreatedDate = fi.CreationTime;
                    rcd.Extension = fi.Extension;
                    rcd.Folder = di.Name;

                    DocRec.Add(rcd);
                }
            }
            dataGridView1.DataSource = DocRec;
            SetColumns(dataGridView1);

            // SetColumns(dataGridView1);
        }

Tags: , ,

CSharp

Dynamic Where clause

by ssi 11. September 2013 10:55

Dynamic LINQ clause with  Join that allows items to  be concatenated.


 if (FormLoaded)             {                 var loans = dc.TRACKING_FILEs;                 var status = dc.TRACKING_FILE_As;                 var results = loans.Join(status, sta => sta.Loan_ID, tr => tr.Loan_ID,                   (tr, sta) => new { tr.Loan_ID, tr.f463_loan_status, tr.f450_loan_officer_code, tr.f2b1_last_name_buyer, tr.F430B1_dob_buyer, tr.f413_application_date, tr.f426_disbursement_date, tr.f7001_Buyer_1_First_and_Last_Name, tr.f13B1_B1_Curr_Street, tr.f14B1_B1_Curr_City, tr.f15B1_B1_Curr_St_Zip, tr.f440b1_Buyers_mailing_street_address, tr.f441b1_Buyers_mailing_city_State_zip, sta.f447b1_b1_email_address }).OrderBy(c => c.Loan_ID)                   .Select(r => new { r.Loan_ID, r.f450_loan_officer_code, r.f463_loan_status, r.f2b1_last_name_buyer, r.F430B1_dob_buyer, r.f413_application_date, r.f426_disbursement_date, r.f7001_Buyer_1_First_and_Last_Name, r.f13B1_B1_Curr_Street, r.f14B1_B1_Curr_City, r.f15B1_B1_Curr_St_Zip, r.f440b1_Buyers_mailing_street_address, r.f441b1_Buyers_mailing_city_State_zip, r.f447b1_b1_email_address });                 if (!string.IsNullOrEmpty(cbLO.Text))                 {                     results = results.Where(r => r.f450_loan_officer_code == cbLO.Text);                 }                 if (rbApplicationDate.Checked)                     results = results.Where(c => c.f413_application_date >= dtpStart.Value.Date                                                  & c.f413_application_date <= dtpEnd.Value.Date);                 if (rbDisbursementDate.Checked)                     results = results.Where(c => c.f426_disbursement_date >= dtpStart.Value.Date                                                  & c.f426_disbursement_date <= dtpEnd.Value.Date);                 if (ckStatus.Checked)                     results = results.Where(c => c.f463_loan_status == cbStatus.Text);                 dataGridView1.DataSource = results;                 lblStatus.Text = string.Format("Record Count: {0:#,##0}", results.Count());                 SetColumns();             }

Tags: ,

Dynamic Where clause

by ssi 11. September 2013 10:33

Dynamic LINQ clause with  Join that allows items to  be concatenated.


 if (FormLoaded)             {                 var loans = dc.TRACKING_FILEs;                 var status = dc.TRACKING_FILE_As;                 var results = loans.Join(status, sta => sta.Loan_ID, tr => tr.Loan_ID,                   (tr, sta) => new { tr.Loan_ID, tr.f463_loan_status, tr.f450_loan_officer_code, tr.f2b1_last_name_buyer, tr.F430B1_dob_buyer, tr.f413_application_date, tr.f426_disbursement_date, tr.f7001_Buyer_1_First_and_Last_Name, tr.f13B1_B1_Curr_Street, tr.f14B1_B1_Curr_City, tr.f15B1_B1_Curr_St_Zip, tr.f440b1_Buyers_mailing_street_address, tr.f441b1_Buyers_mailing_city_State_zip, sta.f447b1_b1_email_address }).OrderBy(c => c.Loan_ID)                   .Select(r => new { r.Loan_ID, r.f450_loan_officer_code, r.f463_loan_status, r.f2b1_last_name_buyer, r.F430B1_dob_buyer, r.f413_application_date, r.f426_disbursement_date, r.f7001_Buyer_1_First_and_Last_Name, r.f13B1_B1_Curr_Street, r.f14B1_B1_Curr_City, r.f15B1_B1_Curr_St_Zip, r.f440b1_Buyers_mailing_street_address, r.f441b1_Buyers_mailing_city_State_zip, r.f447b1_b1_email_address });                 if (!string.IsNullOrEmpty(cbLO.Text))                 {                     results = results.Where(r => r.f450_loan_officer_code == cbLO.Text);                 }                 if (rbApplicationDate.Checked)                     results = results.Where(c => c.f413_application_date >= dtpStart.Value.Date                                                  & c.f413_application_date <= dtpEnd.Value.Date);                 if (rbDisbursementDate.Checked)                     results = results.Where(c => c.f426_disbursement_date >= dtpStart.Value.Date                                                  & c.f426_disbursement_date <= dtpEnd.Value.Date);                 if (ckStatus.Checked)                     results = results.Where(c => c.f463_loan_status == cbStatus.Text);                 dataGridView1.DataSource = results;                 lblStatus.Text = string.Format("Record Count: {0:#,##0}", results.Count());                 SetColumns();             }

Tags: ,

linq

Ask before Delete Row in a datagridview

by ssi 1. May 2013 20:56

   private void bindingNavigatorDeleteItem_Click(object sender, EventArgs e)

        {

            //not here

        }

 

        private void btnDeleteRow_Click(object sender, EventArgs e)

        {

            if (MessageBox.Show("Do you want to delete this Record?", "Confirm Record Deletion",

                MessageBoxButtons.YesNo, MessageBoxIcon.Information)

                == DialogResult.Yes)

            {

                tbl_ssi_BOASuspenseDataGridView.Rows.Remove(tbl_ssi_BOASuspenseDataGridView.Rows[nCurrentRow]);

            }

        }

Tags: , ,

CSharp

GroupBy with Conditional SUMS

by ssi 1. May 2013 15:03
    private static void Main(string[] args)
        {
            DataClasses1DataContext dc = new DataClasses1DataContext(DEFAULT_CONNECTION_STRING);
            int nMonth = 2;
            int nYear = 2013;
            for (int index = 0; index < 5; index++)
             
            {
                nMonth = index;
                Console.WriteLine(string.Format("Month: {0}",nMonth));
                var qry = dc.tbl_ssi_LoanSnapshot_Documents.Where(c => c.TakenMonth == nMonth
                             & c.TakenYear == nYear)
                            .GroupBy(g => g.DocType)
                              .Select(g => new
               {
                   DocType = g.Key
                   ,
                   DocCount = g.Count(p => p.Request_Date != null)
                   ,
                   DocsReqRecd = g.Count(p => p.Request_Date != null & p.Recieved_Date != null)
                   ,
                   DocsReqNOTRecd = g.Count(p => p.Request_Date != null & p.Recieved_Date == null)
 
               })
               .OrderBy(o => o.DocType);
                foreach (var doc in qry)
                {
                    if (doc.DocCount > 100)
                        Console.WriteLine(string.Format("Month: {0} Doc: {1} Count:{2} ReqRecd: {3} ReqNOTRecd: {4}"
                                 , nMonth , doc.DocType, doc.DocCount, doc.DocsReqRecd, doc.DocsReqNOTRecd));
                }
                Console.WriteLine("");
            }
            Console.ReadLine();
        }

Tags: ,

CSharp

Calendar

<<  May 2024  >>
MoTuWeThFrSaSu
293012345
6789101112
13141516171819
20212223242526
272829303112
3456789

View posts in large calendar

RecentComments

None

Development Team @ Shelbysys

We develop custom database applications for our clients. Our development tool of choice is MS Visual Studio. 

Quotations

"Procrastination is, hands down, our favorite form of self-sabotage"
Alyce P. Cornyn-Selby