233 lines
6.5 KiB
C#
233 lines
6.5 KiB
C#
|
using System;
|
|||
|
using System.Data;
|
|||
|
using System.Web.UI;
|
|||
|
using System.Web.UI.WebControls;
|
|||
|
using DeiNiu.wms.Logical;
|
|||
|
using DeiNiu.Utils;
|
|||
|
|
|||
|
public partial class WorkplanMain : PageBase
|
|||
|
{
|
|||
|
private LWorkplan _logic;
|
|||
|
|
|||
|
protected void Page_Load(object sender, EventArgs e)
|
|||
|
{
|
|||
|
lem = (LEmployee)Session["CurrentUser"];
|
|||
|
if (!IsPostBack)
|
|||
|
{
|
|||
|
_logic = new LWorkplan();
|
|||
|
Calendar1.SelectedDate = DateTime.Today ;
|
|||
|
Databound();
|
|||
|
|
|||
|
}
|
|||
|
SessionSeting();
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// bound the query list.
|
|||
|
/// </summary>
|
|||
|
private void Databound()
|
|||
|
{
|
|||
|
_logic.CheckWorkplan(lem.GetEmployee.ID, Calendar1.SelectedDate.ToString(),true);
|
|||
|
GridView1.DataSource = _logic.GetLWorkplan.getWorkplanDetails(lem.GetEmployee.ID,Calendar1.SelectedDate.ToString());
|
|||
|
GridView1.DataBind();
|
|||
|
UpdateSession();
|
|||
|
// btnSubmit.Enabled = false;
|
|||
|
// ClearDetail();
|
|||
|
}
|
|||
|
|
|||
|
private void SessionSeting()
|
|||
|
{
|
|||
|
if (IsPostBack)
|
|||
|
{
|
|||
|
_logic = (LWorkplan)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;
|
|||
|
txtPlanContent.Text = _logic.GetLWorkplanDetail.wpd_content;
|
|||
|
txtPlanMem.Text = _logic.GetLWorkplanDetail.wpd_mem;
|
|||
|
|
|||
|
// chkStatus.Checked = _logic.GetRole.dr;
|
|||
|
}
|
|||
|
|
|||
|
/************************************** protected methods (event listeners) ********************************/
|
|||
|
|
|||
|
protected void btnAddnew_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
chgOperTxt(true);
|
|||
|
// _logic.Initialize(); _logic.CheckWorkplan <20><><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƻ<EFBFBD><C6BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
_logic.InitializeDetail();
|
|||
|
UpdateSession();
|
|||
|
DetailDataBind();
|
|||
|
txtPlanContent.Focus();
|
|||
|
GridView1.SelectedIndex = -1;
|
|||
|
<EFBFBD><EFBFBD>
|
|||
|
Databound();
|
|||
|
}
|
|||
|
|
|||
|
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();
|
|||
|
txtPlanContent.Focus();
|
|||
|
}
|
|||
|
|
|||
|
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.GetLWorkplanDetail.ID > 0 ? _logic.GetLWorkplanDetail.Update() : _logic.GetLWorkplanDetail.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.GetRole.dr = false;
|
|||
|
_logic.GetRole.Update();
|
|||
|
|
|||
|
*/
|
|||
|
_logic.GetLWorkplanDetail.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_RowDataBound(object sender, GridViewRowEventArgs e)
|
|||
|
{
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
protected void GridView1_Sorting(object sender, GridViewSortEventArgs e)
|
|||
|
{
|
|||
|
|
|||
|
string sortExpression = e.SortExpression;
|
|||
|
if (GridView1.SortDirection == SortDirection.Ascending) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
{
|
|||
|
|
|||
|
SortGridView(sortExpression, " DESC");
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
|
|||
|
SortGridView(sortExpression, " ASC");
|
|||
|
}
|
|||
|
}
|
|||
|
private void SortGridView(string sortExpression, string direction)
|
|||
|
{
|
|||
|
DataView dv = new DataView(_logic.GetAllActiveData().Tables[0]);
|
|||
|
dv.Sort = sortExpression + direction;
|
|||
|
GridView1.DataSource = dv; //<2F><>DataView<65><EFBFBD>GridView<65><77>
|
|||
|
GridView1.DataBind();
|
|||
|
|
|||
|
}
|
|||
|
//reset the page
|
|||
|
protected void btnCancel_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
_logic.Initialize();
|
|||
|
Page_Load(this, e);
|
|||
|
ClearDetail();
|
|||
|
}
|
|||
|
|
|||
|
/***************************************** 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.GetLWorkplanDetail.ID > 0)
|
|||
|
// _logic.GetLWorkplanDetail.lastmodified = DateTime.Now.ToString();
|
|||
|
|
|||
|
_logic.GetLWorkplanDetail.wpd_content = txtPlanContent.Text;
|
|||
|
_logic.GetLWorkplanDetail.wpd_mem = txtPlanMem.Text;
|
|||
|
_logic.GetLWorkplanDetail.wpd_workplan = _logic.GetLWorkplan.ID;
|
|||
|
_logic.GetLWorkplanDetail.wpd_number = _logic.getNexNumber(_logic.GetLWorkplan.ID);
|
|||
|
}
|
|||
|
|
|||
|
private void chgOperTxt(bool addNew)
|
|||
|
{
|
|||
|
btnSubmit.Enabled = true;
|
|||
|
DataDetail.Visible = true;
|
|||
|
}
|
|||
|
|
|||
|
private void ClearDetail()
|
|||
|
{
|
|||
|
txtPlanMem.Text = "";
|
|||
|
txtPlanContent.Text = "";
|
|||
|
DataDetail.Visible = false;
|
|||
|
}
|
|||
|
|
|||
|
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();
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
protected void Calendar1_SelectionChanged(object sender, EventArgs e)
|
|||
|
{
|
|||
|
Databound();
|
|||
|
}
|
|||
|
protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
|
|||
|
{
|
|||
|
// e.Cell.Controls.Add(new LiteralControl(" <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> "));
|
|||
|
// e.Cell.Font.Size = FontUnit.XXLarge;
|
|||
|
}
|
|||
|
}
|