Exemplo n.º 1
0
 private void TsmDelGroup_Click(object sender, EventArgs e)
 {
     TreeNode node = treeView_Organization.SelectedNode;
     if (node != null && node.Tag is exGroup)
     {
         if (node.Nodes.Count > 0)
         {
             IMLibrary3.Global.MsgShow("请先删除此分组内所有用户和子分组!");
             return;
         }
         exGroup group = node.Tag as exGroup;
         if (MessageBox.Show("确定要删除分组 " + group.GroupName + "(" + group.GroupID  + ")吗?", "提示",
             MessageBoxButtons.YesNoCancel, MessageBoxIcon.Information) == DialogResult.Yes)
         {
             GroupVcard  card = new  GroupVcard();
             card.GroupID = group.GroupID;
             card.GroupName = group.GroupName;
             card.type = type.delete;
             SendMessageToServer(card);//通知服务器删除用户
         }
     }
 }
Exemplo n.º 2
0
        private void onGroupVcard(GroupVcard card)
        {
            if (frmGroupVcard != null && !frmGroupVcard.IsDisposed && card.type == type.New)
                frmGroupVcard.isUpdateSuccess = true;

            exGroup  group = findGroup(card.GroupID);//查找本地用户是否存在操作用户

            if (card.type == type.New && group == null)
            {
                group = new exGroup();
                group.GroupID = card.GroupID;
                group.SuperiorID = card.SuperiorID;
                Groups.Add(group);
                //将用户节点添加到树
                {
                    TreeNode node = new TreeNode();
                    node.Text = group.GroupName;
                    node.ImageIndex = 14;
                    node.SelectedImageIndex = 15;
                    node.Tag = group;
                    group.TreeNode = node;
                    ///添加根分组节点
                    if (findGroup(group.SuperiorID) == null)
                        treeView_Organization.Nodes.Add(node);
                    else
                        (findGroup(group.SuperiorID).TreeNode as TreeNode).Nodes.Add(node);
                }
                group.GroupName = card.GroupName;

                OpeRecordDB.UpdateGroupVcard(card);//添加分组信息
            }
            else if (card.type == type.delete && group != null)
            {
                TreeNode node = group.TreeNode as TreeNode;
                if (node != null)
                    treeView_Organization.Nodes.Remove(node);
                OpeRecordDB.DeleteGroup(card.GroupID);//本地数据库中删除
            }
            else if (group != null)
            {
                FormGroupVcard frm = getGroupVcardForm(card.GroupID);
                if (frm != null && !frm.IsDisposed)
                    if (card.type != type.set)
                        frm.GroupVcard = card;
                    else
                        frm.isUpdateSuccess = true;
                group.GroupName = card.GroupName;

                OpeRecordDB.UpdateGroupVcard(card);//更新分组信息
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// 更新用户
 /// </summary>
 /// <param name="userVcard"></param>
 public void UpdateGroup(GroupVcard card)
 {
     card.type = type.set;
     SendMessageToServer(card);
 }
Exemplo n.º 4
0
        private void TsmShowGroupVcard_Click(object sender, EventArgs e)
        {
            TreeNode node = treeView_Organization.SelectedNode;
            if (node != null)
            {
                exGroup group = node.Tag as exGroup;
                FormGroupVcard  frm = getGroupVcardForm(group.GroupID);
                if (frm == null)
                {
                    frm = new FormGroupVcard();
                    frmGroupVcards.Add(group.GroupID, frm);
                    if (MyAuth.isAdmin)//如果是管理员,则添加更新事件
                        frm.UpdateVcard += delegate(object sender1, GroupVcard card)
                    {
                        UpdateGroup(card);//更新分组资料
                    };
                    else
                        frm.RefreshVcard += delegate(object sender1, GroupVcard card)
                        {
                            //向服务器请求获得分组最新资料
                            //card.type = type.get;
                            //SendMessageToServer(card);
                        };
                    frm.FormClosed += delegate(object sender1, FormClosedEventArgs e1)
                    {
                        frm.Dispose();
                        frmGroupVcards.Remove(group.GroupID);
                    };
                    GroupVcard vcard = new GroupVcard();
                    vcard.GroupID = group.GroupID;
                    vcard.GroupName = group.GroupName;
                    vcard.SuperiorID = group.SuperiorID;
                    vcard.OrderID = group.OrderID;
                    frm.GroupVcard = vcard;
                }
                if (MyAuth.isAdmin)//如果是管理员
                    frm.Text = "修改 " + group.GroupName + "(" + group.GroupID + ")的资料";
                else
                    frm.Text = "查看 " + group.GroupName + "(" + group.GroupID + ")的资料";

                frm.isAdmin = MyAuth.isAdmin;
                frm.IsCreate = false;
                frm.Show();
            }

        }
Exemplo n.º 5
0
 /// <summary>
 /// 创建新用户
 /// </summary>
 /// <param name="userVcard"></param>
 public void CreateGroup(GroupVcard  card)
 {
     card.type = type.New;
     SendMessageToServer(card);
 }
Exemplo n.º 6
0
 /// <summary>
 /// 更新分组Card,无数据则添加
 /// </summary>
 /// <param name="GroupID"></param>
 /// <param name="e"></param>
 public static void UpdateGroupVcard(GroupVcard  card)
 { 
     string sql = "update GroupsVcard set Vcard=@Vcard where GroupID=@GroupID";
     System.Data.SQLite.SQLiteParameter[] parameters = new System.Data.SQLite.SQLiteParameter[]{   
              new System.Data.SQLite.SQLiteParameter("@GroupID",card.GroupID ),   
              new System.Data.SQLite.SQLiteParameter("@Vcard",Factory.CreateXMLMsg(card)),
              new System.Data.SQLite.SQLiteParameter("@GroupName",card.GroupName ),   
              new System.Data.SQLite.SQLiteParameter("@SuperiorID",card.SuperiorID ),   
              new System.Data.SQLite.SQLiteParameter("@OrderID",card.OrderID ),   
   };
     if (SQLiteDBHelper.ExecuteNonQuery(sql, parameters) == 0)
     {
         sql = "insert into Groups(GroupID,GroupName,SuperiorID,OrderID) values(@GroupID,@GroupName,@SuperiorID,@OrderID);"
         + "insert into GroupsVcard(GroupID,Vcard) values(@GroupID,@Vcard)";
         SQLiteDBHelper.ExecuteNonQuery(sql, parameters);
     }
 }
Exemplo n.º 7
0
        /// <summary>
        /// 管理员变更分组信息
        /// </summary>
        /// <param name="card"></param>
        /// <param name="xmlMsg"></param>
        /// <param name="session"></param>
        private void onGroupVcard(GroupVcard card, string xmlMsg, TCPServerSession session)
        {
            if (card.GroupID.Trim() == "" || card.GroupName.Trim() == "") return;
            card.GroupID = card.GroupID.Trim();

            UserVcard requestUser = session.Tag as UserVcard;//请求用户

            if (card.type == type.New && requestUser.isAdmin)//如果用户是管理员
            {
                if (DBHelper.CreateGroupVcard(card) > 0)//保存于数据库
                {
                    orgVersion = DBHelper.ResetOrgVersion(); //重设组织架构版本相关信息
                    BroadcastingMessageToOnlineUser(xmlMsg);//将创建的分组信息广播给所有在线用户  
                }
            }
            else if (card.type == type.set && requestUser.isAdmin)//如果是更新分组信息
            {
                if (DBHelper.UpdateGroupVcard(card) > 0) //更新数据库
                {
                    orgVersion = DBHelper.ResetOrgVersion(); //重设组织架构版本相关信息
                    SendMessageToUser(requestUser, xmlMsg);//通知管理员创建新用户成功 
                }
            }
            else if (card.type == type.get)//如果是更新 
            {
                card.type = type.result;
                SendMessageToUser(requestUser, Factory.CreateXMLMsg(card));//将分组信息资料发送给请求者
            }
            else if (card.type == type.delete && requestUser.isAdmin)//如果是删除分组
            {
                if (DBHelper.DelGroup(card.GroupID) > 0) //数据库中删除
                {
                    orgVersion = DBHelper.ResetOrgVersion(); //重设组织架构版本相关信息
                    BroadcastingMessageToOnlineUser(xmlMsg);//将删除的用户广播给所有在线用户 
                }
            }
        }
Exemplo n.º 8
0
 /// <summary>
 /// 更新分组信息
 /// </summary>
 /// <param name="group"></param>
 public static int UpdateGroupVcard(GroupVcard group)
 {
     string sql = "update Groups set GroupName=@GroupName,SuperiorId=@SuperiorId,orderID=@orderID where GroupID=@GroupID";
     System.Data.SqlClient.SqlParameter[] sqlpar = new System.Data.SqlClient.SqlParameter[]
                   { new System.Data.SqlClient.SqlParameter("@GroupID",group.GroupID ),
                     new System.Data.SqlClient.SqlParameter("@GroupName",group.GroupName ),
                     new System.Data.SqlClient.SqlParameter("@SuperiorId",group.SuperiorID  ),
                     new System.Data.SqlClient.SqlParameter("@orderID",group.OrderID ),
                   };
     return IMLibrary.SqlData.DataAccess.ExecSql(sql, sqlpar);
 }
Exemplo n.º 9
0
 /// <summary>
 /// 创建分组
 /// </summary>
 /// <param name="group"></param>
 public static int  CreateGroupVcard(GroupVcard group)
 {
     string sql = "insert into Groups(GroupID,GroupName,SuperiorId,orderID)"
                  + "values(@GroupID,@GroupName,@SuperiorId,@orderID)";
     System.Data.SqlClient.SqlParameter[] sqlpar = new System.Data.SqlClient.SqlParameter[]
                   { new System.Data.SqlClient.SqlParameter("@GroupID",group.GroupID ),
                     new System.Data.SqlClient.SqlParameter("@GroupName",group.GroupName ),
                     new System.Data.SqlClient.SqlParameter("@SuperiorId",group.SuperiorID  ),
                     new System.Data.SqlClient.SqlParameter("@orderID",group.OrderID ),
                   };
    return  IMLibrary.SqlData.DataAccess.ExecSql(sql, sqlpar);
 }