PDA

View Full Version : کلاس و ویندوز اپلیکیشن



mr . saeed
دوشنبه 05 اردیبهشت 1390, 11:03 صبح
سلام دوستای عزیزم
من یه سری مشکل دارم که امید وارم با کمک شما بتونم حل کنم
اول اینکه من تقریبا Console.app رو بلدم اما با win.app مشکل دارم در استفاده و فراخوانی کلاس ها
برای مثال من یک کلاس بررسی تاریخ دارم که تا حالا ازش توی کنسول استفاده میکردم حالا میخوام توی win.app استفاده کنم اما نمیدونم چجوری پارامتر ها رو ارسال و در یافت کنم
لطفا راهنماییم کنید

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace EmployeeProject
{
// Date class definition
public class Date

{
private int month; // 1-12
private int day; // 1-31 based on month
private int year; // any year

// constructor confirms proper value for month;
// call method CheckDay to confirm proper
// value for day.
public Date(int theMonth , int theDay, int theYear)
{
// validate month
if (theMonth > 0 && theMonth <= 12)
month = theMonth;

else
{
month = 1;
Console.WriteLine(
"Month {0} invalid. Set to month 1.", theMonth);
}

year = theYear; // could validate year
day = CheckDay(theDay); // validate day

} // end Date constructor

// utility method confirms proper day value
// based on month and year
private int CheckDay(int testDay)
{
int[] daysPerMonth = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };

// check if day in range for month
if (testDay > 0 && testDay <= daysPerMonth[month])
return testDay;

// check for leap year
if (month == 2 && testDay == 29 &&
(year % 400 == 0 ||
(year % 4 == 0 && year % 100 != 0)))
return testDay;

Console.WriteLine(
"Day {0} invalid. Set to day 1.", testDay);

return 1; // leave object in consistent state
}

// return date string as month/day/year
public string ToDateString()
{
return month + "/" + day + "/" + year;
}

} // end class Date
}





این کد کلاس تاریخ .. حالا تو فرم میخوام 3 تا تکست باکس باشه که تاریخ رو از توی اون بگیره
بررسی کنه توسط کلاس و بعد توی یک لیبل به صورت استرینگ چاپ کنه

mr . saeed
دوشنبه 05 اردیبهشت 1390, 18:59 عصر
gلطفا بنده رو راهنمایی کنید


------------------------------------------

خودم متوجه شدم
توی قسمت مورد نیاز کافیه
Date HireDate = new Date(Convert.ToInt32(textBox7.Text),12222,3000);

label8.Text = HireDate.ToDateString();

این کار رو انجام بدم