“博士书阁”管理系统将为一位复旦大学经济史博士开发,并期望成为一个产品。借此站在公司实际项目与培训的角度写一些开发指导示例("增(insert)/删(delete)/改(update)/查(select)"为主线,展示在不同架构下的工作流程,方便初学者直接进入相应架构下的开发学习),望喜欢。
/*考虑到Oracle/sqlserver2005对机器的要求及一些人不熟悉,以下都采用轻量级数据库,真正开发最好Java对Oracle/MySQL,.NET对sqlserver*/
我将继续升级它们...
*******************************************************
[Java Web]/*Eclipse3.3+MyEclipse6.0+Tomcat6+MySQL5.1.2*/
1、html+javascript+jsp+servlet+javabean+MySQL/*未含css+AJAX+工厂*/,示例源代码doctor-bookge.rar]/*下载用户名/密码:gold105wj/123456*/
2、struts2+hibernate+spring+MySQL/*未含AJAX*/
/*已写好,由于本站一篇文章最多允许上传3个文件,传不上,所以想要的和我联系,我通过其他方式给你*/
3、
4、
------------------------------------------------------------------------------------------------------------
[.net] /*Visual Studio2008*/
1、ASP.NET(C#)+Access,示例源代码doctor-bookge-cs.rar]/*下载用户名/密码:gold105wj/123456*/
doctor-bookge-cs.rar全部页面截图与源代码.doc]/*下载用户名/密码:gold105wj/123456*/
1、IIS组件安装
[方法1]开始菜单->控制面板->添加或删除程序->添加/删除Windows组件->勾上”Internet信息服务”->光驱中插入XP盘
->下一步
[方法2]光驱插入XP盘进入安装界面->点击安装Windows组件直接进入IIS安装
2、IIS配置位置
开始菜单->控制面板->管理工具->Internet信息服务
3、在IIS中发布WEB项目
进入IIS->Internet信息服务->XX(本地计算机)- >网站->默认网站,右键菜单->新建->虚拟目录(V)…->下一步->别名(输入一个在URL中用的虚拟目录名,例如testweb)- >选择WEB项目的目录路径->然后全部默认直到完成。
访问URL:http://localhost/testweb/Default.aspx
/*在一个站点右键菜单可以看到该站点的所有属性信息并可修改*/
代码片段系列
//1========================================================================
// [C#访问sqlserver2005全代码(实际开发考虑带参数的sql)]
protected void Button1_Click(object sender, EventArgs e)
{//登录查询(select)用户是否存在
SqlCommand cmd = null;//创建命令对象引用
SqlDataReader dr = null;//创建存放返回数据集对象引用
string strConn = "Server=.;DataBase=bookge;UID=sa;PWD=123;";//sqlserver连接字符串
try
{//访问数据库查询"用户名+密码"是否存在
cmd = new SqlCommand();//创建命令对象
cmd.Connection = new SqlConnection(strConn );//创建数据库连接对象
cmd.Connection.Open();//打开数据库连接
cmd.CommandText = "select * from bookge_user_tab where name='"+tbx_name .Text +"' and password='"+tbx_password .Text +"'";//准备命令字符串
dr = cmd.ExecuteReader();//执行查询并将返回数据集赋给dr
if (dr.Read())
{//用户存在则跳转到主页面
Session["Admin"] = 1;
Response.Redirect("2c-hd-ft-fixed.htm");
}
else {//用户不存在给出提示信息
tbx_name.Text = "failed user not exist";
}
dr.Close();//关闭数据集对象
cmd.Connection.Close();//关闭数据库连接对象
}
catch (Exception ex) {//捕获(数据库访)问异常并给出提示信息
tbx_name.Text = ex.Message;
}
}
protected void Button3_Click(object sender, EventArgs e)
{//增加(insert)/修改(update)/删除(delete)
SqlCommand cmd = null;//创建命令对象引用
string strConn = "Server=.;DataBase=bookge;UID=sa;PWD=123;"; //sqlserver连接字符串
try
{//访问数据库执行命令
cmd = new SqlCommand();//创建命令对象
cmd.Connection = new SqlConnection(strConn );//创建数据库连接对象
cmd.Connection.Open();//打开数据库连接
准备命令字符串
//cmd.CommandText = "insert into bookge_user_tab(name,password) values('"+tbx_name .Text +"','"+tbx_password .Text +"')";
//cmd.CommandText = "update bookge_user_tab set name='"+tbx_name .Text +"',password='"+tbx_password .Text +"' where id=11";
cmd.CommandText = "delete from bookge_user_tab where id=11";
int x=cmd.ExecuteNonQuery();//执行命令
cmd.Connection.Close();//关闭连接
}
catch (Exception ex) {//捕获(数据库访)问异常并给出提示信息
tbx_name.Text = ex.Message;
}
}
//2============================================================================
//[C#类及对象]值/引用传递示例2008.11.19
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace value_ref
{
public class Child
{
private int age;
private string name;
// 不带参数的构造函数
public Child()
{
this.name = "none";
}
// 带参数的构造函数
public Child(string name, int age)
{
this.name = name;
this.age = age;
}
// 输出方法
public void PrintChild()
{
Console.WriteLine("{0}, {1} years old.", name, age);
}
public int GetAge() { return age; }
public void SetAge(int age) { this.age = age; }
}
class Program
{
public static void AddOne(int a)
{//(值类型)值传递
a++;
}
public static void AddOne(ref int a)
{//(值类型)引用传递(本质为值传递)
a++;
}
public static void AddOne(Child a)
{//(引用类型)值传递
a.SetAge(a.GetAge ()+1);
}
public static void AddOne(ref Child a)
{//(引用类型)引用传递(本质为值传递)
a.SetAge(a.GetAge() + 1);
}
static void Main(string[] args)
{
Console.WriteLine("-------(1)------(值类型)值传递-------------------");
int a = 3;
Console.WriteLine("调用AddOne之前,a={0}", a);
AddOne(a);
Console.WriteLine("调用AddOne之后,a={0}", a);
Console.WriteLine("------(2)-------(值类型)引用传递(本质为值传递)-------------------");
int x = 3;
Console.WriteLine("调用AddOne(ref)之前,x={0}", x);
AddOne(ref x);
Console.WriteLine("调用AddOne(ref)之后,x={0}", x);
Console.WriteLine("-----(3)(4)--------(引用类型)值/引用传递-------------------");
Child aa = new Child("rose", 18);
AddOne(aa);
aa.PrintChild();
AddOne(ref aa);
aa.PrintChild();
//除(1)外(2)-(4)都操作传进去的变量(包括基本数据类型的变量+对象)
Console.ReadLine();
}
}
}
//3============================================================================
//[C#对象作为数据成员构造(1)-(4)]示例2008.11.25
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace test
{
//对象作为数据成员
class House
{
private string position;
private float area;
public House() { Console.WriteLine("House()[house.position:{0} house.area:{1}]", position, area); }
public House(string position, float area)
{
this.position = position; this.area = area;
Console.WriteLine("House(string position, float area)[house.position:{0} house.area:{1}]", position, area);
}
public string GetPosition() { return position; }
public float GetArea() { return area; }
}
class Person
{//对象作为数据成员构造(1)-(4)
private string name;
private House house = new House("9-1-8",90.77f);//(1)/*不建议这样用,应在构造函数中构造house对象*/
public Person()
{ //(2)
house = new House();
Console.WriteLine("(2)Person()[person.name:{0} his house.position:{1} his house.area:{2}]", name, house.GetPosition(), house.GetArea());
}
public Person(string name)
{//(3)
house = new House("琴苑9-9-9", 90.77f);
Console.WriteLine("(3)Person(string name)[person.name:{0} his house.position:{1} his house.area:{2}]", name, house.GetPosition(), house.GetArea());
}
public Person(string name, House house)
{//(4)
this.house = house;
Console.WriteLine("(4)Person(string name, House house)[person.name:{0} his house.position:{1} his house.area:{2}]", name, house.GetPosition(), house.GetArea());
}
public House GetHouse() { return house; }
}
class Program
{
static void Main(string[] args)
{
Console.WriteLine("------(1)/*不建议这样用,应在构造函数中构造house对象*/-------------");
Console.WriteLine("------(2)-------------");
new Person().GetHouse();
Console.WriteLine("------(3)-------------");
new Person("xu");
Console.WriteLine("------(4)-------------");
House house = new House("育德六期", 100.00f);
new Person("xu", house);
Console.ReadLine();
}
}
}
}
//4============================================================================
//[C#继承]示例2008.11.26
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Inheritance
{//类的继承:解决代码重用
class Circle {
protected double r;
public Circle() { }
public Circle(double r) { this.r = r; }
public double Area() { return 3.14 * r * r; }
public virtual void Print() { Console.WriteLine("r:{0}",r); }
}
class Cylinder : Circle {
//protected double r;
//protected new double r;
private double h;
public Cylinder() {}
//(1)调用父类构造方法
public Cylinder(double r, double h):base(r) {
//this.r = r;
this.h = h;
}
//(2)方法重写:[1]-[2],<1>-<2>四种写法都可以
//public new double Area() { return 0; }//[1]
public double Area(){ return 2*base.Area()+2*3.14*r*h; }//[2]
//public void Print(){ }//<1>
public override void Print()//<2>
{
base.Print(); Console.WriteLine("h:{0}",h);
}
}
class Program
{
static void Main(string[] args)
{
new Cylinder(); new Cylinder(2, 5); Console.ReadLine();
}
}
}