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;
}
4593d55f-304e-44db-a146-a0f484ebadc5|0|.0|96d5b379-7e1d-4dac-a6ba-1e50db561b04
Tags: Timespan, DateTime
CSharp
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);
}
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;
}
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();
}
70f07ef0-a431-4309-8467-24eade389044|0|.0|96d5b379-7e1d-4dac-a6ba-1e50db561b04
Tags: string.Fomat
CSharp
by ssi
11. September 2013 10:57
private void SetColumns()
{
ssiMethods.clsStaticMethods.SetupGrid(dataGridView1, Color.LightSalmon, false);
for (int c = 0; c < dataGridView1.Columns.Count; c++)
{
DataGridViewColumn column = dataGridView1.Columns[c];
column.HeaderText = column.HeaderText.Replace("_", " ").ToUpper();
column.Width = 125;
if (column.HeaderText.Contains("AMOUNT"))
{
column.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
column.DefaultCellStyle.Format = "##0.00";
column.Width = 100;
}
if (column.HeaderText.Contains("STATUS"))
column.Width = 85;
}
}
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:
f9d4f967-c13c-459f-8ee6-d23c248cc057|0|.0|96d5b379-7e1d-4dac-a6ba-1e50db561b04
Tags: Arrays
CSharp
by ssi
4. May 2013 17:49
{
string sSQL = "UPDATE tbl_Loan SET BorrowerName = @BorrowerName "
+ ",DateCreated = @DateCreated"
+ ",DateDue = @DateDue"
+ ",DateClosedString = @DateClosedString"
+ ",Suspensedescription = @Suspensedescription"
+ " WHERE Id = @RecordId ";
OleDbConnection objConn = new System.Data.OleDb.OleDbConnection(ConnectionString);
OleDbCommand Cmd = new OleDbCommand(sSQL, objConn);
Cmd.Parameters.Add(new OleDbParameter("@BorrowerName", txtBorrowerName.Text));
Cmd.Parameters.Add(new OleDbParameter("@DateCreated", txtDateCreated.Text));
Cmd.Parameters.Add(new OleDbParameter("@DateDue", txtDateDue.Text));
Cmd.Parameters.Add(new OleDbParameter("@DateClosedString", txtClosed.Text));
Cmd.Parameters.Add(new OleDbParameter("@Suspensedescription", txtDesc.Text));
Cmd.Parameters.Add(new OleDbParameter("@RecordId", RecordID));
objConn.Open();
int nResult = Cmd.ExecuteNonQuery();
objConn.Close();
lblResult.Text = string.Format("Result: {0}", nResult == 1 ? "saved" : "err saving");
}
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 = "SELECT * FROM tbl_Loan";
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();
}
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]);
}
}
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();
}
b5c2fd4b-095c-4abe-b7ce-c4d175f16586|0|.0|96d5b379-7e1d-4dac-a6ba-1e50db561b04
Tags: LINQ, GroupBy
CSharp