标签:des datagridview class tar ext c
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();
        private 
PUB_EntityAuthorization_BL _bllEntityAuthorization = new 
PUB_EntityAuthorization_BL();
        string strWhere ="";
        /// <summary>
        /// 激活的标签分类
/// 
</summary>
        private TabType tabType = TabType.Update;
#endregion
#region 枚举
enum TabType
        {
            Add,
            Update
       
 }
        /// <summary>
        /// 操作分类
/// </summary>
   
     [Description("操作类型")]
public enum ActionType
        {
            
/// <summary>
            /// 新建
/// </summary>
            
[NLISServiceEnumAttribute(Name = "新建")]
Add = 0,
            /// <summary>
            /// 修改
/// 
</summary>
            [NLISServiceEnumAttribute(Name = "修改")]
Edit 
= 1,
            /// <summary>
            /// 删除
/// 
</summary>
            [NLISServiceEnumAttribute(Name = 
"删除")]
Remove = 2,
            /// <summary>
            /// 详细
/// 
</summary>
            [NLISServiceEnumAttribute(Name = 
"详细")]
Detail = 3,
            /// <summary>
            /// 搜索
/// 
</summary>
            [NLISServiceEnumAttribute(Name = 
"搜索")]
Search = 4,
            /// <summary>
            /// 导出
/// 
</summary>
            [NLISServiceEnumAttribute(Name = "变更")]
Chang 
= 5
        }
        #endregion
        /// <summary>
        
/// 
        /// </summary>
        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;
            }
      
  }
        /// <summary>
        /// 获取组对象集合分页
/// 
</summary>
        /// <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();
        }
        /// <summary>
        
/// 与gridview选中行的内容保持一致
/// </summary>
        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;
                    #endregion
             
   }
                else if 
(rows[0].Cells["DayClearTempletStatus"].Value.ToString() == "2")//新建
{
    
                #region MyRegion
                    ControlEnable(true);
 
                   tbxsDayClearTempletPositionName.ReadOnly = true;
          
          //初始化 状态combox
                    DataTable dtStatus = new 
DataTable();
                    dtStatus.Columns.Add("name");
            
        dtStatus.Columns.Add("value", typeof(object));
                    
dtStatus.Rows.Add("有效", 1);
                    dtStatus.Rows.Add("新建", 
2);
                    cbxDayClearTempletStatus.DisplayMember = "name";
  
                  cbxDayClearTempletStatus.ValueMember = "value";
            
        cbxDayClearTempletStatus.DataSource = dtStatus;
                    
cbxDayClearTempletStatus.Enabled = true;
                    
this.btnSPost.Enabled = true;
                    
this.tbxDayClearTempletRemark.ReadOnly = false;
                    
#endregion
                }
                else if 
(rows[0].Cells["DayClearTempletStatus"].Value.ToString() == "0")//无效
{
    
                //初始化 状态combox
                    #region MyRegion
       
             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;
                    
ControlEnable(false);
                    cbxDayClearTempletStatus.Enabled = 
false;
                    tbxsDayClearTempletPositionName.ReadOnly = 
true;
                    this.btnSPost.Enabled = false;
                  
  this.tbxDayClearTempletRemark.ReadOnly = true;
                    
#endregion
                }
                
