10 Replies - 1237 Views - Last Post: 12 March 2010 - 11:45 PM Rate Topic: -----

#1 javafreak  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 11
  • View blog
  • Posts: 97
  • Joined: 21-September 09

help in windows form number format to be adopted would be as follows

Posted 12 March 2010 - 07:22 PM

Add a book item. Each book should have following attributes:
Call Number
ISBN/Name of book
Title

Author name

The call number format to be adopted would be as follows:
(First 2 alphabets of title)-(first 2 alphabets of author)-sequence number of book
XX-XX-NNN

The ISBN number format to be adopted would be as follows:
(Numeric code for subject)-(sequence number) NNN-NNNN
It would be unique for each specific title/author combination


how do i implement this in my code any help or hint

i am confused where to start i have to implement it in windows form

Is This A Good Question/Topic? 0
  • +

Replies To: help in windows form number format to be adopted would be as follows

#2 javafreak  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 11
  • View blog
  • Posts: 97
  • Joined: 21-September 09

Re: help in windows form number format to be adopted would be as follows

Posted 12 March 2010 - 07:28 PM

i need help to code further i thank you all for this :-(
Was This Post Helpful? 0
  • +
  • -

#3 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1659
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: help in windows form number format to be adopted would be as follows

Posted 12 March 2010 - 07:46 PM

Show us the code you've written thus far so we can help. We're not just going to post the source code here without seeing what you've tried thus far.

Also, there was no need to bump the topic, you posted the initial question just 22 minutes ago so please show some patience :)
Was This Post Helpful? 0
  • +
  • -

#4 MentalFloss  Icon User is offline

  • .
  • member icon

Reputation: 577
  • View blog
  • Posts: 1,500
  • Joined: 02-September 09

Re: help in windows form number format to be adopted would be as follows

Posted 12 March 2010 - 09:12 PM

Quote

Add a book item. Each book should have following attributes:
Call Number
ISBN/Name of book
Title

Author name

The call number format to be adopted would be as follows:
(First 2 alphabets of title)-(first 2 alphabets of author)-sequence number of book
XX-XX-NNN

The ISBN number format to be adopted would be as follows:
(Numeric code for subject)-(sequence number) NNN-NNNN
It would be unique for each specific title/author combination


So, let's break it down. You need a "book item" - that's a class.

public class Book
{

}



Next, you need a call number. The call number spec states as follows:

Quote

The call number format to be adopted would be as follows:
(First 2 alphabets of title)-(first 2 alphabets of author)-sequence number of book
XX-XX-NNN


What data type might that be? Well, we see that there's some characters there so it's probably a string.

OK. So, what's next? ISBN. ISBN's spec is:

Quote

The ISBN number format to be adopted would be as follows:
(Numeric code for subject)-(sequence number) NNN-NNNN
It would be unique for each specific title/author combination


So, that looks like a string too. So far, you have two string fields that need to be added to that class.

Moving on...

The next thing you need is a title. The title is the title of the book, so again - string.

After that, we have Author name which obviously is going to be a string as well.

Essentially, all of the fields of the class "Book" need to be a string.

Once that's done, you need some validation on ISBN and call number. Everything else appears to be able to be treated as-is.

So, think you can create this class and show us what you come up with?

We'll help you after that. Have fun with it. It's a trial and error process. You don't learn unless you make mistakes so don't let the problems you encounter get you down. Just keep on pushing through it and you'll get it.

Take care.
Was This Post Helpful? 1
  • +
  • -

#5 javafreak  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 11
  • View blog
  • Posts: 97
  • Joined: 21-September 09

Re: help in windows form number format to be adopted would be as follows

Posted 12 March 2010 - 09:23 PM

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

namespace libarymangementsystem
{
    public partial class Form1 : Form
    {
        SqlDataAdapter da1;
        DataSet ds;
        string cstr;
        
        
        //SqlConnection con;

        public Form1()
        {
            InitializeComponent();
        }

        public void Form1_Load(object sender, EventArgs e)
        {
            cstr = "server=DESKTOP;user id=sa;password=admin;database=master";
            ds = new DataSet();
            Fill1();
            }
        private void Fill1()
        {
            string qry = "select * from Employe_details";
            SqlConnection con = new SqlConnection(cstr);
            da1 = new SqlDataAdapter(qry, con);
            da1.Fill(ds, "Employe_details");
            }

