320 lines
8.9 KiB
C#
320 lines
8.9 KiB
C#
|
using System;
|
|||
|
using System.Data;
|
|||
|
using System.IO;
|
|||
|
using System.Text;
|
|||
|
using System.Web;
|
|||
|
using System.Web.UI;
|
|||
|
using System.Web.UI.WebControls;
|
|||
|
using DeiNiu.wms.Logical;
|
|||
|
using DeiNiu.Utils;
|
|||
|
|
|||
|
public partial class LessonView : PageBase
|
|||
|
{
|
|||
|
private Llesson _logic;
|
|||
|
protected void Page_Init()
|
|||
|
{
|
|||
|
|
|||
|
PostBackTrigger trigger = new PostBackTrigger();
|
|||
|
trigger.ControlID = Button1.UniqueID;
|
|||
|
|
|||
|
// (Button)pnGridViewProcess.FindControl("btnExcel")).UniqueID.ToString();
|
|||
|
|
|||
|
// (UpdatePanel)(Page.Controls[0].FindControl("UpdatePanel1")).Triggers.Add(trigger);
|
|||
|
|
|||
|
((UpdatePanel)Master.FindControl("UpdatePanel1")).Triggers.Add(trigger);
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
protected void Page_Load(object sender, EventArgs e)
|
|||
|
{
|
|||
|
|
|||
|
|
|||
|
if (!IsPostBack)
|
|||
|
{
|
|||
|
_logic = new Llesson();
|
|||
|
Databound();
|
|||
|
}
|
|||
|
SessionSeting();
|
|||
|
}
|
|||
|
|
|||
|
/***************************************** private methods ******************************************/
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// bound the query list.
|
|||
|
/// </summary>
|
|||
|
private void Databound()
|
|||
|
{
|
|||
|
//<2F>γ̷<CEB3><CCB7><EFBFBD>
|
|||
|
DataView dvDept = new DataView(_logic.GetAllActivedCategories());
|
|||
|
|
|||
|
|
|||
|
TreeDept.SelectedNode.ChildNodes.Clear();
|
|||
|
BindTree(TreeDept.SelectedNode.Value, TreeDept.SelectedNode, dvDept);
|
|||
|
//<2F>γ̷<CEB3><CCB7><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD>еĿγ̷<CEB3><CCB7><EFBFBD><EFBFBD>µ<EFBFBD><C2B5><EFBFBD><EFBFBD>пγ<D0BF><CEB3><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
DataView dv = TreeDept.SelectedValue != "0" ? new DataView(_logic.GetLessonsByCat(Convert.ToInt32(TreeDept.SelectedValue))) : new DataView(_logic.GetAllActiveData().Tables[0]);
|
|||
|
GridView1.DataSource = dv;
|
|||
|
GridView1.SelectedIndex = -1;
|
|||
|
GridView1.DataBind();
|
|||
|
|
|||
|
|
|||
|
|
|||
|
UpdateSession();
|
|||
|
// btnSubmit.Enabled = false;
|
|||
|
ClearDetail();
|
|||
|
}
|
|||
|
|
|||
|
private void SessionSeting()
|
|||
|
{
|
|||
|
if (IsPostBack)
|
|||
|
{
|
|||
|
_logic = (Llesson)Session[appScope.PagelevelObj];
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
private void UpdateSession()
|
|||
|
{
|
|||
|
Session[appScope.PagelevelObj] = _logic;
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// set data from shift object to page
|
|||
|
/// </summary>
|
|||
|
private void DetailDataBind()
|
|||
|
{
|
|||
|
DataDetail.Visible = true;
|
|||
|
txtName.Text = _logic.GetLesson.le_name;
|
|||
|
txtDesc.Text = _logic.GetLesson.le_desc;
|
|||
|
txtLocation.Text = _logic.GetLesson.le_location;
|
|||
|
// txtMaster.Text = _logic.GetLesson.le_master;
|
|||
|
txtXunFen.Text = _logic.GetLesson.le_xuefen.ToString();
|
|||
|
txtTrainer.Text = _logic.GetLesson.le_trainer;
|
|||
|
// txtPasswd.Text = _logic.GetEmployee.em_passwd;
|
|||
|
txtStartDate.Text = _logic.GetLesson.le_startdate;
|
|||
|
txtEndDate.Text = _logic.GetLesson.le_enddate;
|
|||
|
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
/************************************** protected methods (event listeners) ********************************/
|
|||
|
|
|||
|
protected void btnAddnew_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
chgOperTxt(true);
|
|||
|
_logic.Initialize();
|
|||
|
ClearDetail();
|
|||
|
// DetailDataBind();
|
|||
|
}
|
|||
|
|
|||
|
protected void DetailsView1_PageIndexChanging(object sender, DetailsViewPageEventArgs e)
|
|||
|
{
|
|||
|
}
|
|||
|
|
|||
|
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
|
|||
|
{
|
|||
|
chgOperTxt(false);
|
|||
|
if (GridView1.DataKeys != null)
|
|||
|
{
|
|||
|
string id = GridView1.DataKeys[e.NewEditIndex].Value.ToString();
|
|||
|
_logic.Initialize(int.Parse(id));
|
|||
|
}
|
|||
|
Databound();
|
|||
|
DetailDataBind();
|
|||
|
}
|
|||
|
|
|||
|
protected void btnSubmit_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
SetDataBack();
|
|||
|
//shifts id eq 0 means this is new one,to add; else an old one, to update
|
|||
|
|
|||
|
int oper = 0;
|
|||
|
oper = _logic.GetLesson.ID > 0 ? _logic.GetLesson.Update() : _logic.GetLesson.Add();
|
|||
|
ClearDetail();
|
|||
|
Databound();
|
|||
|
}
|
|||
|
|
|||
|
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
|
|||
|
{
|
|||
|
|
|||
|
if (GridView1 != null)
|
|||
|
{
|
|||
|
if (GridView1.DataKeys != null)
|
|||
|
{
|
|||
|
string id = GridView1.DataKeys[e.RowIndex].Value.ToString();
|
|||
|
_logic.Initialize(int.Parse(id));
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
_logic.GetLesson.Delete();
|
|||
|
ClearDetail();
|
|||
|
Databound();
|
|||
|
}
|
|||
|
|
|||
|
protected void GridView1_PageIndexChanged(object sender, EventArgs e)
|
|||
|
{
|
|||
|
}
|
|||
|
|
|||
|
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
|
|||
|
{
|
|||
|
GridView1.PageIndex = e.NewPageIndex;
|
|||
|
Databound();
|
|||
|
|
|||
|
//GridView1.DataSource = shiftLgc.getAllShifts().Tables[0];
|
|||
|
// GridView1.DataBind();
|
|||
|
}
|
|||
|
|
|||
|
protected void GridView1_DataBinding(object sender, EventArgs e)
|
|||
|
{
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
protected void GridView1_Sorting(object sender, GridViewSortEventArgs e)
|
|||
|
{
|
|||
|
}
|
|||
|
|
|||
|
//reset the page
|
|||
|
protected void btnCancel_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
_logic.Initialize();
|
|||
|
Page_Load(this, e);
|
|||
|
}
|
|||
|
|
|||
|
/***************************************** internal methods ********************************************/
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// set data from page to shift object
|
|||
|
/// </summary>
|
|||
|
private void SetDataBack()
|
|||
|
{
|
|||
|
// _logic.GetRole.operater = Session["CurrentUserID"].ToString(); todo: write a public method to handle operater,createtime,lastmodfied ... log info.
|
|||
|
|
|||
|
// if (_logic.GetLesson.ID > 0)
|
|||
|
//{
|
|||
|
// _logic.GetLesson.last_modified = DateTime.Now.ToString();
|
|||
|
|
|||
|
//}
|
|||
|
_logic.GetLesson.le_category = Convert.ToInt32(TreeDept.SelectedValue);
|
|||
|
|
|||
|
|
|||
|
_logic.GetLesson.le_name = txtName.Text ;
|
|||
|
_logic.GetLesson.le_desc =txtDesc.Text ;
|
|||
|
_logic.GetLesson.le_location =txtLocation.Text ;
|
|||
|
// txtMaster.Text = _logic.GetLesson.le_master;
|
|||
|
<EFBFBD><EFBFBD> _logic.GetLesson.le_xuefen = Convert.ToInt32(txtXunFen.Text);
|
|||
|
<EFBFBD><EFBFBD> _logic.GetLesson.le_trainer = txtTrainer.Text;<EFBFBD><EFBFBD>
|
|||
|
_logic.GetLesson.le_startdate = txtStartDate.Text;
|
|||
|
_logic.GetLesson.le_enddate =txtEndDate.Text ;<EFBFBD><EFBFBD>
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
private void chgOperTxt(bool addNew)
|
|||
|
{
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
private void ClearDetail()
|
|||
|
{
|
|||
|
txtName.Text = "";
|
|||
|
txtDesc.Text = "";
|
|||
|
txtLocation.Text = "";
|
|||
|
// txtMaster.Text = _logic.GetLesson.le_master;
|
|||
|
txtXunFen.Text = "";
|
|||
|
txtTrainer.Text = "";
|
|||
|
// txtPasswd.Text = _logic.GetEmployee.em_passwd;
|
|||
|
txtStartDate.Text = "";
|
|||
|
txtEndDate.Text = "";
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
|
|||
|
{
|
|||
|
chgOperTxt(false);
|
|||
|
if (GridView1.DataKeys != null)
|
|||
|
{
|
|||
|
string id = GridView1.DataKeys[GridView1.SelectedIndex].Value.ToString();
|
|||
|
_logic.Initialize(int.Parse(id));
|
|||
|
}
|
|||
|
DetailDataBind();
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
public void BindTree(string id, TreeNode pNode, DataView dv)
|
|||
|
{
|
|||
|
|
|||
|
|
|||
|
dv.RowFilter = "lc_uplevel = '" + id + "'";
|
|||
|
foreach (DataRowView row in dv)
|
|||
|
{
|
|||
|
TreeNode node = new TreeNode();
|
|||
|
node.Text = row["lc_name"].ToString();
|
|||
|
node.Value = row["ID"].ToString();
|
|||
|
if (pNode == null)
|
|||
|
//˵<><CBB5><EFBFBD>Ǹ<EFBFBD><C7B8>ڵ<EFBFBD>
|
|||
|
{
|
|||
|
|
|||
|
TreeDept.Nodes.Add(node);
|
|||
|
node.Expanded = true;
|
|||
|
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
pNode.ChildNodes.Add(node);
|
|||
|
node.Expanded = true;
|
|||
|
|
|||
|
}
|
|||
|
BindTree(node.Value, node, new DataView(dv.Table));
|
|||
|
|
|||
|
}
|
|||
|
}
|
|||
|
protected void TreeDept_SelectedNodeChanged(object sender, EventArgs e)
|
|||
|
{
|
|||
|
GridView1.SelectedIndex = -1;
|
|||
|
DataView dv = new DataView(_logic.GetAllActiveData().Tables[0]);
|
|||
|
if(TreeDept.SelectedValue !="0")
|
|||
|
dv.RowFilter = "le_category = '" + TreeDept.SelectedValue + "'";
|
|||
|
GridView1.DataSource = dv;
|
|||
|
GridView1.DataBind();
|
|||
|
ClearDetail();
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
//<2F><><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>淽<EFBFBD><E6B7BD><EFBFBD>ᱨ<EFBFBD><E1B1A8><EFBFBD><EFBFBD><EFBFBD>͡<EFBFBD>GridView<65><77><EFBFBD>Ŀؼ<C4BF><D8BC><EFBFBD>GridView1<77><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ھ<EFBFBD><DABE><EFBFBD> runat=server <20>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
public override void VerifyRenderingInServerForm(Control control)
|
|||
|
{
|
|||
|
}
|
|||
|
protected void Excel_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
|
|||
|
Master.ScriptMgr.RegisterPostBackControl(this.Button1);
|
|||
|
GridView1.AllowPaging = false;
|
|||
|
GridView1.Columns[GridView1.Columns.Count-1].Visible = false;
|
|||
|
Databound();
|
|||
|
Export("application/ms-excel", "<22><>ѵ<EFBFBD><D1B5><EFBFBD><EFBFBD>.xls");
|
|||
|
GridView1.AllowPaging = false;
|
|||
|
GridView1.Columns[GridView1.Columns.Count - 1].Visible = true;
|
|||
|
Databound();
|
|||
|
}
|
|||
|
|
|||
|
private void Export(string FileType, string FileName)
|
|||
|
{
|
|||
|
|
|||
|
Response.Charset = "GB2312";
|
|||
|
Response.ContentEncoding = Encoding.UTF7;
|
|||
|
Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(FileName, Encoding.UTF8).ToString());
|
|||
|
Response.ContentType = FileType;
|
|||
|
EnableViewState = false;
|
|||
|
StringWriter tw = new StringWriter();
|
|||
|
HtmlTextWriter hw = new HtmlTextWriter(tw);
|
|||
|
GridView1.RenderControl(hw);
|
|||
|
Response.Write(tw.ToString());
|
|||
|
Response.End();
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
}
|