明天,订餐系统要正式投入使用啦,好开心的感受~
从7月16日到昨天(8月6日)至,订餐系统发布算是告一段落。历经20天,一周的彻夜加班,让我有一周收获成果的自豪。这其中,当然少不了我们小组“一师傅四徒弟”五人帮的努力,在这里同样感谢其余小伙伴。今天师徒会说起这事,我和师傅说我在其中做的不是很好,师傅却不这么认为:作为一个真正上线的,投入使用的项目,能被使用就已经是与众不同了,可能这其中我们还需要有学习的地方,但依旧是很棒的成果了,要对自己的项目自信,就像我们要自信一样!
然后,我恍然遇到启明灯。是啊,我为什么要气馁?要觉得不好呢?已经做出来了,已经可以初步使用了,那就是最棒的。人生没有完美,只有更美。可能做不到一下子成功,但是我们可以修改每一个小错误,测试一遍又一遍,将系统尽可能降低到不会产生太大bug为止。
其实,这个项目认真算来也不是我们开发,只不过算是维护。系统是采用的永和系统而来,上面有很多很多师哥师姐的痕迹,这让我在敲代码的时候更有动力,可以在代码中学习师哥师姐的技术,还是一个不错的方式!
记得,这个项目起初,只是约定了10天的时间,然而临近没有做好。被用户找到了米老师,然后就是听说师傅被骂得很惨很惨~再然后就是连续一周六夜的紧急加班,到了一同吃一同住的程度。不过,也是这次加班让我深深体会到学习知识实践的重要性。相对于其他人,我的任务相对来说是最省事的。但是由于我对于用户的体验和具体流程了解的不是很合理,导致前期的工作近乎白做。当然,也正是由于前期的工作不好,让我在后面的敲代码过程中更加注重规范化,更加注重用户的体验效果。
对于这次的项目学习,虽然不是负责人,但是我也深刻体会到了一个项目的准备工作的重要性。
下面是我对于这次学习的感受:
1、项目文档一定要齐全。
2、需求分析要到位。
3、代码注释一定要有,方便你我他。
4、站在用户角度考虑问题。
5、要尽可能多测试。
6、不能盲目上手,要有一定的逻辑思考。
7、在项目进行中,万不可焦急,调整心态全身心投入。
总之,不参加项目不知道,参加了项目自己才发现:只有不努力,没有做不好!
其实,我感觉这项目对于我来说更是意义非凡。这个项目大概是最让我兴奋的生日礼物了!哈哈~
下面是系统中的部分代码及功能展示,有所欠缺,请多多包涵:
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<div id="FoodManage" class="m_Manage">
<h3>菜单设置</h3>
<div style="height: 40px">
搜索食物: <input type="text" runat="server" id="txtFood"
style="font-size:12pt;height: 26px"/>
<asp:Button ID="btnSearchFood" Text="搜索" OnClick="btnSearchFood_Click" Height="40"
Font-Bold="true" Font-Size="12" runat="server" />
<%--<asp:Label runat="server" ID="lblFood" Visible="false"></asp:Label>--%>
<%-- <asp:DropDownList ID="ddlFood" runat="server" Width="140" Height="30" Font-Size="12" OnSelectedIndexChanged="ddlFood_SelectedIndexChanged" AutoPostBack ="true" >
</asp:DropDownList>--%>
</div>
<hr />
<div>
所属类别:<asp:DropDownList ID="DDLFoodType" runat="server"
AutoPostBack="true" OnSelectedIndexChanged="DDLFoodType_SelectedIndexChanged"
Height="30px" Width="70px" Font-Size ="12">
</asp:DropDownList>
<input runat="server" id="menusTime" value="<%#menusTime%>" type="text" name="txtnowdate"
class="Wdate" οnfοcus="WdatePicker({lang:'zh-cn',readOnly:true,minDate:'%y-%M-%d'})" style ="height :30px;font-size :12pt" />
订餐时段:<asp:DropDownList
ID="DDLEatTime" runat="server" AutoPostBack="true"
OnSelectedIndexChanged="DDLFoodType_SelectedIndexChanged" Font-Size ="12" Height="30px"
Width="70px" OnTextChanged="Button1_Click2">
</asp:DropDownList>
<asp:Button ID="Button1" runat="server" Text="确定" OnClick="Button1_Click2"
Font-Bold="true" Font-Size="12" Height="40" width="70"/>
<%--<asp:Timer ID="Timer1" runat="server" Interval="1000" ></asp:Timer>--%><br />
</div>
</div>
<asp:GridView ID="GvBase" class="gv" runat="server" AutoGenerateColumns="False"
OnRowUpdating="gvFood_Updating"
DataKeyNames="foodId" BackColor="White" BorderColor="#CCCCCC" BorderStyle="None"
BorderWidth="1px" CellPadding="3" AllowPaging="True" OnPageIndexChanging="GvBase_PageIndexChanging"
HorizontalAlign="Center"
EmptyDataText="您好,没有您要查找的记录." Width="600px" Style="margin-left: 0px; margin-right: 62px"
Height="479px" >
<FooterStyle BackColor="White" ForeColor="#000066" />
<RowStyle ForeColor="#000066" HorizontalAlign="Center" />
<PagerStyle HorizontalAlign="Center" />
<HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#F7F7F7" HorizontalAlign="Center" />
<AlternatingRowStyle BackColor="#F7F7F7" />
<Columns>
<asp:BoundField DataField="foodId" HeaderText="食物编号" ReadOnly="True" ItemStyle-HorizontalAlign="Center">
<ItemStyle HorizontalAlign="Center"></ItemStyle>
</asp:BoundField>
<asp:BoundField DataField="foodName" HeaderText="食物名称" ReadOnly="True" ItemStyle-HorizontalAlign="Center">
<ItemStyle HorizontalAlign="Center"></ItemStyle>
</asp:BoundField>
<asp:BoundField DataField="price" HeaderText="食物价格" ReadOnly="True" ItemStyle-HorizontalAlign="Center">
<ItemStyle HorizontalAlign="Center"></ItemStyle>
</asp:BoundField>
<asp:TemplateField HeaderText="今日菜单">
<ItemTemplate>
<asp:CheckBox ID="ckbSelect" runat="server" AutoPostBack="true" OnLoad="ckbSelect_Load"
OnCheckedChanged="ckbSelect_CheckedChanged" />
<%--<input type="checkbox" name="conid[]" id="conid" value="<?=$row[""]?>" />--%>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="foodState" HeaderText="是否显示" Visible="false" ReadOnly="false"
ItemStyle-HorizontalAlign="Center">
<ItemStyle HorizontalAlign="Center"></ItemStyle>
</asp:BoundField>
</Columns>
</asp:GridView>
<div id="AddFood">
</div>
<h2>已选中的菜单
<asp:GridView ID="gwSelected" runat="server" AutoGenerateColumns="False"
GridLines="None" CssClass="mGrid" DataKeyNames="foodId" BackColor="White" BorderColor="#CCCCCC"
BorderStyle="None" OnPageIndexChanging="gwSelected_OnPageIndexChanging" PageSize ="10"
BorderWidth="1px" CellPadding="3" AllowPaging="True" HorizontalAlign="Center"
EmptyDataText="您好,没有您要查找的记录." Width="365px">
<FooterStyle BackColor="White" ForeColor="#000066" />
<RowStyle ForeColor="#000066" HorizontalAlign="Center" />
<PagerStyle HorizontalAlign="Center" />
<HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#F7F7F7" HorizontalAlign="Center" />
<AlternatingRowStyle BackColor="#F7F7F7" />
<Columns>
<asp:BoundField DataField="foodId" HeaderText="食物编号" ReadOnly="True" ItemStyle-HorizontalAlign="Center">
<ItemStyle HorizontalAlign="Center"></ItemStyle>
</asp:BoundField>
<asp:BoundField DataField="foodName" HeaderText="食物名称" ReadOnly="True" ItemStyle-HorizontalAlign="Center">
<ItemStyle HorizontalAlign="Center"></ItemStyle>
</asp:BoundField>
<asp:BoundField DataField="price" HeaderText="食物价格" ReadOnly="True" ItemStyle-HorizontalAlign="Center">
<ItemStyle HorizontalAlign="Center"></ItemStyle>
</asp:BoundField>
</Columns>
</asp:GridView>
</h2>
<webdiyer:AspNetPager ID="anp" runat="server">
</webdiyer:AspNetPager>
</asp:Content>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BLL;
using Entity;
using System.Data;
using System.Data.SqlClient;
using System.Collections;
namespace OrderSystem.Behind
{
public partial class NotTakeOrder : System.Web.UI.Page
{
OrderBll orderBll = new OrderBll();
public string FoodNameDetailOut;//食物名拼接
public string FoodNumDetailOut;//份数拼接
public string FoodDetail;//最后的拼接
DataTable dtDinner;
DataTable dtLunch;
static string ButtonClickTime;//日期 郑晓东 2016年7月18日 20:13:10
protected void Page_Load(object sender, EventArgs e)
{
//判断session里面是否存在管理员
if (Session["admin"] != null)
{
//已登陆
if (!Page.IsPostBack)
{
DateTimeLoad();
GetLunchNotTakeOrder(ButtonClickTime);
GetDinnerNotTakeOrder(ButtonClickTime);
}
}
}
#region 日期和饭餐类型改变后获取数据 郑晓东 2016年7月18日 20:13:10
protected void Button1_Click(object sender, EventArgs e)
{
DateTimeChange(); //获取时间
GetLunchNotTakeOrder(ButtonClickTime);//获取中午未取餐人详情
GetDinnerNotTakeOrder(ButtonClickTime);//获取晚上未取餐人详情
}
#endregion
#region 判断是否选择日期 郑晓东 2016年7月18日 21:22:10
/// <summary>
/// 判断是否选择日期
/// </summary>
public void DateTimeChange()
{
ButtonClickTime = menusTime.Value;
if (ButtonClickTime == null )
{
Page.ClientScript.RegisterStartupScript(Page.GetType(), "message", "<script language='javascript' defer>alert('请选择查询日期!');</script>");
}
}
#endregion
#region 加载系统当前日期 郑晓东 2016年7月18日 21:18:30
/// <summary>
/// 加载系统当前日期
/// </summary>
public void DateTimeLoad()
{
//日期默认为今天
menusTime.Value = DateTime.Now.ToString("yyyy-MM-dd");
ButtonClickTime = menusTime.Value;
}
#endregion
#region 通过日期获取中午和晚上未取餐数据 郑晓东 2016年7月18日 21:21:30
/// <summary>
/// 获取中午未取餐人数据
/// </summary>
/// <param name="orderDate">日期</param>
/// <param name="isDennerEat"></param>
public void GetLunchNotTakeOrder(string orderDate)
{
string eattimeQuantum="中午";
dtLunch = orderBll.QueryNotTakeFoodDetailOther(orderDate,eattimeQuantum);
gvLunchFoodDetail.DataSource = dtLunch ;//dt3用来绑定页面数据,同时“食物详情”借尸还魂,用它的"foodstate"字段,展示出来
//获取所有未取餐的订单号
DataTable dt1 = orderBll.QueryNotTakeOrder(orderDate, eattimeQuantum);
//获得一共多少个未取餐订单号
int len = dt1.Rows.Count;
//设置字符串数组是多大的
string[] str = new string[len];
for (int i = 0; i < len; i++)
{
//获取所有的订单号
str[i] = dt1.Rows[i]["orderid"].ToString();
//挨个订单号进行查询
DataTable dt2 = orderBll.QueryNotTakeFoodDetail(str[i]);
//获取该订单号下所有食物名称
int len2 = dt2.Rows.Count;
string[] str2 = new string[len2];
for (int j = 0; j < len2; j++)
{
FoodNameDetailOut += dt2.Rows[j]["foodName"].ToString() + "-";
}
//用完后立马清空字符串数组
for (int a = 0; a < str2.Length; a++)
{
str2[a] = "";
}
//获取该订单号下所有食物的份数
int len3 = dt2.Rows.Count;
string[] str3 = new string[len3];
for (int z = 0; z < len3; z++)
{
FoodNumDetailOut += dt2.Rows[z]["num"].ToString() + "-";
}
//用完后立马清空字符串数组
for (int a = 0; a < str3.Length; a++)
{
str3[a] = "";
}
string[] FoodName = FoodNameDetailOut.Split('-');
string[] FoodNum = FoodNumDetailOut.Split('-');
FoodNameDetailOut = "";
FoodNumDetailOut = "";
//还是获取行数
int len4 = dt2.Rows.Count;
for (int m = 0; m < len4; m++)
{
//该订单号下的所有食物及其各自数量拼接完毕
FoodDetail += FoodName[m] + ":" + FoodNum[m] + "份 ";
}
for (int a = 0; a < FoodName.Length; a++)
{
FoodName[a] = "";
}
for (int a = 0; a < FoodNum.Length; a++)
{
FoodNum[a] = "";
}
string[] strall = new string[len];
strall[i] = FoodDetail;
FoodDetail = "";//不然字符串越拼越多,越来越长……
//使用的是FoodState列,提前修改数据库该字段数据类型为nvarchar(50),即大容量字符串,以免出错
dtLunch.Rows[i]["foodState"] = strall[i];//借用datatable给框赋值
}
gvLunchFoodDetail.DataBind();
}
/// <summary>
/// 获取晚上未取餐人员
/// </summary>
/// <param name="orderDate"></param>
public void GetDinnerNotTakeOrder(string orderDate)
{
string eattimeQuantum = "晚上";
dtDinner = orderBll.QueryNotTakeFoodDetailOther(orderDate, eattimeQuantum);
gvDinnerFoodDetail.DataSource = dtDinner;//dt3用来绑定页面数据,同时“食物详情”借尸还魂,用它的"foodstate"字段,展示出来
//获取所有未取餐的订单号
DataTable dt1 = orderBll.QueryNotTakeOrder(orderDate, eattimeQuantum);
//获得一共多少个未取餐订单号
int len = dt1.Rows.Count;
//设置字符串数组是多大的
string[] str = new string[len];
for (int i = 0; i < len; i++)
{
//获取所有的订单号
str[i] = dt1.Rows[i]["orderid"].ToString();
//挨个订单号进行查询
DataTable dt2 = orderBll.QueryNotTakeFoodDetail(str[i]);
//获取该订单号下所有食物名称
int len2 = dt2.Rows.Count;
string[] str2 = new string[len2];
for (int j = 0; j < len2; j++)
{
FoodNameDetailOut += dt2.Rows[j]["foodName"].ToString() + "-";
}
//用完后立马清空字符串数组
for (int a = 0; a < str2.Length; a++)
{
str2[a] = "";
}
//获取该订单号下所有食物的份数
int len3 = dt2.Rows.Count;
string[] str3 = new string[len3];
for (int z = 0; z < len3; z++)
{
FoodNumDetailOut += dt2.Rows[z]["num"].ToString() + "-";
}
//用完后立马清空字符串数组
for (int a = 0; a < str3.Length; a++)
{
str3[a] = "";
}
string[] FoodName = FoodNameDetailOut.Split('-');
string[] FoodNum = FoodNumDetailOut.Split('-');
FoodNameDetailOut = "";
FoodNumDetailOut = "";
//还是获取行数
int len4 = dt2.Rows.Count;
for (int m = 0; m < len4; m++)
{
//该订单号下的所有食物及其各自数量拼接完毕
FoodDetail += FoodName[m] + ":" + FoodNum[m] + "份 ";
}
for (int a = 0; a < FoodName.Length; a++)
{
FoodName[a] = "";
}
for (int a = 0; a < FoodNum.Length; a++)
{
FoodNum[a] = "";
}
string[] strall = new string[len];
strall[i] = FoodDetail;
FoodDetail = "";//不然字符串越拼越多,越来越长……
//使用的是FoodState列,提前修改数据库该字段数据类型为nvarchar(50),即大容量字符串,以免出错
dtDinner.Rows[i]["foodState"] = strall[i];//借用datatable给框赋值
}
gvDinnerFoodDetail.DataBind();
}
#endregion
protected void gvDinnerFoodDetail_OnPageIndexChanging(object sender, GridViewPageEventArgs e)
{
gvDinnerFoodDetail.PageIndex = e.NewPageIndex;
GetDinnerNotTakeOrder(menusTime.Value);
}
protected void gvLunchFoodDetail_OnPageIndexChanging(object sender, GridViewPageEventArgs e)
{
gvLunchFoodDetail.PageIndex = e.NewPageIndex;
GetLunchNotTakeOrder(menusTime.Value );
}
}
}
后面我还会继续完成一些在其中 一部分没有完成的功能,敬请期待!