        private void label17_Click(object sender, EventArgs e)
        {

        }

        private void tabPage1_Click(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {

                if (validate1())
                {

                    DataTable tab = ds.Tables["Employe_details"];
                    DataRow row = tab.NewRow();
                    row[0] = int.Parse(textBox1.Text);
                    row[1] = textBox2.Text;
                    row[2] = textBox3.Text;
                    row[3] = int.Parse(textBox4.Text);
                    row[4] = textBox5.Text;

                    tab.Rows.Add(row);
                    MessageBox.Show("Your record has been successfully added");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }



        private bool validate1()
        {

            if (textBox1.Text.Length > 0 && textBox2.Text.Length > 0 && textBox3.Text.Length > 0 && textBox4.Text.Length > 0 && textBox5.Text.Length > 0)
                return true;
            else
            {
                if (textBox1.Text == "")
                    MessageBox.Show("Roll Number field cannot be left blank...", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);

                if (textBox2.Text == "")
                    MessageBox.Show(" First Name field cannot be left blank...", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);

                if (textBox3.Text == "")
                    MessageBox.Show("Last Name field cannot be left blank...", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);

                if (textBox4.Text == "")
                    MessageBox.Show("Father's Name field cannot be left blank...", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);

                if (textBox5.Text == "")
                    MessageBox.Show("Father's Name field cannot be left blank...", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            return false;

        }

                                                                                                                                                     
      
        private void button2_Click(object sender, EventArgs e)
        {
            MessageBox.Show("sam");
        }

        private void Form1_FormClosed(object sender, FormClosedEventArgs e)
        {
            SqlCommandBuilder cb1 = new SqlCommandBuilder(da1);
            da1.InsertCommand = cb1.GetInsertCommand();
            da1.UpdateCommand = cb1.GetUpdateCommand();
            da1.DeleteCommand = cb1.GetDeleteCommand();
            da1.Update(ds, "Employe_details");
        }

        private void button6_Click(object sender, EventArgs e)
        {
            try
            {

                if (validate2())
                {

                    DataTable tab = ds.Tables["Employe_details"];
                    DataRow row = tab.NewRow();
                    row[0] = textBox7.Text;
                    row[1] = textBox8.Text;
                    row[2] = textBox9.Text;
                    row[3] = textBox10.Text;                   
                    tab.Rows.Add(row);
                    MessageBox.Show("Your record has been successfully added");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
        private bool validate2()
        {

            if (textBox1.Text.Length > 0 && textBox2.Text.Length > 0 && textBox3.Text.Length > 0 && textBox4.Text.Length > 0 && textBox5.Text.Length > 0)
                return true;
            else
            {
                if (textBox7.Text == "")
                    MessageBox.Show("Call Number field cannot be left blank...", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);

                if (textBox8.Text == "")
                    MessageBox.Show(" ISBN Name field cannot be left blank...", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);

                if (textBox9.Text == "")
                    MessageBox.Show(" TITLE field cannot be left blank...", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);

                if (textBox10.Text == "")
                    MessageBox.Show("AUTHOR 's Name field cannot be left blank...", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);

              
            }
            return false;

        }
        private void textbox7_Validating(object sender, System.ComponentModel.CancelEventArgs e)
        {
            string errorMsg;
            if (!Validc(textBox7.Text, out errorMsg))
            {
                e.Cancel = true;
                textBox7.Select(0, textBox7.TextLength);
                this.errorProvider1.SetError(textBox7, errorMsg);
            }
        }


        }
    }





i need help in validate2() functions to implement check there ????

This post has been edited by javafreak: 12 March 2010 - 09:28 PM

Was This Post Helpful? 0
  • +
  • -

#6 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1659
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: help in windows form number format to be adopted would be as follows

Posted 12 March 2010 - 10:06 PM

Ok, hopefully this will be the last step in the fact finding process. Are you getting any error messages, if so you need to let us know that now (paste them word for word).
Was This Post Helpful? 0
  • +
  • -

#7 javafreak  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 11
  • View blog
  • Posts: 97
  • Joined: 21-September 09

Re: help in windows form number format to be adopted would be as follows

Posted 12 March 2010 - 10:21 PM

need hint how to do this

Add a book item. Each book should have following attributes:
Call Number
ISBN/Name of book
Title

Author name

The call number format to be adopted would be as follows:
(First 2 alphabets of title)-(first 2 alphabets of author)-sequence number of book
XX-XX-NNN

The ISBN number format to be adopted would be as follows:
(Numeric code for subject)-(sequence number) NNN-NNNN
It would be unique for each specific title/author combination


how do i implement this in my code any help or hint


how to enter value in text box in this manner

XX-XX-NNN - - how so it come i donot know :-((
Was This Post Helpful? 0
  • +
  • -

#8 MentalFloss  Icon User is offline

  • .
  • member icon

Reputation: 577
  • View blog
  • Posts: 1,500
  • Joined: 02-September 09

Re: help in windows form number format to be adopted would be as follows

Posted 12 March 2010 - 10:46 PM

Quote

The call number format to be adopted would be as follows:
(First 2 alphabets of title)-(first 2 alphabets of author)-sequence number of book
XX-XX-NNN


OK. The first 2 characters (that's XX) are the first two characters of the title. You have the title already so look into substring().

The next 2 characters (that's also XX) is the first two characters of the author. You also already have the author so the substring method will work again.

There's a dash in between each of those. So it's as simple as concatenating the two values together:

//pseudo code
string part1 = titlePiece + "-" + authorPiece;



After that, there's the sequence number. I don't know what this is, but let's pretend it's just the ID of the book entry.

The sequence number is most likely an integer so look into parsing integers into strings.

Then, once you have all the assignments, just concatenate them together.

Any questions?

EDIT: Why the hell are you already doing a database application? This is cart before the carriage... back up and re-evaluate what's going on here. You're moving way too fast.

This post has been edited by MentalFloss: 12 March 2010 - 10:49 PM

Was This Post Helpful? 1
  • +
  • -

#9 javafreak  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 11
  • View blog
  • Posts: 97
  • Joined: 21-September 09

Re: help in windows form number format to be adopted would be as follows

Posted 12 March 2010 - 11:22 PM

  if (validate2())
                {
                  
                    string part1 = textBox9.Text + "-" + textBox10.Text+"-"+textBox7.Text;

                    textBox7.Text = part1;



how to select first 2 values from textbox9.text
Was This Post Helpful? 0
  • +
  • -

#10 javafreak  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 11
  • View blog
  • Posts: 97
  • Joined: 21-September 09

Re: help in windows form number format to be adopted would be as follows

Posted 12 March 2010 - 11:35 PM

private void button6_Click(object sender, EventArgs e)
        {
            try
            {

                if (validate2())
                {
                  
                    string part1 = left(textBox9.Text,2) + "-" + left(textBox10.Text,2)+"-"+left(textBox8.Text,3);

                    textBox7.Text = part1;

                    DataTable tab = ds.Tables["Book_Item"];
                    DataRow row = tab.NewRow();
                    row[0] = textBox7.Text;
                    row[1] = textBox8.Text;
                    row[2] = textBox9.Text;
                    row[3] = textBox10.Text;             



can you tell me where i am dong wrong :-(
Was This Post Helpful? 0
  • +
  • -

#11 javafreak  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 11
  • View blog
  • Posts: 97
  • Joined: 21-September 09

Re: help in windows form number format to be adopted would be as follows

Posted 12 March 2010 - 11:45 PM

any help ????????
public static String left(String s, int len)
        {
            return s.Substring(0, Math.Min(len, s.Length));
        }
        private void button6_Click(object sender, EventArgs e)
        {
            try
            {

                if (validate2())
                {
                  string p1=textBox9.Text.ToString();
                    string p2=textBox10.Text.ToString();
                    string p3=textBox8.Text.ToString();
                    string part1 = left(p1,2) + "-" + left(p2,2)+"-"+left(p3,3);

        
    
                    label7.Text = part1;



why its not working

This post has been edited by JackOfAllTrades: 13 March 2010 - 06:33 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1