204 lines
5.8 KiB
C#
204 lines
5.8 KiB
C#
using System;
|
|
using System.Data;
|
|
using System.Configuration;
|
|
using System.Collections;
|
|
using System.Web;
|
|
using System.Web.Security;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
using System.Web.UI.WebControls.WebParts;
|
|
using System.Web.UI.HtmlControls;
|
|
using System.Data.Common;
|
|
using Wellan.Data;
|
|
using Wellan.Common;
|
|
using System.Text;
|
|
using System.IO;
|
|
|
|
/// <summary>
|
|
/// 年度特休輸入
|
|
/// </summary>
|
|
public partial class forms_worker_fmRbsa : Wellan.Web.UI.WUserControlBase
|
|
{
|
|
private int yy;
|
|
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
txtYear.Focus();
|
|
//if (IsPostBack)
|
|
// gvRbsa.DataBind();
|
|
}
|
|
|
|
private void 註冊按鈕事件(Control owner)
|
|
{
|
|
RegisterLookupEvent(owner, "btnRBENO_WQRY", "txtRBENO",
|
|
"txtRBENO,lbRBENOX", "BPSN",
|
|
"EXISTS (SELECT RANUM FROM RASN WHERE RAPYN='" + ddl專案.SelectedValue + "' AND RANUM=BPENO)",
|
|
false);
|
|
}
|
|
|
|
protected override void OnInit(EventArgs e)
|
|
{
|
|
base.OnInit(e);
|
|
}
|
|
|
|
protected override void LoadControlState(object savedState)
|
|
{
|
|
base.LoadControlState(savedState);
|
|
註冊按鈕事件(this);
|
|
}
|
|
|
|
protected void btnYY_Click(object sender, EventArgs e)
|
|
{
|
|
yy = WDAC.GetInt32Value(txtYear.Text);
|
|
ddl專案.DataSource = new BpaaDAC().GetBpaaWithTY(yy + WGuard1.CY11);
|
|
ddl專案.DataTextField = "BPPYM";
|
|
ddl專案.DataValueField = "BPPYN";
|
|
ddl專案.DataBind();
|
|
}
|
|
|
|
protected void btnSearch_Click(object sender, EventArgs e)
|
|
{
|
|
if (!CheckProjectRight())
|
|
return;
|
|
|
|
Panel1.Visible = true;
|
|
註冊按鈕事件(this);
|
|
gvRbsa.DataBind();
|
|
}
|
|
|
|
protected void dsRbsa_Updating(object sender, ObjectDataSourceMethodEventArgs e)
|
|
{
|
|
e.InputParameters["RBPYN"] = ddl專案.SelectedValue;
|
|
e.InputParameters["TRUSR"] = UserId;
|
|
}
|
|
|
|
protected void gvRbsa_RowCommand(object sender, GridViewCommandEventArgs e)
|
|
{
|
|
/*
|
|
if (e.CommandName == "Save")
|
|
{
|
|
yy = WDAC.GetInt32Value(txtYear.Text);
|
|
int rytot = WDAC.GetInt32Value(((e.CommandSource as Control).Parent.FindControl("TextBox1") as TextBox).Text);
|
|
new RyerDAC(Query).UpdateOne(e.CommandArgument.ToString(), yy + WGuard1.CY11, rytot, UserId);
|
|
|
|
gvRbsa.DataBind();
|
|
}
|
|
*/
|
|
}
|
|
|
|
protected void dsRbsa_Selecting(object sender, ObjectDataSourceSelectingEventArgs e)
|
|
{
|
|
e.InputParameters["RBPYN"] = ddl專案.SelectedValue;
|
|
if (e.InputParameters["RBPYN"] == null)
|
|
e.InputParameters["RBPYN"] = "";
|
|
}
|
|
|
|
protected void btnInsert_Click(object sender, EventArgs e)
|
|
{
|
|
cvMessage.ErrorMessage = "";
|
|
cvMessage.IsValid = true;
|
|
|
|
if (txtRBENO.Text.Trim().Length == 0)
|
|
{
|
|
cvMessage.ErrorMessage = "請輸入人員編號";
|
|
cvMessage.IsValid = false;
|
|
return;
|
|
}
|
|
|
|
DateTime rbdat = txtRBDAT.Value;
|
|
if (rbdat.Ticks == 0)
|
|
{
|
|
cvMessage.ErrorMessage = "請輸入正確的日期";
|
|
cvMessage.IsValid = false;
|
|
return;
|
|
}
|
|
|
|
yy = WDAC.GetInt32Value(txtYear.Text);
|
|
if (rbdat.Year != yy + WGuard1.CY11)
|
|
{
|
|
cvMessage.ErrorMessage = "請輸入與作業年度同年度的日期";
|
|
cvMessage.IsValid = false;
|
|
return;
|
|
}
|
|
|
|
int rbtct;
|
|
if (!Int32.TryParse(txtRBTCT.Text, out rbtct))
|
|
{
|
|
cvMessage.ErrorMessage = "請輸入正確的時數";
|
|
cvMessage.IsValid = false;
|
|
return;
|
|
}
|
|
|
|
RbsaDAC rbsaDao = new RbsaDAC(Query);
|
|
rbsaDao.InsertOne(txtRBENO.Text, ddl專案.SelectedValue, rbdat, rbtct, UserId);
|
|
|
|
gvRbsa.DataBind();
|
|
}
|
|
|
|
protected void gvRbsa_RowUpdating(object sender, GridViewUpdateEventArgs e)
|
|
{
|
|
cvMessage.ErrorMessage = "";
|
|
cvMessage.IsValid = true;
|
|
|
|
if (e.NewValues["RBENO"] == null || e.NewValues["RBENO"].ToString().Trim().Length == 0)
|
|
{
|
|
cvMessage.ErrorMessage = "請輸入人員編號";
|
|
cvMessage.IsValid = false;
|
|
e.Cancel = true;
|
|
return;
|
|
}
|
|
|
|
DateTime rbdat = Convert.ToDateTime(e.NewValues["RBDAT"]);
|
|
if (rbdat.Ticks == 0)
|
|
{
|
|
cvMessage.ErrorMessage = "請輸入正確的日期";
|
|
cvMessage.IsValid = false;
|
|
e.Cancel = true;
|
|
return;
|
|
}
|
|
|
|
yy = WDAC.GetInt32Value(txtYear.Text);
|
|
if (rbdat.Year != yy + WGuard1.CY11)
|
|
{
|
|
cvMessage.ErrorMessage = "請輸入與作業年度同年度的日期";
|
|
cvMessage.IsValid = false;
|
|
e.Cancel = true;
|
|
return;
|
|
}
|
|
|
|
int rbtct;
|
|
if (e.NewValues["RBTCT"] == null || !Int32.TryParse(e.NewValues["RBTCT"].ToString(), out rbtct))
|
|
{
|
|
cvMessage.ErrorMessage = "請輸入正確的時數";
|
|
cvMessage.IsValid = false;
|
|
e.Cancel = true;
|
|
return;
|
|
}
|
|
|
|
e.NewValues["RBDAT"] = rbdat;
|
|
e.NewValues["RBTCT"] = rbtct;
|
|
}
|
|
|
|
protected void gvRbsa_RowDataBound(object sender, GridViewRowEventArgs e)
|
|
{
|
|
if (e.Row.RowType == DataControlRowType.DataRow)
|
|
註冊按鈕事件(e.Row.Cells[1]);
|
|
//GridView_RowDataBound_Shrink_ViewState(sender, e);
|
|
}
|
|
|
|
protected bool CheckProjectRight()
|
|
{
|
|
// 檢查此使用者是否有權限處理這個專案
|
|
BprmDAC bprm = new BprmDAC(Query);
|
|
if (!bprm.GetRight(ddl專案.SelectedValue, UserId))
|
|
{
|
|
//MultiView1.Visible = false;
|
|
cvMessage.ErrorMessage = "對不起,你沒有處理這個專案的權限!";
|
|
cvMessage.IsValid = false;
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
}
|