📄 ywitemlist.cs
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;
using Jinrm.Data;
using GzglClient.ColumnStyles;
using GzglClient.Froms;
using GzglClient.BLL;
//using Jinrm.Public;
namespace GzglClient.Views
{
/// <summary>
/// YWItemList 的摘要说明。
/// </summary>
public class YWItemList : System.Windows.Forms.UserControl , IView
{
private System.Windows.Forms.ContextMenu CMYWItemList;
private System.Windows.Forms.MenuItem miAdd;
private System.Windows.Forms.MenuItem miUpdate;
private System.Windows.Forms.MenuItem miDel;
internal System.Windows.Forms.DataGrid YWItemListGrid;
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.Splitter splitter1;
private System.Windows.Forms.Panel panel2;
private System.ComponentModel.Container components = null;
#region 自定义变量
/// <summary>
/// 业务类别
/// </summary>
public string YWType = "所有业务";
private string YWItemState = "全部";//业务状态
private DoAccess conn = new DoAccess();
private string OrgBaseId = "";
private System.Windows.Forms.Button btnAllList;
private System.Windows.Forms.Button btnNoUpdateList;
private System.Windows.Forms.Button btnPassList;
private System.Windows.Forms.Button btnNoPassList;
private System.Windows.Forms.Button btnAdd;
private System.Windows.Forms.Button btnUpdate;
private System.Windows.Forms.Button btnDel;
private string strSql = "";
#endregion
/// <summary>
///
/// </summary>
public YWItemList()
{
InitializeComponent();
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region 组件设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器
/// 修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.CMYWItemList = new System.Windows.Forms.ContextMenu();
this.miAdd = new System.Windows.Forms.MenuItem();
this.miUpdate = new System.Windows.Forms.MenuItem();
this.miDel = new System.Windows.Forms.MenuItem();
this.YWItemListGrid = new System.Windows.Forms.DataGrid();
this.panel1 = new System.Windows.Forms.Panel();
this.btnNoPassList = new System.Windows.Forms.Button();
this.btnPassList = new System.Windows.Forms.Button();
this.btnAllList = new System.Windows.Forms.Button();
this.btnNoUpdateList = new System.Windows.Forms.Button();
this.splitter1 = new System.Windows.Forms.Splitter();
this.panel2 = new System.Windows.Forms.Panel();
this.btnAdd = new System.Windows.Forms.Button();
this.btnUpdate = new System.Windows.Forms.Button();
this.btnDel = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.YWItemListGrid)).BeginInit();
this.panel1.SuspendLayout();
this.panel2.SuspendLayout();
this.SuspendLayout();
//
// CMYWItemList
//
this.CMYWItemList.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.miAdd,
this.miUpdate,
this.miDel});
//
// miAdd
//
this.miAdd.Index = 0;
this.miAdd.Text = "添加";
this.miAdd.Click += new System.EventHandler(this.miAdd_Click);
//
// miUpdate
//
this.miUpdate.Index = 1;
this.miUpdate.Text = "修改";
this.miUpdate.Click += new System.EventHandler(this.miUpdate_Click);
//
// miDel
//
this.miDel.Index = 2;
this.miDel.Text = "删除";
this.miDel.Click += new System.EventHandler(this.miDel_Click);
//
// YWItemListGrid
//
this.YWItemListGrid.AllowDrop = true;
this.YWItemListGrid.BackgroundColor = System.Drawing.SystemColors.Window;
this.YWItemListGrid.CaptionVisible = false;
this.YWItemListGrid.ContextMenu = this.CMYWItemList;
this.YWItemListGrid.DataMember = "";
this.YWItemListGrid.Dock = System.Windows.Forms.DockStyle.Fill;
this.YWItemListGrid.HeaderForeColor = System.Drawing.SystemColors.ControlText;
this.YWItemListGrid.Location = new System.Drawing.Point(0, 0);
this.YWItemListGrid.Name = "YWItemListGrid";
this.YWItemListGrid.ReadOnly = true;
this.YWItemListGrid.Size = new System.Drawing.Size(700, 445);
this.YWItemListGrid.TabIndex = 14;
this.YWItemListGrid.DoubleClick += new System.EventHandler(this.YWItemListGrid_DoubleClick);
//
// panel1
//
this.panel1.Controls.Add(this.btnDel);
this.panel1.Controls.Add(this.btnUpdate);
this.panel1.Controls.Add(this.btnAdd);
this.panel1.Controls.Add(this.btnNoPassList);
this.panel1.Controls.Add(this.btnPassList);
this.panel1.Controls.Add(this.btnAllList);
this.panel1.Controls.Add(this.btnNoUpdateList);
this.panel1.Dock = System.Windows.Forms.DockStyle.Top;
this.panel1.Location = new System.Drawing.Point(0, 0);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(700, 40);
this.panel1.TabIndex = 15;
//
// btnNoPassList
//
this.btnNoPassList.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnNoPassList.Location = new System.Drawing.Point(208, 8);
this.btnNoPassList.Name = "btnNoPassList";
this.btnNoPassList.Size = new System.Drawing.Size(80, 25);
this.btnNoPassList.TabIndex = 5;
this.btnNoPassList.Text = "未通过审核";
this.btnNoPassList.Click += new System.EventHandler(this.btnNoPassList_Click);
//
// btnPassList
//
this.btnPassList.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnPassList.Location = new System.Drawing.Point(120, 8);
this.btnPassList.Name = "btnPassList";
this.btnPassList.Size = new System.Drawing.Size(80, 25);
this.btnPassList.TabIndex = 4;
this.btnPassList.Text = "已通过审核";
this.btnPassList.Click += new System.EventHandler(this.btnPassList_Click);
//
// btnAllList
//
this.btnAllList.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnAllList.Location = new System.Drawing.Point(8, 8);
this.btnAllList.Name = "btnAllList";
this.btnAllList.Size = new System.Drawing.Size(40, 25);
this.btnAllList.TabIndex = 3;
this.btnAllList.Text = "全部";
this.btnAllList.Click += new System.EventHandler(this.btnAllList_Click);
//
// btnNoUpdateList
//
this.btnNoUpdateList.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnNoUpdateList.Location = new System.Drawing.Point(56, 8);
this.btnNoUpdateList.Name = "btnNoUpdateList";
this.btnNoUpdateList.Size = new System.Drawing.Size(56, 25);
this.btnNoUpdateList.TabIndex = 0;
this.btnNoUpdateList.Text = "未上报";
this.btnNoUpdateList.Click += new System.EventHandler(this.btnNoUpdateList_Click);
//
// splitter1
//
this.splitter1.Dock = System.Windows.Forms.DockStyle.Top;
this.splitter1.Enabled = false;
this.splitter1.Location = new System.Drawing.Point(0, 40);
this.splitter1.Name = "splitter1";
this.splitter1.Size = new System.Drawing.Size(700, 3);
this.splitter1.TabIndex = 16;
this.splitter1.TabStop = false;
//
// panel2
//
this.panel2.Controls.Add(this.YWItemListGrid);
this.panel2.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel2.Location = new System.Drawing.Point(0, 43);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(700, 445);
this.panel2.TabIndex = 17;
//
// btnAdd
//
this.btnAdd.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnAdd.Location = new System.Drawing.Point(392, 8);
this.btnAdd.Name = "btnAdd";
this.btnAdd.Size = new System.Drawing.Size(75, 25);
this.btnAdd.TabIndex = 6;
this.btnAdd.Text = "添加";
this.btnAdd.Click += new System.EventHandler(this.miAdd_Click);
//
// btnUpdate
//
this.btnUpdate.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnUpdate.Location = new System.Drawing.Point(480, 8);
this.btnUpdate.Name = "btnUpdate";
this.btnUpdate.Size = new System.Drawing.Size(75, 25);
this.btnUpdate.TabIndex = 7;
this.btnUpdate.Text = "修改";
this.btnUpdate.Click += new System.EventHandler(this.miUpdate_Click);
//
// btnDel
//
this.btnDel.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnDel.Location = new System.Drawing.Point(568, 8);
this.btnDel.Name = "btnDel";
this.btnDel.Size = new System.Drawing.Size(75, 25);
this.btnDel.TabIndex = 8;
this.btnDel.Text = "删除";
this.btnDel.Click += new System.EventHandler(this.miDel_Click);
//
// YWItemList
//
this.Controls.Add(this.panel2);
this.Controls.Add(this.splitter1);
this.Controls.Add(this.panel1);
this.Name = "YWItemList";
this.Size = new System.Drawing.Size(700, 488);
this.Load += new System.EventHandler(this.YWItemList_Load);
((System.ComponentModel.ISupportInitialize)(this.YWItemListGrid)).EndInit();
this.panel1.ResumeLayout(false);
this.panel2.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private void YWItemList_Load(object sender, System.EventArgs e)
{
OrgBaseId = Key.GetOrgBaseFromKey(Application.StartupPath + "//Config//OrgBase.ini");
YWItemListGrid.TableStyles.Add(YWItemListDgStyle.GetStyle());
BuildDataGrid();
}
/// <summary>
///
/// </summary>
/// <returns></returns>
public bool BuildDataGrid()
{
string strSql = "SELECT *,(SELECT Name FROM Person WHERE YWItem.WPersonID = Person.PersonID) AS UserName FROM YWItem INNER JOIN Person ON Person.PersonId = YWItem.WPersonId where YWItem.WOrgBaseId = '"+ OrgBaseId +"'";
if(YWType != "所有业务")
{
strSql += " and YWItemType = '"+ YWType +"'";
}
if(YWItemState != "全部")
{
strSql += " and YWItemState = '"+ YWItemState +"'";
}
strSql += " order by PostTime desc";
DataSet ds = conn.GetDs(strSql,"YWItem");
YWItemListGrid.DataSource = ds.Tables[0].DefaultView;
return true;
}
private void miAdd_Click(object sender, System.EventArgs e)
{
switch(YWType)
{
case "晋升职岗" :
frm_YW_ZG f_y_z = new frm_YW_ZG();
f_y_z.FuncType = "Add";
f_y_z.ShowDialog();
break;
case "工资套改" :
frm_YW_TG f_y_t = new frm_YW_TG();
f_y_t.FuncType = "Add";
f_y_t.ShowDialog();
break;
case "试用审核" :
frm_YW_SY f_y_s = new frm_YW_SY();
f_y_s.FuncType = "Add";
f_y_s.ShowDialog();
break;
case "转正定级" :
frm_YW_DJ f_y_d = new frm_YW_DJ();
f_y_d.FuncType = "Add";
f_y_d.ShowDialog();
break;
case "所有业务" :
MessageBox.Show("选择分类后在添加!");
break;
}
}
private void miUpdate_Click(object sender, System.EventArgs e)
{
}
private void miDel_Click(object sender, System.EventArgs e)
{
string tempIDCard = GetSelectedIDCard();
conn.ExecDelete("YWItem","YWItemID = '"+ tempIDCard +"' ");
BuildDataGrid();
}
private void YWItemListGrid_DoubleClick(object sender, System.EventArgs e)
{
string tempIDCard = GetSelectedIDCard();
if(tempIDCard != "-1" && tempIDCard != "")
{
string tempYWItemType = conn.GetValueFromName("YWItemType","YWItem","YWItemID = '"+ tempIDCard +"' ");
switch(tempYWItemType)
{
case "试用审核" :
frm_YW_SY f_y_s = new frm_YW_SY();
f_y_s.YWItemID = tempIDCard;
f_y_s.FuncType = "Update";
f_y_s.ShowDialog();
break;
// case "转正定级" :
// frm_YW_DJ f_y_d = new frm_YW_DJ();
// f_y_d.FuncType = "Add";
// f_y_d.ShowDialog();
// break;
}
BuildDataGrid();
}
}
/// <summary>
/// 获取当前Grid的选定项的IDCard
/// </summary>
/// <returns></returns>
private string GetSelectedIDCard()
{
if (YWItemListGrid.DataSource == null || !YWItemListGrid.TableStyles.Contains(YWItemListDgStyle.TableName))
return "-1";
try
{
int taskIDColumnIndex = 0;
foreach (DataGridColumnStyle dgColumnStyle in YWItemListGrid.TableStyles[YWItemListDgStyle.TableName].GridColumnStyles)
{
if (dgColumnStyle.HeaderText == "业务完整编号")
break;
else
taskIDColumnIndex++;
}
int currentRow = YWItemListGrid.CurrentRowIndex;
return (string) YWItemListGrid[currentRow, taskIDColumnIndex];
}
catch (Exception)
{
return "-1";
}
}
private void btnAllList_Click(object sender, System.EventArgs e)
{
YWItemState = "全部";
BuildDataGrid();
}
private void btnNoUpdateList_Click(object sender, System.EventArgs e)
{
YWItemState = "未上报";
BuildDataGrid();
}
private void btnPassList_Click(object sender, System.EventArgs e)
{
YWItemState = "已通过审核";
BuildDataGrid();
}
private void btnNoPassList_Click(object sender, System.EventArgs e)
{
YWItemState = "未通过审核";
BuildDataGrid();
}
#region IView 成员
public void Release()
{
Dispose();
}
public ViewType TheType
{
get {return ViewType.YWItemList;}
}
#endregion
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -