Click here to Skip to main content
15,889,462 members
Home / Discussions / C#
   

C#

 
GeneralRe: An easy one... problems converting a decimal to an integer Pin
DaveyM692-Apr-09 5:50
professionalDaveyM692-Apr-09 5:50 
AnswerRe: An easy one... problems converting a decimal to an integer Pin
harold aptroot2-Apr-09 6:08
harold aptroot2-Apr-09 6:08 
GeneralRe: An easy one... problems converting a decimal to an integer Pin
bbranded2-Apr-09 7:06
bbranded2-Apr-09 7:06 
GeneralRe: An easy one... problems converting a decimal to an integer Pin
harold aptroot2-Apr-09 8:19
harold aptroot2-Apr-09 8:19 
GeneralRe: An easy one... problems converting a decimal to an integer Pin
Luc Pattyn2-Apr-09 8:53
sitebuilderLuc Pattyn2-Apr-09 8:53 
GeneralRe: An easy one... problems converting a decimal to an integer Pin
harold aptroot2-Apr-09 9:11
harold aptroot2-Apr-09 9:11 
AnswerRe: An easy one... problems converting a decimal to an integer Pin
Luc Pattyn2-Apr-09 8:58
sitebuilderLuc Pattyn2-Apr-09 8:58 
Question1st Post and Code snip so far Pin
stonebergftw2-Apr-09 5:03
stonebergftw2-Apr-09 5:03 
Hi I'm Tim and this is my first post. I just started coding in C# a few days ago. I'm developing a piece of software to manage some things at work. If anyone here has a few minutes, can you go over my code so far and let me know if it looks solid and please please let me know if I'm doing anything that throws up "warning flags" as far as coding style etc? Thanks in advance!

2 Forms so far.
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;
using System.Collections;

namespace WindowsFormsApplication1
{



    public partial class Form1 : Form
    {
        ArrayList vins = new ArrayList();

        public Form1()
        {
            InitializeComponent();
        }

        public void CreateDataTable()
        {
            string s1 = "Date";
            string s2 = "System.String";
            DataTable dt = new DataTable();
            dt.TableName = textBox1.Text;

            while (s1!= "Stop")
            {   
                DataColumn dc = new DataColumn();
                dc.ColumnName = s1;
                dc.Caption = dc.ColumnName;
                dc.DataType = System.Type.GetType(s2);
                dc.DefaultValue = null;
                dt.Columns.Add(dc);

                switch (s1)
                {
                    case "Date":
                        s1 = "Member#";
                        s2 = "System.Int32";
                        break;
                    case "Member#":
                        s1 = "VIN#";
                        s2 = "System.Int32";
                        break;
                    case "VIN#":
                        s1 = "Location Name";
                        s2 = "System.String";
                        break;
                    case "Location Name":
                        s1 = "Address";
                        s2 = "System.String";
                        break;
                    case "Address":
                        s1 = "City";
                        s2 = "System.String";
                        break;
                    case "City":
                        s1 = "State";
                        s2 = "System.String";
                        break;
                    case "State":
                        s1 = "Zip";
                        s2 = "System.Int32";
                        break;
                    case "Zip":
                        s1 = "Phone";
                        s2 = "System.String";
                        break;
                    case "Phone":
                        s1 = "Fax";
                        s2 = "System.String";
                        break;
                    case "Fax":
                        s1 = "Email";
                        s2 = "System.String";
                        break;
                    case "Email":
                        s1 = "Stop";
                        break;
                }
            }
            DataRow dr;
            dr = CreateTableRow(dt);
        }

