SheetSign.cs
资源名称:H3_OA.rar [点击查看]
上传用户:li2971742
上传日期:2021-11-18
资源大小:39096k
文件大小:4k
源码类别:
OA系统
开发平台:
C#
- using System;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.ComponentModel;
- namespace OThinker.H3.WorkSheet
- {
- /// <summary>
- /// Summary description for SheetSign.
- /// </summary>
- [DefaultProperty("Text"),
- ToolboxData("<{0}:SheetSign runat=server></{0}:SheetSign>")]
- public class SheetSign : SheetLabel
- {
- public SheetSign()
- {
- }
- private string PackSign(string Signer, string SignDate)
- {
- return Signer + " " + SignDate;
- }
- private string UnpackSign(string Sign)
- {
- if(Sign == null || Sign.IndexOf(" ") == -1)
- {
- return null;
- }
- else
- {
- int index = Sign.IndexOf(" ");
- string Signer = Sign.Substring(0, index);
- string SignDate = Sign.Substring(index + 1);
- return this.GetText(Signer, SignDate);
- }
- }
- private string GetText(string Signer, string SignDate)
- {
- return "签名:" + Signer + " 日期:" + SignDate;
- }
- public override void LoadDataField(SheetPage SheetPage)
- {
- }
- public override void SaveDataField(OThinker.H3.WorkSheet.SheetPage SheetPage)
- {
- if(
- this.DataField != null &&
- this.DataField != "" &&
- SheetPage.Enviroment.InstanceData[this.DataField] != null &&
- SheetPage.Enviroment.InstanceData[this.DataField].ItemType == typeof(string) &&
- SheetPage.Enviroment.InstanceData[this.DataField].ToString().Trim() != "" &&
- SheetPage.Enviroment.InstanceData[this.DataField].ToString().Trim() != null &&
- SheetPage.Enviroment.InstanceData[this.DataField].Visible &&
- SheetPage.Enviroment.InstanceData[this.DataField].Editable)
- {
- // 如果允许写的话,则读取当前用户
- string Signer = SheetPage.Enviroment.Organization.GetFullName(SheetPage.Enviroment.Participant);
- string SignDate = System.DateTime.Now.ToShortDateString();
- // 打包
- SheetPage.Enviroment.InstanceData[DataField].Value = this.PackSign(Signer, SignDate);
- }
- }
- /// <summary>
- /// Render this control to the output parameter specified.
- /// </summary>
- /// <param name="output"> The HTML writer to write out to </param>
- protected override void Render(HtmlTextWriter output)
- {
- SheetPage sheetPage = (SheetPage)this.Page;
- if (this.DataField == null || this.DataField == "" ||
- sheetPage.Enviroment.InstanceData[this.DataField] == null ||
- sheetPage.Enviroment.InstanceData[this.DataField].ItemType != typeof(string) ||
- sheetPage.Enviroment.InstanceData[this.DataField].Visible == false)
- {
- this.Text = null;
- }
- else if (sheetPage.Enviroment.InstanceData[this.DataField].Value != null &&
- ((string)sheetPage.Enviroment.InstanceData[this.DataField].Value) != "")
- {
- // 获得签名的全部内容
- string sign = sheetPage.Enviroment.InstanceData[this.DataField].Value.ToString();
- // 解开签名
- this.Text = this.UnpackSign(sign);
- }
- else if (sheetPage.Enviroment.InstanceData[this.DataField].Editable)
- {
- // 如果允许写的话,则读取当前用户
- string Signer = sheetPage.Enviroment.Organization.GetFullName(sheetPage.Enviroment.Participant);
- string SignDate = System.DateTime.Now.ToShortDateString();
- this.Text = this.GetText(Signer, SignDate);
- }
- else
- {
- this.Text = null;
- }
- base.Render(output);
- }
- }
- }