Time Span

by ssi 13. August 2015 15:38
TimeSpan tsSystime = DateTime.Now.TimeOfDay;
 
               if (tsSystime.Minutes >= 0 & tsSystime.Minutes <= nMinutes)
               {
                   MessageBox.Show(sText, "Database Restoring"MessageBoxButtons.OK, MessageBoxIcon.Hand);
                   bRet = false;
               }

Tags: ,

CSharp

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

Load a Datagridview with sub directoriesusing List<>

by ssi 11. November 2013 07:13
 private void LoadGridPrim( )
        {
            sMask = "*.*";
            string[] aExcludeExt = { ".db" };
            DirectoryInfo di = new DirectoryInfo(RootFolder);
            List<PolicyFolder> FolderRec = new List<PolicyFolder>();
            foreach (DirectoryInfo dir in di.GetDirectories())
            {
                PolicyFolder rcd = new PolicyFolder();
                rcd.Folder = dir.Name;
                FolderRec.Add(rcd);
            }
           
                var qryAll = FolderRec;
                dataGridView1.DataSource = qryAll;
           
 
 
            dataGridView1.RowHeadersVisible = false;
            string sTip = "Click on header to sort grid";
            ssiMethods.clsStaticMethods.SetupGrid(dataGridView1, Color.LightBlue, false);
            int i = 0;
            DataGridViewColumn column = dataGridView1.Columns[i];
            column.Visible = true;
            column.Width = 450;
            column.HeaderText = "Folder";
            column.HeaderCell.ToolTipText = sTip;
        }

Tags:

CSharp

string.Fomat() is may favorite method in c#

by ssi 18. October 2013 16:54
  static void Main(string[] args)
        {
            Console.WriteLine("string.Fomat() is may favorite method in c#");
            string sOuput = string.Format("Whatever you put after the comma converts to a string");
 
            Console.WriteLine(sOuput);
            object[] array = new object[8];
            array[0] = 1000;
            array[1] = DateTime.Parse("1/1/2013");
            array[2] = "Cadence bank";
            array[3] = DateTime.Now;
            array[4] = 'A';
            array[5] = null;
            array[6] = true;
            array[7] = "ross";
           for (int i = 0; i <= array.GetUpperBound(0); i++)
			{
                 sOuput = string.Format("{0}", array[i]);
                 Console.WriteLine(sOuput);
			}  
            Console.ReadLine();
 
        }

Tags:

CSharp

Set DataGridView Columns

by ssi 11. September 2013 10:57

private void SetColumns()
{
ssiMethods.clsStaticMethods.SetupGrid(dataGridView1, Color.LightSalmon, false);



for (int c = 0; c &lt; dataGridView1.Columns.Count; c++)
{
DataGridViewColumn column = dataGridView1.Columns[c];
column.HeaderText = column.HeaderText.Replace(&quot;_&quot;, &quot; &quot;).ToUpper();

column.Width = 125;
if (column.HeaderText.Contains(&quot;AMOUNT&quot;))
{
column.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
column.DefaultCellStyle.Format = &quot;##0.00&quot;;
column.Width = 100;
}
if (column.HeaderText.Contains(&quot;STATUS&quot;))
column.Width = 85;
}

}

Tags: , ,

Blog | CSharp

Arrays

by ssi 4. May 2013 20:04

Initializing Arrays

C# provides simple and straightforward ways to initialize arrays at declaration time by enclosing the initial values in curly braces ({}). The following examples show different ways to initialize different kinds of arrays.

Note   If you do not initialize an array at the time of declaration, the array members are automatically initialized to the default initial value for the array type. Also, if you declare the array as a field of a type, it will be set to the default value null when you instantiate the type.

Single-Dimensional Array

 
 
int[] numbers = new int[5] {1, 2, 3, 4, 5};
string[] names = new string[3] {"Matt", "Joanne", "Robert"};

You can omit the size of the array, like this:

 
 
int[] numbers = new int[] {1, 2, 3, 4, 5};
string[] names = new string[] {"Matt", "Joanne", "Robert"};

You can also omit the new operator if an initializer is provided, like this:

 
 
int[] numbers = {1, 2, 3, 4, 5};
string[] names = {"Matt", "Joanne", "Robert"};

