using System;
|
using System.Collections.Generic;
|
using System.ComponentModel;
|
using System.Data;
|
using System.Drawing;
|
using System.Text;
|
using System.Windows.Forms;
|
|
namespace BLL
|
{
|
public partial class Xt_UserGroup : Form
|
{
|
public Xt_UserGroup()
|
{
|
InitializeComponent();
|
}
|
|
|
public Pub_Class.ClsPub.Enum_InputMode InputMode; //¼Èë״̬±êÖ¾(0-·Ç¼Èë״̬ 1-Ôö¼Ó 2-ÐÞ¸Ä)
|
public long HGroupID;
|
//´°Ìå¼ÓÔØ
|
private void Xt_UserGroup_Load(object sender, EventArgs e)
|
{
|
lblError.Text = "";
|
LbYes.Items.Clear();
|
LbNo.Items.Clear();
|
Init();
|
Display();
|
}
|
//²éÕÒÊý¾Ý----Óû§
|
private void Display()
|
{
|
if (InputMode == Pub_Class.ClsPub.Enum_InputMode.InputMode_AddNew)
|
{
|
try
|
{
|
SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
|
DataSet oDs = new DataSet();
|
oDs = oCn.RunProcReturn("select Czybm,Czymc from Gy_Czygl order by Czymc", "Gy_Czygl", ref DBUtility.ClsPub.sExeReturnInfo);
|
if (oDs == null)
|
{
|
MessageBox.Show("ÏÔʾʧ°Ü£¡ÔÒò£º" + DBUtility.ClsPub.sExeReturnInfo);
|
return;
|
}
|
//
|
for (int i = 0; i <= oDs.Tables[0].Rows.Count - 1; i++)
|
{
|
LbNo.Items.Add(oDs.Tables[0].Rows[i][0].ToString().Trim() + "-" + oDs.Tables[0].Rows[i][1].ToString().Trim());
|
}
|
}
|
catch (Exception e)
|
{
|
MessageBox.Show(e.Message, "Ìáʾ");
|
return;
|
}
|
}
|
else
|
{
|
try
|
{
|
SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
|
DataSet oDs = new DataSet();
|
DataSet oDS = new DataSet();
|
//¼ÓÔØ²»Êô×é
|
oDs = oCn.RunProcReturn("select Czybm,Czymc from Gy_Czygl"
|
+ " where Czybm not IN (select userid from system_UserGroupInfo where Groupid=" + HGroupID.ToString() + ")", "Gy_Czygl", ref DBUtility.ClsPub.sExeReturnInfo);
|
if (oDs == null)
|
{
|
MessageBox.Show("ÏÔʾʧ°Ü£¡ÔÒò£º" + DBUtility.ClsPub.sExeReturnInfo);
|
return;
|
}
|
//
|
if (oDs.Tables[0].Rows.Count != 0)
|
{
|
for (int i = 0; i <= oDs.Tables[0].Rows.Count - 1; i++)
|
{
|
|
LbNo.Items.Add(oDs.Tables[0].Rows[i][0].ToString().Trim() + "-" + oDs.Tables[0].Rows[i][1].ToString().Trim());
|
}
|
}
|
//¼ÓÔØÊôÓÚ×é
|
oDS = oCn.RunProcReturn("select Czybm,Czymc from Gy_Czygl"
|
+ " where Czybm IN (select userid from system_UserGroupInfo where Groupid='" + HGroupID.ToString() + "')", "Gy_Czygl", ref DBUtility.ClsPub.sExeReturnInfo);
|
if (oDS == null)
|
{
|
MessageBox.Show("ÏÔʾʧ°Ü£¡ÔÒò£º" + DBUtility.ClsPub.sExeReturnInfo);
|
return;
|
}
|
//
|
if (oDS.Tables[0].Rows.Count != 0)
|
{
|
for (int i = 0; i <= oDS.Tables[0].Rows.Count - 1; i++)
|
{
|
|
LbYes.Items.Add(oDS.Tables[0].Rows[i][0].ToString().Trim() + "-" + oDS.Tables[0].Rows[i][1].ToString().Trim());
|
}
|
}
|
}
|
catch (Exception e)
|
{
|
MessageBox.Show(e.Message, "Ìáʾ");
|
return;
|
}
|
}
|
}
|
//³õʼ»¯½çÃæ
|
private void Init()
|
{
|
if (InputMode == Pub_Class.ClsPub.Enum_InputMode.InputMode_AddNew)
|
{
|
}
|
else
|
{
|
ShowData(HGroupID);
|
}
|
}
|
//¼ÓÔØ±íÍ·
|
private void ShowData(long HGroupID)
|
{
|
DataSet oDs = new DataSet();
|
SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
|
try
|
{
|
oDs = oCn.RunProcReturn("select * from System_UserGroup where GroupID=" + HGroupID.ToString(), "System_UserGroup", ref DBUtility.ClsPub.sExeReturnInfo);
|
if (oDs == null)
|
{
|
MessageBox.Show("ÏÔʾʧ°Ü£¡ÔÒò£º" + DBUtility.ClsPub.sExeReturnInfo);
|
return;
|
}
|
else if (oDs.Tables[0].Rows.Count != 0)
|
{
|
txtGroup.Text = oDs.Tables[0].Rows[0]["GroupName"].ToString().Trim();
|
txtExplain.Text = oDs.Tables[0].Rows[0]["Explain"].ToString().Trim();
|
cmbHLev.Text = oDs.Tables[0].Rows[0]["HLev"].ToString().Trim();
|
//txtHCheckMoney.Text = oDs.Tables[0].Rows[0]["HCheckMoney"].ToString().Trim();
|
//txtHCheckPrice.Text = oDs.Tables[0].Rows[0]["HCheckPrice"].ToString().Trim();
|
}
|
}
|
catch (Exception e)
|
{
|
MessageBox.Show(e.Message, "Ìáʾ");
|
return;
|
}
|
}
|
//×óÒÆ
|
private void cmdLeft_Click(object sender, EventArgs e)
|
{
|
if (this.LbNo.SelectedItems.Count > 0)
|
{
|
int i = this.LbNo.SelectedIndex;
|
this.LbYes.Items.Add(this.LbNo.SelectedItem.ToString());
|
this.LbNo.Items.RemoveAt(i);
|
}
|
}
|
//È«²¿×óÒÆ
|
private void cmdAllLeft_Click(object sender, EventArgs e)
|
{
|
if (this.LbNo.Items.Count > 0)
|
{
|
for (int i = 0; i <= this.LbNo.Items.Count - 1; i++)
|
{
|
this.LbYes.Items.Add(this.LbNo.Items[i].ToString());
|
this.LbNo.Items.RemoveAt(i);
|
i--;
|
}
|
}
|
}
|
//ÓÒÒÆ
|
private void cmdRight_Click(object sender, EventArgs e)
|
{
|
if (this.LbYes.SelectedItems.Count > 0)
|
{
|
int i = this.LbYes.SelectedIndex;
|
this.LbNo.Items.Add(this.LbYes.SelectedItem.ToString());
|
this.LbYes.Items.RemoveAt(i);
|
}
|
}
|
//È«²¿ÓÒÒÆ
|
private void cmdAllRight_Click(object sender, EventArgs e)
|
{
|
if (this.LbYes.Items.Count > 0)
|
{
|
for (int i = 0; i <= this.LbYes.Items.Count - 1; i++)
|
{
|
this.LbNo.Items.Add(this.LbYes.Items[i].ToString());
|
this.LbYes.Items.RemoveAt(i);
|
i--;
|
}
|
}
|
}
|
//È¡Ïû
|
private void cmdCancel_Click(object sender, EventArgs e)
|
{
|
this.Close();
|
}
|
//È·¶¨
|
private void cmdOK_Click(object sender, EventArgs e)
|
{
|
lblError.Text = "";
|
DataSet oDs = new DataSet();
|
SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
|
if (!Sub_AllowSave()) //µ¥¾ÝÍêÕûÐÔÅжÏ
|
return;
|
if (InputMode == Pub_Class.ClsPub.Enum_InputMode.InputMode_AddNew)
|
{
|
oCn.RunProc("insert into System_UserGroup (GroupName,HLev,Explain) "+
|
"values ('" + txtGroup.Text.ToString() + "','" + cmbHLev.Text.ToString() + "','" + txtExplain.Text.ToString() + "')");
|
oDs = oCn.RunProcReturn("Select * from System_UserGroup where GroupName='" + txtGroup.Text.ToString()+"'","System_UserGroup");
|
if (oDs == null || oDs.Tables[0].Rows.Count == 0)
|
{
|
MessageBox.Show("ÐÂÔöʧ°Ü£¡", "Ìáʾ");
|
}
|
this.HGroupID = DBUtility.ClsPub.isLong(oDs.Tables[0].Rows[0]["GroupID"]);
|
oCn.RunProc("delete from System_UserGroupInfo where GroupId=" + HGroupID.ToString());
|
for (int i = 0; i <= LbYes.Items.Count - 1; i++)
|
{
|
oCn.RunProc("insert into System_UserGroupInfo (GroupId,UserId) values (" + HGroupID.ToString() + ",'" + Get_Code(this.LbYes.Items[i].ToString())+"')");
|
}
|
lblError.Text = "* ÐÂÔö³É¹¦£¡";
|
|
}
|
else
|
{
|
oCn.RunProc("update System_UserGroup set GroupName='" + txtGroup.Text.ToString() + "',HLev='" + cmbHLev.Text.ToString() + "',Explain='" + txtExplain.Text.ToString() + "'"
|
+ " where GroupId="+ HGroupID.ToString());
|
//
|
oCn.RunProc("delete from System_UserGroupInfo where GroupId=" + HGroupID.ToString());
|
for (int i = 0; i <= LbYes.Items.Count - 1; i++)
|
{
|
oCn.RunProc("insert into System_UserGroupInfo (GroupId,UserId) values (" + HGroupID.ToString() + ",'" + Get_Code(this.LbYes.Items[i].ToString()) + "')");
|
}
|
lblError.Text = "* Ð޸ijɹ¦£¡";
|
}
|
}
|
//µ¥¾ÝÍêÕûÐÔÅжÏ
|
private bool Sub_AllowSave()
|
{
|
if (txtGroup.Text.Trim() == "")
|
{
|
lblError.Text = "* ×éÃû²»ÄÜΪ¿Õ£¡";
|
return false;
|
}
|
//if (cmbHLev.Text.Trim() == "")
|
//{
|
// lblError.Text = "* ¸Úλ¼¶±ð²»ÄÜΪ¿Õ£¡";
|
// return false;
|
//}
|
//if (txtHCheckMoney.Text.Trim() == "")
|
//{
|
// lblError.Text = "* ½ð¶î¿ØÖƲ»ÄÜΪ¿Õ£¡";
|
// return false;
|
//}
|
//if (txtHCheckPrice.Text.Trim() == "")
|
//{
|
// lblError.Text = "* µ¥¼Û¿ØÖƲ»ÄÜΪ¿Õ£¡";
|
// return false;
|
//}
|
//×éÃû ÊÇ·ñÖØ¸´
|
if (InputMode == Pub_Class.ClsPub.Enum_InputMode.InputMode_AddNew)
|
{
|
DataSet oDs = new DataSet();
|
SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
|
oDs = oCn.RunProcReturn("select * from System_UserGroup where GroupName='" + txtGroup.Text.ToString() + "'", "System_UserGroup");
|
if (oDs.Tables[0].Rows.Count != 0)
|
{
|
lblError.Text = "* ×éÃûÖØ¸´£¡";
|
return false;
|
}
|
}
|
return true;
|
}
|
//²ð·Ö
|
private string Get_Code(string sCode)
|
{
|
sCode = sCode.Trim();
|
char c = Convert.ToChar("-");
|
string[] s = sCode.Split(c);
|
if (s.Length > 1)
|
{
|
return s[0].Trim();
|
}
|
else
|
{
|
return "0";
|
}
|
}
|
}
|
}
|