cbxDayClearTempletStatus.SelectedValue = 
rows[0].Cells["DayClearTempletStatus"].Value;
                #endregion
            }
            else
            {
                tabType 
= TabType.Add;
                ControlEnable(true);
                
#region 状态初始化 新建、有效、无效
try
                {
                    //初始化 
状态combox
                    DataTable dtStatus = new DataTable();
        
            dtStatus.Columns.Add("name");
                    
dtStatus.Columns.Add("value", typeof(object));
                    
dtStatus.Rows.Add("有效", 1);
                    dtStatus.Rows.Add("新建", 
2);
                    cbxDayClearTempletStatus.DisplayMember = "name";
  
                  cbxDayClearTempletStatus.ValueMember = "value";
            
        cbxDayClearTempletStatus.DataSource = dtStatus;
                    
cbxDayClearTempletStatus.SelectedIndex = 1;
                    
cbxDayClearTempletStatus.Enabled = false;
                    
tbxsDayClearTempletPositionName.ReadOnly = false;
                    
txtEmployeePost.ReadOnly = false;
                    
tbxDayClearTempletRemark.ReadOnly = false;
                }
              
  catch (Exception)
                {
                    throw;
       
         }
                #endregion
                
lblDayClearTempletID.Text = "";
                
tbxsDayClearTempletPositionName.Tag = null;
                
tbxsDayClearTempletPositionName.Text = "";
                
txtEmployeePost.Text = "";
                tbxDayClearTempletRemark.Text = 
"";
                lblNewUserName.Text = "";
                
lblNewTime.Text = "";
                lblUpdateUserName.Text = "";
        
        lblUpdateTime.Text = "";
            }
            
txtEmployeePost.Focus();
        }
        /// <summary>
        /// 状态控制控件的可用性
/// 
</summary>
        public void ControlEnable(bool flag)
        
{
            txtEmployeePost.Enabled =!flag;
            
tbxsDayClearTempletPositionName.ReadOnly =flag;
            
tbxDayClearTempletRemark.ReadOnly = !flag;
        }
        /// 
<summary>
        /// 获取查询条件
/// </summary>
        /// 
<returns>查询条件</returns>
        public string GetWhere()
      
  {
            strWhere = " 1=1";
            //工作模块
if 
(tbxDayClearTempletItem.Text.Trim() != "")
            {
                
strWhere += " AND DayClearTempletWorkModule Like ‘%" + 
tbxDayClearTempletItem.Text + "%‘";
            }
            //所属职务
if 
(txtEmployeePostName.Text.Trim() != "")
            {
                
strWhere += " AND DayClearTempletPostID =" + lblEmployeePostID.Text;
         
   }
            //状态
if (cbxSStatus.Text.Trim() != "")
            
{
                strWhere += " AND DayClearTempletStatus =" + 
cbxSStatus.SelectedValue;
            }
            return strWhere;
   
     }
        /// <summary>
        /// 收索绑定
/// 
</summary>
        public void ComboxUnit()
        {
            
//初始化 状态combox
            DataTable dtStatus = new DataTable();
          
  dtStatus.Columns.Add("name");
            dtStatus.Columns.Add("value", 
typeof(object));
            dtStatus.Rows.Add("无效", 0);
            
dtStatus.Rows.Add("有效", 1);
            dtStatus.Rows.Add("新建", 2);
       
     dtStatus.Rows.Add("", 3);
            cbxSStatus.DisplayMember = 
"name";
            cbxSStatus.ValueMember = "value";
            
cbxSStatus.DataSource = dtStatus;
            cbxSStatus.SelectedIndex = 
dtStatus.Rows.Count - 1;
        }
        #region 实现接口
/// 
<summary>
        /// 添加
/// </summary>
        /// 
<returns></returns>
        public bool Add()
        {
    
        bool IsAuthorization = false;
            //判断用户是否有单独权限
if 
(!_infoUser.UserIsAuthority)
            {
                IsAuthorization 
= _bllEntityAuthorization.IsAuthorization(_infoUser.UserGroupID, 
client.GetNamespace(), ActionType.Add.ToString("D"));
            }
       
     else
            {
                IsAuthorization = 
_bllEntityAuthorization.IsAuthorizations(_infoUser.UserID, 
_infoUser.UserGroupID, client.GetNamespace(), ActionType.Add.ToString("D"));
 
           }
            //判断是否具有对该业务实体操作的权限
if (IsAuthorization)
      
      {
                dgv.ClearSelection();
                
TextBoxUnit();
            }
            else
            {
         
       MessageBox.Show("您没有权限进行此操作!", "NLIS系统信息提示", MessageBoxButtons.OK, 
MessageBoxIcon.Information);
            }
            return true;
    
    }
        /// <summary>
        /// 保存
