Пример #1
0
 public int countNotInAInB(CCollection ip_coll)
 {
     int v_count = 0;
     for (int i = 0; i < index; i++)
     {
         for (int j = 0; j < ip_coll.index; j++)
         {
             if (s[i] == ip_coll.s[j])
             {
                 v_count++;
                 break;
             }
         }
     }
     return ip_coll.index - v_count;
 }
Пример #2
0
 public CCollection InANotInB(CCollection ip_coll)
 {
     CCollection v_result = new CCollection(countInANotInB(ip_coll));
     for (int i = 0; i < index; i++)
     {
         int j;
         for (j = 0; j < ip_coll.index; j++)
         {
             if (s[i] == ip_coll.s[j])
             {
                 break;
             }
         }
         if (j == ip_coll.index)
         {
             v_result.insert(s[i]);
         }
     }
     return v_result;
 }
        private void m_cmd_save_Click(object sender, EventArgs e)
        {
            try
            {
                US_HT_PHAN_QUYEN_CHO_NHOM v_us_ht_phan_quyen_cho_nhom;
                DS_HT_PHAN_QUYEN_CHO_NHOM v_ds_ht_phan_quyen_cho_nhom = new DS_HT_PHAN_QUYEN_CHO_NHOM();

                CCollection v_coll_new = new CCollection(m_lbox_quyen_da_cap.Items.Count);
                for (int i = 0; i < m_lbox_quyen_da_cap.Items.Count; i++)
                {
                    v_coll_new.insert(m_lbox_quyen_da_cap.Items[i].ToString());
                }

                US_HT_PHAN_QUYEN_HE_THONG v_us_pqht = new US_HT_PHAN_QUYEN_HE_THONG();
                DS_HT_PHAN_QUYEN_HE_THONG v_ds_pqht = new DS_HT_PHAN_QUYEN_HE_THONG();
                v_us_pqht.FillDatasetQuyenDaCapByIdUserGroup(v_ds_pqht, m_dc_id_user_group);
                CCollection v_coll_old = new CCollection(v_ds_pqht.Tables[0].Rows.Count);
                for (int i = 0; i < v_ds_pqht.Tables[0].Rows.Count; i++)
                {
                    DataRow v_dr = v_ds_pqht.Tables[0].Rows[i];
                    v_coll_old.insert(v_dr[HT_PHAN_QUYEN_HE_THONG.MA_PHAN_QUYEN].ToString());
                }

                CCollection v_coll_quyen_insert = new CCollection(v_coll_new.countInANotInB(v_coll_old));
                v_coll_quyen_insert = v_coll_new.InANotInB(v_coll_old);
                for (int i = 0; i < v_coll_quyen_insert.getIndex(); i++)
                {
                    v_us_ht_phan_quyen_cho_nhom = new US_HT_PHAN_QUYEN_CHO_NHOM();
                    //v_us_ht_phan_quyen_cho_nhom.dcID_USER_GROUP = 1;
                    v_us_ht_phan_quyen_cho_nhom.dcID_USER_GROUP = m_dc_id_user_group;
                    v_ds_pqht.Clear();
                    v_us_pqht.FillDatasetByMaPhanQuyen(v_ds_pqht, v_coll_quyen_insert.s[i]);
                    v_us_ht_phan_quyen_cho_nhom.dcID_PHAN_QUYEN_HE_THONG = CIPConvert.ToDecimal(v_ds_pqht.Tables[0].Rows[0][HT_PHAN_QUYEN_HE_THONG.ID]);
                    v_us_ht_phan_quyen_cho_nhom.Insert();
                }

                CCollection v_coll_quyen_delete = new CCollection(v_coll_new.countNotInAInB(v_coll_old));
                v_coll_quyen_delete = v_coll_new.NotInAInB(v_coll_old);
                for (int i = 0; i < v_coll_quyen_delete.getIndex(); i++)
                {
                    v_ds_ht_phan_quyen_cho_nhom.Clear();
                    v_us_ht_phan_quyen_cho_nhom = new US_HT_PHAN_QUYEN_CHO_NHOM();
                    v_us_ht_phan_quyen_cho_nhom.FillDatasetByIdUserGroupAndMaPhanQuyen(v_ds_ht_phan_quyen_cho_nhom, m_dc_id_user_group, v_coll_quyen_delete.s[i]);
                    v_us_ht_phan_quyen_cho_nhom.dcID = CIPConvert.ToDecimal(v_ds_ht_phan_quyen_cho_nhom.Tables[0].Rows[0][HT_PHAN_QUYEN_CHO_NHOM.ID]);
                    v_us_ht_phan_quyen_cho_nhom.Delete();
                }
                BaseMessages.MsgBox_Infor("Dữ liệu đã được cập nhật");
                //this.Close();
            }
            catch (Exception v_e)
            {
                CSystemLog_301.ExceptionHandle(v_e);
            }
        }