using System;
|
using System.Collections.Generic;
|
using System.ComponentModel;
|
using System.Data;
|
using System.Drawing;
|
using System.Text;
|
using System.Windows.Forms;
|
|
namespace SCM
|
{
|
public partial class Xt_User : Form
|
{
|
public Xt_User()
|
{
|
InitializeComponent();
|
}
|
|
public string sDisplay; //ÅжÏÑ¡ÖеÄÊÇÄĸöÍø¸ñ
|
public SCM.WMSWeb.WebService1 oWeb = new SCM.WMSWeb.WebService1();
|
//´°Ìå¼ÓÔØ
|
private void Xt_User_Load(object sender, EventArgs e)
|
{
|
oWeb.Url = ClsPub1.WEBSURL;
|
sDisplay = "Óû§";
|
initGrid();
|
Display1();
|
Display2();
|
}
|
|
//Íø¸ñ³õʼ»¯
|
private void initGrid()
|
{
|
//Íø¸ñ--Óû§
|
grdMain.SelectionMode = DataGridViewSelectionMode.FullRowSelect; //Ñ¡ÖÐģʽ--ÐÐÑ¡ÖÐ
|
grdMain.ColumnHeadersVisible = true; //±êÌâÁÐÏÔʾ--ÊÇ
|
grdMain.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing; //±êÌâÁгߴçģʽ--£¨×Ô¶¯µ÷Õû£¬¿Éµ÷Õû£©
|
grdMain.RowTemplate.Height = 18;
|
grdMain.RowTemplate.MinimumHeight = 18;
|
grdMain.ColumnHeadersHeight = 35; //±êÌâÐиß
|
grdMain.RowHeadersVisible = false; //±êÌâÐпɼû--·ñ
|
grdMain.AllowUserToAddRows = false; //ÊÇ·ñÔÊÐí×ÔÔö--·ñ
|
grdMain.AllowUserToDeleteRows = false; //ÊÇ·ñÔÊÐíɾ³ý--·ñ
|
grdMain.ColumnCount = 0; //×ÜÁÐÊý--5
|
grdMain.RowCount = 0;
|
grdMain.AllowUserToResizeColumns = true; //ÔÊÐíµ÷ÕûÁпí--ÊÇ
|
grdMain.AllowUserToResizeRows = false; //ÔÊÐíµ÷ÕûÐиß--·ñ
|
grdMain.ReadOnly = true; //Ö»¶Á--ÊÇ
|
grdMain.MultiSelect = false; //Ö»ÄÜÑ¡ÖÐÒ»ÐÐ
|
grdMain.BackgroundColor = Color.White;
|
grdMain.GridColor = Color.LightGray;
|
grdMain.DefaultCellStyle.SelectionBackColor = Color.Black;
|
grdMain.EnableHeadersVisualStyles = false; //Íø¸ñ±êÌâ Ñùʽ
|
//
|
//Íø¸ñ--Óû§×é
|
grdSub.SelectionMode = DataGridViewSelectionMode.FullRowSelect; //Ñ¡ÖÐģʽ--ÐÐÑ¡ÖÐ
|
grdSub.ColumnHeadersVisible = true; //±êÌâÁÐÏÔʾ--ÊÇ
|
grdSub.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing; //±êÌâÁгߴçģʽ--£¨×Ô¶¯µ÷Õû£¬¿Éµ÷Õû£©
|
grdSub.RowTemplate.Height = 18;
|
grdSub.RowTemplate.MinimumHeight = 18;
|
grdSub.ColumnHeadersHeight = 35; //±êÌâÐиß
|
grdSub.RowHeadersVisible = false; //±êÌâÐпɼû--·ñ
|
grdSub.AllowUserToAddRows = false; //ÊÇ·ñÔÊÐí×ÔÔö--·ñ
|
grdSub.AllowUserToDeleteRows = false; //ÊÇ·ñÔÊÐíɾ³ý--·ñ
|
grdSub.ColumnCount = 0; //×ÜÁÐÊý--5
|
grdSub.RowCount = 0;
|
grdSub.AllowUserToResizeColumns = true; //ÔÊÐíµ÷ÕûÁпí--ÊÇ
|
grdSub.AllowUserToResizeRows = false; //ÔÊÐíµ÷ÕûÐиß--·ñ
|
grdSub.ReadOnly = true; //Ö»¶Á--ÊÇ
|
grdSub.MultiSelect = false; //Ö»ÄÜÑ¡ÖÐÒ»ÐÐ
|
grdSub.BackgroundColor = Color.White;
|
grdSub.GridColor = Color.LightGray;
|
grdSub.DefaultCellStyle.SelectionBackColor = Color.Black;
|
grdSub.EnableHeadersVisualStyles = false; //Íø¸ñ±êÌâ Ñùʽ
|
}
|
|
//²éÕÒÊý¾Ý----Óû§
|
private void Display1()
|
{
|
try
|
{
|
//SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
|
DataSet oDs = new DataSet();
|
oDs = oWeb.getDataSetBySQL("select * from h_v_Gy_Czygl order by Óû§", "h_v_Gy_Czygl", ref DBUtility.ClsPub.sExeReturnInfo);
|
if (oDs == null)
|
{
|
MessageBox.Show("ÏÔʾʧ°Ü£¡ÔÒò£º" + DBUtility.ClsPub.sExeReturnInfo);
|
return;
|
}
|
//
|
grdMain.DataSource = oDs.Tables[0].DefaultView;
|
//¼ÓÔØÁпí
|
for (int i = 0; i < grdMain.ColumnCount; i++)
|
{
|
grdMain.Columns[i].Width = 100;
|
if (grdMain.Columns[i].HeaderText.Substring(0, 1).ToLower() == "h")
|
{
|
grdMain.Columns[i].Visible = false;
|
}
|
else
|
{
|
grdMain.Columns[i].Visible = true;
|
}
|
}
|
//DBUtility.ClsPub.GetGridView(this.grdMain, this.Name + "1", DBUtility.ClsPub.AppPath);
|
}
|
catch (Exception e)
|
{
|
MessageBox.Show(e.Message, "Ìáʾ");
|
return;
|
}
|
}
|
|
//²éÕÒÊý¾Ý--Óû§×é
|
private void Display2()
|
{
|
try
|
{
|
//SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
|
DataSet oDs = new DataSet();
|
oDs = oWeb.getDataSetBySQL("select * from h_v_System_UserGroup order by ½ÇÉ«", "h_v_System_UserGroup", ref DBUtility.ClsPub.sExeReturnInfo);
|
if (oDs == null)
|
{
|
MessageBox.Show("ÏÔʾʧ°Ü£¡ÔÒò£º" + DBUtility.ClsPub.sExeReturnInfo);
|
return;
|
}
|
//
|
grdSub.DataSource = oDs.Tables[0].DefaultView;
|
//¼ÓÔØÁпí
|
for (int i = 0; i < grdSub.ColumnCount; i++)
|
{
|
grdSub.Columns[i].Width = 100;
|
if (grdSub.Columns[i].HeaderText.Substring(0, 1).ToLower() == "h")
|
{
|
grdSub.Columns[i].Visible = false;
|
}
|
else
|
{
|
grdSub.Columns[i].Visible = true;
|
}
|
}
|
//DBUtility.ClsPub.GetGridView(this.grdSub, this.Name + "2", DBUtility.ClsPub.AppPath);
|
}
|
catch (Exception e)
|
{
|
MessageBox.Show(e.Message, "Ìáʾ");
|
return;
|
}
|
}
|
//Ë¢ÐÂ
|
private void shuax_Click(object sender, EventArgs e)
|
{
|
Display1();
|
Display2();
|
}
|
//Í˳ö
|
private void tc_Click(object sender, EventArgs e)
|
{
|
this.Close();
|
}
|
//ÐÂÔöÓû§
|
private void xz_Click(object sender, EventArgs e)
|
{
|
Xt_UserNew oNew = new Xt_UserNew();
|
oNew.InputMode = Pub_Class.ClsPub.Enum_InputMode.InputMode_AddNew;
|
oNew.ShowDialog();
|
}
|
//ÐÂÔöÓû§×é
|
private void xzz_Click(object sender, EventArgs e)
|
{
|
Xt_UserGroup oGroup = new Xt_UserGroup();
|
oGroup.InputMode = Pub_Class.ClsPub.Enum_InputMode.InputMode_AddNew;
|
oGroup.ShowDialog();
|
}
|
//ÐÞ¸ÄÓû§
|
private void grdMain_DoubleClick(object sender, EventArgs e)
|
{
|
if (grdMain.CurrentRow != null)
|
{
|
Xt_UserNew oNew = new Xt_UserNew();
|
oNew.InputMode = Pub_Class.ClsPub.Enum_InputMode.InputMode_Modify;
|
oNew.Czybm = grdMain.Rows[grdMain.CurrentRow.Index].Cells[Fun_GetCol("HCzybm")].Value.ToString();
|
oNew.ShowDialog();
|
}
|
}
|
//ÐÞ¸ÄÓû§×é
|
private void grdSub_DoubleClick(object sender, EventArgs e)
|
{
|
if (grdSub.CurrentRow != null)
|
{
|
Xt_UserGroup oGroup = new Xt_UserGroup();
|
oGroup.InputMode = Pub_Class.ClsPub.Enum_InputMode.InputMode_Modify;
|
oGroup.HGroupID = DBUtility.ClsPub.isLong(grdSub.Rows[grdSub.CurrentRow.Index].Cells[Fun_GetCol("HGroupID")].Value.ToString());
|
|
oGroup.ShowDialog();
|
}
|
}
|
//µÃµ½¶ÔÓ¦ÁÐ
|
private Int32 Fun_GetCol(string sCol)//Lock
|
{
|
for (int c = 0; c < grdMain.ColumnCount; c++)
|
{
|
if (DBUtility.ClsPub.isStrNull(grdMain.Columns[c].HeaderText).ToUpper().Trim() == sCol.Trim().ToUpper())
|
{
|
return c;
|
}
|
}
|
return 0;
|
}
|
|
//µÃµ½¶ÔÓ¦ÁÐ
|
private Int32 Fun_GetCol_Sub(string sCol)//Lock
|
{
|
for (int c = 0; c < grdSub.ColumnCount; c++)
|
{
|
if (DBUtility.ClsPub.isStrNull(grdSub.Columns[c].HeaderText).ToUpper().Trim() == sCol.Trim().ToUpper())
|
{
|
return c;
|
}
|
}
|
return 0;
|
}
|
|
private void bclk_Click(object sender, EventArgs e)
|
{
|
//±£´æÁпí
|
//DBUtility.ClsPub.SaveGridView(grdMain, this.Name + "1", DBUtility.ClsPub.AppPath);
|
////±£´æÁпí
|
//DBUtility.ClsPub.SaveGridView(grdSub, this.Name + "2", DBUtility.ClsPub.AppPath);
|
}
|
|
private void mrlk_Click(object sender, EventArgs e)
|
{
|
DBUtility.ClsPub.DefaultGridView(grdMain);
|
//²ÎÊý½âÊÍ ¿ªÊ¼ÁÐ £¬½áÊøÁУ¬ÊÇ·ñÒÔ×î´óÁпíΪ׼£¬×îСÁпí
|
DBUtility.ClsPub.SaveGridView(grdMain, this.Name + "1", DBUtility.ClsPub.AppPath);
|
//
|
DBUtility.ClsPub.DefaultGridView(grdSub);
|
//²ÎÊý½âÊÍ ¿ªÊ¼ÁÐ £¬½áÊøÁУ¬ÊÇ·ñÒÔ×î´óÁпíΪ׼£¬×îСÁпí
|
DBUtility.ClsPub.SaveGridView(grdSub, this.Name + "2", DBUtility.ClsPub.AppPath);
|
}
|
|
private void qx_Click(object sender, EventArgs e)
|
{
|
Xt_Authorization oAuth = new Xt_Authorization();
|
oAuth.sDisplay = this.sDisplay;
|
if (sDisplay == "Óû§")
|
{
|
oAuth.czybm = grdMain.Rows[grdMain.CurrentCell.RowIndex].Cells[Fun_GetCol("HCzybm")].Value.ToString();
|
oAuth.lblUser.Text = grdMain.Rows[grdMain.CurrentCell.RowIndex].Cells[Fun_GetCol("Óû§")].Value.ToString() + "--ȨÏÞÉèÖÃ";
|
}
|
else
|
{
|
oAuth.HGroupID = DBUtility.ClsPub.isLong(grdSub.Rows[grdSub.CurrentCell.RowIndex].Cells[Fun_GetCol_Sub("HGroupID")].Value);
|
oAuth.lblUser.Text = grdSub.Rows[grdSub.CurrentCell.RowIndex].Cells[Fun_GetCol_Sub("½ÇÉ«")].Value.ToString() + "--ȨÏÞÉèÖÃ";
|
}
|
//дÈëÈÕÖ¾
|
//DBUtility.ClsPub.Add_Log(DBUtility.ClsPub.CurUserName, "ɾ³ýÓû§:" + oAuth.lblUser.Text, DBUtility.ClsPub.CurUserName);
|
oAuth.ShowDialog();
|
}
|
|
private void grdMain_CellClick(object sender, DataGridViewCellEventArgs e)
|
{
|
sDisplay = "Óû§";
|
}
|
|
private void grdSub_CellClick(object sender, DataGridViewCellEventArgs e)
|
{
|
sDisplay = "½ÇÉ«";
|
}
|
|
private void sc_Click(object sender, EventArgs e)
|
{
|
if (MessageBox.Show("È·¶¨ÒªÉ¾³ýµ±Ç°Óû§£¿" + grdMain.Rows[grdMain.CurrentRow.Index].Cells[Fun_GetCol("Óû§")].Value.ToString(), "Ìáʾ", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
|
{
|
return;
|
}
|
if (MessageBox.Show("ÔÙ´ÎÈ·¶¨ÒªÉ¾³ýµ±Ç°Óû§£¿" + grdMain.Rows[grdMain.CurrentRow.Index].Cells[Fun_GetCol("Óû§")].Value.ToString(), "Ìáʾ", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
|
{
|
return;
|
}
|
DeleteBill();
|
Display1();
|
Display2();
|
}
|
|
private void DeleteBill()
|
{
|
//SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
|
if (sDisplay == "Óû§")
|
{
|
try
|
{
|
//oCn.BeginTran();
|
oWeb.getRunProc("delete from Gy_Czygl where Czybm='" + grdMain.Rows[grdMain.CurrentCell.RowIndex].Cells[Fun_GetCol("HCzybm")].Value.ToString() + "'", ref DBUtility.ClsPub.sExeReturnInfo);
|
oWeb.getRunProc("delete from System_UserGroupInfo where UserId='" + grdMain.Rows[grdMain.CurrentCell.RowIndex].Cells[Fun_GetCol("HCzybm")].Value.ToString() + "'", ref DBUtility.ClsPub.sExeReturnInfo);
|
//DBUtility.ClsPub.Add_Log(DBUtility.ClsPub.CurUserName, "ɾ³ýÓû§:" + grdMain.Rows[grdMain.CurrentCell.RowIndex].Cells[Fun_GetCol("HCzybm")].Value.ToString(), DBUtility.ClsPub.CurUserName);
|
//oCn.Commit();
|
}
|
catch (Exception e)
|
{
|
MessageBox.Show(e.Message, "Ìáʾ");
|
//oCn.RollBack();
|
return;
|
}
|
}
|
else
|
{
|
try
|
{
|
//oCn.BeginTran();
|
oWeb.getRunProc("delete from System_UserGroup where GroupId=" + grdSub.Rows[grdSub.CurrentCell.RowIndex].Cells[Fun_GetCol("HGroupID")].Value.ToString(), ref DBUtility.ClsPub.sExeReturnInfo);
|
oWeb.getRunProc("delete from System_UserGroupInfo where GroupId=" + grdSub.Rows[grdSub.CurrentCell.RowIndex].Cells[Fun_GetCol("HGroupID")].Value.ToString(), ref DBUtility.ClsPub.sExeReturnInfo);
|
//oCn.Commit();
|
}
|
catch (Exception e)
|
{
|
MessageBox.Show(e.Message, "Ìáʾ");
|
//oCn.RollBack();
|
return;
|
}
|
}
|
MessageBox.Show(sDisplay + "ɾ³ý³É¹¦£¡", "Ìáʾ");
|
}
|
private void sx_Click(object sender, EventArgs e)
|
{
|
|
}
|
|
private void grdMain_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
|
{
|
|
}
|
|
public int i = 0; //ÐеÄÏÂ±ê¿ØÖÆÆ÷ (*****¿ØÖÆ´ÓµÚ¼¸ÐпªÊ¼±éÀú*****)
|
public bool notNull = false; //µÝ¹é¿ØÖÆÆ÷ (*****¿ØÖÆÊÇ·ñ¿Éµ÷Óõݹé******)
|
private void cmdHUser_Click(object sender, EventArgs e)
|
{
|
string sFind = txtHUser.Text.Trim();
|
string sUser = "";
|
foreach (DataGridViewRow dr in grdMain.SelectedRows) //È¡ÏûÐеÄÑ¡ÖÐ
|
{
|
dr.Selected = false;
|
}
|
for (int a = i; a <= grdMain.RowCount - 1; a++)
|
{
|
sUser = DBUtility.ClsPub.isStrNull(this.grdMain.Rows[a].Cells[Fun_GetCol("Óû§")].Value);
|
if (sUser.IndexOf(sFind) != -1)
|
{
|
grdMain.Rows[a].Selected = true; //Èç¹ûÆ¥ÅäÔòÑ¡ÖиÃÐÐ
|
grdMain.FirstDisplayedScrollingRowIndex = a; //¹ö¶¯Ìõ»¬×Ô¸ÃÐÐ
|
i = a + 1; //ʹÏ´αéÀú´Ó¸ÃÐеÄÏÂÒ»ÐпªÊ¼²éÕÒ
|
notNull = true;
|
return; //ÉèÖÃnotNullÎªÕæ,Ìø³ö
|
}
|
}
|
if (notNull) //ʼÖÕδÕÒµ½Æ¥ÅäÏîÔò½øÈë
|
{
|
i = 0; //ÖØÖôӵÚÒ»ÐбéÀú
|
notNull = false; //ÉèÖÃnotNullΪ¼Ù,Èç¹ûÔÙÒ»´Î´ÓµÚÒ»ÐбéÀúδÕÒµ½Æ¥ÅäÏîÔò²»»áÔÙ½øÈëIFµ÷Óõݹé
|
cmdHUser_Click(sender, e); //µÝ¹é
|
}
|
else
|
{
|
MessageBox.Show("δÕÒµ½£¡£¡");
|
}
|
}
|
|
private void sjqx_Click(object sender, EventArgs e)
|
{
|
//Xt_UserDataRight oRight = new Xt_UserDataRight();
|
//if (sDisplay == "Óû§")
|
//{
|
// oRight.sUserName = grdMain.Rows[grdMain.CurrentCell.RowIndex].Cells[Fun_GetCol("Óû§")].Value.ToString() + "";
|
//}
|
//else
|
//{
|
// //oAuth.HGroupID = DBUtility.ClsPub.isLong(grdSub.Rows[grdSub.CurrentCell.RowIndex].Cells[Fun_GetCol_Sub("HGroupID")].Value);
|
// //oAuth.lblUser.Text = grdSub.Rows[grdSub.CurrentCell.RowIndex].Cells[Fun_GetCol_Sub("½ÇÉ«")].Value.ToString() + "--ȨÏÞÉèÖÃ";
|
//}
|
////дÈëÈÕÖ¾
|
////DBUtility.ClsPub.Add_Log(DBUtility.ClsPub.CurUserName, "ɾ³ýÓû§:" + oAuth.lblUser.Text, DBUtility.ClsPub.CurUserName);
|
//oRight.ShowDialog();
|
}
|
|
|
|
}
|
}
|