/// 
</summary>
        /// <returns></returns>
        
public bool SaveDate()
        {
            try
            {
                bool IsAuthorization = 
false;
                //判断用户是否有单独权限
if (!_infoUser.UserIsAuthority)
   
             {
                    IsAuthorization = 
_bllEntityAuthorization.IsAuthorization(_infoUser.UserGroupID, 
client.GetNamespace(), ActionType.Add.ToString("D"));
                }
   
             else
                {
                    IsAuthorization = 
_bllEntityAuthorization.IsAuthorizations(_infoUser.UserID, 
_infoUser.UserGroupID, client.GetNamespace(), ActionType.Add.ToString("D"));
 
               }
                //判断是否具有对该业务实体操作的权限
if 
(IsAuthorization)
                {
                    if (tabType == 
TabType.Add)
                    {
                        #region 
验证
if (tbxsDayClearTempletPositionName.Text.Trim() == "")
                 
       {
                            MessageBox.Show("工作模块不能为空!", 
"NLIS系统信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
             
               tbxsDayClearTempletPositionName.Focus();
                      
      return false;
                        }
                        if 
(txtEmployeePost.Text.Trim() == "")
                        {
             
               MessageBox.Show("请输入职位!", "NLIS系统信息提示", MessageBoxButtons.OK, 
MessageBoxIcon.Information);
                            
txtEmployeePost.Focus();
                            return false;
        
                }
                        #endregion
                      
  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);
   
                     }
                    }
                    else
  
                  {
                        
MessageBox.Show("不是新建数据不能保存,请先点击添加按钮!", "NLIS系统信息提示", MessageBoxButtons.OK, 
MessageBoxIcon.Information);
                    }
                }
   
             else
                {
                    
MessageBox.Show("您没有权限进行此操作!", "NLIS系统信息提示", MessageBoxButtons.OK, 
MessageBoxIcon.Information);
                }
            }
           
 catch (Exception)
            {
                throw;
            
}
            return true;
        }
        /// <summary>
    
    /// 修改
/// </summary>
        /// 
<returns></returns>
        public new bool Update()
        
{
            if (lblDayClearTempletID.Text != "" && tabType == 
TabType.Update)
            {
                bool IsAuthorization = 
false;
                //判断用户是否有单独权限
if (!_infoUser.UserIsAuthority)
   
             {
                    IsAuthorization = 
_bllEntityAuthorization.IsAuthorization(_infoUser.UserGroupID, 
client.GetNamespace(), ActionType.Edit.ToString("D"));
                }
  
              else
                {
                    IsAuthorization = 
_bllEntityAuthorization.IsAuthorizations(_infoUser.UserID, 
_infoUser.UserGroupID, client.GetNamespace(), 
ActionType.Edit.ToString("D"));
                }
                
//判断是否具有对该业务实体操作的权限
if (IsAuthorization)
                {
             
       if (MessageBox.Show("确认修改?", "NLIS系统信息提示", MessageBoxButtons.OKCancel, 
MessageBoxIcon.Question) == DialogResult.OK)
                    {
        
                try
                        {
                            
#region 验证
if (tbxsDayClearTempletPositionName.Text.Trim() == "")
         
                   {
                                
MessageBox.Show("工作模块不能为空!", "NLIS系统信息提示", MessageBoxButtons.OK, 
MessageBoxIcon.Information);
                                
tbxsDayClearTempletPositionName.Focus();
                                
return false;
                            }
                            if 
(txtEmployeePost.Text.Trim() == "")
                            {
         
                       MessageBox.Show("请输入职位!", "NLIS系统信息提示", 
MessageBoxButtons.OK, MessageBoxIcon.Information);
                           
     txtEmployeePost.Focus();
                                return 
false;
                            }
                            
#endregion
                            OEC_DayClearTemplet BI = new 
OEC_DayClearTemplet();
                            
BI.DayClearTempletWorkModule = tbxsDayClearTempletPositionName.Text;
         
                   BI.DayClearTempletID = 
Convert.ToInt32(lblDayClearTempletID.Text);
                            
BI.DayClearTempletPostID = Convert.ToInt32(lblEmployeePostID.Text);
          
                  BI.DayClearTempletStatus = 
Convert.ToInt16(cbxDayClearTempletStatus.SelectedValue);
                     
       BI.DayClearTempletRemark = tbxDayClearTempletRemark.Text.Trim();
      
                      BI.DayClearTempletUpdateTime = DateTime.Now;
           
                 BI.DayClearTempletUpdateUserID = _infoUser.UserID;
          
                  MessageInfo messageinfo = client.UpdateById(BI);
       
                     NLISServiceMessage.ShowMessage(messageinfo, 
MessageBoxType.Info);
                            if 
(messageinfo.Success)
                            {
                       
         MyBind(wfpPaging.PageIndex, wfpPaging.PageSize, strWhere);
          
                  }
                        }
                        
catch (Exception)
                        {
                            
throw;
                        }
                    }
                
}
                else
                {
                    
MessageBox.Show("您没有权限进行此操作!", "NLIS系统信息提示", MessageBoxButtons.OK, 
MessageBoxIcon.Information);
                }
            }
           
 else
            {
                MessageBox.Show("不是数据修改,请先点击一条数据后修改!", 
"NLIS系统信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            
}
            return true;
        }
        /// <summary>
    
    /// 删除
/// </summary>
        /// 
<returns></returns>
        public bool Delete()
        {
 
           try
            {
                bool IsAuthorization = 
false;
                //判断用户是否有单独权限
if (!_infoUser.UserIsAuthority)
   
             {
                    IsAuthorization = 
_bllEntityAuthorization.IsAuthorization(_infoUser.UserGroupID, 
client.GetNamespace(), ActionType.Remove.ToString("D"));
                
}
                else
                {
                    
IsAuthorization = _bllEntityAuthorization.IsAuthorizations(_infoUser.UserID, 
_infoUser.UserGroupID, client.GetNamespace(), 
ActionType.Remove.ToString("D"));
                }
                
//判断是否具有对该业务实体操作的权限
if (IsAuthorization)
                {
             
       if (lblDayClearTempletID.Text.Trim() != "")
                    {
  
                      if (MessageBox.Show("确认删除?", "NLIS系统信息提示", 
MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
     
                   {
                            MessageInfo messageinfo = 
client.DeleteById(Convert.ToInt64(lblDayClearTempletID.Text));
               
             NLISServiceMessage.ShowMessage(messageinfo, 
MessageBoxType.Info);
                            if 
(messageinfo.Success)
                            {
                       
         MyBind(this.wfpPaging.PageIndex, this.wfpPaging.PageSize, 
strWhere);
                            }
                        }
     
               }
                    else
                    {
        
                MessageBox.Show("您没有选中一行数据,不能删除!", "NLIS系统信息提示", 
MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
  
              }
                else
                {
                 
   MessageBox.Show("您没有权限进行此操作!", "NLIS系统信息提示", MessageBoxButtons.OK, 
MessageBoxIcon.Information);
                }
            }
           
 catch (Exception)
            {
                throw;
            
}
            return true;
        }
        /// <summary>
    
    /// 查询事件
/// </summary>
        public new bool Select()
     
   {
            try
            {
                bool IsAuthorization 
= false;
                //判断用户是否有单独权限
if (!_infoUser.UserIsAuthority)
 
               {
                    IsAuthorization = 
_bllEntityAuthorization.IsAuthorization(_infoUser.UserGroupID, 
client.GetNamespace(), ActionType.Search.ToString("D"));
                
}
                else
                {
                    
IsAuthorization = _bllEntityAuthorization.IsAuthorizations(_infoUser.UserID, 
_infoUser.UserGroupID, client.GetNamespace(), 
ActionType.Search.ToString("D"));
                }
                
//判断是否具有对该业务实体操作的权限
if (IsAuthorization)
                {
             
       strWhere = GetWhere();
                    MyBind(1, 
this.wfpPaging.PageSize, strWhere);
                    if (dgv.Rows.Count == 
0)
                    {
                        
MessageBox.Show("未查到与条件相符的数据!", "NLIS系统信息提示", MessageBoxButtons.OK, 
MessageBoxIcon.Information);
                    }
                }
                else
        
        {
                    MessageBox.Show("您没有权限进行此操作!", "NLIS系统信息提示", 
MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception)
            {
           
     throw;
            }
            return true;
        }
        /// <summary>
        /// 预览
/// </summary>
     
   /// <returns></returns>
        public bool Preview()
      
  {
            DataGridViewSelectedRowCollection rows = 
this.dgv.SelectedRows;
            if (rows != null && rows.Count == 
1)
            {
                try
                {
              
      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();
             
       }
                }
                catch (Exception)
           
     {
                    throw;
                }
            }
   
         return true;
        }
#endregion
        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);
            
postForm.Owner = this;
            postForm.ShowDialog();
            
lblEmployeePostID.Visible = false;
            //lblEmployeePostID.Text = 
"";
            //txtEmployeePost.Text = "";
        }
        private void dgv_CellClick(object sender, DataGridViewCellEventArgs 
e)
        {
            try
            {
                
this.TextBoxUnit();
            }
            catch (Exception)
        
    {
                throw;
            }
        }
        /// 
<summary>
        /// 双击查看详细
/// </summary>
        /// 
<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 == 
TabType.Update)
            {
                bool IsAuthorization = 
false;
                //判断用户是否有单独权限
if (!_infoUser.UserIsAuthority)
   
             {
                    IsAuthorization = 
_bllEntityAuthorization.IsAuthorization(_infoUser.UserGroupID, 
client.GetNamespace(), ActionType.Detail.ToString("D"));
                
}
                else
                {
                    
IsAuthorization = _bllEntityAuthorization.IsAuthorizations(_infoUser.UserID, 
_infoUser.UserGroupID, client.GetNamespace(), 
ActionType.Detail.ToString("D"));
                }
                
//判断是否具有对该业务实体操作的权限
if (IsAuthorization)
                {
             
       try
                    {
                        if 
(Convert.ToInt32(rows[0].Cells["DayClearTempletStatus"].Value) != 2 && 
Convert.ToInt32(rows[0].Cells["DayClearTempletStatus"].Value) != 0)
          
              {
                            Label lbl = new Label();
      
                      lbl.Text = 
rows[0].Cells["DayClearTempletWorkModule"].Value.ToString();
                 
           lbl.Tag = rows[0].Cells["DayClearTempletID"].Value;
               
             DayClearTempletInfoForm info = new 
DayClearTempletInfoForm(lbl);
                            info.Tag = 
this.Tag;
                            info.Owner = this;
                  
          info.ShowDialog();
                        }
                    
}
                    catch (Exception)
                    {
          
          }
                }
                else
                
{
                    MessageBox.Show("您没有权限进行此操作!", "NLIS系统信息提示", 
MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
      
      }
            else
            {
                
MessageBox.Show("不是数据修改,请先点击一条数据后修改!", "NLIS系统信息提示", MessageBoxButtons.OK, 
MessageBoxIcon.Information);
            }
        }
        private void wfpPaging_PageIndexChanged(object sender, EventArgs 
e)
        {
            try
            {
                
wfpPaging.PageIndex = wfpPaging.PageIndex;
                
MyBind(wfpPaging.PageIndex, wfpPaging.PageSize, strWhere);
            }
  
          catch (Exception)
            {
                throw;
            }
        }
    }
}
标签:des datagridview class tar ext c
原文地址:http://www.cnblogs.com/eric-gms/p/3718784.html