        public DataRow CreateTableRow(DataTable dtPass)
        {
            // Check VIN against DataTable
            DataRow myRow;
            myRow = dtPass.NewRow();
            DateTime today = DateTime.Now;
            string date;
            int year = today.Year;
            int month = today.Month;
            int day = today.Day;
            date = month + "\\" + day + "\\" + year;
            // From Form1
            myRow[0] = date;
            myRow[1] = int.Parse(textBox1.Text);
            myRow[2] = int.Parse(textBox2.Text); // Change to a while statement to add all vins in ArrayList and also call the VIN checking function
            
            // From Form2
            //dr[3] = 
            return myRow;
        }

        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void AddTruck()
        {
            try
            {
                if (textBox2.Text != null)
                {
                    long vinNumber = long.Parse(textBox2.Text);
                    vins.Add(vinNumber);
                    textBox2.Text = "";
                    label3.Text = label3.Text + vinNumber + Environment.NewLine;
                }
            }
            catch (FormatException)
            {
                textBox2.Text = "";
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Form2 f = new Form2(this);
            //f.Show();   // This shows Form2

            AddTruck();
            // CheckforDuplicateVin();

            /* 
             * Check DB for Member#
             * Check DB for duplicate VIN#
             * 
             * If Member#.!Exist && !duplicateVin
             * {
             *      Create DataTable for new member
             *      Open a form to fill in the location information
             *      Open the new DataTable
             *      Save the DataTable to the DataSheet/Database
             * }
             * Elseif Member#.Exist && !duplicateVin
             * {
             *      Open DataTabel for current member
             *      Add new VIN to the DataSheet/Database
             * }
             * Else
             * {
             *      Output duplicate VIN error message
             * }
            */
        }

        private void OpenContactInfo()
        {
            //Open form 2
        }
        private void button2_Click(object sender, EventArgs e)
        {
            /* Check DB for an existing member
             * If No, open Form2
             * If Yes, Pull data from Data Table
             * Do not open Form2
             * Possibly open a Form for confirmation 
            */

            // Check ArrayList vin vs DB for a duplicate

            // Edit the line below so that it only runs if the member is new
            
            // If !ExistingMember
            //{A
            try // Edit this so that it catches non numerical character entry
            {
                if (textBox1.Text != null)
                {
                    
                    CreateDataTable();
                    // Call OpenContactInfo
                }
            }
            catch (FormatException)
            {
                textBox1.Text = "";
            }
            //}A


        }
    }
}


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 Form2 : Form
    {
        Form1 f;

        public Form2()
        {
            InitializeComponent();
        }

        public Form2(Form1 fr1)
        {
            InitializeComponent();
            f = new Form1();
            f = fr1;

        }

        private void Form2_Load(object sender, EventArgs e)
        {

        }
    }
}

AnswerRe: 1st Post and Code snip so far Pin
Judah Gabriel Himango2-Apr-09 5:45
sponsorJudah Gabriel Himango2-Apr-09 5:45 
GeneralRe: 1st Post and Code snip so far Pin
stonebergftw2-Apr-09 6:02
stonebergftw2-Apr-09 6:02 
GeneralRe: 1st Post and Code snip so far Pin
Judah Gabriel Himango2-Apr-09 6:04
sponsorJudah Gabriel Himango2-Apr-09 6:04 
AnswerRe: 1st Post and Code snip so far Pin
Simon P Stevens2-Apr-09 5:52
Simon P Stevens2-Apr-09 5:52 
GeneralRe: 1st Post and Code snip so far Pin
stonebergftw2-Apr-09 6:44
stonebergftw2-Apr-09 6:44 
GeneralRe: 1st Post and Code snip so far Pin
Simon P Stevens2-Apr-09 21:20
Simon P Stevens2-Apr-09 21:20 
GeneralRe: 1st Post and Code snip so far Pin
stonebergftw6-Apr-09 7:29
stonebergftw6-Apr-09 7:29 
QuestionVisualizing Windows Form interactively!!!! Pin
Rajdeep.NET is BACK2-Apr-09 4:57
Rajdeep.NET is BACK2-Apr-09 4:57 
QuestionRe: Visualizing Windows Form interactively!!!! Pin
led mike2-Apr-09 5:02
led mike2-Apr-09 5:02 
AnswerRe: Visualizing Windows Form interactively!!!! Pin
Rajdeep.NET is BACK2-Apr-09 5:13
Rajdeep.NET is BACK2-Apr-09 5:13 
GeneralRe: Visualizing Windows Form interactively!!!! Pin
led mike2-Apr-09 5:41
led mike2-Apr-09 5:41 
AnswerRe: Visualizing Windows Form interactively!!!! Pin
Alok Sharma ji2-Apr-09 12:38
Alok Sharma ji2-Apr-09 12:38 
AnswerRe: Visualizing Windows Form interactively!!!! Pin
DaveyM692-Apr-09 5:26
professionalDaveyM692-Apr-09 5:26 
AnswerRe: Visualizing Windows Form interactively!!!! Pin
Alok Sharma ji3-Apr-09 6:57
Alok Sharma ji3-Apr-09 6:57 
QuestionDatagridview ComboboxColumn Error: System.ArgumentException: The value of DatagridviewComboboxCell is invalid [modified] Pin
Priya Prk2-Apr-09 4:37
Priya Prk2-Apr-09 4:37 
AnswerRe: Datagridview ComboboxColumn Error: System.ArgumentException: The value of DatagridviewComboboxCell is invalid Pin
Rajdeep.NET is BACK2-Apr-09 4:47
Rajdeep.NET is BACK2-Apr-09 4:47 
GeneralRe: Datagridview ComboboxColumn Error: System.ArgumentException: The value of DatagridviewComboboxCell is invalid Pin
Priya Prk2-Apr-09 4:53
Priya Prk2-Apr-09 4:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.