Multidimensional Array

 
 
int[,] numbers = new int[3, 2] { {1, 2}, {3, 4}, {5, 6} };
string[,] siblings = new string[2, 2] { {"Mike","Amy"}, {"Mary","Albert"} };

You can omit the size of the array, like this:

 
 
int[,] numbers = new int[,] { {1, 2}, {3, 4}, {5, 6} };
string[,] siblings = new string[,] { {"Mike","Amy"}, {"Mary","Albert"} };

You can also omit the new operator if an initializer is provided, like this:

 
 
int[,] numbers = { {1, 2}, {3, 4}, {5, 6} };
string[,] siblings = { {"Mike", "Amy"}, {"Mary", "Albert"} };

Jagged Array (Array-of-Arrays)

You can initialize jagged arrays like this example:

 
 
int[][] numbers = new int[2][] { new int[] {2,3,4}, new int[] {5,6,7,8,9} };

You can also omit the size of the first array, like this:

 
 
int[][] numbers = new int[][] { new int[] {2,3,4}, new int[] {5,6,7,8,9} };

-or-

 
 
int[][] numbers = { new int[] {2,3,4}, new int[] {5,6,7,8,9} };

Notice that there is no initialization syntax for the elements of a jagged array.

Accessing Array Members

Accessing array members is straightforward and similar to how you access array members in C/C++. For example, the following code creates an array called numbers and then assigns a 5 to the fifth element of the array:

Tags:

CSharp

private void btnSave_Click(object sender, EventArgs e)

by ssi 4. May 2013 17:49
{
string sSQL = &quot;UPDATE tbl_Loan SET BorrowerName = @BorrowerName &quot;
+ &quot;,DateCreated = @DateCreated&quot;
+ &quot;,DateDue = @DateDue&quot;
+ &quot;,DateClosedString = @DateClosedString&quot;
+ &quot;,Suspensedescription = @Suspensedescription&quot;
+ &quot; WHERE Id = @RecordId &quot;;

OleDbConnection objConn = new System.Data.OleDb.OleDbConnection(ConnectionString);

OleDbCommand Cmd = new OleDbCommand(sSQL, objConn);

Cmd.Parameters.Add(new OleDbParameter(&quot;@BorrowerName&quot;, txtBorrowerName.Text));
Cmd.Parameters.Add(new OleDbParameter(&quot;@DateCreated&quot;, txtDateCreated.Text));
Cmd.Parameters.Add(new OleDbParameter(&quot;@DateDue&quot;, txtDateDue.Text));
Cmd.Parameters.Add(new OleDbParameter(&quot;@DateClosedString&quot;, txtClosed.Text));
Cmd.Parameters.Add(new OleDbParameter(&quot;@Suspensedescription&quot;, txtDesc.Text));
Cmd.Parameters.Add(new OleDbParameter(&quot;@RecordId&quot;, RecordID));

objConn.Open();
int nResult = Cmd.ExecuteNonQuery();
objConn.Close();
lblResult.Text = string.Format(&quot;Result: {0}&quot;, nResult == 1 ? &quot;saved&quot; : &quot;err saving&quot;);
}

Tags: , ,

Blog | CSharp

string sAccessFilePath = SuspenseMgrAccess

by ssi 4. May 2013 17:46

 

 

Properties.Settings.Default.AccessFilePathAndname;

if (File.Exists(sAccessFilePath))
{
ConnectionString = SuspenseMgrAccess.Properties.Settings.Default.AccessConnectionString;
OleDbConnection objConn = new System.Data.OleDb.OleDbConnection(ConnectionString);

String QueryString = &quot;SELECT * FROM tbl_Loan&quot;;
OleDbCommand Cmd = new OleDbCommand(QueryString, objConn);

objConn.Open();
OleDbDataReader reader = Cmd.ExecuteReader();

OleDbDataAdapter dataAdapter = new OleDbDataAdapter(QueryString, objConn);
OleDbCommandBuilder commandBuilder = new OleDbCommandBuilder(dataAdapter);
DataTable table = new DataTable();
dataAdapter.Fill(table);

dataGridView1.DataSource = table;
objConn.Close();
}

Tags: , ,

Blog | CSharp

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

"Courage is fear holding on a minute longer"
General George Patton Jr