namespace nlisclient.oecform
{
/// <summary>
///
<para>程式名稱:日清模闆用戶端窗體</para>
/// <list type="table">
/// <listheader>
<term>作者</term><term>日期</term><term>版本</term><term>更改說明</term>
/// <item>
<term>高明勝</term><term>2014-04-2</term><term>v1.0</term><term>建立</term>
/// </item>
/// </listheader>
/// </list>
/// </summary>
public partial class daycleartempletform :
dataeditmiddlebase, nlisclient.interface.imaintooldelete,
nlisclient.interface.imaintooladd, nlisclient.interface.imaintoolupdate,
nlisclient.interface.imaintoolsave,
nlisclient.interface.imaintoolselect,nlisclient.interface.imaintoolpreview
#region 屬性
wcfdaycleartempletservice.daycleartempletserviceclient client = new
wcfdaycleartempletservice.daycleartempletserviceclient();
private
authorizationscope _authorizationscope = authorizationscope.personal;
//部門
private pub_department_bl department_bl = new pub_department_bl();
private pub_useinfo _infouser = new pub_useinfo();
pub_entityauthorization_bl _bllentityauthorization = new
pub_entityauthorization_bl();
string strwhere ="";
/// 激活的标簽分類
</summary>
private tabtype tabtype = tabtype.update;
#endregion
#region 枚舉
enum tabtype
add,
update
}
/// 操作分類
[description("操作類型")]
public enum actiontype
/// 建立
[nlisserviceenumattribute(name = "建立")]
add = 0,
/// 修改
[nlisserviceenumattribute(name = "修改")]
edit
= 1,
/// 删除
[nlisserviceenumattribute(name =
"删除")]
remove = 2,
/// 詳細
"詳細")]
detail = 3,
/// 搜尋
"搜尋")]
search = 4,
/// 導出
[nlisserviceenumattribute(name = "變更")]
chang
= 5
public daycleartempletform()
initializecomponent();
private void daycleartempletform_load(object sender, eventargs e)
try
_infouser =
(pub_useinfo)applicationdata.get("userinfo");
tbxdaycleartempletitem.focus();
this.wfppaging.pagesize =
30;
comboxunit();
mybind(1,
wfppaging.pagesize, getwhere());
catch
(exception)
throw;
/// 擷取組對象集合分頁
/// <param name="pagenum">頁碼</param>
/// <param name="pagesize">每頁顯示條數</param>
<returns></returns>
private void mybind(int pagenum, int
pagesize, string strwhere)
dictionary<string,
string> dic = new dictionary<string, string>();
dic =
client.search(pagenum, this.wfppaging.pagesize, strwhere);
this.wfppaging.recordcount = convert.toint32(dic["pages"]);
wfppaging.pageindex = pagenum;
dgv.autogeneratecolumns =
false;
dgv.columns["daycleartempletid"].datapropertyname =
"daycleartempletid";
dgv.columns["daycleartempletworkmodule"].datapropertyname =
"daycleartempletworkmodule";
dgv.columns["daycleartempletpostid"].datapropertyname =
"daycleartempletpostid";
dgv.columns["daycleartempletpostname"].datapropertyname =
"daycleartempletpostname";
dgv.columns["daycleartempletstatus"].datapropertyname =
"daycleartempletstatus";;
dgv.columns["statusname"].datapropertyname = "statusname";
dgv.columns["daycleartempletremark"].datapropertyname =
"daycleartempletremark";
dgv.columns["daycleartempletnewuserid"].datapropertyname =
"daycleartempletnewuserid";
dgv.columns["daycleartempletnewusername"].datapropertyname =
"daycleartempletnewusername";
dgv.columns["daycleartempletnewtime"].datapropertyname =
"daycleartempletnewtime";
dgv.columns["daycleartempletupdateusername"].datapropertyname =
"daycleartempletupdateusername";
dgv.columns["daycleartempletupdateuserid"].datapropertyname =
"daycleartempletupdateuserid";
dgv.columns["daycleartempletupdatetime"].datapropertyname =
"daycleartempletupdatetime";
datatable dt =
nlisclient.uibase.helper.tablehelper.deserializationtable(dic["table"]);
datacolumn dc = new datacolumn("statusname");
dt.columns.add(dc);
foreach (datarow row in dt.rows)
row["statusname"] = (convert.toint16(row["daycleartempletstatus"]) == 1 ?
"有效" :
(convert.toint16(row["daycleartempletstatus"]) == 0 ? "無效" : "建立"));
this.dgv.datasource = null;
this.dgv.datasource = dt;
textboxunit();
/// 與gridview選中行的内容保持一緻
public void
textboxunit()
lblnewusername.text = "";
lblnewtime.text = "";
lblupdateusername.text = "";
lblupdatetime.text = "";
datagridviewselectedrowcollection rows
= dgv.selectedrows;
if (rows != null && rows.count ==
1)
tabtype = tabtype.update;
lbldaycleartempletid.text =
rows[0].cells["daycleartempletid"].value.tostring();
tbxsdaycleartempletpositionname.text =
rows[0].cells["daycleartempletworkmodule"].value.tostring();
txtemployeepost.text =
rows[0].cells["daycleartempletpostname"].value.tostring();
lblemployeepostid.text =
rows[0].cells["daycleartempletpostid"].value.tostring();
tbxdaycleartempletremark.text =
rows[0].cells["daycleartempletremark"].value.tostring();
lblnewusername.text =
rows[0].cells["daycleartempletnewusername"].value.tostring();
lblnewtime.text = rows[0].cells["daycleartempletnewtime"].value.tostring();
lblupdateusername.text =
rows[0].cells["daycleartempletupdateusername"].value.tostring();
lblupdatetime.text =
rows[0].cells["daycleartempletupdatetime"].value.tostring();
#region 狀态的控制
//狀态若為有效,則控件不可用
if
(rows[0].cells["daycleartempletstatus"].value.tostring() == "1")
#region myregion
controlenable(false);
cbxdaycleartempletstatus.enabled =
true;
//初始化 狀态combox
datatable
dtstatus = new datatable();
dtstatus.columns.add("name");
dtstatus.columns.add("value", typeof(object));
dtstatus.rows.add("無效", 0);
dtstatus.rows.add("有效",
1);
cbxdaycleartempletstatus.displaymember = "name";
cbxdaycleartempletstatus.valuemember = "value";
cbxdaycleartempletstatus.datasource = dtstatus;
tbxsdaycleartempletpositionname.readonly = true;
txtemployeepost.readonly = true;
tbxdaycleartempletremark.readonly = true;
this.btnspost.enabled = false;
else if
(rows[0].cells["daycleartempletstatus"].value.tostring() == "2")//建立
controlenable(true);
datatable dtstatus = new
datatable();
dtstatus.rows.add("有效", 1);
dtstatus.rows.add("建立",
2);
cbxdaycleartempletstatus.enabled = true;
this.btnspost.enabled = true;
this.tbxdaycleartempletremark.readonly = false;
(rows[0].cells["daycleartempletstatus"].value.tostring() == "0")//無效
datatable dtstatus = new datatable();
tbxsdaycleartempletpositionname.readonly =
this.tbxdaycleartempletremark.readonly = true;
cbxdaycleartempletstatus.selectedvalue =
rows[0].cells["daycleartempletstatus"].value;
else
tabtype
= tabtype.add;
#region 狀态初始化 建立、有效、無效
//初始化
狀态combox
cbxdaycleartempletstatus.selectedindex = 1;
cbxdaycleartempletstatus.enabled = false;
tbxsdaycleartempletpositionname.readonly = false;
txtemployeepost.readonly = false;
tbxdaycleartempletremark.readonly = false;
catch (exception)
lbldaycleartempletid.text = "";
tbxsdaycleartempletpositionname.tag = null;
tbxsdaycleartempletpositionname.text = "";
txtemployeepost.text = "";
"";
txtemployeepost.focus();
/// 狀态控制控件的可用性
public void controlenable(bool flag)
txtemployeepost.enabled =!flag;
tbxsdaycleartempletpositionname.readonly =flag;
tbxdaycleartempletremark.readonly = !flag;
<summary>
/// 擷取查詢條件
<returns>查詢條件</returns>
public string getwhere()
strwhere = " 1=1";
//工作子產品
(tbxdaycleartempletitem.text.trim() != "")
strwhere += " and daycleartempletworkmodule like ‘%" +
tbxdaycleartempletitem.text + "%‘";
//所屬職務
(txtemployeepostname.text.trim() != "")
strwhere += " and daycleartempletpostid =" + lblemployeepostid.text;
//狀态
if (cbxsstatus.text.trim() != "")
strwhere += " and daycleartempletstatus =" +
cbxsstatus.selectedvalue;
return strwhere;
/// 收索綁定
public void comboxunit()
dtstatus.columns.add("value",
typeof(object));
dtstatus.rows.add("建立", 2);
dtstatus.rows.add("", 3);
cbxsstatus.displaymember =
"name";
cbxsstatus.valuemember = "value";
cbxsstatus.datasource = dtstatus;
cbxsstatus.selectedindex =
dtstatus.rows.count - 1;
#region 實作接口
/// 添加
public bool add()
bool isauthorization = false;
//判斷使用者是否有單獨權限
(!_infouser.userisauthority)
isauthorization
= _bllentityauthorization.isauthorization(_infouser.usergroupid,
client.getnamespace(), actiontype.add.tostring("d"));
isauthorization =
_bllentityauthorization.isauthorizations(_infouser.userid,
_infouser.usergroupid, client.getnamespace(), actiontype.add.tostring("d"));
//判斷是否具有對該業務實體操作的權限
if (isauthorization)
dgv.clearselection();
messagebox.show("您沒有權限進行此操作!", "nlis系統資訊提示", messageboxbuttons.ok,
messageboxicon.information);
return true;
/// 儲存
/// <returns></returns>
public bool savedate()
bool isauthorization =
if (!_infouser.userisauthority)
_bllentityauthorization.isauthorization(_infouser.usergroupid,
(isauthorization)
if (tabtype ==
tabtype.add)
#region
驗證
if (tbxsdaycleartempletpositionname.text.trim() == "")
messagebox.show("工作子產品不能為空!",
"nlis系統資訊提示", messageboxbuttons.ok, messageboxicon.information);
tbxsdaycleartempletpositionname.focus();
return false;
(txtemployeepost.text.trim() == "")
messagebox.show("請輸入職位!", "nlis系統資訊提示", messageboxbuttons.ok,
oec_daycleartemplet bi = new oec_daycleartemplet();
bi.daycleartempletworkmodule = tbxsdaycleartempletpositionname.text;
bi.daycleartempletpostid =
convert.toint32(lblemployeepostid.text);
bi.daycleartempletstatus =
convert.toint16(cbxdaycleartempletstatus.selectedvalue);
bi.daycleartempletremark = tbxdaycleartempletremark.text.trim();
bi.daycleartempletnewtime = datetime.now;
bi.daycleartempletnewuserid = _infouser.userid;
messageinfo messageinfo = client.add(bi);
nlisservicemessage.showmessage(messageinfo, messageboxtype.info);
if (messageinfo.success)
mybind(wfppaging.pageindex, wfppaging.pagesize, strwhere);
messagebox.show("不是建立資料不能儲存,請先點選添加按鈕!", "nlis系統資訊提示", messageboxbuttons.ok,
public new bool update()
if (lbldaycleartempletid.text != "" && tabtype ==
tabtype.update)
client.getnamespace(), actiontype.edit.tostring("d"));
_infouser.usergroupid, client.getnamespace(),
actiontype.edit.tostring("d"));
if (messagebox.show("确認修改?", "nlis系統資訊提示", messageboxbuttons.okcancel,
messageboxicon.question) == dialogresult.ok)
#region 驗證
messagebox.show("工作子產品不能為空!", "nlis系統資訊提示", messageboxbuttons.ok,
messagebox.show("請輸入職位!", "nlis系統資訊提示",
messageboxbuttons.ok, messageboxicon.information);
return
oec_daycleartemplet bi = new
oec_daycleartemplet();
bi.daycleartempletid =
convert.toint32(lbldaycleartempletid.text);
bi.daycleartempletpostid = convert.toint32(lblemployeepostid.text);
bi.daycleartempletupdatetime = datetime.now;
bi.daycleartempletupdateuserid = _infouser.userid;
messageinfo messageinfo = client.updatebyid(bi);
nlisservicemessage.showmessage(messageinfo,
messageboxtype.info);
(messageinfo.success)
messagebox.show("不是資料修改,請先點選一條資料後修改!",
public bool delete()
client.getnamespace(), actiontype.remove.tostring("d"));
isauthorization = _bllentityauthorization.isauthorizations(_infouser.userid,
actiontype.remove.tostring("d"));
if (lbldaycleartempletid.text.trim() != "")
if (messagebox.show("确認删除?", "nlis系統資訊提示",
messageboxbuttons.okcancel, messageboxicon.question) == dialogresult.ok)
messageinfo messageinfo =
client.deletebyid(convert.toint64(lbldaycleartempletid.text));
mybind(this.wfppaging.pageindex, this.wfppaging.pagesize,
strwhere);
messagebox.show("您沒有選中一行資料,不能删除!", "nlis系統資訊提示",
/// 查詢事件
public new bool select()
bool isauthorization
= false;
client.getnamespace(), actiontype.search.tostring("d"));
actiontype.search.tostring("d"));
strwhere = getwhere();
this.wfppaging.pagesize, strwhere);
if (dgv.rows.count ==
0)
messagebox.show("未查到與條件相符的資料!", "nlis系統資訊提示", messageboxbuttons.ok,
messagebox.show("您沒有權限進行此操作!", "nlis系統資訊提示",
/// 預覽
public bool preview()
datagridviewselectedrowcollection rows =
this.dgv.selectedrows;
if (convert.toint32(rows[0].cells["daycleartempletstatus"].value) !=
2)
daycleartempletpreviewinfoform info = new
daycleartempletpreviewinfoform(rows[0].cells["daycleartempletpostid"].value.tostring());
info.tag = this.tag;
info.owner = this;
info.showdialog();
private void btnspost_click(object sender, eventargs e)
postlistform postform = new postlistform(txtemployeepost,
lblemployeepostid);
postform.owner = this;
postform.showdialog();
lblemployeepostid.visible = false;
//lblemployeepostid.text = "";
//txtemployeepostname.text
= "";
private void btnspostname_click(object sender, eventargs
e)
postlistform postform = new
postlistform(txtemployeepostname, lblemployeepostid);
//lblemployeepostid.text =
//txtemployeepost.text = "";
private void dgv_cellclick(object sender, datagridviewcelleventargs
this.textboxunit();
/// 輕按兩下檢視詳細
<param name="sender"></param>
/// <param
name="e"></param>
private void dgv_celldoubleclick(object
sender, datagridviewcelleventargs e)
datagridviewselectedrowcollection rows = this.dgv.selectedrows;
if (rows != null && rows.count == 1 && tabtype ==
client.getnamespace(), actiontype.detail.tostring("d"));
actiontype.detail.tostring("d"));
(convert.toint32(rows[0].cells["daycleartempletstatus"].value) != 2 &&
convert.toint32(rows[0].cells["daycleartempletstatus"].value) != 0)
label lbl = new label();
lbl.text =
lbl.tag = rows[0].cells["daycleartempletid"].value;
daycleartempletinfoform info = new
daycleartempletinfoform(lbl);
info.tag =
this.tag;
messagebox.show("不是資料修改,請先點選一條資料後修改!", "nlis系統資訊提示", messageboxbuttons.ok,
private void wfppaging_pageindexchanged(object sender, eventargs
wfppaging.pageindex = wfppaging.pageindex;