Ejemplo n.º 1
0
        protected override void ShowFormDetail(ActionMode actionMode)
        {
            base.ShowFormDetail(actionMode);
            string UserID = null;

            if (actionMode != ActionMode.AddNew)
            {
                UserID = ((Desktop.Entity.DictionaryDataSet.EmployeeRow)((System.Data.DataRowView)bsList.Current).Row).UserID.ToString();
            }

            var tableUser = oBLUser.Get();
            var tableRole = oBLRole.Get();

            DictionaryDataSet.UserDataTable         dt     = new DictionaryDataSet.UserDataTable();
            DictionaryDataSet.UserJoinRoleDataTable dtRole = new DictionaryDataSet.UserJoinRoleDataTable();
            if (tableUser.Select("UserID = '" + UserID + "'").Count() > 0)
            {
                dt.ImportRow(tableUser.Select("UserID = '" + UserID + "'")[0]);
                dsDictionary.User.Clear();
                dsDictionary.Merge(dt);
            }
            DataRow[] dr = tableRole.Select("UserID = '" + UserID + "'");
            if (dr.Count() > 0)
            {
                for (int i = 0; i < dr.Count(); i++)
                {
                    dtRole.ImportRow(dr[i]);
                }
                dsDictionary.Role.Clear();
                dsDictionary.Merge(dtRole);
            }
            using (var fDetail = new FrmEmployeeDetail())
            {
                fDetail.DsDictionary   = dsDictionary;
                fDetail.BsDetail       = bsList;
                fDetail.objBLDetail    = oBL;
                fDetail.FormActionMode = actionMode;
                if (fDetail.ShowDialog() != DialogResult.OK)
                {
                    dsDictionary.Employee.RejectChanges();
                }
                else
                {
                    dsDictionary.Customer.AcceptChanges();
                    LoadDataForm();
                }
            }
            ActiveAndSelectRow();
        }