Пример #1
0
        private VR_Role RowtoBuliding(DataRow dr)
        {
            VR_Role sc = new VR_Role();

            sc.Id   = Convert.ToInt32(dr["id"]);
            sc.Name = Convert.ToString(dr["name"]);
            return(sc);
        }
Пример #2
0
        /// <summary>
        /// 店家添加按钮 添加一个场景
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button2_Click(object sender, EventArgs e)
        {
            // 名称不能为null
            if (BoxName.Text.Length < 1)
            {
                MessageBox.Show("名称不能为空!", "提示!");
                return;
            }
            // 添加场景到数据库
            script scp = new script();

            scp.Scencname = BoxName.Text;
            scp.Isonline  = Boxonline.Checked ? 1 : 0;

            // 修改操作
            if (this.Tg == 1)
            {
                if (this.ScRoles.Count < 1)
                {
                    MessageBox.Show("请选择角色!", "提示!");
                    return;
                }
                scp.Id = this.Scenc.Id;
                scDAL.editSenceWith(scp, this.ScRoles);
                // 回调
                this.Call(scp);
            }
            else   //添加操作
                   // 获取所有选中的checkbox
            {
                List <script> scencScripts = new List <script>();
                foreach (CheckBox box in this.panel1.Controls)
                {
                    VR_Role ro = (VR_Role)box.Tag;
                    if (box.Checked)
                    {
                        script sc = new script();
                        sc.Screncscriptid   = ro.Id;
                        sc.Screncscriptname = box.Text;
                        scencScripts.Add(sc);
                    }
                }
                if (scencScripts.Count < 1)
                {
                    MessageBox.Show("请选择角色!", "提示!");
                    return;
                }
                int senceid;
                if (scDAL.addScript(scp, scencScripts, out senceid))
                {
                    scp.Id = senceid;
                    this.Call(scp);
                }
                ;
            }
            // 关闭窗口
            this.Close();
        }
Пример #3
0
        /// <summary>
        /// 点击chenboX时发生
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void valueCheckedChanged(object sender, EventArgs e)
        {
            if (this.Loadtag != 1)
            {
                return;
            }

            CheckBox box = (CheckBox)sender;
            VR_Role  ro  = (VR_Role)box.Tag;

            script sc = new script();

            // 修改的时候才回传过来场景id
            if (this.Tg == 1)
            {
                sc.Id = this.Scenc.Id;
            }
            sc.Screncscriptid = ro.Id;
            // 删除(移除则要,先查看数据库里面当前角色是否有在使用)
            if (!box.Checked)
            {
                if (this.Tg == 1)
                {
                    if (!scDAL.checkRoleOnScencIsNotWith(this.Scenc.Id, ro.Id))
                    {
                        foreach (script sp in this.ScRoles)
                        {
                            if (sp.Screncscriptid == sc.Screncscriptid)
                            {
                                this.ScRoles.Remove(sp);
                                break;
                            }
                        }
                    }
                    else
                    { //说明 这个角色在当前任务里面有使用 不能删除
                        MessageBox.Show("当前角色使用中,不能删除!", "提示!");
                        this.Loadtag = 0;
                        box.Checked  = true;
                        this.Loadtag = 1;
                    }
                }
                else
                {
                    foreach (script sp in this.ScRoles)
                    {
                        if (sp.Screncscriptid == sc.Screncscriptid)
                        {
                            this.ScRoles.Remove(sp);
                            break;
                        }
                    }
                }
            }
            else
            {
                if (this.ScRoles.Count < AllowRolesNum)
                {
                    //添加一个
                    this.ScRoles.Add(sc);
                }
                else
                {
                    MessageBox.Show("角色数量建议不要超过10个!", "提示!");
                    box.Checked = false;
                    return;
                }
            }
        }