code
stringlengths
1
2.01M
repo_name
stringlengths
3
62
path
stringlengths
1
267
language
stringclasses
231 values
license
stringclasses
13 values
size
int64
1
2.01M
<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %> <asp:Content ID="aboutTitle" ContentPlaceHolderID="TitleContent" runat="server"> About Us </asp:Content> <asp:Content ID="aboutContent" ContentPlaceHolderID="MainContent" runat="server"> <h2>About</h2> <p> Put content here. </p> </asp:Content>
1142008-1142076-1142085-ptexpress
trunk/PTExpress/PTExpress/Views/Home/About.aspx
ASP.NET
asf20
390
<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %> <asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server"> Home Page </asp:Content> <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"> <h2><%: ViewData["Message"] %></h2> <p>trong view thi tuong tu php, sua va f5</p> <p><% Response.Write(ViewData["test"]); %></p> <p> To learn more about ASP.NET MVC visit <a href="http://asp.net/mvc" title="ASP.NET MVC Website">http://asp.net/mvc</a>. </p> </asp:Content>
1142008-1142076-1142085-ptexpress
trunk/PTExpress/PTExpress/Views/Home/Index.aspx
ASP.NET
asf20
610
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %> <fieldset id="button"> <a href="/QLKhuyenMai/Them">Thêm mới</a> </fieldset>
1142008-1142076-1142085-ptexpress
trunk/PTExpress/PTExpress/Views/Shared/QLKhuyenMaiButton.ascx
ASP.NET
asf20
165
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %> <% if (Request.IsAuthenticated) { %> Chào <b><%: Page.User.Identity.Name %></b>! [<%: Html.ActionLink("Đăng xuất", "Logout", "Login") %>] <br /> [<%: Html.ActionLink("Thông tin tài khoản", "Logout", "Login")%>] <br /> [<%: Html.ActionLink("Đổi mật khẩu", "Logout", "Login") %>] <% }%> <asp:Literal runat="server"> </asp:Literal>
1142008-1142076-1142085-ptexpress
trunk/PTExpress/PTExpress/Views/Shared/LogOnUserControl.ascx
ASP.NET
asf20
441
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %> <fieldset id="button"> <%: Html.ActionLink("Thêm", "Them", "QLTuyenDuong") %> </fieldset>
1142008-1142076-1142085-ptexpress
trunk/PTExpress/PTExpress/Views/Shared/QLTuyenDuongButton.ascx
ASP.NET
asf20
170
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<dynamic>" %> <fieldset id="button"> <a href="/QLNhanVien/Them">Thêm mới</a> </fieldset>
1142008-1142076-1142085-ptexpress
trunk/PTExpress/PTExpress/Views/Shared/QLNhanVienButton.ascx
ASP.NET
asf20
173
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %> <fieldset id="button"> <a href="/QLKhachHang/Them">Thêm mới</a> </fieldset>
1142008-1142076-1142085-ptexpress
trunk/PTExpress/PTExpress/Views/Shared/QLKhachHangButton.ascx
ASP.NET
asf20
165
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %> <fieldset id="button"> <a href="/QLXe/Them">Thêm mới</a> <a href="/QLXe/Them">Xóa các xe đã chọn</a> <% if (this.ViewContext.Controller.ValueProvider.GetValue("action").RawValue == "Index") { %> <a href="/QLXe/NgungSuDung">Xe đã ngưng sử dụng</a> <% } else { %> <a href="/QLXe">Quản lý xe</a> <% } %> </fieldset>
1142008-1142076-1142085-ptexpress
trunk/PTExpress/PTExpress/Views/Shared/QLXeButton.ascx
ASP.NET
asf20
470
<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<System.Web.Mvc.HandleErrorInfo>" %> <asp:Content ID="errorTitle" ContentPlaceHolderID="TitleContent" runat="server"> Error </asp:Content> <asp:Content ID="errorContent" ContentPlaceHolderID="MainContent" runat="server"> <h2> Sorry, an error occurred while processing your request. </h2> </asp:Content>
1142008-1142076-1142085-ptexpress
trunk/PTExpress/PTExpress/Views/Shared/Error.aspx
ASP.NET
asf20
439
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %> <fieldset id="button"> <%: Html.ActionLink("Thêm", "Them", "QLChuyenXe") %> </fieldset>
1142008-1142076-1142085-ptexpress
trunk/PTExpress/PTExpress/Views/Shared/QLChuyenXeButton.ascx
ASP.NET
asf20
168
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %> <fieldset id="button"> <%: Html.ActionLink("Đặt vé", "DatVe", "QLDatVe") %> </fieldset>
1142008-1142076-1142085-ptexpress
trunk/PTExpress/PTExpress/Views/Shared/QLDatVeButton.ascx
ASP.NET
asf20
172
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %> <% IEnumerable<SelectListItem> lsEXe = (IEnumerable<SelectListItem>)ViewData["lsEXe"]; IEnumerable<SelectListItem> lsEChuyenXe = (IEnumerable<SelectListItem>)ViewData["lsEChuyenXe"]; IEnumerable<SelectListItem> lsETuyenDuong = (IEnumerable<SelectListItem>)ViewData["lsETuyenDuong"]; IEnumerable<SelectListItem> lsEKhachHang = (IEnumerable<SelectListItem>)ViewData["lsEKhachHang"]; IEnumerable<SelectListItem> lsELoaiTuyenDuong = (List<SelectListItem>)ViewData["lsELoaiTuyenDuong"]; %>
1142008-1142076-1142085-ptexpress
trunk/PTExpress/PTExpress/Views/Shared/Init.ascx
ASP.NET
asf20
588
<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %> <asp:Content ID="aboutTitle" ContentPlaceHolderID="TitleContent" runat="server"> Quản lý xe </asp:Content> <asp:Content ID="aboutContent" ContentPlaceHolderID="MainContent" runat="server"> <h2>Quản lý xe</h2> <% using (Html.BeginForm()) { %> <% Html.RenderPartial("QLXeButton"); %> <div> <fieldset> <legend>Danh sách xe</legend> <table> <tbody> <tr> <th><input type="checkbox" name="checkAll" /></th> <th>Tên xe</th> <th>Biển số</th> <th>Loại</th> <th>Số ghế</th> <th>Hãng sản xuất</th> <th>Tình trạng</th> <th colspan="2" align="center">Lựa chọn</th> </tr> <% Dictionary<int, string> LoaiXe = (Dictionary<int, string>) ViewData["LoaiXe"]; Dictionary<int, string> TinhTrangXe = (Dictionary<int, string>)ViewData["TinhTrangXe"]; foreach (DTO.XeDTO xe in (List<DTO.XeDTO>)ViewData["dsXe"]) { %> <tr> <td><input type="checkbox" name="check[<% Response.Write(xe.Id); %>]" /></td> <td><% Response.Write(xe.TenXe); %></td> <td><% Response.Write(xe.BienSo); %></td> <td><% Response.Write(LoaiXe[xe.Loai]); %></td> <td align="right"><% Response.Write(xe.SoGhe); %></td> <td><% Response.Write(xe.HangSanXuat); %></td> <td><% Response.Write(TinhTrangXe[xe.TinhTrang]); %></td> <td align="center"> <%: Html.ActionLink( "Sửa", "Sua", "QLXe", new { id = xe.Id }, null)%></td> <td align="center"> <%: Html.ActionLink( "Ngưng sử dụng", "ChuyenTinhTrangNgungSuDung", "QLXe", new { id = xe.Id }, null)%></td> </tr> <% } %> </tbody> </table> </fieldset> </div> <% } %> </asp:Content>
1142008-1142076-1142085-ptexpress
trunk/PTExpress/PTExpress/Views/QLXe/Index.aspx
ASP.NET
asf20
2,345
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<PTExpress.Models.Xe>" %> <asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server"> Thêm mới xe </asp:Content> <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"> <% IEnumerable<SelectListItem> lsETinhTrang = (List<SelectListItem>)ViewData["lsETinhTrang"]; IEnumerable<SelectListItem> lsELoaiGhe = (List<SelectListItem>)ViewData["lsELoaiGhe"]; %> <h2>Thêm mới xe</h2> <% using (Html.BeginForm()) { %> <%: Html.ValidationSummary(true, "Dữ liệu chưa được lưu trữ. Vui lòng sửa các lỗi bên dưới và nhấn Lưu.") %> <% if (this.Request.HttpMethod == "POST" && (bool)ViewData["ModelState"]) { if( (bool)ViewData["ThanhCong"]) { %> <span id="mess" class="success">Dữ liệu đã được lưu trữ thành công.</span> <% } else{ %> <span id="mess"class="error">Dữ liệu chưa được lưu trữ, đã có lỗi trong quá trình truy cập cơ sở dữ liệu.</span> <% } %> <% } %> <div> <fieldset> <legend>Thông tin xe</legend> <div class="editor-label"> <%: Html.LabelFor(m => m.TenXe) %> </div> <div class="editor-field"> <%: Html.TextBoxFor(m => m.TenXe)%> <%: Html.ValidationMessageFor(m => m.TenXe)%> </div> <div class="editor-label"> <%: Html.LabelFor(m => m.BienSo) %> </div> <div class="editor-field"> <%: Html.TextBoxFor(m => m.BienSo) %> <%: Html.ValidationMessageFor(m => m.BienSo) %> </div> <div class="editor-label"> <%: Html.LabelFor(m => m.Loai) %> </div> <div class="editor-field"> <%: Html.DropDownListFor(m => m.Loai, lsELoaiGhe)%> <%: Html.ValidationMessageFor(m => m.Loai)%> </div> <div class="editor-label"> <%: Html.LabelFor(m => m.SoGhe) %> </div> <div class="editor-field"> <%: Html.TextBoxFor(m => m.SoGhe)%> <%: Html.ValidationMessageFor(m => m.SoGhe)%> </div> <div class="editor-label"> <%: Html.LabelFor(m => m.HangSanXuat) %> </div> <div class="editor-field"> <%: Html.TextBoxFor(m => m.HangSanXuat)%> <%: Html.ValidationMessageFor(m => m.HangSanXuat)%> </div> <div class="editor-label"> <%: Html.LabelFor(m => m.TinhTrang) %> </div> <div class="editor-field"> <%: Html.DropDownListFor(m => m.TinhTrang, lsETinhTrang)%> <%: Html.ValidationMessageFor(m => m.TinhTrang)%> </div> <div class="editor-label"> <%: Html.LabelFor(m => m.NgungSuDung) %> </div> <div class="editor-field"> <%: Html.CheckBoxFor(m => m.NgungSuDung)%> <%: Html.ValidationMessageFor(m => m.NgungSuDung)%> </div> <p> <input type="submit" value="Lưu" /> </p> </fieldset> </div> <% } %> </asp:Content>
1142008-1142076-1142085-ptexpress
trunk/PTExpress/PTExpress/Views/QLXe/Them.aspx
ASP.NET
asf20
3,939
<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %> <asp:Content ID="aboutTitle" ContentPlaceHolderID="TitleContent" runat="server"> Quản lý xe </asp:Content> <asp:Content ID="aboutContent" ContentPlaceHolderID="MainContent" runat="server"> <h2>Xe đã ngưng sử dụng</h2> <p><i>Ghi chú</i></p> <% using (Html.BeginForm()) { %> <% Html.RenderPartial("QLXeButton"); %> <div> <fieldset> <legend>Danh sách xe</legend> <table> <tbody> <tr> <th><input type="checkbox" name="checkAll" /></th> <th>Tên xe</th> <th>Biển số</th> <th>Loại</th> <th>Số ghế</th> <th>Hãng sản xuất</th> <th>Tình trạng</th> <th colspan="2" align="center">Lựa chọn</th> </tr> <% Dictionary<int, string> LoaiXe = (Dictionary<int, string>) ViewData["LoaiXe"]; Dictionary<int, string> TinhTrangXe = (Dictionary<int, string>)ViewData["TinhTrangXe"]; foreach (DTO.XeDTO xe in (List<DTO.XeDTO>)ViewData["dsXe"]) { %> <tr> <td><input type="checkbox" name="check[<% Response.Write(xe.Id); %>]" /></td> <td><% Response.Write(xe.TenXe); %></td> <td><% Response.Write(xe.BienSo); %></td> <td><% Response.Write(LoaiXe[xe.Loai]); %></td> <td align="right"><% Response.Write(xe.SoGhe); %></td> <td><% Response.Write(xe.HangSanXuat); %></td> <td><% Response.Write(TinhTrangXe[xe.TinhTrang]); %></td> <td align="center"> <%: Html.ActionLink( "Sửa", "Sua", "QLXe", new { id = xe.Id }, null)%></td> <td align="center"> <%: Html.ActionLink("Sử dụng", "ChuyenTinhTrangSuDung", "QLXe", new { id = xe.Id }, null)%></td> </tr> <% } %> </tbody> </table> </fieldset> </div> <% } %> </asp:Content>
1142008-1142076-1142085-ptexpress
trunk/PTExpress/PTExpress/Views/QLXe/NgungSuDung.aspx
ASP.NET
asf20
2,373
<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<PTExpress.Models.Xe>" %> <asp:Content ID="registerTitle" ContentPlaceHolderID="TitleContent" runat="server"> Cập nhật thông tin xe: <% Response.Write(ViewData["tenXe"].ToString()); %> </asp:Content> <asp:Content ID="registerContent" ContentPlaceHolderID="MainContent" runat="server"> <% IEnumerable<SelectListItem> lsETinhTrang = (List<SelectListItem>)ViewData["lsETinhTrang"]; IEnumerable<SelectListItem> lsELoaiGhe = (List<SelectListItem>)ViewData["lsELoaiGhe"]; %> <h2>Cập nhật thông tin xe: <% Response.Write(ViewData["tenXe"].ToString()); %></h2> <% using (Html.BeginForm()) { %> <%: Html.ValidationSummary(true, "Dữ liệu chưa được lưu trữ. Vui lòng sửa các lỗi bên dưới và nhấn Lưu.") %> <% if (this.Request.HttpMethod == "POST" && (bool)ViewData["ModelState"]) { if( (bool)ViewData["ThanhCong"]) { %> <span id="mess" class="success">Dữ liệu đã được lưu trữ thành công.</span> <% } else{ %> <span id="mess"class="error">Dữ liệu chưa được lưu trữ, đã có lỗi trong quá trình truy cập cơ sở dữ liệu.</span> <% } %> <% } %> <div> <fieldset> <legend>Thông tin xe</legend> <div class="editor-label"> <%: Html.LabelFor(m => m.Id) %> </div> <div class="editor-field"> <%: Html.TextBoxFor(m => m.Id, new { READONLY = "READONLY" })%> <%: Html.ValidationMessageFor(m => m.Id) %> </div> <div class="editor-label"> <%: Html.LabelFor(m => m.TenXe) %> </div> <div class="editor-field"> <%: Html.TextBoxFor(m => m.TenXe)%> <%: Html.ValidationMessageFor(m => m.TenXe)%> </div> <div class="editor-label"> <%: Html.LabelFor(m => m.BienSo) %> </div> <div class="editor-field"> <%: Html.TextBoxFor(m => m.BienSo) %> <%: Html.ValidationMessageFor(m => m.BienSo) %> </div> <div class="editor-label"> <%: Html.LabelFor(m => m.Loai) %> </div> <div class="editor-field"> <%: Html.DropDownListFor(m => m.Loai, lsELoaiGhe)%> <%: Html.ValidationMessageFor(m => m.Loai)%> </div> <div class="editor-label"> <%: Html.LabelFor(m => m.SoGhe) %> </div> <div class="editor-field"> <%: Html.TextBoxFor(m => m.SoGhe)%> <%: Html.ValidationMessageFor(m => m.SoGhe)%> </div> <div class="editor-label"> <%: Html.LabelFor(m => m.HangSanXuat) %> </div> <div class="editor-field"> <%: Html.TextBoxFor(m => m.HangSanXuat)%> <%: Html.ValidationMessageFor(m => m.HangSanXuat)%> </div> <div class="editor-label"> <%: Html.LabelFor(m => m.TinhTrang) %> </div> <div class="editor-field"> <%: Html.DropDownListFor(m => m.TinhTrang, lsETinhTrang)%> <%: Html.ValidationMessageFor(m => m.TinhTrang)%> </div> <div class="editor-label"> <%: Html.LabelFor(m => m.NgungSuDung) %> </div> <div class="editor-field"> <%: Html.CheckBoxFor(m => m.NgungSuDung)%> <%: Html.ValidationMessageFor(m => m.NgungSuDung)%> </div> <p> <input type="submit" value="Lưu" /> </p> </fieldset> </div> <% } %> </asp:Content>
1142008-1142076-1142085-ptexpress
trunk/PTExpress/PTExpress/Views/QLXe/Sua.aspx
ASP.NET
asf20
4,428
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %> <asp:Content ID="aboutTitle" ContentPlaceHolderID="TitleContent" runat="server"> Quản lý khách hàng </asp:Content> <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"> <h2>Quản lý khách hàng</h2> <% using (Html.BeginForm()) { Html.RenderPartial("QLKhachHangButton"); %> <div> <fieldset> <legend>Danh sách khách hàng</legend> <table> <tbody> <tr> <th><input type="checkbox" name="checkAll" /></th> <th>ID</th> <th>Tên đăng nhập</th> <th>Email</th> <th>Họ tên</th> <th>CMND</th> <th>Giới tính</th> <th>Ngày đăng ký</th> <th>Điểm</th> <th colspan="2" align="center">Lựa chọn</th> </tr> <% Dictionary<int, string> GioiTinh = (Dictionary<int, string>)ViewData["GioiTinh"]; foreach (DTO.KhachHangDTO khachhang in (List<DTO.KhachHangDTO>)ViewData["dsKhachHang"]) { %> <tr> <td><input type="checkbox" name="check[<% Response.Write(khachhang.Id); %>]" /></td> <td><% Response.Write(khachhang.Id); %></td> <td><% Response.Write(khachhang.Tendangnhap); %></td> <td><% Response.Write(khachhang.Email); %></td> <td <% if (khachhang.LaKHTT) { Response.Write("class='KHTT'"); }%> ><% Response.Write(khachhang.Hoten); %></td> <td><% Response.Write(khachhang.Cmnd); %></td> <td><% Response.Write(GioiTinh[khachhang.Gioitinh]); %></td> <td><% Response.Write(khachhang.Ngaydangky); %></td> <td><% if (khachhang.LaKHTT) { Response.Write(khachhang.DiemThuong); }%></td> <td align="center"> <%: Html.ActionLink("Sửa", "Sua", "QLKhachHang", new { id = khachhang.Id }, null)%></td> </tr> <% } %> </tbody> </table> </fieldset> </div> <% } %> </asp:Content>
1142008-1142076-1142085-ptexpress
trunk/PTExpress/PTExpress/Views/QLKhachHang/Index.aspx
ASP.NET
asf20
2,533
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<PTExpress.Models.KhachHang>" %> <asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server"> Thêm khách hàng </asp:Content> <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"> <% IEnumerable<SelectListItem> lsEGioiTinh = (List<SelectListItem>)ViewData["lsEGioiTinh"]; %> <h2>Thêm khách hàng</h2> <% using (Html.BeginForm()) { %> <%: Html.ValidationSummary(true, "Dữ liệu chưa được lưu trữ. Vui lòng sửa các lỗi bên dưới và nhấn Lưu.") %> <% if (this.Request.HttpMethod == "POST" && (bool)ViewData["ModelState"]) { if( (bool)ViewData["ThanhCong"]) { %> <span id="mess" class="success">Dữ liệu đã được lưu trữ thành công.</span> <% } else{ %> <span id="mess"class="error">Dữ liệu chưa được lưu trữ, đã có lỗi trong quá trình truy cập cơ sở dữ liệu.</span> <% } %> <% } %> <div> <fieldset> <legend>Thông tin khách hàng</legend> <div class="editor-label"> <%: Html.LabelFor(m => m.Tendangnhap) %> </div> <div class="editor-field"> <%: Html.TextBoxFor(m => m.Tendangnhap)%> <%: Html.ValidationMessageFor(m => m.Tendangnhap)%> </div> <div class="editor-label"> <%: Html.LabelFor(m => m.Matkhau) %> </div> <div class="editor-field"> <%: Html.PasswordFor(m => m.Matkhau) %> <%: Html.ValidationMessageFor(m => m.Matkhau) %> </div> <div class="editor-label"> <%: Html.LabelFor(m => m.Gioitinh) %> </div> <div class="editor-field"> <%: Html.DropDownListFor(m => m.Gioitinh, lsEGioiTinh)%> <%: Html.ValidationMessageFor(m => m.Gioitinh)%> </div> <div class="editor-label"> <%: Html.LabelFor(m => m.Email) %> </div> <div class="editor-field"> <%: Html.TextBoxFor(m => m.Email)%> <%: Html.ValidationMessageFor(m => m.Email)%> </div> <div class="editor-label"> <%: Html.LabelFor(m => m.Hoten) %> </div> <div class="editor-field"> <%: Html.TextBoxFor(m => m.Hoten)%> <%: Html.ValidationMessageFor(m => m.Hoten)%> </div> <div class="editor-label"> <%: Html.LabelFor(m => m.Cmnd) %> </div> <div class="editor-field"> <%: Html.TextBoxFor(m => m.Cmnd)%> <%: Html.ValidationMessageFor(m => m.Cmnd)%> </div> <p> <input type="submit" value="Lưu" /> </p> </fieldset> </div> <% } %> </asp:Content>
1142008-1142076-1142085-ptexpress
trunk/PTExpress/PTExpress/Views/QLKhachHang/Them.aspx
ASP.NET
asf20
3,473
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<PTExpress.Models.KhachHang>" %> <asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server"> Cập nhật thông tin khách hàng: <% Response.Write(ViewData["HoTen"].ToString()); %> </asp:Content> <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"> <h2>Sua</h2> <% IEnumerable<SelectListItem> lsEGioiTinh = (List<SelectListItem>)ViewData["lsEGioiTinh"]; %> <h2>Cập nhật thông tin khách hàng: <% Response.Write(ViewData["HoTen"].ToString()); %> </h2> <% using (Html.BeginForm()) { %> <%: Html.ValidationSummary(true, "Dữ liệu chưa được lưu trữ. Vui lòng sửa các lỗi bên dưới và nhấn Lưu.") %> <% if (this.Request.HttpMethod == "POST" && (bool)ViewData["ModelState"]) { if( (bool)ViewData["ThanhCong"]) { %> <span id="mess" class="success">Dữ liệu đã được lưu trữ thành công.</span> <% } else{ %> <span id="mess"class="error">Dữ liệu chưa được lưu trữ, đã có lỗi trong quá trình truy cập cơ sở dữ liệu.</span> <% } %> <% } %> <div> <fieldset> <legend>Thông tin khách hàng</legend> <div class="editor-label"> <%: Html.LabelFor(m => m.Tendangnhap) %> </div> <div class="editor-field"> <%: Html.TextBoxFor(m => m.Tendangnhap)%> <%: Html.ValidationMessageFor(m => m.Tendangnhap)%> </div> <div class="editor-label"> <%: Html.LabelFor(m => m.Matkhau) %> </div> <div class="editor-field"> <%: Html.PasswordFor(m => m.Matkhau) %> <%: Html.ValidationMessageFor(m => m.Matkhau) %> </div> <div class="editor-label"> <%: Html.LabelFor(m => m.Gioitinh) %> </div> <div class="editor-field"> <%: Html.DropDownListFor(m => m.Gioitinh, lsEGioiTinh)%> <%: Html.ValidationMessageFor(m => m.Gioitinh)%> </div> <div class="editor-label"> <%: Html.LabelFor(m => m.Email) %> </div> <div class="editor-field"> <%: Html.TextBoxFor(m => m.Email)%> <%: Html.ValidationMessageFor(m => m.Email)%> </div> <div class="editor-label"> <%: Html.LabelFor(m => m.Hoten) %> </div> <div class="editor-field"> <%: Html.TextBoxFor(m => m.Hoten)%> <%: Html.ValidationMessageFor(m => m.Hoten)%> </div> <div class="editor-label"> <%: Html.LabelFor(m => m.Cmnd) %> </div> <div class="editor-field"> <%: Html.TextBoxFor(m => m.Cmnd)%> <%: Html.ValidationMessageFor(m => m.Cmnd)%> </div> <div class="editor-label"> <%: Html.LabelFor(m => m.No) %> </div> <div class="editor-field"> <%: Html.TextBoxFor(m => m.No)%> <%: Html.ValidationMessageFor(m => m.No)%> </div> <p> <input type="submit" value="Lưu" /> </p> </fieldset> </div> <% } %> </asp:Content>
1142008-1142076-1142085-ptexpress
trunk/PTExpress/PTExpress/Views/QLKhachHang/Sua.aspx
ASP.NET
asf20
3,947
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using DAO; using DTO; using PTExpress.Models; namespace PTExpress.Controllers { [Authorize] public class QLKhuyenMaiController : Controller { public ActionResult Index() { KhuyenMaiDAO khuyenmaiDAO = new KhuyenMaiDAO(); List<KhuyenMaiDTO> ls = khuyenmaiDAO.GetAll(); this.ViewData.Add("dsKhuyenmai", ls); return View(); } public ActionResult Details(int id) { return View(); } public ActionResult Them() { return View(); } [HttpPost] public ActionResult Them(KhuyenMai model) { ViewData["ModelState"] = ModelState.IsValid; bool thanhCong = false; if (ModelState.IsValid) { KhuyenMaiDAO khuyenmaiDAO = new KhuyenMaiDAO(); KhuyenMaiDTO khuyenmaiDTO = new KhuyenMaiDTO(); khuyenmaiDTO.Id = model.Id; khuyenmaiDTO.Phantram = model.Phantram; khuyenmaiDTO.Batdau = model.Batdau; khuyenmaiDTO.Ketthuc = model.Ketthuc; thanhCong = khuyenmaiDAO.AddNew(khuyenmaiDTO); if (thanhCong) { return RedirectToAction("Index", "QLKhuyenMai"); } } ViewData["ThanhCong"] = thanhCong; return View(model); } public ActionResult Sua(int id) { KhuyenMai model = new KhuyenMai(); KhuyenMaiDAO khuyenmaiDAO = new KhuyenMaiDAO(); KhuyenMaiDTO khuyenmaiDTO = khuyenmaiDAO.getById(id.ToString()); ViewData["Id"] = khuyenmaiDTO.Id; model.Id = id; model.Phantram = khuyenmaiDTO.Phantram; model.Batdau = khuyenmaiDTO.Batdau; model.Ketthuc = khuyenmaiDTO.Ketthuc; return View(model); } [HttpPost] public ActionResult Sua(KhuyenMai model, String id) { KhuyenMaiDAO khuyenmaiDAO = new KhuyenMaiDAO(); KhuyenMaiDTO khuyenmaiDTO = khuyenmaiDAO.getById(id); KhuyenMaiDTO newkhuyenmaiDTO = khuyenmaiDAO.getById(id); ViewData["Id"] = khuyenmaiDTO.Id; ViewData["ModelState"] = ModelState.IsValid; bool thanhCong = false; if (ModelState.IsValid) { newkhuyenmaiDTO.Batdau = model.Batdau; newkhuyenmaiDTO.Ketthuc = model.Ketthuc; newkhuyenmaiDTO.Phantram = model.Phantram; thanhCong = khuyenmaiDAO.Edit(khuyenmaiDTO,newkhuyenmaiDTO); } ViewData["ThanhCong"] = thanhCong; return View(model); } } }
1142008-1142076-1142085-ptexpress
trunk/PTExpress/PTExpress/Controllers/QLKhuyenMaiController.cs
C#
asf20
3,002
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using DAO; using DTO; using System.Web.Routing; using PTExpress.Models; namespace PTExpress.Controllers { [Authorize] public class QLChuyenXeController : Controller { protected void Initialize() { XeDAO xeDao = new XeDAO(); List<XeDTO> lsXe = xeDao.GetAllWhere("daxoa = 0"); List<SelectListItem> lsXeItem = new List<SelectListItem>(); lsXeItem.Add(new SelectListItem()); foreach (XeDTO xe in lsXe) { SelectListItem item = new SelectListItem(); item.Text = xe.TenXe; item.Value = xe.Id.ToString(); lsXeItem.Add(item); } ViewData["lsEXe"] = lsXeItem; TuyenDuongDAO tuyenDuongDAO = new TuyenDuongDAO(); List<TuyenDuongDTO> lsTuyenDuong = tuyenDuongDAO.GetAll(); List<SelectListItem> lsTuyenDuongItem = new List<SelectListItem>(); lsTuyenDuongItem.Add(new SelectListItem()); foreach (TuyenDuongDTO xe in lsTuyenDuong) { SelectListItem item = new SelectListItem(); item.Text = string.Format("{0} đi {1}", xe.NoiDi, xe.NoiDen); item.Value = xe.Id.ToString(); lsTuyenDuongItem.Add(item); } ViewData["lsETuyenDuong"] = lsTuyenDuongItem; } public ActionResult Index() { ChuyenXeDAO xeDAO = new ChuyenXeDAO(); List<ChuyenXeDTO> ls = xeDAO.GetAll(); this.ViewData.Add("dsChuyenXe", ls); return View(); } public ActionResult Them() { Initialize(); ChuyenXe model = new ChuyenXe(); model.XuatPhat = DateTime.Now; model.DenNoi = DateTime.Now; return View(model); } [HttpPost] public ActionResult Them(ChuyenXe model) { ViewData["IsValid"] = ModelState.IsValid; if (ModelState.IsValid) { ChuyenXeDTO chuyenXeDTO = new ChuyenXeDTO(); ChuyenXeDAO chuyenXeDAO = new ChuyenXeDAO(); chuyenXeDTO.DenNoi = model.DenNoi; chuyenXeDTO.GiaVe = model.giaVe; chuyenXeDTO.TuyenDuongId = model.TuyenDuong; chuyenXeDTO.XeId = model.Xe; chuyenXeDTO.XuatPhat = model.XuatPhat; bool thanhCong = chuyenXeDAO.AddNew(chuyenXeDTO); ViewData["ThanhCong"] = thanhCong; if (thanhCong) { return RedirectToAction("Index", "QLChuyenXe"); } } Initialize(); return View(model); } } }
1142008-1142076-1142085-ptexpress
trunk/PTExpress/PTExpress/Controllers/QLChuyenXeController.cs
C#
asf20
2,979
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; namespace PTExpress.Controllers { public class NhanVienController : Controller { // // GET: /NhanVien/ public ActionResult Index() { return View(); } // // GET: /NhanVien/Details/5 public ActionResult Details(int id) { return View(); } // // GET: /NhanVien/Create public ActionResult Create() { return View(); } // // POST: /NhanVien/Create [HttpPost] public ActionResult Create(FormCollection collection) { try { // TODO: Add insert logic here return RedirectToAction("Index"); } catch { return View(); } } // // GET: /NhanVien/Edit/5 public ActionResult Edit(int id) { return View(); } // // POST: /NhanVien/Edit/5 [HttpPost] public ActionResult Edit(int id, FormCollection collection) { try { // TODO: Add update logic here return RedirectToAction("Index"); } catch { return View(); } } // // GET: /NhanVien/Delete/5 public ActionResult Delete(int id) { return View(); } // // POST: /NhanVien/Delete/5 [HttpPost] public ActionResult Delete(int id, FormCollection collection) { try { // TODO: Add delete logic here return RedirectToAction("Index"); } catch { return View(); } } } }
1142008-1142076-1142085-ptexpress
trunk/PTExpress/PTExpress/Controllers/NhanVienController.cs
C#
asf20
2,107
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using DTO; using DAO; using PTExpress.Models; using System.Data; namespace PTExpress.Controllers { [Authorize] public class QLTuyenDuongController : AbstractController { public QLTuyenDuongController() : base() { Dictionary<int, string> LoaiTuyenDuong = new Dictionary<int, string>(); LoaiTuyenDuong.Add(1, "Đường dài"); LoaiTuyenDuong.Add(2, "Trung chuyển"); this.ViewData.Add("LoaiTuyenDuong", LoaiTuyenDuong); ViewData["lsELoaiTuyenDuong"] = TuyenDuongDTO.GetListLoaiTuyenDuong(); } public ActionResult Index() { TuyenDuongDAO tuyenDuongDAO = new TuyenDuongDAO(); List<TuyenDuongDTO> ls = tuyenDuongDAO.GetAll(); this.ViewData.Add("dsTuyenDuong", ls); return View(); } public ActionResult Sua(int id) { TuyenDuongDAO tuyenDuongDAO = new TuyenDuongDAO(); TuyenDuongDTO td = tuyenDuongDAO.getById(id); TuyenDuong model = new TuyenDuong(); model.Id = id; model.GioChay = td.GioBatDauChay; model.GioNghi = td.GioNghi; model.KhoangCach = td.KhoangCach; model.LoaiTuyenDuong = td.Loai; model.NoiDen = td.NoiDen; model.NoiDi = td.NoiDi; model.SoLuongXe = td.SoLuongXe; ViewData["TenTuyenDuong"] = string.Format("{0} đi {1}", td.NoiDi,td.NoiDen); return View(model); } [HttpPost] public ActionResult Sua(TuyenDuong model, int id) { TuyenDuongDAO xeDAO = new TuyenDuongDAO(); TuyenDuongDTO xeDTO = xeDAO.getById(id); ViewData["TenTuyenDuong"] = string.Format("{0} đi {1}", xeDTO.NoiDi, xeDTO.NoiDen); ViewData["ModelState"] = ModelState.IsValid; if (ModelState.IsValid) { xeDTO.GioBatDauChay = model.GioChay; xeDTO.GioNghi = model.GioNghi; xeDTO.KhoangCach = model.KhoangCach; xeDTO.Loai = model.LoaiTuyenDuong; xeDTO.NoiDen = model.NoiDen; xeDTO.NoiDi = model.NoiDi; bool thanhCong = xeDAO.Edit(xeDTO); ViewData["ThanhCong"] = thanhCong; } return View(model); } public ActionResult Them() { TuyenDuong model = new TuyenDuong(); model.GioChay = "06:00:00"; model.GioNghi = "20:00:00"; return View(model); } [HttpPost] public ActionResult Them(TuyenDuong model) { if (ModelState.IsValid) { TuyenDuongDAO tuyenDuongDAO = new TuyenDuongDAO(); TuyenDuongDTO tuyenDuongDTO = new TuyenDuongDTO(); tuyenDuongDTO.NoiDen = model.NoiDen; tuyenDuongDTO.NoiDi = model.NoiDi; tuyenDuongDTO.KhoangCach = model.KhoangCach; tuyenDuongDTO.GioBatDauChay = model.GioChay; tuyenDuongDTO.GioNghi = model.GioNghi; tuyenDuongDTO.Loai = model.LoaiTuyenDuong; bool thanhCong = tuyenDuongDAO.AddNew(tuyenDuongDTO); ViewData["ThanhCong"] = thanhCong; if (thanhCong) { return RedirectToAction("Index"); } } return View(); } } }
1142008-1142076-1142085-ptexpress
trunk/PTExpress/PTExpress/Controllers/QLTuyenDuongController.cs
C#
asf20
3,738
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using DAO; using DTO; using PTExpress.Models; using System.Web.Routing; namespace PTExpress.Controllers { public abstract class AbstractController : Controller { protected NhanVienDTO nhanVienDTO; public IFormsAuthenticationService FormsService { get; set; } protected override void Initialize(RequestContext requestContext) { base.Initialize(requestContext); if (FormsService == null) { FormsService = new FormsAuthenticationService(); } if (this.HttpContext.Request.IsAuthenticated) { string userName = this.User.Identity.Name; NhanVienDAO nvDAO = new NhanVienDAO(); nhanVienDTO = nvDAO.getByTenDangNhap(userName); } } protected AbstractController() : base() { XeDAO xeDao = new XeDAO(); List<XeDTO> lsXe = xeDao.GetAllWhere("daxoa = 0"); List<SelectListItem> lsXeItem = new List<SelectListItem>(); lsXeItem.Add(new SelectListItem()); foreach (XeDTO xe in lsXe) { SelectListItem item = new SelectListItem(); item.Text = xe.TenXe; item.Value = xe.Id.ToString(); lsXeItem.Add(item); } ViewData["lsEXe"] = lsXeItem; TuyenDuongDAO tuyenDuongDAO = new TuyenDuongDAO(); List<TuyenDuongDTO> lsTuyenDuong = tuyenDuongDAO.GetAll(); List<SelectListItem> lsTuyenDuongItem = new List<SelectListItem>(); lsTuyenDuongItem.Add(new SelectListItem()); foreach (TuyenDuongDTO xe in lsTuyenDuong) { SelectListItem item = new SelectListItem(); item.Text = string.Format("{0} đi {1}", xe.NoiDi, xe.NoiDen); item.Value = xe.Id.ToString(); lsTuyenDuongItem.Add(item); } ViewData["lsETuyenDuong"] = lsTuyenDuongItem; KhachHangDAO khachHangDAO = new KhachHangDAO(); List<KhachHangDTO> lsKhachHang = khachHangDAO.GetAllUnCommited(); List<SelectListItem> lsKhachHangItem = new List<SelectListItem>(); lsKhachHangItem.Add(new SelectListItem()); foreach (KhachHangDTO kh in lsKhachHang) { SelectListItem item = new SelectListItem(); item.Text = kh.Hoten; item.Value = kh.Id.ToString(); lsKhachHangItem.Add(item); } ViewData["lsEKhachHang"] = lsKhachHangItem; ChuyenXeDAO chuyenXeDAO = new ChuyenXeDAO(); List<ChuyenXeDTO> lsChuyenXe = chuyenXeDAO.GetAll(); List<SelectListItem> lsChuyenXeItem = new List<SelectListItem>(); lsChuyenXeItem.Add(new SelectListItem()); foreach (ChuyenXeDTO cx in lsChuyenXe) { SelectListItem item = new SelectListItem(); item.Text = string.Format("{0} ngày {1}", cx.TenTuyenDuong, cx.XuatPhat.Date); item.Value = cx.Id.ToString(); lsChuyenXeItem.Add(item); } ViewData["lsEChuyenXe"] = lsChuyenXeItem; } } }
1142008-1142076-1142085-ptexpress
trunk/PTExpress/PTExpress/Controllers/AbstractController.cs
C#
asf20
3,500
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using PTExpress.Models; using DTO; using DAO; namespace PTExpress.Controllers { [Authorize] public class QLNhanVienController : Controller { public IFormsAuthenticationService FormsService { get; set; } public Dictionary<int, string> Loai; public QLNhanVienController() : base() { Loai = new Dictionary<int, string>(); Loai.Add(1, "Nhân viên bán vé"); Loai.Add(2, "Nhân viên quản lý"); Loai.Add(3, "Nhân viên tin học"); this.ViewData.Add("Loai", Loai); IEnumerable<SelectListItem> lsELoai = NhanVienDTO.GetListLoai(); this.ViewData.Add("lsELoai", lsELoai); } // // GET: /QLNhanVien/ public ActionResult Index() { NhanVienDAO nhanvienDAO = new NhanVienDAO(); List<NhanVienDTO> ls = nhanvienDAO.GetAll(); this.ViewData.Add("dsNhanVien", ls); return View(); } // // GET: /QLNhanVien/Details/5 public ActionResult Details(int id) { return View(); } // // GET: /QLNhanVien/Create public ActionResult Them() { return View(); } // // POST: /QLNhanVien/Create [HttpPost] public ActionResult Them(NhanVien model) { try { ViewData["ModelState"] = ModelState.IsValid; bool thanhCong = false; if (ModelState.IsValid) { NhanVienDAO nhanvienDAO = new NhanVienDAO(); if (nhanvienDAO.CheckUsername(model.Tendangnhap)) { ModelState.AddModelError("TenDangNhap", "Trùng tên đăng nhập, vui lòng chọn một tên khác chưa sử dụng."); ViewData["ModelState"] = false; return View(model); } if (nhanvienDAO.CheckEmail(model.Email)) { ModelState.AddModelError("Email", "Trùng email, vui lòng chọn một email khác chưa sử dụng."); ViewData["ModelState"] = false; return View(model); } NhanVienDTO nhanvienDTO = new NhanVienDTO(); nhanvienDTO.TenDangNhap = model.Tendangnhap; nhanvienDTO.MatKhau = model.Matkhau; nhanvienDTO.Email = model.Email; nhanvienDTO.Loai = model.Loai; thanhCong = nhanvienDAO.AddNew(nhanvienDTO); if (thanhCong) { return RedirectToAction("Index", "QLNhanVien"); } } ViewData["ThanhCong"] = thanhCong; return View(model); } catch { return View(); } } // // GET: /QLNhanVien/Edit/5 public ActionResult Sua(int id) { NhanVien model = new NhanVien(); NhanVienDAO nhanvienDAO = new NhanVienDAO(); NhanVienDTO nhanvienDTO = nhanvienDAO.getById(id); ViewData["TenDangNhap"] = nhanvienDTO.TenDangNhap; model.Id = id; model.Tendangnhap = nhanvienDTO.TenDangNhap; model.Matkhau = nhanvienDTO.MatKhau; model.Email = nhanvienDTO.Email; model.Loai = nhanvienDTO.Loai; return View(model); } // // POST: /QLNhanVien/Edit/5 [HttpPost] public ActionResult Sua(int id, NhanVien model) { NhanVienDAO nhanvienDAO = new NhanVienDAO(); NhanVienDTO nhanvienDTO = nhanvienDAO.getById(id); ViewData["TenDangNhap"] = nhanvienDTO.TenDangNhap; ViewData["ModelState"] = ModelState.IsValid; bool thanhCong = false; if (ModelState.IsValid) { nhanvienDTO.TenDangNhap = model.Tendangnhap; nhanvienDTO.MatKhau = model.Matkhau; nhanvienDTO.Email = model.Email; nhanvienDTO.Loai = model.Loai; thanhCong = nhanvienDAO.Edit(nhanvienDTO); } ViewData["ThanhCong"] = thanhCong; return View(model); } // // GET: /QLNhanVien/Delete/5 public ActionResult Delete(int id) { return View(); } // // POST: /QLNhanVien/Delete/5 [HttpPost] public ActionResult Delete(int id, FormCollection collection) { try { // TODO: Add delete logic here return RedirectToAction("Index"); } catch { return View(); } } } }
1142008-1142076-1142085-ptexpress
trunk/PTExpress/PTExpress/Controllers/QLNhanVienController.cs
C#
asf20
5,329
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using PTExpress.Models; using System.Web.Routing; using DTO; namespace PTExpress.Controllers { public class LoginController : AbstractController { public ActionResult Index() { return View(); } [HttpPost] public ActionResult Index(Login model, string returnUrl) { if (ModelState.IsValid) { if (LoginService.ValidateUser(model.UserName, model.Password)) { DAO.NhanVienDAO nvDAO = new DAO.NhanVienDAO(); DTO.NhanVienDTO nv = nvDAO.getByTenDangNhap(model.UserName); Session.Add(NhanVienDTO.SSNHANVIEN, nv); FormsService.SignIn(model.UserName, false); if (string.IsNullOrEmpty(returnUrl)) { return RedirectToAction("Index", "QLDatVe"); } return Redirect(returnUrl); } else { ModelState.AddModelError("", "The user name or password provided is incorrect."); } } return View(model); } public ActionResult Logout() { FormsService.SignOut(); Session.Remove(NhanVienDTO.SSNHANVIEN); return RedirectToAction("Index", "Login"); } } }
1142008-1142076-1142085-ptexpress
trunk/PTExpress/PTExpress/Controllers/LoginController.cs
C#
asf20
1,583
using System.Collections.Generic; using System.Web.Mvc; using DAO; using DTO; using PTExpress.Models; namespace PTExpress.Controllers { [HandleError] [Authorize] public class QLXeController : Controller { public IFormsAuthenticationService FormsService { get; set; } public QLXeController() : base() { Dictionary<int, string> LoaiXe; Dictionary<int, string> TinhTrangXe; LoaiXe = new Dictionary<int, string>(); LoaiXe.Add(1, "Ghế ngồi"); LoaiXe.Add(2, "Giường nằm"); LoaiXe.Add(3, "Trung chuyển"); this.ViewData.Add("LoaiXe", LoaiXe); TinhTrangXe = new Dictionary<int, string>(); TinhTrangXe.Add(1, "Đang chạy"); TinhTrangXe.Add(2, "Đang bảo trì"); this.ViewData.Add("TinhTrangXe", TinhTrangXe); IEnumerable<SelectListItem> lsETinhTrang = XeDTO.GetListTinhTrang(); this.ViewData.Add("lsETinhTrang", lsETinhTrang); IEnumerable<SelectListItem> lsELoaiGhe = XeDTO.GetListLoaiXe(); this.ViewData.Add("lsELoaiGhe", lsELoaiGhe); } public ActionResult Index() { XeDAO xeDAO = new XeDAO(); List<XeDTO> ls = xeDAO.GetAllWhere("daxoa = 0"); this.ViewData.Add("dsXe", ls); return View(); } public ActionResult NgungSuDung() { XeDAO xeDAO = new XeDAO(); List<XeDTO> ls = xeDAO.GetAllWhere("daxoa = 1"); this.ViewData.Add("dsXe", ls); return View(); } public ActionResult Sua(int id) { Xe model = new Xe(); XeDAO xeDAO = new XeDAO(); XeDTO xeDTO = xeDAO.getById(id); ViewData["tenXe"] = xeDTO.TenXe; model.Id = id; model.TenXe = xeDTO.TenXe; model.BienSo = xeDTO.BienSo; model.HangSanXuat = xeDTO.HangSanXuat; model.Loai = xeDTO.Loai; model.NgungSuDung = xeDTO.DaXoa; model.SoGhe = xeDTO.SoGhe; model.TinhTrang = model.TinhTrang; return View(model); } [HttpPost] public ActionResult Sua(Xe model, int id) { XeDAO xeDAO = new XeDAO(); XeDTO xeDTO = xeDAO.getById(id); ViewData["tenXe"] = xeDTO.TenXe; ViewData["ModelState"] = ModelState.IsValid; bool thanhCong = false; if (ModelState.IsValid) { xeDTO.BienSo = model.BienSo; xeDTO.DaXoa = model.NgungSuDung; xeDTO.HangSanXuat = model.HangSanXuat; xeDTO.Loai = model.Loai; xeDTO.SoGhe = model.SoGhe; xeDTO.TenXe = model.TenXe; xeDTO.TinhTrang = model.TinhTrang; thanhCong = xeDAO.Edit(xeDTO); } ViewData["ThanhCong"] = thanhCong; return View(model); } public ActionResult Them() { return View(); } [HttpPost] public ActionResult Them(Xe model) { ViewData["ModelState"] = ModelState.IsValid; bool thanhCong = false; if (ModelState.IsValid) { XeDAO xeDAO = new XeDAO(); if (xeDAO.CheckNameExists(model.TenXe)) { ModelState.AddModelError("TenXe", "Trùng tên xe, vui lòng chọn một tên khác chưa sử dụng."); ViewData["ModelState"] = false; return View(model); } XeDTO xeDTO = new XeDTO(); xeDTO.BienSo = model.BienSo; xeDTO.DaXoa = model.NgungSuDung; if (string.IsNullOrEmpty(model.HangSanXuat)) { xeDTO.HangSanXuat = ""; } else { xeDTO.HangSanXuat = model.HangSanXuat; } xeDTO.Loai = model.Loai; xeDTO.SoGhe = model.SoGhe; xeDTO.TenXe = model.TenXe; xeDTO.TinhTrang = model.TinhTrang; thanhCong = xeDAO.AddNew(xeDTO); if (thanhCong) { return RedirectToAction("Index", "QLXe"); } } ViewData["ThanhCong"] = thanhCong; return View(model); } public ActionResult ChuyenTinhTrangNgungSuDung(int id) { XeDAO xeDAO = new XeDAO(); xeDAO.NgungSuDung(id, true); return RedirectToAction("Index", "QLXe"); } public ActionResult ChuyenTinhTrangSuDung(int id) { XeDAO xeDAO = new XeDAO(); xeDAO.NgungSuDung(id, false); return RedirectToAction("NgungSuDung", "QLXe"); } } }
1142008-1142076-1142085-ptexpress
trunk/PTExpress/PTExpress/Controllers/QLXeController.cs
C#
asf20
5,220
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using System.Web.Routing; using PTExpress.Models; using DTO; namespace PTExpress.Controllers { [HandleError] [Authorize] public class HomeController : Controller { public IFormsAuthenticationService FormsService { get; set; } public ActionResult Index() { ViewData["test"] = "phai build lai"; return View(); } public ActionResult About() { return View(); } } }
1142008-1142076-1142085-ptexpress
trunk/PTExpress/PTExpress/Controllers/HomeController.cs
C#
asf20
615
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using DAO; using DTO; using PTExpress.Models; namespace PTExpress.Controllers { [Authorize] public class QLDatVeController : AbstractController { public ActionResult Index() { DatVeDAO datVeDAO = new DatVeDAO(); List<DatVeDTO> ls = datVeDAO.GetAll(); this.ViewData.Add("dsDatVe", ls); return View(); } public ActionResult DatVe() { GheDAO gheDAO = new GheDAO(); List<GheDTO> ls = gheDAO.GetAll(); ViewData["ds_ghe"] = ls; return View(); } [HttpPost] public ActionResult DatVe(DatVe model) { GheDAO gheDAO = new GheDAO(); List<GheDTO> ls = gheDAO.GetAll(); ViewData["ds_ghe"] = ls; int a = model.SoGhe; if (ModelState.IsValid) { DatVeDAO datVeDAO = new DatVeDAO(); DatVeDTO datVeDTO = new DatVeDTO(); datVeDTO.KhachHangId = model.KhachHang; datVeDTO.ChuyenXeId = model.ChuyenXe; datVeDTO.NhanVienId = nhanVienDTO.Id; datVeDTO.Ghe = model.SoGhe; datVeDTO.NgayDatVe = DateTime.Now; int maLoi = datVeDAO.AddNew(datVeDTO); ViewData["ThanhCong"] = maLoi == 0; ViewData["maLoi"] = maLoi; if (maLoi == 0) { return RedirectToAction("Index"); } } return View(model); } public ActionResult ThanhToan(int id) { DatVeDAO dvDAO = new DatVeDAO(); DatVeDTO dvDTO = dvDAO.getById(id); ChuyenXeDAO chuyenXeDAO = new ChuyenXeDAO(); ChuyenXeDTO cx = chuyenXeDAO.getById(dvDTO.ChuyenXeId); DatVe model = new DatVe(); model.Id = id; model.KhachHang = dvDTO.KhachHangId; model.ChuyenXe = dvDTO.ChuyenXeId; model.SoGhe = dvDTO.Ghe; model.GiaVe = cx.GiaVe; return View(model); } [HttpPost] public ActionResult ThanhToan(DatVe model, int id) { double giave = new double(); double tongtien = new double(); bool reset = new bool(); double diemhientai = new double(); DatVeDTO datVeDTO = new DatVeDTO(); DatVeDAO datVeDAO = new DatVeDAO(); datVeDTO.Id = id; bool thanhCong = datVeDAO.ThanhToan(datVeDTO, ref giave, ref tongtien, ref reset, ref diemhientai); if (thanhCong) { ViewData["giave"] = giave; ViewData["giave"] = giave; ViewData["reset"] = reset; ViewData["diemhientai"] = diemhientai; return RedirectToAction("Index", "QLDatVe"); } else { return RedirectToAction("Error", "QLDatVe", new { mess = "Hệ thống đang bận, vui lòng thử lại sau." }); } } public ActionResult Error(string mess) { ViewData["mess"] = mess; return View(); } public ActionResult Huy(int id) { DatVeDAO dvDAO = new DatVeDAO(); DatVeDTO dvDTO = dvDAO.getById(id); ChuyenXeDAO chuyenXeDAO = new ChuyenXeDAO(); ChuyenXeDTO cx = chuyenXeDAO.getById(dvDTO.ChuyenXeId); DatVe model = new DatVe(); model.Id = id; model.KhachHang = dvDTO.KhachHangId; model.ChuyenXe = dvDTO.ChuyenXeId; model.SoGhe = dvDTO.Ghe; model.GiaVe = cx.GiaVe; return View(model); } [HttpPost] public ActionResult Huy(DatVe model, int id) { DatVeDTO datVeDTO = new DatVeDTO(); DatVeDAO datVeDAO = new DatVeDAO(); datVeDTO.Id = id; datVeDTO.Ghe = model.SoGhe; bool thanhCong = datVeDAO.HuyDatVe(datVeDTO); if (thanhCong) { return RedirectToAction("Index", "QLDatVe"); } else { return RedirectToAction("Error", "QLDatVe", new { mess = "Hệ thống đang bận, vui lòng thử lại sau." }); } } } }
1142008-1142076-1142085-ptexpress
trunk/PTExpress/PTExpress/Controllers/QLDatVeController.cs
C#
asf20
4,668
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using DAO; using DTO; using PTExpress.Models; namespace PTExpress.Controllers { [Authorize] public class QLKhachHangController : Controller { public Dictionary<int, string> GioiTinh; public QLKhachHangController() : base() { GioiTinh = new Dictionary<int, string>(); GioiTinh.Add(1, "Nam"); GioiTinh.Add(0, "Nữ"); this.ViewData.Add("GioiTinh", GioiTinh); IEnumerable<SelectListItem> lsEGioiTinh = KhachHangDTO.GetListGioiTinh(); this.ViewData.Add("lsEGioiTinh", lsEGioiTinh); } // // GET: /KhachHang/ public ActionResult Index() { KhachHangDAO khachhangDAO = new KhachHangDAO(); List<KhachHangDTO> ls = khachhangDAO.GetAllUnCommited(); this.ViewData.Add("dsKhachHang", ls); return View(); } // // GET: /KhachHang/Details/5 public ActionResult Details(int id) { return View(); } // // GET: /KhachHang/Create public ActionResult Them() { return View(); } // // POST: /KhachHang/Create [HttpPost] public ActionResult Them(KhachHang model) { ViewData["ModelState"] = ModelState.IsValid; bool thanhCong = false; if (ModelState.IsValid) { KhachHangDAO khachhangDAO = new KhachHangDAO(); if (khachhangDAO.CheckUsername(model.Tendangnhap)) { ModelState.AddModelError("TenDangNhap", "Trùng tên đăng nhập, vui lòng chọn một tên khác chưa sử dụng."); ViewData["ModelState"] = false; return View(model); } if (khachhangDAO.CheckEmail(model.Email)) { ModelState.AddModelError("Email", "Trùng email, vui lòng chọn một email khác chưa sử dụng."); ViewData["ModelState"] = false; return View(model); } if (khachhangDAO.CheckCMND(model.Cmnd)) { ModelState.AddModelError("CMND", "Trùng CMND, vui lòng chọn một CMND khác chưa sử dụng."); ViewData["ModelState"] = false; return View(model); } KhachHangDTO khachhangDTO = new KhachHangDTO(); khachhangDTO.Tendangnhap = model.Tendangnhap; khachhangDTO.Matkhau = model.Matkhau; khachhangDTO.Email = model.Email; khachhangDTO.Hoten = model.Hoten; khachhangDTO.Cmnd = model.Cmnd; khachhangDTO.Gioitinh = model.Gioitinh; khachhangDTO.Ngaydangky = DateTime.Now; khachhangDTO.No = 0.0; thanhCong = khachhangDAO.AddNew(khachhangDTO); if (thanhCong) { return RedirectToAction("Index", "QLKhachHang"); } } ViewData["ThanhCong"] = thanhCong; return View(model); } // // GET: /KhachHang/Edit/5 public ActionResult Sua(int id) { KhachHang model = new KhachHang(); KhachHangDAO khachhangDAO = new KhachHangDAO(); KhachHangDTO khachhangDTO = khachhangDAO.getById(id); ViewData["HoTen"] = khachhangDTO.Hoten; model.Id = id; model.Tendangnhap = khachhangDTO.Tendangnhap; model.Matkhau = khachhangDTO.Matkhau; model.Email = khachhangDTO.Email; model.Hoten = khachhangDTO.Hoten; model.Cmnd = khachhangDTO.Cmnd; model.Gioitinh = khachhangDTO.Gioitinh; model.No = khachhangDTO.No; return View(model); } // // POST: /KhachHang/Edit/5 [HttpPost] public ActionResult Sua(int id, KhachHang model) { KhachHangDAO khachhangDAO = new KhachHangDAO(); KhachHangDTO khachhangDTO = khachhangDAO.getById(id); ViewData["HoTen"] = khachhangDTO.Hoten; ViewData["ModelState"] = ModelState.IsValid; bool thanhCong = false; if (ModelState.IsValid) { khachhangDTO.Tendangnhap = model.Tendangnhap; khachhangDTO.Matkhau = model.Matkhau; khachhangDTO.Email = model.Email; khachhangDTO.Cmnd = model.Cmnd; khachhangDTO.Gioitinh = model.Gioitinh; khachhangDTO.No = model.No; khachhangDTO.Hoten = model.Hoten; thanhCong = khachhangDAO.Edit(khachhangDTO); } ViewData["ThanhCong"] = thanhCong; return View(model); } // // GET: /KhachHang/Delete/5 public ActionResult Delete(int id) { return View(); } // // POST: /KhachHang/Delete/5 [HttpPost] public ActionResult Delete(int id, FormCollection collection) { try { // TODO: Add delete logic here return RedirectToAction("Index"); } catch { return View(); } } } }
1142008-1142076-1142085-ptexpress
trunk/PTExpress/PTExpress/Controllers/QLKhachHangController.cs
C#
asf20
5,960
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.ComponentModel.DataAnnotations; namespace PTExpress.Models.Validation { public class MinValueAttribute :ValidationAttribute { private readonly int _value; public MinValueAttribute(int value) { _value = value; } public override bool IsValid(object value) { return (int)value >= _value; } } }
1142008-1142076-1142085-ptexpress
trunk/PTExpress/PTExpress/Models/Validation/MaxValueAttribute.cs
C#
asf20
508
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.ComponentModel.DataAnnotations; using System.ComponentModel; namespace PTExpress.Models { public class NhanVien { [DisplayName("Mã nhân viên")] public int Id { get; set; } [Required] [DisplayName("Tên đăng nhập")] public String Tendangnhap { get; set; } [Required] [DisplayName("Mật khẩu")] public String Matkhau { get; set; } [Required] [DisplayName("Email")] public String Email { get; set; } [Required] [DisplayName("Loại")] public int Loai { get; set; } } }
1142008-1142076-1142085-ptexpress
trunk/PTExpress/PTExpress/Models/NhanVien.cs
C#
asf20
735
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.ComponentModel.DataAnnotations; using System.ComponentModel; namespace PTExpress.Models { public class Xe { [DisplayName("Mã xe")] public int Id { get; set; } [Required] [DisplayName("Tên xe")] public string TenXe { get; set; } [Required] [DisplayName("Biển số")] public string BienSo { get; set; } [Required] [DisplayName("Loại xe")] public int Loai { get; set; } [Required] [DisplayName("Số ghế")] public int SoGhe { get; set; } [DisplayName("Hãng sản xuất")] public string HangSanXuat { get; set; } [Required] [DisplayName("Tình trạng")] public int TinhTrang { get; set; } [Required] [DisplayName("Ngưng sử dụng")] public bool NgungSuDung { get; set; } } }
1142008-1142076-1142085-ptexpress
trunk/PTExpress/PTExpress/Models/Xe.cs
C#
asf20
1,022
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.ComponentModel.DataAnnotations; using System.ComponentModel; using System.Web.Security; namespace PTExpress.Models { public class Login { [Required] [DisplayName("Tên đăng nhập")] public string UserName { get; set; } [Required] [DataType(DataType.Password)] [DisplayName("Mật khẩu")] public string Password { get; set; } } public class LoginService { public static bool ValidateUser(string userName, string password) { if (String.IsNullOrEmpty(userName)) throw new ArgumentException("Value cannot be null or empty.", "userName"); if (String.IsNullOrEmpty(password)) throw new ArgumentException("Value cannot be null or empty.", "password"); DAO.NhanVienDAO nvDAO = new DAO.NhanVienDAO(); int kqDangNhap = nvDAO.DangNhap(userName, password); return kqDangNhap == 0; } } public interface IFormsAuthenticationService { void SignIn(string userName, bool createPersistentCookie); void SignOut(); } public class FormsAuthenticationService : IFormsAuthenticationService { public void SignIn(string userName, bool createPersistentCookie) { if (String.IsNullOrEmpty(userName)) throw new ArgumentException("Value cannot be null or empty.", "userName"); FormsAuthentication.SetAuthCookie(userName, createPersistentCookie); } public void SignOut() { FormsAuthentication.SignOut(); } } }
1142008-1142076-1142085-ptexpress
trunk/PTExpress/PTExpress/Models/Login.cs
C#
asf20
1,752
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.ComponentModel; using System.ComponentModel.DataAnnotations; namespace PTExpress.Models { public class DatVe { public int Id { get; set; } [Required] [DisplayName("Khách hàng")] public int KhachHang { get; set; } [Required] [DisplayName("Chuyến xe")] public int ChuyenXe { get; set; } [DisplayName("Nhân viên đặt vé")] public DateTime NhanVien { get; set; } [Required] [Range(1,100)] [DisplayName("Mã số ghế")] public int SoGhe { get; set; } [DisplayName("Ngày đặt vé")] public double NgayDatVe { get; set; } [DisplayName("Giá vé")] public double GiaVe { get; set; } [DisplayName("Ngày thanh toán")] public double NgayThanhToan { get; set; } [DisplayName("Hủy đặt vé")] public double HuyDatVe { get; set; } [DisplayName("Ngày hủy")] public double NgayHuy { get; set; } } }
1142008-1142076-1142085-ptexpress
trunk/PTExpress/PTExpress/Models/DatVe.cs
C#
asf20
1,156
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.ComponentModel; using System.ComponentModel.DataAnnotations; using PTExpress.Models.Validation; namespace PTExpress.Models { public class TuyenDuong { [DisplayName("Mã tuyến đường")] public int Id { get; set; } [Required] [DisplayName("Nơi đến")] public string NoiDen { get; set; } [Required] [DisplayName("Nơi đi")] public string NoiDi { get; set; } [Required] [MinValueAttribute(1)] [DisplayName("Khoảng cách")] public int KhoangCach { get; set; } [Required] [DisplayName("Số lượng xe")] public int SoLuongXe { get; set; } [DisplayName("Giờ chạy")] [DefaultValue("08:00:00")] public string GioChay { get; set; } [Required] [DisplayName("Giờ nghỉ")] [DefaultValue("20:00:00")] public string GioNghi { get; set; } [Required] [DisplayName("Loại tuyến đường")] public int LoaiTuyenDuong { get; set; } } }
1142008-1142076-1142085-ptexpress
trunk/PTExpress/PTExpress/Models/TuyenDuong.cs
C#
asf20
1,205
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.ComponentModel; using System.ComponentModel.DataAnnotations; namespace PTExpress.Models { public class ChuyenXe { [DisplayName("Mã chuyến xe")] public int Id { get; set; } [Required] [DisplayName("Tuyến đường")] public int TuyenDuong { get; set; } [Required] [DisplayName("Sử dụng xe")] public int Xe { get; set; } [Required] [DisplayName("Thời gian xuất phát")] public DateTime XuatPhat { get; set; } [Required] [DisplayName("Thời gian đến dự kiến")] public DateTime DenNoi { get; set; } [Required] [DisplayName("Giá vé")] public double giaVe { get; set; } } }
1142008-1142076-1142085-ptexpress
trunk/PTExpress/PTExpress/Models/ChuyenXe.cs
C#
asf20
881
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.ComponentModel.DataAnnotations; using System.ComponentModel; namespace PTExpress.Models { public class KhachHang { [DisplayName("Mã khách hàng")] public int Id { get; set; } [Required] [DisplayName("Tên đăng nhập")] public String Tendangnhap { get; set; } [Required] [DisplayName("Mật khẩu")] public String Matkhau { get; set; } [Required] [DisplayName("Email")] public String Email { get; set; } [Required] [DisplayName("Họ tên")] public String Hoten { get; set; } [Required] [DisplayName("Chứng minh nhân dân")] public String Cmnd { get; set; } [Required] [DisplayName("Giới tính")] public int Gioitinh { get; set; } [Required] [DisplayName("Nợ")] public double No { get; set; } } }
1142008-1142076-1142085-ptexpress
trunk/PTExpress/PTExpress/Models/KhachHang.cs
C#
asf20
1,055
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.ComponentModel.DataAnnotations; using System.ComponentModel; namespace PTExpress.Models { public class KhuyenMai { [DisplayName("Mã chuyến xe")] public int Id { get; set; } [Required] [DisplayName("Phần trăm")] public int Phantram { get; set; } [Required] [DisplayName("Ngày bắt đầu")] public DateTime Batdau { get; set; } [Required] [DisplayName("Ngày kết thúc")] public DateTime Ketthuc { get; set; } } }
1142008-1142076-1142085-ptexpress
trunk/PTExpress/PTExpress/Models/KhuyenMai.cs
C#
asf20
653
<%@ Application Codebehind="Global.asax.cs" Inherits="PTExpress.MvcApplication" Language="C#" %>
1142008-1142076-1142085-ptexpress
trunk/PTExpress/PTExpress/Global.asax
ASP.NET
asf20
101
using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("PTExpress")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("PTExpress")] [assembly: AssemblyCopyright("Copyright © 2012")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] // Setting ComVisible to false makes the types in this assembly not visible // to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] // The following GUID is for the ID of the typelib if this project is exposed to COM [assembly: Guid("c6222b03-5a10-46f9-a8d2-4a8e72df56f2")] // Version information for an assembly consists of the following four values: // // Major Version // Minor Version // Build Number // Revision // // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")]
1142008-1142076-1142085-ptexpress
trunk/PTExpress/PTExpress/Properties/AssemblyInfo.cs
C#
asf20
1,389
/*---------------------------------------------------------- The base color for this template is #5c87b2. If you'd like to use a different color start by replacing all instances of #5c87b2 with your new color. ----------------------------------------------------------*/ body { background-color: #5c87b2; font-size: .75em; font-family: Verdana, Helvetica, Sans-Serif; margin: 0; padding: 0; color: #696969; } a:link { color: #034af3; text-decoration: underline; } a:visited { color: #505abc; } a:hover { color: #1d60ff; text-decoration: none; } a:active { color: #12eb87; } p, ul { margin-bottom: 20px; line-height: 1.6em; } /* HEADINGS ----------------------------------------------------------*/ h1, h2, h3, h4, h5, h6 { font-size: 1.5em; color: #000; font-family: Arial, Helvetica, sans-serif; } h1 { font-size: 2em; padding-bottom: 0; margin-bottom: 0; } h2 { padding: 0 0 10px 0; } h3 { font-size: 1.2em; } h4 { font-size: 1.1em; } h5, h6 { font-size: 1em; } /* this rule styles <h2> tags that are the first child of the left and right table columns */ .rightColumn > h1, .rightColumn > h2, .leftColumn > h1, .leftColumn > h2 { margin-top: 0; } /* PRIMARY LAYOUT ELEMENTS ----------------------------------------------------------*/ /* you can specify a greater or lesser percentage for the page width. Or, you can specify an exact pixel width. */ .page { width: 90%; margin-left: auto; margin-right: auto; } #header { position: relative; margin-bottom: 0px; color: #000; padding: 0; } #header h1 { font-weight: bold; padding: 5px 0; margin: 0; color: #fff; border: none; line-height: 2em; font-family: Arial, Helvetica, sans-serif; font-size: 32px !important; } #main { padding: 30px 30px 15px 30px; background-color: #fff; margin-bottom: 30px; _height: 1px; /* only IE6 applies CSS properties starting with an underscore */ } #footer { color: #666; text-align: center; line-height: normal; margin: 0; font-size: .9em; border-top: 3px dotted #999; } /* TAB MENU ----------------------------------------------------------*/ ul#menu { border-bottom: 1px #5C87B2 solid; padding: 0 0 2px; position: relative; margin: 0; text-align: left; } ul#menu li { display: inline; list-style: none; } ul#menu li#greeting { padding: 10px 20px; font-weight: bold; text-decoration: none; line-height: 2.8em; color: #fff; } ul#menu li a, fieldset#button a { padding: 10px 20px; font-weight: bold; text-decoration: none; line-height: 2.8em; background-color: #e8eef4; color: #034af3; } ul#menu li a:hover { background-color: #fff; text-decoration: none; } fieldset#button a:hover { background-color: #e8fff4; text-decoration: none; } ul#menu li a:active, fieldset#button a:active { background-color: #a6e2a6; text-decoration: none; } ul#menu li.selected a { background-color: #fff; color: #000; } /* FORM LAYOUT ELEMENTS ----------------------------------------------------------*/ fieldset { margin: 1em 0; padding: 1em; border: 1px solid #CCC; } fieldset p { margin: 2px 12px 10px 10px; } legend { font-size: 1.1em; font-weight: 600; padding: 2px 4px 8px 4px; } input[type="text"] { width: 200px; border: 1px solid #CCC; } input[type="password"] { width: 200px; border: 1px solid #CCC; } /* TABLE ----------------------------------------------------------*/ table { border: solid 1px #e8eef4; border-collapse: collapse; width: 100%; } table td { padding: 5px; border: solid 1px #e8eef4; color: Black; } table th { padding: 6px 5px; text-align: left; background-color: #e8eef4; border: solid 1px #e8eef4; } /* MISC ----------------------------------------------------------*/ .clear { clear: both; } .error { color: Red; } .success { color: Green; font-weight: bold; } #menucontainer { -margin-top: 40px; } div#title { display: block; float: left; text-align: left; } #logindisplay { font-size: 1.1em; display: block; text-align: right; margin: 10px; color: White; } #logindisplay a:link { color: white; text-decoration: underline; } #logindisplay a:visited { color: white; text-decoration: underline; } #logindisplay a:hover { color: white; text-decoration: none; } /* Styles for validation helpers -----------------------------------------------------------*/ .field-validation-error { color: #ff0000; } .field-validation-valid { display: none; } .input-validation-error { border: 1px solid #ff0000; background-color: #ffeeee; } .validation-summary-errors { font-weight: bold; color: #ff0000; } .validation-summary-valid { display: none; } /* Styles for editor and display helpers ----------------------------------------------------------*/ .display-label, .editor-label, .display-field, .editor-field { margin: 0.5em 0; } .text-box { width: 30em; } .text-box.multi-line { height: 6.5em; } .tri-state { width: 6em; } .KHTT { font-weight: bold; }
1142008-1142076-1142085-ptexpress
trunk/PTExpress/PTExpress/Content/Site.css
CSS
asf20
5,672
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using System.Web.Routing; namespace PTExpress { // Note: For instructions on enabling IIS6 or IIS7 classic mode, // visit http://go.microsoft.com/?LinkId=9394801 public class MvcApplication : System.Web.HttpApplication { public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute( "Default", // Route name "{controller}/{action}/{id}", // URL with parameters new { controller = "QLDatVe", action = "Index", id = UrlParameter.Optional } // Parameter defaults ); } protected void Application_Start() { AreaRegistration.RegisterAllAreas(); RegisterRoutes(RouteTable.Routes); } } }
1142008-1142076-1142085-ptexpress
trunk/PTExpress/PTExpress/Global.asax.cs
C#
asf20
970
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data.SqlClient; using DTO; using System.Data; namespace DAO { public class NhanVienDAO : AbstractDAO<DTO.NhanVienDTO> { protected override string GetTableName() { return "nhanvien"; } public override DTO.NhanVienDTO GetByDataRow(System.Data.DataRow data) { DTO.NhanVienDTO nv = new DTO.NhanVienDTO(); int id, loai; int.TryParse(data["id"].ToString(), out id); int.TryParse(data["loai"].ToString(), out loai); nv.TenDangNhap = data["tendangnhap"].ToString(); nv.MatKhau = data["matkhau"].ToString(); nv.Email = data["email"].ToString(); nv.Id = id; nv.Loai = loai; return nv; } public int DangNhap(string tenDangNhap, string matKhau) { IList<SqlParameter> listParameter = new List<SqlParameter>(); listParameter.Add(new SqlParameter("@TenDangNhap", tenDangNhap)); listParameter.Add(new SqlParameter("@MatKhau", matKhau)); SqlParameter sqlThongBao = new SqlParameter("@ThongBao", SqlDbType.Int ); sqlThongBao.Direction = System.Data.ParameterDirection.Output; listParameter.Add(sqlThongBao); this.dataProvider.ExecuteStoreProc( "Proc_DangNhap", listParameter); return (int)sqlThongBao.Value; } public NhanVienDTO getByTenDangNhap(string tenDangNhap) { NhanVienDTO nv = null; string tableName = GetTableName(); String query = String.Format( "SELECT * FROM {0} WHERE tendangnhap = '{1}'", tableName, tenDangNhap); DataTable dt = dataProvider.ExecuteQuery(query); if (dt.Rows.Count > 0) { DataRow row = dt.Rows[0]; nv = GetByDataRow(row); } return nv; } public bool AddNew(DTO.NhanVienDTO nhanvienDTO) { IList<SqlParameter> listParameter = new List<SqlParameter>(); listParameter.Add(new SqlParameter("@TenDangNhap", nhanvienDTO.TenDangNhap)); listParameter.Add(new SqlParameter("@MatKhau", nhanvienDTO.MatKhau)); listParameter.Add(new SqlParameter("@Email", nhanvienDTO.Email)); listParameter.Add(new SqlParameter("@Loai", nhanvienDTO.Loai)); SqlParameter sqlThongBao = new SqlParameter("@ThanhCong", SqlDbType.Bit); sqlThongBao.Direction = System.Data.ParameterDirection.Output; listParameter.Add(sqlThongBao); this.dataProvider.ExecuteStoreProc( "Proc_ThemNhanVien", listParameter); return (bool)sqlThongBao.Value; } public bool Edit(DTO.NhanVienDTO nhanvienDTO) { IList<SqlParameter> listParameter = new List<SqlParameter>(); listParameter.Add(new SqlParameter("@Id", nhanvienDTO.Id)); listParameter.Add(new SqlParameter("@TenDangNhap", nhanvienDTO.TenDangNhap)); listParameter.Add(new SqlParameter("@MatKhau", nhanvienDTO.MatKhau)); listParameter.Add(new SqlParameter("@Email", nhanvienDTO.Email)); listParameter.Add(new SqlParameter("@Loai", nhanvienDTO.Loai)); SqlParameter thongBao = new SqlParameter("@ThanhCong", System.Data.SqlDbType.Bit); thongBao.Direction = System.Data.ParameterDirection.Output; listParameter.Add(thongBao); this.dataProvider.ExecuteStoreProc( "Proc_CapNhatNhanVien", listParameter); return (bool)thongBao.Value; } public bool CheckUsername(String username) { return false; } public bool CheckEmail(String email) { return false; } } }
1142008-1142076-1142085-ptexpress
trunk/PTExpress/DAO/NhanVienDAO.cs
C#
asf20
4,172
using System; using System.Collections.Generic; using System.Linq; using System.Text; using DTO; using System.Data; using System.Data.SqlClient; namespace DAO { public class ChuyenXeDAO : AbstractDAO<ChuyenXeDTO> { protected override string GetTableName() { return "chuyenxe"; } public ChuyenXeDTO GetFullByDataRow(System.Data.DataRow data) { ChuyenXeDTO chuyenXe = new ChuyenXeDTO(); int id, soGheTrong; double giaVe; int.TryParse(data["id"].ToString(), out id); int.TryParse(data["soghetrong"].ToString(), out soGheTrong); double.TryParse(data["giave"].ToString(), out giaVe); chuyenXe.Id = id; chuyenXe.SoGheTrong = soGheTrong; chuyenXe.GiaVe = giaVe; chuyenXe.TenXe = data["tenxe"].ToString(); chuyenXe.TenTuyenDuong = data["TenTuyenDuong"].ToString(); chuyenXe.XuatPhat = DateTime.Parse(data["thoigianxuatphat"].ToString()); chuyenXe.DenNoi = DateTime.Parse(data["thoigianden"].ToString()); chuyenXe.NgayLenLich = DateTime.Parse(data["ngaytao"].ToString()); return chuyenXe; } public override List<ChuyenXeDTO> GetAll() { List<ChuyenXeDTO> ls = new List<ChuyenXeDTO>(); String query = "EXEC [Proc_GetChuyenXe]"; DataTable dt = dataProvider.ExecuteQuery(query); if (dt.Rows.Count > 0) { foreach (DataRow r in dt.Rows) { ChuyenXeDTO p = GetFullByDataRow(r); ls.Add(p); } } return ls; } public bool AddNew(ChuyenXeDTO chuyenXeDTO) { IList<SqlParameter> listParameter = new List<SqlParameter>(); listParameter.Add(new SqlParameter("@XeId", chuyenXeDTO.XeId)); listParameter.Add(new SqlParameter("@TuyenDuongId", chuyenXeDTO.TuyenDuongId)); listParameter.Add(new SqlParameter("@XuatPhat", chuyenXeDTO.XuatPhat)); listParameter.Add(new SqlParameter("@DenNoi", chuyenXeDTO.DenNoi)); listParameter.Add(new SqlParameter("@GiaVe", chuyenXeDTO.GiaVe)); SqlParameter sqlThongBao = new SqlParameter("@ThanhCong", SqlDbType.Bit); sqlThongBao.Direction = System.Data.ParameterDirection.Output; listParameter.Add(sqlThongBao); this.dataProvider.ExecuteStoreProc( "Proc_ThemChuyenXe", listParameter); return (bool)sqlThongBao.Value; } public override ChuyenXeDTO GetByDataRow(DataRow data) { ChuyenXeDTO chuyenXe = new ChuyenXeDTO(); int id, soGheTrong; double giaVe; int.TryParse(data["id"].ToString(), out id); int.TryParse(data["soghetrong"].ToString(), out soGheTrong); double.TryParse(data["giave"].ToString(), out giaVe); chuyenXe.Id = id; chuyenXe.SoGheTrong = soGheTrong; chuyenXe.GiaVe = giaVe; chuyenXe.XuatPhat = DateTime.Parse(data["thoigianxuatphat"].ToString()); chuyenXe.DenNoi = DateTime.Parse(data["thoigianden"].ToString()); chuyenXe.NgayLenLich = DateTime.Parse(data["ngaytao"].ToString()); return chuyenXe; } } }
1142008-1142076-1142085-ptexpress
trunk/PTExpress/DAO/ChuyenXeDAO.cs
C#
asf20
3,557
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data; using System.Data.SqlClient; namespace DAO { public abstract class AbstractDAO<P> { protected string tableName; protected abstract string GetTableName(); protected DataProvider dataProvider; public AbstractDAO() { dataProvider = new DataProvider(); tableName = GetTableName(); } public P getById(int id) { P p; String query = String.Format("SELECT * FROM {0} WHERE id = '{1}'", tableName, id.ToString()); DataTable dt = dataProvider.ExecuteQuery(query); if (dt.Rows.Count > 0) { DataRow row = dt.Rows[0]; p = GetByDataRow(row); } else { p = Activator.CreateInstance<P>(); } return p; } public virtual List<P> GetAll() { List<P> ls = new List<P>(); String query = String.Format("SELECT * FROM {0}", tableName); DataTable dt = dataProvider.ExecuteQuery(query); if (dt.Rows.Count > 0) { foreach (DataRow r in dt.Rows) { P p = GetByDataRow(r); ls.Add(p); } } return ls; } public virtual List<P> GetAllUnCommited() { List<P> ls = new List<P>(); String query = String.Format("exec Proc_Get_{0}", tableName); DataTable dt = dataProvider.ExecuteQuery(query); if (dt.Rows.Count > 0) { foreach (DataRow r in dt.Rows) { P p = GetByDataRow(r); ls.Add(p); } } return ls; } public DataTable GetDataTable() { String query = String.Format("SELECT * FROM {0}", tableName); DataTable dt = dataProvider.ExecuteQuery(query); return dt; } public List<P> GetAllWhere(string where) { List<P> ls = new List<P>(); String query = String.Format("SELECT * FROM {0} WHERE {1}", tableName, where); DataTable dt = dataProvider.ExecuteQuery(query); if (dt.Rows.Count > 0) { foreach (DataRow r in dt.Rows) { P p = GetByDataRow(r); ls.Add(p); } } return ls; } public abstract P GetByDataRow(DataRow data); } }
1142008-1142076-1142085-ptexpress
trunk/PTExpress/DAO/AbstractDAO.cs
C#
asf20
2,827
using System; using System.Collections.Generic; using System.Linq; using System.Text; using DTO; using System.Data.SqlClient; using System.Data; namespace DAO { public class TuyenDuongDAO : AbstractDAO<TuyenDuongDTO> { protected override string GetTableName() { return "tuyenduong"; } public override TuyenDuongDTO GetByDataRow(System.Data.DataRow data) { DTO.TuyenDuongDTO tuyenDuong = new DTO.TuyenDuongDTO(); int id, loai, kc, soLuongXe; int.TryParse(data["id"].ToString(), out id); int.TryParse(data["loai"].ToString(), out loai); int.TryParse(data["khoangcach"].ToString(), out kc); int.TryParse(data["soluongxe"].ToString(), out soLuongXe); tuyenDuong.Id = id; tuyenDuong.Loai = loai; tuyenDuong.KhoangCach = kc; tuyenDuong.SoLuongXe = soLuongXe; tuyenDuong.GioBatDauChay = data["giobatdauchay"].ToString(); tuyenDuong.GioNghi = data["gionghi"].ToString(); tuyenDuong.NoiDen = data["noiden"].ToString(); tuyenDuong.NoiDi = data["noidi"].ToString(); return tuyenDuong; } public bool Edit(DTO.TuyenDuongDTO xeDTO) { IList<SqlParameter> listParameter = new List<SqlParameter>(); listParameter.Add(new SqlParameter("@Id", xeDTO.Id)); listParameter.Add(new SqlParameter("@NoiDen", xeDTO.NoiDen)); listParameter.Add(new SqlParameter("@NoiDi", xeDTO.NoiDi)); listParameter.Add(new SqlParameter("@KhoangCach", xeDTO.KhoangCach)); listParameter.Add(new SqlParameter("@GioChay", xeDTO.GioBatDauChay)); listParameter.Add(new SqlParameter("@GioNghi", xeDTO.GioNghi)); listParameter.Add(new SqlParameter("@Loai", xeDTO.Loai)); SqlParameter thongBao = new SqlParameter("@ThanhCong", SqlDbType.Bit); thongBao.Direction = System.Data.ParameterDirection.Output; listParameter.Add(thongBao); this.dataProvider.ExecuteStoreProc( "Proc_CapNhatTuyenDuong", listParameter); return (bool)thongBao.Value; } public bool AddNew(TuyenDuongDTO tuyenDuongDTO) { IList<SqlParameter> listParameter = new List<SqlParameter>(); listParameter.Add(new SqlParameter("@NoiDen", tuyenDuongDTO.NoiDen)); listParameter.Add(new SqlParameter("@NoiDi", tuyenDuongDTO.NoiDi)); listParameter.Add(new SqlParameter("@KhoangCach", tuyenDuongDTO.KhoangCach)); listParameter.Add(new SqlParameter("@GioBatDauChay", tuyenDuongDTO.GioBatDauChay)); listParameter.Add(new SqlParameter("@GioNghi", tuyenDuongDTO.GioNghi)); listParameter.Add(new SqlParameter("@Loai", tuyenDuongDTO.Loai)); SqlParameter sqlThongBao = new SqlParameter("@ThanhCong", SqlDbType.Bit); sqlThongBao.Direction = System.Data.ParameterDirection.Output; listParameter.Add(sqlThongBao); this.dataProvider.ExecuteStoreProc( "Proc_ThemTuyenDuong", listParameter); return (bool)sqlThongBao.Value; } } }
1142008-1142076-1142085-ptexpress
trunk/PTExpress/DAO/TuyenDuongDAO.cs
C#
asf20
3,384
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace DAO { public class QuyDinhDTO { private string _ten; public string Ten { get { return _ten; } set { _ten = value; } } private string _giaTri; public string GiaTri { get { return _giaTri; } set { _giaTri = value; } } } }
1142008-1142076-1142085-ptexpress
trunk/PTExpress/DAO/QuyDinhDTO.cs
C#
asf20
471
using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("DAO")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("DAO")] [assembly: AssemblyCopyright("Copyright © 2012")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] // Setting ComVisible to false makes the types in this assembly not visible // to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] // The following GUID is for the ID of the typelib if this project is exposed to COM [assembly: Guid("ff9b7b5d-696b-4583-a791-a47c8df3d64f")] // Version information for an assembly consists of the following four values: // // Major Version // Minor Version // Build Number // Revision // // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")]
1142008-1142076-1142085-ptexpress
trunk/PTExpress/DAO/Properties/AssemblyInfo.cs
C#
asf20
1,418
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data; namespace DAO { public class QuyDinhDAO : AbstractDAO<QuyDinhDTO> { protected override string GetTableName() { return "quydinh"; } public string GetByName(string tenquydinh) { String query = String.Format("SELECT * FROM {0} WHERE tenquydinh = '{1}'", tableName, tenquydinh); DataTable dt = dataProvider.ExecuteQuery(query); if (dt.Rows.Count > 0) { return dt.Rows[0]["giatri"].ToString(); } return ""; } public override QuyDinhDTO GetByDataRow(DataRow data) { throw new NotImplementedException(); } } }
1142008-1142076-1142085-ptexpress
trunk/PTExpress/DAO/QuyDinhDAO.cs
C#
asf20
844
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data.SqlClient; using System.Data.SqlTypes; using System.Data; namespace DAO { public class XeDAO : AbstractDAO<DTO.XeDTO> { protected override string GetTableName() { return "xe"; } public override DTO.XeDTO GetByDataRow(System.Data.DataRow data) { DTO.XeDTO xe = new DTO.XeDTO(); int id, soGhe, tinhTrang, loai; bool daXoa; int.TryParse(data["id"].ToString(), out id); xe.TenXe = data["tenxe"].ToString(); xe.BienSo = data["bienso"].ToString(); xe.HangSanXuat = data["hangsanxuat"].ToString(); int.TryParse(data["loai"].ToString(), out loai); int.TryParse(data["soghe"].ToString(), out soGhe); int.TryParse(data["tinhtrang"].ToString(), out tinhTrang); bool.TryParse(data["daxoa"].ToString(), out daXoa); xe.Id = id; xe.SoGhe = soGhe; xe.TinhTrang = tinhTrang; xe.DaXoa = daXoa; xe.Loai = loai; return xe; } public bool AddNew(DTO.XeDTO xeDTO) { IList<SqlParameter> listParameter = new List<SqlParameter>(); listParameter.Add(new SqlParameter("@TenXe", xeDTO.TenXe)); listParameter.Add(new SqlParameter("@BienSo", xeDTO.BienSo)); listParameter.Add(new SqlParameter("@Loai", xeDTO.Loai)); listParameter.Add(new SqlParameter("@HangSanXuat", xeDTO.HangSanXuat)); listParameter.Add(new SqlParameter("@SoGhe", xeDTO.SoGhe)); listParameter.Add(new SqlParameter("@TinhTrang", xeDTO.TinhTrang)); SqlParameter sqlThongBao = new SqlParameter("@ThanhCong", SqlDbType.Bit); sqlThongBao.Direction = System.Data.ParameterDirection.Output; listParameter.Add(sqlThongBao); this.dataProvider.ExecuteStoreProc( "Proc_ThemXeMoi", listParameter); return (bool)sqlThongBao.Value; } public bool Edit(DTO.XeDTO xeDTO) { IList<SqlParameter> listParameter = new List<SqlParameter>(); listParameter.Add(new SqlParameter("@Id", xeDTO.Id)); listParameter.Add(new SqlParameter("@TenXe", xeDTO.TenXe)); listParameter.Add(new SqlParameter("@BienSo", xeDTO.BienSo)); listParameter.Add(new SqlParameter("@Loai", xeDTO.Loai)); listParameter.Add(new SqlParameter("@HangSanXuat", xeDTO.HangSanXuat)); listParameter.Add(new SqlParameter("@SoGhe", xeDTO.SoGhe)); listParameter.Add(new SqlParameter("@TinhTrang", xeDTO.TinhTrang)); listParameter.Add(new SqlParameter("@DaXoa", xeDTO.DaXoa)); SqlParameter thongBao = new SqlParameter("@ThanhCong", System.Data.SqlDbType.Bit); thongBao.Direction = System.Data.ParameterDirection.Output; listParameter.Add(thongBao); this.dataProvider.ExecuteStoreProc( "Proc_CapNhatXe", listParameter); return (bool)thongBao.Value; } public bool CheckNameExists(string name) { IList<SqlParameter> listParameter = new List<SqlParameter>(); listParameter.Add(new SqlParameter("@TenXe", name)); SqlParameter thanhCong = new SqlParameter("@ThanhCong", System.Data.SqlDbType.Bit); thanhCong.Direction = System.Data.ParameterDirection.Output; listParameter.Add(thanhCong); this.dataProvider.ExecuteStoreProc( "Proc_CheckCarNameExists", listParameter); return (bool)thanhCong.Value; } public bool CapNhatTinhTrang(int id, int tinhtrang) { IList<SqlParameter> listParameter = new List<SqlParameter>(); listParameter.Add(new SqlParameter("@Id", id)); listParameter.Add(new SqlParameter("@TinhTrang", tinhtrang)); this.dataProvider.ExecuteStoreProc( "Proc_CapNhatTinhTrang", listParameter); return (bool)true; } public bool NgungSuDung(int id, bool ngungSuDung) { IList<SqlParameter> listParameter = new List<SqlParameter>(); listParameter.Add(new SqlParameter("@Id", id)); listParameter.Add(new SqlParameter("@NgungSuDung", ngungSuDung)); this.dataProvider.ExecuteStoreProc( "Proc_NgungSuDung", listParameter); return (bool)true; } } }
1142008-1142076-1142085-ptexpress
trunk/PTExpress/DAO/XeDAO.cs
C#
asf20
4,828
using System; using System.Collections.Generic; using System.Linq; using System.Text; using DTO; using System.Data; namespace DAO { public class GheDAO : AbstractDAO<GheDTO> { protected override string GetTableName() { return "vitridatve"; } public override GheDTO GetByDataRow(System.Data.DataRow data) { GheDTO gheDTO = new GheDTO(); gheDTO.ChuyenXeId = int.Parse(data["chuyenxe_id"].ToString()); gheDTO.MaSoGhe = int.Parse(data["maso"].ToString()); gheDTO.KhachHangId = int.Parse(data["khachhang_id"].ToString()); return gheDTO; } public List<GheDTO> GetByChuyenXeId(int chuyenXeId) { List<GheDTO> ls = new List<GheDTO>(); String query = String.Format("SELECT * FROM {0} where chuyenxe_id = {1}", tableName, chuyenXeId); DataTable dt = dataProvider.ExecuteQuery(query); if (dt.Rows.Count > 0) { foreach (DataRow r in dt.Rows) { GheDTO p = GetByDataRow(r); ls.Add(p); } } return ls; } } }
1142008-1142076-1142085-ptexpress
trunk/PTExpress/DAO/GheDAO.cs
C#
asf20
1,271
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data.SqlClient; using System.Data.SqlTypes; using System.Data; namespace DAO { public class KhuyenMaiDAO : AbstractDAO<DTO.KhuyenMaiDTO> { protected override string GetTableName() { return "khuyenmai"; } public override DTO.KhuyenMaiDTO GetByDataRow(System.Data.DataRow row) { DTO.KhuyenMaiDTO khuyenmai = new DTO.KhuyenMaiDTO(); int id, phantram; DateTime batdau, ketthuc; int.TryParse(row["chuyenxe_id"].ToString(), out id); int.TryParse(row["phantram"].ToString(), out phantram); DateTime.TryParse(row["thoigianbatdau"].ToString(), out batdau); DateTime.TryParse(row["thoigianketthuc"].ToString(), out ketthuc); khuyenmai.Id = id; khuyenmai.Phantram = phantram; khuyenmai.Batdau = batdau; khuyenmai.Ketthuc = ketthuc; return khuyenmai; } public DTO.KhuyenMaiDTO getById(String chuyenxe_id) { DTO.KhuyenMaiDTO khuyenmai = new DTO.KhuyenMaiDTO(); IList<DTO.KhuyenMaiDTO> ls = GetAllWhere("chuyenxe_id = " + chuyenxe_id); khuyenmai = ls[0]; return khuyenmai; } public bool Edit(DTO.KhuyenMaiDTO khuyenmaiDTO, DTO.KhuyenMaiDTO newkhuyenmaiDTO) { IList<SqlParameter> listParameter = new List<SqlParameter>(); listParameter.Add(new SqlParameter("@ChuyenXeId", khuyenmaiDTO.Id)); listParameter.Add(new SqlParameter("@PhanTram", khuyenmaiDTO.Phantram)); listParameter.Add(new SqlParameter("@BatDau", khuyenmaiDTO.Batdau)); listParameter.Add(new SqlParameter("@KetThuc", khuyenmaiDTO.Ketthuc)); listParameter.Add(new SqlParameter("@ChuyenXeIdMoi", newkhuyenmaiDTO.Id)); listParameter.Add(new SqlParameter("@PhanTramMoi", newkhuyenmaiDTO.Phantram)); listParameter.Add(new SqlParameter("@BatDauMoi", newkhuyenmaiDTO.Batdau)); listParameter.Add(new SqlParameter("@KetThucMoi", newkhuyenmaiDTO.Ketthuc)); SqlParameter thongBao = new SqlParameter("@ThanhCong", System.Data.SqlDbType.Bit); thongBao.Direction = System.Data.ParameterDirection.Output; listParameter.Add(thongBao); this.dataProvider.ExecuteStoreProc( "Proc_CapNhatKhuyenMai", listParameter); return (bool)thongBao.Value; } public bool AddNew(DTO.KhuyenMaiDTO khuyenmaiDTO) { IList<SqlParameter> listParameter = new List<SqlParameter>(); listParameter.Add(new SqlParameter("@ChuyenXeId", khuyenmaiDTO.Id)); listParameter.Add(new SqlParameter("@PhanTram", khuyenmaiDTO.Phantram)); listParameter.Add(new SqlParameter("@ThoiGianBatDau", khuyenmaiDTO.Batdau)); listParameter.Add(new SqlParameter("@ThoiGianKetThuc", khuyenmaiDTO.Ketthuc)); SqlParameter sqlThongBao = new SqlParameter("@ThanhCong", SqlDbType.Bit); sqlThongBao.Direction = System.Data.ParameterDirection.Output; listParameter.Add(sqlThongBao); this.dataProvider.ExecuteStoreProc( "Proc_ThemKhuyenMai", listParameter); return (bool)sqlThongBao.Value; } } }
1142008-1142076-1142085-ptexpress
trunk/PTExpress/DAO/KhuyenMaiDAO.cs
C#
asf20
3,561
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data.SqlClient; using System.Data.SqlTypes; using System.Data; namespace DAO { public class KhachHangDAO : AbstractDAO<DTO.KhachHangDTO> { protected override string GetTableName() { return "khachhang"; } public override DTO.KhachHangDTO GetByDataRow(System.Data.DataRow row) { DTO.KhachHangDTO khachhang = new DTO.KhachHangDTO(); int id; String tendangnhap, matkhau, email, hoten, cmnd; int gioitinh; double no; DateTime ngaydangky; int.TryParse(row["id"].ToString(), out id); int.TryParse(row["gioitinh"].ToString(), out gioitinh); tendangnhap = row["tendangnhap"].ToString(); matkhau = row["matkhau"].ToString(); email = row["email"].ToString(); hoten = row["hoten"].ToString(); cmnd = row["cmnd"].ToString(); DateTime.TryParse(row["ngaydangky"].ToString(), out ngaydangky); double.TryParse(row["no"].ToString(), out no); khachhang.Id = id; khachhang.Tendangnhap = tendangnhap; khachhang.Matkhau = matkhau; khachhang.Email = email; khachhang.Hoten = hoten; khachhang.Cmnd = cmnd; khachhang.Gioitinh = gioitinh; khachhang.Ngaydangky = ngaydangky; khachhang.No = no; return khachhang; } public DTO.KhachHangDTO GetByDataRow(System.Data.DataRow row, int mode) { DTO.KhachHangDTO khachhang = new DTO.KhachHangDTO(); int id; String tendangnhap, matkhau, email, hoten, cmnd; int gioitinh; double no; DateTime ngaydangky; int.TryParse(row["id"].ToString(), out id); int.TryParse(row["gioitinh"].ToString(), out gioitinh); tendangnhap = row["tendangnhap"].ToString(); matkhau = row["matkhau"].ToString(); email = row["email"].ToString(); hoten = row["hoten"].ToString(); cmnd = row["cmnd"].ToString(); DateTime.TryParse(row["ngaydangky"].ToString(), out ngaydangky); double.TryParse(row["no"].ToString(), out no); khachhang.Id = id; khachhang.Tendangnhap = tendangnhap; khachhang.Matkhau = matkhau; khachhang.Email = email; khachhang.Hoten = hoten; khachhang.Cmnd = cmnd; khachhang.Gioitinh = gioitinh; khachhang.Ngaydangky = ngaydangky; khachhang.No = no; khachhang.LaKHTT = row["laKHTT"].ToString() == "True"; if (khachhang.LaKHTT) { khachhang.DiemThuong = int.Parse(row["diem"].ToString()); } return khachhang; } public bool AddNew(DTO.KhachHangDTO khachhangDTO) { IList<SqlParameter> listParameter = new List<SqlParameter>(); listParameter.Add(new SqlParameter("@TenDangNhap", khachhangDTO.Tendangnhap)); listParameter.Add(new SqlParameter("@MatKhau", khachhangDTO.Matkhau)); listParameter.Add(new SqlParameter("@GioiTinh", khachhangDTO.Gioitinh)); listParameter.Add(new SqlParameter("@Email", khachhangDTO.Email)); listParameter.Add(new SqlParameter("@HoTen", khachhangDTO.Hoten)); listParameter.Add(new SqlParameter("@NgayDangKy", khachhangDTO.Ngaydangky)); listParameter.Add(new SqlParameter("@No", khachhangDTO.No)); listParameter.Add(new SqlParameter("@CMND", khachhangDTO.Cmnd)); SqlParameter sqlThongBao = new SqlParameter("@ThanhCong", SqlDbType.Bit); sqlThongBao.Direction = System.Data.ParameterDirection.Output; listParameter.Add(sqlThongBao); this.dataProvider.ExecuteStoreProc( "Proc_ThemKhachHang", listParameter); return (bool)sqlThongBao.Value; } public bool Edit(DTO.KhachHangDTO khachhangDTO) { IList<SqlParameter> listParameter = new List<SqlParameter>(); listParameter.Add(new SqlParameter("@Id", khachhangDTO.Id)); listParameter.Add(new SqlParameter("@TenDangNhap", khachhangDTO.Tendangnhap)); listParameter.Add(new SqlParameter("@MatKhau", khachhangDTO.Matkhau)); listParameter.Add(new SqlParameter("@Email", khachhangDTO.Email)); listParameter.Add(new SqlParameter("@HoTen", khachhangDTO.Hoten)); listParameter.Add(new SqlParameter("@GioiTinh", khachhangDTO.Gioitinh)); listParameter.Add(new SqlParameter("@CMND", khachhangDTO.Cmnd)); listParameter.Add(new SqlParameter("@No", khachhangDTO.No)); SqlParameter thongBao = new SqlParameter("@ThanhCong", System.Data.SqlDbType.Bit); thongBao.Direction = System.Data.ParameterDirection.Output; listParameter.Add(thongBao); this.dataProvider.ExecuteStoreProc( "Proc_CapNhatKhachHang", listParameter); return (bool)thongBao.Value; } public bool CheckUsername(String username) { return false; } public bool CheckEmail(String email) { return false; } public bool CheckCMND(String cmnd) { return false; } } }
1142008-1142076-1142085-ptexpress
trunk/PTExpress/DAO/KhachHangDAO.cs
C#
asf20
5,750
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data.Common; using System.Data; using System.Configuration; using System.Data.SqlClient; using System.Collections; using System.Threading; namespace DAO { public class DataProvider { private static SqlConnection _con = null; static DataProvider() { //lấy chuỗi kết nối từ web.config string strConnection = ConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString.ToString(); _con = new SqlConnection(strConnection); } // thực thi câu truy vấn sql public DataTable ExecuteQuery(string strQuery) { DataTable resTable = new DataTable(); try { _con.Open(); SqlDataAdapter adapter = new SqlDataAdapter(strQuery, _con); adapter.Fill(resTable); } catch (Exception ex) { throw new Exception("Loi khi thuc thi lenh SQL: " + ex.Message); } finally { _con.Close(); } return resTable; } // thực thi câu truy vấn bằng StoreProcedure public DataTable ExecuteStoreProc(string storeProcName, IList<SqlParameter> arrParameter) { DataTable resTable = new DataTable(); try { _con.Open(); SqlCommand cmd = new SqlCommand(storeProcName, _con); cmd.CommandText = storeProcName; cmd.CommandType = CommandType.StoredProcedure; //Lay so parameter int N = arrParameter.Count; for (int i = 0; i < N; i++) { cmd.Parameters.Add(arrParameter[i]); } SqlDataAdapter adapter = new SqlDataAdapter(cmd); adapter.Fill(resTable); } catch (Exception ex) { throw new Exception("Lỗi khi thực thi stored procedure: " + ex.Message); } finally { _con.Close(); } return resTable; } } }
1142008-1142076-1142085-ptexpress
trunk/PTExpress/DAO/DataProvider.cs
C#
asf20
2,404
using System; using System.Collections.Generic; using System.Linq; using System.Text; using DTO; using System.Data.SqlClient; using System.Data; namespace DAO { public class DatVeDAO : AbstractDAO<DatVeDTO> { protected override string GetTableName() { return "datve"; } public DatVeDTO GetFullByDataRow(System.Data.DataRow data) { DatVeDTO datVe = new DatVeDTO(); datVe.Id = int.Parse(data["id"].ToString()); datVe.HoTen = data["hoten"].ToString(); datVe.Chuyen = data["chuyen"].ToString(); datVe.NhanVien = data["nhanvien"].ToString(); datVe.Ghe = int.Parse(data["soghe"].ToString()); datVe.NgayDatVe = DateTime.Parse(data["ngaydatve"].ToString()); datVe.DaThanhToan = bool.Parse(data["dathanhtoan"].ToString()); if (data["ngaythanhtoan"].GetType() == typeof(DateTime)) { datVe.NgayThanhToan = DateTime.Parse(data["ngaythanhtoan"].ToString()); } if (data["ngayhuy"].GetType() == typeof(DateTime)) { datVe.NgayHuy = DateTime.Parse(data["ngayhuy"].ToString()); } datVe.HuyDatVe = data["huydatve"].ToString() == "True"; return datVe; } public int AddNew(DatVeDTO datVeDTO) { IList<SqlParameter> listParameter = new List<SqlParameter>(); listParameter.Add(new SqlParameter("@KhachHangID", datVeDTO.KhachHangId)); listParameter.Add(new SqlParameter("@ChuyenXeID", datVeDTO.ChuyenXeId)); listParameter.Add(new SqlParameter("@NhanVienID", datVeDTO.NhanVienId)); listParameter.Add(new SqlParameter("@SoGhe", datVeDTO.Ghe)); listParameter.Add(new SqlParameter("@NgayDatVe", datVeDTO.NgayDatVe)); SqlParameter sqlThongBao = new SqlParameter("@MaLoi", SqlDbType.Int); sqlThongBao.Direction = System.Data.ParameterDirection.Output; listParameter.Add(sqlThongBao); this.dataProvider.ExecuteStoreProc( "Proc_DatVe", listParameter); return (int)sqlThongBao.Value; } public override List<DatVeDTO> GetAll() { List<DatVeDTO> ls = new List<DatVeDTO>(); String query = String.Format( "SELECT" + " datve.id, " + " khachhang.hoten, " + " tuyenduong.noidi + ' - ' + " + " tuyenduong.noiden + ' - ' + convert(varchar, chuyenxe.thoigianxuatphat, 101) chuyen, " + " nhanvien.tendangnhap nhanvien, " + " datve.soghe, " + " datve.ngaydatve, " + " datve.dathanhtoan, " + " CAST( CASE " + " WHEN datve.dathanhtoan = 0 and DATEADD(DAY,7, datve.ngaydatve) < GETDATE() THEN 1 " + " else 0 " + " END as bit) | huydatve huydatve, " + " datve.ngaythanhtoan, " + " datve.ngayhuy " + "FROM " + " datve INNER JOIN " + " nhanvien ON datve.nhanvien_id = nhanvien.id INNER JOIN " + " chuyenxe ON datve.chuyenxe_id = chuyenxe.id INNER JOIN " + " khachhang ON datve.khachhang_id = khachhang.id INNER JOIN " + " tuyenduong ON chuyenxe.tuyenduong_id = tuyenduong.id"); DataTable dt = dataProvider.ExecuteQuery(query); if (dt.Rows.Count > 0) { foreach (DataRow r in dt.Rows) { DatVeDTO p = GetFullByDataRow(r); ls.Add(p); } } return ls; } public override DatVeDTO GetByDataRow(DataRow data) { DatVeDTO datVe = new DatVeDTO(); datVe.Id = int.Parse(data["id"].ToString()); datVe.KhachHangId = int.Parse(data["khachhang_id"].ToString()); datVe.ChuyenXeId = int.Parse(data["chuyenxe_id"].ToString()); datVe.Ghe = int.Parse(data["soghe"].ToString()); datVe.NgayDatVe = DateTime.Parse(data["ngaydatve"].ToString()); datVe.DaThanhToan = bool.Parse(data["dathanhtoan"].ToString()); if (data["ngaythanhtoan"].GetType() == typeof(DateTime)) { datVe.NgayThanhToan = DateTime.Parse(data["ngaythanhtoan"].ToString()); } if (data["ngayhuy"].GetType() == typeof(DateTime)) { datVe.NgayHuy = DateTime.Parse(data["ngayhuy"].ToString()); } datVe.HuyDatVe = bool.Parse(data["huydatve"].ToString()); return datVe; } public bool ThanhToan(DatVeDTO datVeDTO, ref double giave, ref double tongtien, ref bool reset, ref double diemhientai) { IList<SqlParameter> listParameter = new List<SqlParameter>(); listParameter.Add(new SqlParameter("@DatVeId", datVeDTO.Id)); SqlParameter sqlReset = new SqlParameter("@Reset", SqlDbType.Bit); sqlReset.Direction = System.Data.ParameterDirection.Output; listParameter.Add(sqlReset); SqlParameter sqlGiaVe = new SqlParameter("@GiaVe", SqlDbType.Float); sqlGiaVe.Direction = System.Data.ParameterDirection.Output; listParameter.Add(sqlGiaVe); SqlParameter sqlTongTien = new SqlParameter("@TongTien", SqlDbType.Float); sqlTongTien.Direction = System.Data.ParameterDirection.Output; listParameter.Add(sqlTongTien); SqlParameter sqlDiemCongHienTai = new SqlParameter("@DiemCongHienTai", SqlDbType.Float); sqlDiemCongHienTai.Direction = System.Data.ParameterDirection.Output; listParameter.Add(sqlDiemCongHienTai); try { this.dataProvider.ExecuteStoreProc( "Proc_ThanhToan", listParameter); double.TryParse(sqlGiaVe.Value.ToString(), out giave); double.TryParse(sqlTongTien.Value.ToString(), out tongtien); bool.TryParse(sqlReset.Value.ToString(), out reset); double.TryParse(sqlDiemCongHienTai.Value.ToString(), out diemhientai); } catch (Exception e) { return false; } return true; } public bool HuyDatVe(DatVeDTO datVeDTO) { IList<SqlParameter> listParameter = new List<SqlParameter>(); listParameter.Add(new SqlParameter("@DatVeId", datVeDTO.Id)); listParameter.Add(new SqlParameter("@MaSo", datVeDTO.Ghe)); try { this.dataProvider.ExecuteStoreProc( "Proc_HuyDatVe", listParameter); } catch (Exception e) { return false; } return true; } } }
1142008-1142076-1142085-ptexpress
trunk/PTExpress/DAO/DatVeDAO.cs
C#
asf20
7,338
package org.vaadin.appfoundation.example; import java.io.File; import java.net.URL; import javax.servlet.ServletContextEvent; import javax.servlet.ServletContextListener; import org.vaadin.appfoundation.i18n.InternationalizationServlet; import org.vaadin.appfoundation.persistence.facade.FacadeFactory; public class DemoContextListener implements ServletContextListener { public void contextDestroyed(ServletContextEvent arg0) { } public void contextInitialized(ServletContextEvent arg0) { URL url = DemoApplication.class.getClassLoader().getResource( "translations.xml"); File file = new File(url.getPath()); InternationalizationServlet.loadTranslations(file); try { FacadeFactory.registerFacade(ExampleMockFacade.class, "default", true); } catch (InstantiationException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } System.setProperty("authentication.maxFailedLoginAttempts", "2"); } }
007lee-test
src/org/vaadin/appfoundation/example/DemoContextListener.java
Java
asf20
1,090
package org.vaadin.appfoundation.example; public class MainView extends Page { private static final long serialVersionUID = -4129066221019915249L; public MainView() { super("main view"); } }
007lee-test
src/org/vaadin/appfoundation/example/MainView.java
Java
asf20
215
package org.vaadin.appfoundation.example; import org.vaadin.appfoundation.authentication.data.User; import org.vaadin.appfoundation.authentication.util.PasswordUtil; import org.vaadin.appfoundation.view.ViewHandler; import com.vaadin.Application; import com.vaadin.service.ApplicationContext.TransactionListener; public class ExampleData implements TransactionListener { private static final long serialVersionUID = 5184835038248219005L; // Store this instance of the view handler in this thread local variable private static final ThreadLocal<ExampleData> instance = new ThreadLocal<ExampleData>(); private final Application application; private User user1; private User user2; public ExampleData(Application application) { instance.set(this); this.application = application; } /** * {@inheritDoc} */ public void transactionEnd(Application application, Object transactionData) { // Clear thread local instance at the end of the transaction if (this.application == application) { instance.set(null); } } /** * {@inheritDoc} */ public void transactionStart(Application application, Object transactionData) { // Set the thread local instance if (this.application == application) { instance.set(this); } } /** * Initializes the {@link ViewHandler} for the given {@link Application} * * @param application */ public static void initialize(Application application) { if (application == null) { throw new IllegalArgumentException("Application may not be null"); } ExampleData exampleData = new ExampleData(application); application.getContext().addTransactionListener(exampleData); } public static User getUser(Long id) { if (id == 1L) { if (instance.get().user1 == null) { instance.get().user1 = new User(); instance.get().user1.setUsername("demo"); instance.get().user1.setPassword(PasswordUtil .generateHashedPassword("demo123")); } return instance.get().user1; } else if (id == 2L) { if (instance.get().user2 == null) { instance.get().user2 = new User(); instance.get().user2.setUsername("demo2"); instance.get().user2.setPassword(PasswordUtil .generateHashedPassword("demo123")); } return instance.get().user2; } return null; } }
007lee-test
src/org/vaadin/appfoundation/example/ExampleData.java
Java
asf20
2,643
package org.vaadin.appfoundation.example; import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.net.URL; public class ExampleLoader { public static enum Examples { // Example code for the authentication module AUTHENTICATE_USER("examples/authenticate_user.txt"), AUTHENTICATE_CONTEXT_LISTENER( "examples/authentication_context_listener.txt"), AUTHENTICATE_INIT_MODULE("examples/authentication_init_module.txt"), AUTHENTICATE_GET_USER_INSTANCE( "examples/authentication_get_user_instance.txt"), AUTHENTICATE_LOGOUT_LISTENER( "examples/authentication_logout_listener.txt"), AUTHENTICATE_LOGOUT_BUTTON("examples/authentication_logout_button.txt"), AUTHENTICATE_CHANGE_PASSWORD( "examples/authentication_change_password.txt"), AUTHENTICATE_REGISTER_USER("examples/authentication_register.txt"), AUTHENTICATE_FETCH_USER("examples/authentication_fetch_user.txt"), AUTHENTICATE_STORE_USER("examples/authentication_store_user.txt"), AUTHENTICATE_GENERATE_HASHED_PASSWORD( "examples/authentication_generateHashedPassword.txt"), AUTHENTICATE_GET_MIN_PWD_LENGTH( "examples/authentication_getMinPasswordLength.txt"), AUTHENTICATE_PASSWORD_VALIDATORS( "examples/authentication_password_validators.txt"), AUTHENTICATE_PASSWORD_VALIDITY( "examples/authentication_password_validity.txt"), AUTHENTICATE_PASSWORD_VERIFICATION( "examples/authentication_verify_password.txt"), // Example code for the i18n module I18N_SERVLET("examples/i18n_configure_servlet.txt"), I18N_INIT_LANG("examples/i18n_init_lang.txt"), I18N_ORIGINAL_XML("examples/i18n_original_xml.txt"), I18N_UPDATED_XML("examples/i18n_updated_xml.txt"), I18N_FILE_UPDATER("examples/i18n_file_updater.txt"), I18N_LOAD_TRANSLATIONS("examples/i18n_load_translations.txt"), I18N_EXAMPLE_XML("examples/i18n_example_translations.txt"), I18N_GET_MSG_TEXT_FIELD("examples/i18n_getmsg_ex1.txt"), I18N_GET_MSG_WITH_PARAM("examples/i18n_getmsg_ex2.txt"), I18N_GET_MSG_VIA_LANG("examples/i18n_getmsg_ex3.txt"), I18N_CUSTOMER_POJO("examples/i18n_customer_pojo.txt"), I18N_CUSTOMER_POJO_TRANSLATIONS( "examples/i18n_customer_pojo_translations.txt"), I18N_FORM("examples/i18n_form.txt"), ; private final String fileName; private Examples(String fileName) { this.fileName = fileName; } public String getFileName() { return fileName; } } public static String getExample(Examples example) { URL url = ExampleLoader.class.getClassLoader().getResource( example.getFileName()); StringBuffer fileData = new StringBuffer(1000); try { BufferedReader reader = new BufferedReader(new FileReader(url .getPath())); char[] buf = new char[1024]; int numRead = 0; while ((numRead = reader.read(buf)) != -1) { String readData = String.valueOf(buf, 0, numRead); fileData.append(readData); buf = new char[1024]; } reader.close(); return fileData.toString(); } catch (FileNotFoundException e) { return ""; } catch (IOException e) { return ""; } } }
007lee-test
src/org/vaadin/appfoundation/example/ExampleLoader.java
Java
asf20
3,676
package org.vaadin.appfoundation.example.authorization; import org.vaadin.appfoundation.example.Page; public class Roles extends Page { private static final long serialVersionUID = -5911537891534815351L; public Roles() { super("roles text"); } }
007lee-test
src/org/vaadin/appfoundation/example/authorization/Roles.java
Java
asf20
271
package org.vaadin.appfoundation.example.authorization; import org.vaadin.appfoundation.example.Page; public class PermissionManagers extends Page { private static final long serialVersionUID = -6274302806342638976L; public PermissionManagers() { super("permission managers text"); } }
007lee-test
src/org/vaadin/appfoundation/example/authorization/PermissionManagers.java
Java
asf20
310
package org.vaadin.appfoundation.example.authorization; import org.vaadin.appfoundation.example.Page; public class RemovingPermissions extends Page { private static final long serialVersionUID = -8791692860237872670L; public RemovingPermissions() { super("removing permissions text"); } }
007lee-test
src/org/vaadin/appfoundation/example/authorization/RemovingPermissions.java
Java
asf20
314
package org.vaadin.appfoundation.example.authorization; import org.vaadin.appfoundation.example.Page; public class GrantingAccess extends Page { private static final long serialVersionUID = -3105399359073542039L; public GrantingAccess() { super("granting access text"); } }
007lee-test
src/org/vaadin/appfoundation/example/authorization/GrantingAccess.java
Java
asf20
298
package org.vaadin.appfoundation.example.authorization; import org.vaadin.appfoundation.example.Page; public class MemPm extends Page { private static final long serialVersionUID = -8804477345384416181L; public MemPm() { super("mempm text"); } }
007lee-test
src/org/vaadin/appfoundation/example/authorization/MemPm.java
Java
asf20
270
package org.vaadin.appfoundation.example.authorization; import org.vaadin.appfoundation.example.Page; public class Resources extends Page { private static final long serialVersionUID = -3718212835159660181L; public Resources() { super("resources text"); } }
007lee-test
src/org/vaadin/appfoundation/example/authorization/Resources.java
Java
asf20
283
package org.vaadin.appfoundation.example.authorization; import org.vaadin.appfoundation.example.Page; public class InitAuthorization extends Page { private static final long serialVersionUID = -7484360026836952388L; public InitAuthorization() { super("init authorization text"); } }
007lee-test
src/org/vaadin/appfoundation/example/authorization/InitAuthorization.java
Java
asf20
307
package org.vaadin.appfoundation.example.authorization; import org.vaadin.appfoundation.example.Page; public class CheckingAccessRights extends Page { private static final long serialVersionUID = 4485783747750332903L; public CheckingAccessRights() { super("checking for access rights"); } }
007lee-test
src/org/vaadin/appfoundation/example/authorization/CheckingAccessRights.java
Java
asf20
315
package org.vaadin.appfoundation.example.authorization; import org.vaadin.appfoundation.example.Page; public class AuthorizationIntro extends Page { private static final long serialVersionUID = 5662292822937928175L; public AuthorizationIntro() { super("intro to authorization text"); } }
007lee-test
src/org/vaadin/appfoundation/example/authorization/AuthorizationIntro.java
Java
asf20
313
package org.vaadin.appfoundation.example.authorization; import org.vaadin.appfoundation.example.Page; public class DenyingAccess extends Page { private static final long serialVersionUID = 7082724989547758176L; public DenyingAccess() { super("denying access text"); } }
007lee-test
src/org/vaadin/appfoundation/example/authorization/DenyingAccess.java
Java
asf20
296
package org.vaadin.appfoundation.example.authorization; import org.vaadin.appfoundation.example.Page; public class JPAPm extends Page { private static final long serialVersionUID = 5337991003614823677L; public JPAPm() { super("jpapm text"); } }
007lee-test
src/org/vaadin/appfoundation/example/authorization/JPAPm.java
Java
asf20
269
package org.vaadin.appfoundation.example.view; import org.vaadin.appfoundation.example.Page; public class Views extends Page { private static final long serialVersionUID = -7650506914228979289L; public Views() { super("views text"); } }
007lee-test
src/org/vaadin/appfoundation/example/view/Views.java
Java
asf20
262
package org.vaadin.appfoundation.example.view; import org.vaadin.appfoundation.example.Page; public class ViewEvents extends Page { private static final long serialVersionUID = 8056163603161932812L; public ViewEvents() { super("view events text"); } }
007lee-test
src/org/vaadin/appfoundation/example/view/ViewEvents.java
Java
asf20
277
package org.vaadin.appfoundation.example.view; import org.vaadin.appfoundation.example.Page; public class ConfiguringView extends Page { private static final long serialVersionUID = 1602593248018609427L; public ConfiguringView() { super("configuring view module text"); } }
007lee-test
src/org/vaadin/appfoundation/example/view/ConfiguringView.java
Java
asf20
299
package org.vaadin.appfoundation.example.view; import org.vaadin.appfoundation.example.Page; public class ViewHandlerExample extends Page { private static final long serialVersionUID = 3391814647955929447L; public ViewHandlerExample() { super("view handler example text"); } }
007lee-test
src/org/vaadin/appfoundation/example/view/ViewHandlerExample.java
Java
asf20
301
package org.vaadin.appfoundation.example.view; import org.vaadin.appfoundation.example.Page; public class ViewFactories extends Page { private static final long serialVersionUID = -935187288659828886L; public ViewFactories() { super("view factories text"); } }
007lee-test
src/org/vaadin/appfoundation/example/view/ViewFactories.java
Java
asf20
285
package org.vaadin.appfoundation.example.view; import org.vaadin.appfoundation.example.Page; public class ViewIntro extends Page { private static final long serialVersionUID = -4225762553285921918L; public ViewIntro() { super("view module intro text"); } }
007lee-test
src/org/vaadin/appfoundation/example/view/ViewIntro.java
Java
asf20
281
package org.vaadin.appfoundation.example.view; import org.vaadin.appfoundation.example.Page; public class ViewContainerExample extends Page { private static final long serialVersionUID = -4180097923322032070L; public ViewContainerExample() { super("view container text"); } }
007lee-test
src/org/vaadin/appfoundation/example/view/ViewContainerExample.java
Java
asf20
300
package org.vaadin.appfoundation.example.authentication; import org.vaadin.appfoundation.example.ExampleLoader.Examples; import org.vaadin.appfoundation.example.components.CodeExample; import org.vaadin.appfoundation.i18n.Lang; import org.vaadin.appfoundation.view.AbstractView; import ys.wikiparser.WikiParser; import com.vaadin.ui.Label; import com.vaadin.ui.VerticalLayout; public class ConfiguringAuth extends AbstractView<VerticalLayout> { private static final long serialVersionUID = -3149135945432852122L; public ConfiguringAuth() { super(new VerticalLayout()); getContent().addComponent( new Label(WikiParser.renderXHTML(Lang .getMessage("configuring auth text")), Label.CONTENT_XHTML)); CodeExample contextListenerExample = new CodeExample( Examples.AUTHENTICATE_CONTEXT_LISTENER); contextListenerExample.setWidth("100%"); contextListenerExample.setDefaultCaption(Lang .getMessage("example for auth context listener")); getContent().addComponent(contextListenerExample); CodeExample initAuthModuleExample = new CodeExample( Examples.AUTHENTICATE_INIT_MODULE); initAuthModuleExample.setWidth("100%"); initAuthModuleExample.setDefaultCaption(Lang .getMessage("auth module init example")); getContent().addComponent(initAuthModuleExample); } @Override public void activated(Object... params) { // TODO Auto-generated method stub } @Override public void deactivated(Object... params) { // TODO Auto-generated method stub } }
007lee-test
src/org/vaadin/appfoundation/example/authentication/ConfiguringAuth.java
Java
asf20
1,703
package org.vaadin.appfoundation.example.authentication; import javax.persistence.OptimisticLockException; import org.vaadin.appfoundation.authentication.LogoutEvent; import org.vaadin.appfoundation.authentication.LogoutListener; import org.vaadin.appfoundation.authentication.SessionHandler; import org.vaadin.appfoundation.authentication.data.User; import org.vaadin.appfoundation.authentication.exceptions.InvalidCredentialsException; import org.vaadin.appfoundation.authentication.exceptions.PasswordRequirementException; import org.vaadin.appfoundation.authentication.exceptions.PasswordsDoNotMatchException; import org.vaadin.appfoundation.authentication.exceptions.TooShortPasswordException; import org.vaadin.appfoundation.authentication.util.PasswordUtil; import org.vaadin.appfoundation.authentication.util.UserUtil; import org.vaadin.appfoundation.example.Page; import org.vaadin.appfoundation.example.ExampleLoader.Examples; import org.vaadin.appfoundation.persistence.facade.FacadeFactory; import com.vaadin.ui.Button; import com.vaadin.ui.FormLayout; import com.vaadin.ui.Label; import com.vaadin.ui.Layout; import com.vaadin.ui.Panel; import com.vaadin.ui.TextField; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Button.ClickListener; public class ChangePassword extends Page { private static final long serialVersionUID = 5204650511382347253L; private User currentUser; private Panel examplePanel = new Panel(); public ChangePassword() { super("change user password"); getContent().addComponent(examplePanel); addCodeExample(Examples.AUTHENTICATE_CHANGE_PASSWORD, "show code"); } private Layout buildPwdChangeForm() { FormLayout layout = new FormLayout(); // Create a label which we can use to give feedback to the user final Label feedbackLabel = new Label(); final Label logoutLabel = new Label(); SessionHandler.addListener(new LogoutListener() { @Override public void logout(LogoutEvent event) { logoutLabel .setValue("You entered the password incorrectly too many " + "times, so you would have now been logged out"); SessionHandler.setUser(event.getUser()); event.getUser().clearFailedPasswordChangeAttempts(); } }); // Create input fields for passwords final TextField currentPassword = new TextField("Current password"); currentPassword.setSecret(true); currentPassword.setNullRepresentation(""); final TextField newPassword = new TextField("New password"); newPassword.setSecret(true); newPassword.setNullRepresentation(""); final TextField newPasswordVerified = new TextField( "Verify new password"); newPasswordVerified.setSecret(true); newPasswordVerified.setNullRepresentation(""); // Add the save button Button saveBtn = new Button("Save", new ClickListener() { private static final long serialVersionUID = -5577423546946890721L; public void buttonClick(ClickEvent event) { logoutLabel.setValue(null); // Try to change the password when the button is clicked String password = (String) currentPassword.getValue(); String newPasswordStr = (String) newPassword.getValue(); String newPasswordStr2 = (String) newPasswordVerified .getValue(); try { UserUtil.changePassword(SessionHandler.get(), password, newPasswordStr, newPasswordStr2); } catch (InvalidCredentialsException e) { feedbackLabel.setValue("Current password was invalid!"); clearPwdFields(); return; } catch (TooShortPasswordException e) { feedbackLabel .setValue("New password was too short, the password " + "needs to be at least " + PasswordUtil.getMinPasswordLength() + " characters long."); clearPwdFields(); return; } catch (PasswordsDoNotMatchException e) { feedbackLabel .setValue("Password verification was incorrect"); clearPwdFields(); return; } catch (PasswordRequirementException e) { feedbackLabel .setValue("Password did not meet set requirements"); clearPwdFields(); return; } catch (OptimisticLockException e) { // IGNORE only in this example, because we don't care that // the password wasn't actually stored. } feedbackLabel.setValue("Password changed!"); clearPwdFields(); } private void clearPwdFields() { currentPassword.setValue(null); newPassword.setValue(null); newPasswordVerified.setValue(null); } }); layout.addComponent(logoutLabel); layout.addComponent(feedbackLabel); layout.addComponent(currentPassword); layout.addComponent(newPassword); layout.addComponent(newPasswordVerified); layout.addComponent(saveBtn); return layout; } @Override public void activated(Object... params) { currentUser = FacadeFactory.getFacade().find(User.class, 2L); currentUser.setPassword(PasswordUtil.generateHashedPassword("demo123")); examplePanel.removeAllComponents(); examplePanel.addComponent(buildPwdChangeForm()); SessionHandler.setUser(currentUser); } @Override public void deactivated(Object... params) { // TODO Auto-generated method stub } }
007lee-test
src/org/vaadin/appfoundation/example/authentication/ChangePassword.java
Java
asf20
6,156
package org.vaadin.appfoundation.example.authentication; import org.vaadin.appfoundation.example.ExampleLoader.Examples; import org.vaadin.appfoundation.example.components.CodeExample; import org.vaadin.appfoundation.i18n.Lang; import org.vaadin.appfoundation.view.AbstractView; import ys.wikiparser.WikiParser; import com.vaadin.ui.Label; import com.vaadin.ui.VerticalLayout; public class LogoutExample extends AbstractView<VerticalLayout> { private static final long serialVersionUID = 3319859864849238330L; public LogoutExample() { super(new VerticalLayout()); getContent() .addComponent( new Label(WikiParser.renderXHTML(Lang .getMessage("logging out a user")), Label.CONTENT_XHTML)); CodeExample logoutButtonExample = new CodeExample( Examples.AUTHENTICATE_LOGOUT_BUTTON); logoutButtonExample.setWidth("100%"); logoutButtonExample .setDefaultCaption(Lang.getMessage("logout example")); getContent().addComponent(logoutButtonExample); CodeExample logoutEventExample = new CodeExample( Examples.AUTHENTICATE_LOGOUT_LISTENER); logoutEventExample.setWidth("100%"); logoutEventExample.setDefaultCaption(Lang .getMessage("logout event example")); getContent().addComponent(logoutEventExample); } @Override public void activated(Object... params) { // TODO Auto-generated method stub } @Override public void deactivated(Object... params) { // TODO Auto-generated method stub } }
007lee-test
src/org/vaadin/appfoundation/example/authentication/LogoutExample.java
Java
asf20
1,691
package org.vaadin.appfoundation.example.authentication; import org.vaadin.appfoundation.authentication.SessionHandler; import org.vaadin.appfoundation.authentication.data.User; import org.vaadin.appfoundation.authentication.exceptions.AccountLockedException; import org.vaadin.appfoundation.authentication.exceptions.InvalidCredentialsException; import org.vaadin.appfoundation.authentication.util.AuthenticationUtil; import org.vaadin.appfoundation.example.ExampleLoader.Examples; import org.vaadin.appfoundation.example.components.CodeExample; import org.vaadin.appfoundation.i18n.Lang; import org.vaadin.appfoundation.persistence.facade.FacadeFactory; import org.vaadin.appfoundation.view.AbstractView; import ys.wikiparser.WikiParser; import com.vaadin.ui.Button; import com.vaadin.ui.FormLayout; import com.vaadin.ui.Label; import com.vaadin.ui.Layout; import com.vaadin.ui.Panel; import com.vaadin.ui.TextField; import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Button.ClickListener; public class UserAuth extends AbstractView<VerticalLayout> { private static final long serialVersionUID = 3319859864849238330L; private Panel examplePanel; public UserAuth() { super(new VerticalLayout()); getContent().addComponent( new Label(WikiParser.renderXHTML(Lang .getMessage("text for auth a user")), Label.CONTENT_XHTML)); CodeExample example = new CodeExample(Examples.AUTHENTICATE_USER); example.setWidth("100%"); initExamplePanel(); getContent().addComponent(examplePanel); getContent().addComponent(example); } private void initExamplePanel() { examplePanel = new Panel(); } private Layout buildLoginForm() { FormLayout layout = new FormLayout(); // Create a label which we can use to give feedback to the user final Label feedbackLabel = new Label(); // Create input fields for username and password final TextField usernameField = new TextField("Username"); final TextField passwordField = new TextField("Password"); passwordField.setSecret(true); // Add the login button Button login = new Button("Login", new ClickListener() { private static final long serialVersionUID = -5577423546946890721L; public void buttonClick(ClickEvent event) { // Try to log in the user when the button is clicked String username = (String) usernameField.getValue(); String password = (String) passwordField.getValue(); try { loggedInAs(AuthenticationUtil.authenticate(username, password)); } catch (InvalidCredentialsException e) { feedbackLabel .setValue("Either username or password was wrong"); } catch (AccountLockedException e) { feedbackLabel.setValue("The given account has been locked"); } } }); layout.addComponent(feedbackLabel); layout.addComponent(usernameField); layout.addComponent(passwordField); layout.addComponent(login); return layout; } @Override public void activated(Object... params) { User user = FacadeFactory.getFacade().find(User.class, 1L); if (user.isAccountLocked()) { user.setAccountLocked(false); } refreshExamplePanel(); } @Override public void deactivated(Object... params) { // TODO Auto-generated method stub } private void loggedInAs(User user) { VerticalLayout layout = new VerticalLayout(); layout.addComponent(new Label("You are now logged in as the user " + user.getUsername())); layout.addComponent(new Button("Click here to log out", new ClickListener() { private static final long serialVersionUID = 4067453946827830672L; @Override public void buttonClick(ClickEvent event) { SessionHandler.logout(); refreshExamplePanel(); } })); examplePanel.removeAllComponents(); examplePanel.addComponent(layout); } private void refreshExamplePanel() { examplePanel.removeAllComponents(); examplePanel.addComponent(buildLoginForm()); } }
007lee-test
src/org/vaadin/appfoundation/example/authentication/UserAuth.java
Java
asf20
4,599
package org.vaadin.appfoundation.example.authentication; import org.vaadin.appfoundation.i18n.Lang; import org.vaadin.appfoundation.view.AbstractView; import ys.wikiparser.WikiParser; import com.vaadin.ui.Label; import com.vaadin.ui.VerticalLayout; public class AuthIntro extends AbstractView<VerticalLayout> { private static final long serialVersionUID = 3319859864849238330L; public AuthIntro() { super(new VerticalLayout()); getContent().addComponent( new Label(WikiParser.renderXHTML(Lang .getMessage("intro text to auth module")), Label.CONTENT_XHTML)); } @Override public void activated(Object... params) { // TODO Auto-generated method stub } @Override public void deactivated(Object... params) { // TODO Auto-generated method stub } }
007lee-test
src/org/vaadin/appfoundation/example/authentication/AuthIntro.java
Java
asf20
788
package org.vaadin.appfoundation.example.authentication; import org.vaadin.appfoundation.example.ExampleLoader.Examples; import org.vaadin.appfoundation.example.components.CodeExample; import org.vaadin.appfoundation.i18n.Lang; import org.vaadin.appfoundation.view.AbstractView; import ys.wikiparser.WikiParser; import com.vaadin.ui.Label; import com.vaadin.ui.VerticalLayout; public class GettingUserInstance extends AbstractView<VerticalLayout> { private static final long serialVersionUID = 3319859864849238330L; public GettingUserInstance() { super(new VerticalLayout()); getContent().addComponent( new Label(WikiParser.renderXHTML(Lang .getMessage("getting user instance")), Label.CONTENT_XHTML)); CodeExample getUserInstanceExample = new CodeExample( Examples.AUTHENTICATE_GET_USER_INSTANCE); getUserInstanceExample.setWidth("100%"); getContent().addComponent(getUserInstanceExample); } @Override public void activated(Object... params) { // TODO Auto-generated method stub } @Override public void deactivated(Object... params) { // TODO Auto-generated method stub } }
007lee-test
src/org/vaadin/appfoundation/example/authentication/GettingUserInstance.java
Java
asf20
1,260
package org.vaadin.appfoundation.example.authentication; import org.vaadin.appfoundation.example.Page; import org.vaadin.appfoundation.example.ExampleLoader.Examples; public class StoreUser extends Page { private static final long serialVersionUID = 1531144454612314170L; public StoreUser() { super("storing a user object"); addCodeExample(Examples.AUTHENTICATE_STORE_USER, "show code"); } }
007lee-test
src/org/vaadin/appfoundation/example/authentication/StoreUser.java
Java
asf20
425
package org.vaadin.appfoundation.example.authentication; import org.vaadin.appfoundation.authentication.util.PasswordUtil; import org.vaadin.appfoundation.example.Page; import org.vaadin.appfoundation.example.ExampleLoader.Examples; import com.vaadin.data.Validator; import com.vaadin.data.Property.ValueChangeEvent; import com.vaadin.data.Property.ValueChangeListener; import com.vaadin.data.Validator.InvalidValueException; import com.vaadin.ui.TextField; public class PasswordUtilityMethods extends Page { private static final long serialVersionUID = 3319859864849238330L; public PasswordUtilityMethods() { super("password utility methods"); addWikiText("generateHashedPassword"); addCodeExample(Examples.AUTHENTICATE_GENERATE_HASHED_PASSWORD, "show code"); addWikiText("getMinPasswordLength"); addCodeExample(Examples.AUTHENTICATE_GET_MIN_PWD_LENGTH, "show code"); addWikiText("password validators"); getContent().addComponent(buildPasswordTextField()); addCodeExample(Examples.AUTHENTICATE_PASSWORD_VALIDATORS, "show code"); addWikiText("password validity"); addCodeExample(Examples.AUTHENTICATE_PASSWORD_VALIDITY, "show code"); addWikiText("password verification"); addCodeExample(Examples.AUTHENTICATE_PASSWORD_VERIFICATION, "show code"); } private TextField buildPasswordTextField() { final TextField password = new TextField("Password"); password.setSecret(true); password.setNullRepresentation(""); for (Validator validator : PasswordUtil.getValidators()) { password.addValidator(validator); } // Set the password field to immediate password.setImmediate(true); // Validate the password right after it has been changed password.addListener(new ValueChangeListener() { private static final long serialVersionUID = 1666908198186227437L; @Override public void valueChange(ValueChangeEvent event) { try { password.validate(); } catch (InvalidValueException e) { // IGNORE } } }); return password; } }
007lee-test
src/org/vaadin/appfoundation/example/authentication/PasswordUtilityMethods.java
Java
asf20
2,290
package org.vaadin.appfoundation.example.authentication; import org.vaadin.appfoundation.authentication.data.User; import org.vaadin.appfoundation.authentication.exceptions.PasswordRequirementException; import org.vaadin.appfoundation.authentication.exceptions.PasswordsDoNotMatchException; import org.vaadin.appfoundation.authentication.exceptions.TooShortPasswordException; import org.vaadin.appfoundation.authentication.exceptions.TooShortUsernameException; import org.vaadin.appfoundation.authentication.exceptions.UsernameExistsException; import org.vaadin.appfoundation.authentication.util.UserUtil; import org.vaadin.appfoundation.example.Page; import org.vaadin.appfoundation.example.ExampleLoader.Examples; import org.vaadin.appfoundation.persistence.facade.FacadeFactory; import com.vaadin.ui.Button; import com.vaadin.ui.FormLayout; import com.vaadin.ui.Label; import com.vaadin.ui.Layout; import com.vaadin.ui.Panel; import com.vaadin.ui.TextField; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Button.ClickListener; import com.vaadin.ui.Window.Notification; public class RegisterUser extends Page { private static final long serialVersionUID = 3319859864849238330L; private Panel examplePanel = new Panel(); public RegisterUser() { super("registering a user"); getContent().addComponent(examplePanel); addCodeExample(Examples.AUTHENTICATE_REGISTER_USER, "show code"); } private Layout buildRegisterForm() { FormLayout layout = new FormLayout(); final Label feedbackLabel = new Label(); layout.addComponent(feedbackLabel); final TextField username = new TextField("Username"); username.setNullRepresentation(""); layout.addComponent(username); final TextField password = new TextField("Password"); password.setNullRepresentation(""); password.setSecret(true); layout.addComponent(password); final TextField verifyPassword = new TextField("Verify password"); verifyPassword.setNullRepresentation(""); verifyPassword.setSecret(true); layout.addComponent(verifyPassword); final TextField realName = new TextField("Real name"); realName.setNullRepresentation(""); layout.addComponent(realName); final TextField email = new TextField("Email address"); email.setNullRepresentation(""); layout.addComponent(email); Button registerButton = new Button("Register", new ClickListener() { private static final long serialVersionUID = 9048069425045731789L; @Override public void buttonClick(ClickEvent event) { try { User user = UserUtil.registerUser((String) username .getValue(), (String) password.getValue(), (String) verifyPassword.getValue()); // user successfully registered user.setName((String) realName.getValue()); user.setEmail((String) email.getValue()); // The user pojo needs to be stored as we've added the name // and email address as additional information FacadeFactory.getFacade().store(user); getApplication().getMainWindow().showNotification( "User registered", Notification.TYPE_HUMANIZED_MESSAGE); examplePanel.removeAllComponents(); examplePanel.addComponent(buildRegisterForm()); } catch (TooShortPasswordException e) { feedbackLabel .setValue("Password is too short, it needs to be at least " + UserUtil.getMinPasswordLength() + " characters long"); } catch (TooShortUsernameException e) { feedbackLabel .setValue("Username is too short, it needs to be at least " + UserUtil.getMinUsernameLength() + " characters long"); } catch (PasswordsDoNotMatchException e) { feedbackLabel.setValue("Password verification has failed"); } catch (UsernameExistsException e) { feedbackLabel .setValue("The chosen username already exists, please pick another one"); } catch (PasswordRequirementException e) { feedbackLabel .setValue("Password does not meet the set requirements"); } password.setValue(null); verifyPassword.setValue(null); } }); layout.addComponent(registerButton); return layout; } @Override public void activated(Object... params) { examplePanel.removeAllComponents(); examplePanel.addComponent(buildRegisterForm()); } }
007lee-test
src/org/vaadin/appfoundation/example/authentication/RegisterUser.java
Java
asf20
5,114
package org.vaadin.appfoundation.example.authentication; import org.vaadin.appfoundation.example.Page; import org.vaadin.appfoundation.example.ExampleLoader.Examples; public class FetchUser extends Page { private static final long serialVersionUID = 3336970179429259887L; public FetchUser() { super("fetching a user object"); addCodeExample(Examples.AUTHENTICATE_FETCH_USER, "show code"); } }
007lee-test
src/org/vaadin/appfoundation/example/authentication/FetchUser.java
Java
asf20
426
package org.vaadin.appfoundation.example.components; import org.vaadin.appfoundation.example.ExampleLoader; import org.vaadin.appfoundation.example.ExampleLoader.Examples; import org.vaadin.appfoundation.i18n.Lang; import org.vaadin.codelabel.CodeLabel; import org.vaadin.henrik.drawer.Drawer; public class CodeExample extends Drawer { private static final long serialVersionUID = 981189256494004603L; public CodeExample(Examples example) { super(Lang.getMessage("show code"), null); CodeLabel codeExample = new CodeLabel(); codeExample.setValue(ExampleLoader.getExample(example)); setDrawerComponent(codeExample); } }
007lee-test
src/org/vaadin/appfoundation/example/components/CodeExample.java
Java
asf20
668
package org.vaadin.appfoundation.example.components; import org.vaadin.appfoundation.view.AbstractView; import org.vaadin.appfoundation.view.View; import org.vaadin.appfoundation.view.ViewContainer; import org.vaadin.appfoundation.view.ViewHandler; import com.vaadin.ui.Component; import com.vaadin.ui.Panel; public class MainArea extends AbstractView<Panel> implements ViewContainer { private static final long serialVersionUID = 9010669373711637452L; private View currentView; public MainArea() { super(new Panel()); getContent().setSizeFull(); getContent().addComponent(ViewHandler.getUriFragmentUtil()); } /** * {@inheritDoc} */ @Override public void activated(Object... params) { // Do nothing } /** * {@inheritDoc} */ @Override public void deactivated(Object... params) { // Do nothing } /** * {@inheritDoc} */ public void activate(View view) { if (currentView == null) { getContent().addComponent((Component) view); } else { getContent().replaceComponent((Component) currentView, (Component) view); } currentView = view; } /** * {@inheritDoc} */ public void deactivate(View view) { if (currentView != null) { getContent().removeComponent((Component) view); } currentView = null; } }
007lee-test
src/org/vaadin/appfoundation/example/components/MainArea.java
Java
asf20
1,465
package org.vaadin.appfoundation.example; import java.util.Locale; import org.vaadin.appfoundation.authentication.SessionHandler; import org.vaadin.appfoundation.i18n.Lang; import org.vaadin.appfoundation.view.ViewHandler; import com.vaadin.Application; import com.vaadin.ui.Window; public class DemoApplication extends Application { private static final long serialVersionUID = 1L; private Window mainWindow; @Override public void init() { Lang.initialize(this); Lang.setLocale(Locale.ENGLISH); ViewHandler.initialize(this); SessionHandler.initialize(this); ExampleData.initialize(this); mainWindow = new MainWindow(); mainWindow.setSizeFull(); setMainWindow(mainWindow); } }
007lee-test
src/org/vaadin/appfoundation/example/DemoApplication.java
Java
asf20
771
package org.vaadin.appfoundation.example.persistence; import org.vaadin.appfoundation.example.Page; public class RemovingData extends Page { private static final long serialVersionUID = 2858026847696773764L; public RemovingData() { super("removing data text"); } }
007lee-test
src/org/vaadin/appfoundation/example/persistence/RemovingData.java
Java
asf20
289
package org.vaadin.appfoundation.example.persistence; import org.vaadin.appfoundation.example.Page; public class StoringData extends Page { private static final long serialVersionUID = -4227203122303296952L; public StoringData() { super("storing data text"); } }
007lee-test
src/org/vaadin/appfoundation/example/persistence/StoringData.java
Java
asf20
287
package org.vaadin.appfoundation.example.persistence; import org.vaadin.appfoundation.example.Page; public class CreatingPojos extends Page { private static final long serialVersionUID = -8065190889615168139L; public CreatingPojos() { super("creating pojos text"); } }
007lee-test
src/org/vaadin/appfoundation/example/persistence/CreatingPojos.java
Java
asf20
294
package org.vaadin.appfoundation.example.persistence; import org.vaadin.appfoundation.example.Page; public class ConfiguringPersistence extends Page { private static final long serialVersionUID = 8584529931203561701L; public ConfiguringPersistence() { super("configuring persistence module text"); } }
007lee-test
src/org/vaadin/appfoundation/example/persistence/ConfiguringPersistence.java
Java
asf20
326
package org.vaadin.appfoundation.example.persistence; import org.vaadin.appfoundation.example.Page; public class FacadeFactoryExamples extends Page { private static final long serialVersionUID = 2091504573134600933L; public FacadeFactoryExamples() { super("facade factory exmaple text"); } }
007lee-test
src/org/vaadin/appfoundation/example/persistence/FacadeFactoryExamples.java
Java
asf20
317
package org.vaadin.appfoundation.example.persistence; import org.vaadin.appfoundation.example.Page; public class FetchingData extends Page { private static final long serialVersionUID = -8312944787394716728L; public FetchingData() { super("fetching data text"); } }
007lee-test
src/org/vaadin/appfoundation/example/persistence/FetchingData.java
Java
asf20
290
package org.vaadin.appfoundation.example.persistence; import org.vaadin.appfoundation.example.Page; public class PersistenceIntro extends Page { private static final long serialVersionUID = -247122143360422499L; public PersistenceIntro() { super("persistence module intro text"); } }
007lee-test
src/org/vaadin/appfoundation/example/persistence/PersistenceIntro.java
Java
asf20
309
package org.vaadin.appfoundation.example; import java.util.HashMap; import java.util.Map; import org.vaadin.appfoundation.example.authentication.AuthIntro; import org.vaadin.appfoundation.example.authentication.ChangePassword; import org.vaadin.appfoundation.example.authentication.ConfiguringAuth; import org.vaadin.appfoundation.example.authentication.FetchUser; import org.vaadin.appfoundation.example.authentication.GettingUserInstance; import org.vaadin.appfoundation.example.authentication.LogoutExample; import org.vaadin.appfoundation.example.authentication.PasswordUtilityMethods; import org.vaadin.appfoundation.example.authentication.RegisterUser; import org.vaadin.appfoundation.example.authentication.StoreUser; import org.vaadin.appfoundation.example.authentication.UserAuth; import org.vaadin.appfoundation.example.authorization.AuthorizationIntro; import org.vaadin.appfoundation.example.authorization.CheckingAccessRights; import org.vaadin.appfoundation.example.authorization.DenyingAccess; import org.vaadin.appfoundation.example.authorization.GrantingAccess; import org.vaadin.appfoundation.example.authorization.InitAuthorization; import org.vaadin.appfoundation.example.authorization.JPAPm; import org.vaadin.appfoundation.example.authorization.MemPm; import org.vaadin.appfoundation.example.authorization.PermissionManagers; import org.vaadin.appfoundation.example.authorization.RemovingPermissions; import org.vaadin.appfoundation.example.authorization.Resources; import org.vaadin.appfoundation.example.authorization.Roles; import org.vaadin.appfoundation.example.components.MainArea; import org.vaadin.appfoundation.example.i18n.ConfigureAndIniI18n; import org.vaadin.appfoundation.example.i18n.FieldTranslations; import org.vaadin.appfoundation.example.i18n.GettingMessages; import org.vaadin.appfoundation.example.i18n.I18nIntro; import org.vaadin.appfoundation.example.i18n.TranslationsFile; import org.vaadin.appfoundation.example.i18n.UpdatingTranslationsFile; import org.vaadin.appfoundation.example.persistence.ConfiguringPersistence; import org.vaadin.appfoundation.example.persistence.CreatingPojos; import org.vaadin.appfoundation.example.persistence.FacadeFactoryExamples; import org.vaadin.appfoundation.example.persistence.FetchingData; import org.vaadin.appfoundation.example.persistence.PersistenceIntro; import org.vaadin.appfoundation.example.persistence.RemovingData; import org.vaadin.appfoundation.example.persistence.StoringData; import org.vaadin.appfoundation.example.view.ConfiguringView; import org.vaadin.appfoundation.example.view.ViewContainerExample; import org.vaadin.appfoundation.example.view.ViewEvents; import org.vaadin.appfoundation.example.view.ViewFactories; import org.vaadin.appfoundation.example.view.ViewHandlerExample; import org.vaadin.appfoundation.example.view.ViewIntro; import org.vaadin.appfoundation.example.view.Views; import org.vaadin.appfoundation.i18n.Lang; import org.vaadin.appfoundation.view.View; import org.vaadin.appfoundation.view.ViewContainer; import org.vaadin.appfoundation.view.ViewHandler; import com.vaadin.data.Item; import com.vaadin.data.Property.ValueChangeEvent; import com.vaadin.data.Property.ValueChangeListener; import com.vaadin.ui.Accordion; import com.vaadin.ui.SplitPanel; import com.vaadin.ui.Tree; import com.vaadin.ui.Window; import com.vaadin.ui.TabSheet.Tab; public class MainWindow extends Window implements ViewContainer, ValueChangeListener { private static final long serialVersionUID = -7336305153060921847L; private SplitPanel splitPanel; private MainArea mainArea; private Accordion menu; private Tree authModuleTree; private Tree authorizationModuleTree; private Tree i18nModuleTree; private Tree persistenceModuleTree; private Tree viewModuleTree; private Map<Object, Tree> viewToTree = new HashMap<Object, Tree>(); public MainWindow() { setCaption(Lang.getMessage("application foundation")); buildMainLayout(); buildAuthenticationModule(); buildAuthorizationModule(); buildI18nModule(); buildPersistenceModule(); buildViewModule(); ViewHandler.addView(MainView.class, this); ViewHandler.activateView(MainView.class); } private void buildMainLayout() { splitPanel = new SplitPanel(); menu = new Accordion(); mainArea = new MainArea(); splitPanel.addComponent(menu); splitPanel.addComponent(mainArea); splitPanel.setOrientation(SplitPanel.ORIENTATION_HORIZONTAL); splitPanel.setSizeFull(); splitPanel.setSplitPosition(250, SplitPanel.UNITS_PIXELS); setContent(splitPanel); } private void buildAuthenticationModule() { initAuthTree(); addAuthViews(); Tab tab = menu.addTab(authModuleTree); tab.setCaption(Lang.getMessage("auth module")); } private void buildAuthorizationModule() { initAuthorizationTree(); addAuthorizationViews(); Tab tab = menu.addTab(authorizationModuleTree); tab.setCaption(Lang.getMessage("authorization")); } private void buildI18nModule() { initI18nTree(); addI18nViews(); Tab tab = menu.addTab(i18nModuleTree); tab.setCaption(Lang.getMessage("i18n")); } private void buildPersistenceModule() { initPersistenceTree(); addPersistenceViews(); Tab tab = menu.addTab(persistenceModuleTree); tab.setCaption(Lang.getMessage("persistence")); } private void buildViewModule() { initViewTree(); addViewViews(); Tab tab = menu.addTab(viewModuleTree); tab.setCaption(Lang.getMessage("view module")); } private void initAuthTree() { authModuleTree = new Tree(); prepareTree(authModuleTree); } private void initAuthorizationTree() { authorizationModuleTree = new Tree(); prepareTree(authorizationModuleTree); } private void initI18nTree() { i18nModuleTree = new Tree(); prepareTree(i18nModuleTree); } private void initPersistenceTree() { persistenceModuleTree = new Tree(); prepareTree(persistenceModuleTree); } private void initViewTree() { viewModuleTree = new Tree(); prepareTree(viewModuleTree); } private void prepareTree(Tree tree) { tree.addContainerProperty("name", String.class, null); tree.setItemCaptionPropertyId("name"); tree.addListener(this); tree.setImmediate(true); } private void addAuthViews() { addViewToModule(authModuleTree, AuthIntro.class, "auth intro", "auth-intro"); addViewToModule(authModuleTree, ConfiguringAuth.class, "configuring auth", "auth-config"); addViewToModule(authModuleTree, UserAuth.class, "auth a user", "auth-authenticate"); addViewToModule(authModuleTree, GettingUserInstance.class, "getting user instance caption", "get-user-instance"); addViewToModule(authModuleTree, LogoutExample.class, "logging out a user caption", "logout"); addViewToModule(authModuleTree, ChangePassword.class, "change password", "change-password"); addViewToModule(authModuleTree, RegisterUser.class, "register user", "register-user"); addViewToModule(authModuleTree, FetchUser.class, "fetching users", "fetch-user"); addViewToModule(authModuleTree, StoreUser.class, "storing users", "store-user"); addViewToModule(authModuleTree, PasswordUtilityMethods.class, "password util", "password-util"); } private void addAuthorizationViews() { addViewToModule(authorizationModuleTree, AuthorizationIntro.class, "intro to authorization", "authorization-intro"); addViewToModule(authorizationModuleTree, Resources.class, "resources", "resources"); addViewToModule(authorizationModuleTree, Roles.class, "roles", "roles"); addViewToModule(authorizationModuleTree, PermissionManagers.class, "permission managers", "permission-managers"); addViewToModule(authorizationModuleTree, JPAPm.class, "jpapm", "jpa-permission-managers"); addViewToModule(authorizationModuleTree, MemPm.class, "mempm", "mem-permission-managers"); addViewToModule(authorizationModuleTree, InitAuthorization.class, "init authorization", "init-authorization"); addViewToModule(authorizationModuleTree, GrantingAccess.class, "granting access", "granting-access"); addViewToModule(authorizationModuleTree, DenyingAccess.class, "denying access", "denying-access"); addViewToModule(authorizationModuleTree, CheckingAccessRights.class, "checking for access rights", "checking-access"); addViewToModule(authorizationModuleTree, RemovingPermissions.class, "removing permissions", "removing-permissions"); } private void addI18nViews() { addViewToModule(i18nModuleTree, I18nIntro.class, "i18n intro", "i18n-intro"); addViewToModule(i18nModuleTree, TranslationsFile.class, "translations file", "translations"); addViewToModule(i18nModuleTree, UpdatingTranslationsFile.class, "updating translations file", "updating-translations"); addViewToModule(i18nModuleTree, ConfigureAndIniI18n.class, "configure i18n", "i18n-config"); addViewToModule(i18nModuleTree, GettingMessages.class, "getting messages", "getmsg"); addViewToModule(i18nModuleTree, FieldTranslations.class, "field translations", "i18n-forms"); } private void addPersistenceViews() { addViewToModule(persistenceModuleTree, PersistenceIntro.class, "persistence module intro", "persistence-intro"); addViewToModule(persistenceModuleTree, ConfiguringPersistence.class, "configuring persistence module", "persistence-config"); addViewToModule(persistenceModuleTree, FacadeFactoryExamples.class, "facade factory exmaple", "facadefactory"); addViewToModule(persistenceModuleTree, CreatingPojos.class, "creating pojos", "creating-pojos"); addViewToModule(persistenceModuleTree, FetchingData.class, "fetching data", "fetching-data"); addViewToModule(persistenceModuleTree, StoringData.class, "storing data", "storing-data"); addViewToModule(persistenceModuleTree, RemovingData.class, "removing data", "removing-data"); } private void addViewViews() { addViewToModule(viewModuleTree, ViewIntro.class, "view module intro", "view-intro"); addViewToModule(viewModuleTree, ConfiguringView.class, "configuring view module", "view-config"); addViewToModule(viewModuleTree, Views.class, "views", "views"); addViewToModule(viewModuleTree, ViewContainerExample.class, "view container", "view-container"); addViewToModule(viewModuleTree, ViewEvents.class, "view events", "view-events"); addViewToModule(viewModuleTree, ViewHandlerExample.class, "view handler example", "viewhandler"); addViewToModule(viewModuleTree, ViewFactories.class, "view factories", "viewfactories"); } private void addViewToModule(Tree tree, Class<? extends View> c, String captionTuid, String uri) { ViewHandler.addView(c, this); ViewHandler.addUri(uri, c); viewToTree.put(c, tree); Item item = tree.addItem(c); item.getItemProperty("name").setValue(Lang.getMessage(captionTuid)); } public void activate(View view) { mainArea.activate(view); Tree tree = viewToTree.get(view.getClass()); if (tree != null) { menu.setSelectedTab(tree); tree.select(view.getClass()); } } public void deactivate(View view) { mainArea.deactivate(view); } public void valueChange(ValueChangeEvent event) { if (event.getProperty().getValue() != null) { ViewHandler.activateView(event.getProperty().getValue(), true); } } }
007lee-test
src/org/vaadin/appfoundation/example/MainWindow.java
Java
asf20
12,594
package org.vaadin.appfoundation.example.i18n; import org.vaadin.appfoundation.example.Page; import org.vaadin.appfoundation.example.ExampleLoader.Examples; public class ConfigureAndIniI18n extends Page { private static final long serialVersionUID = -2316783633541238871L; public ConfigureAndIniI18n() { super("configure i18n text"); addCodeExample(Examples.I18N_SERVLET, "show code"); addCodeExample(Examples.I18N_INIT_LANG, "show code"); } }
007lee-test
src/org/vaadin/appfoundation/example/i18n/ConfigureAndIniI18n.java
Java
asf20
484