public Sys_RoleMaster_rlm_Info DisplayRecord(Model.IModel.IModelObject KeyObject)
        {
            Sys_RoleMaster_rlm_Info rlm = new Sys_RoleMaster_rlm_Info();
            Sys_RoleMaster_rlm_Info info = new Sys_RoleMaster_rlm_Info();
            rlm = KeyObject as Sys_RoleMaster_rlm_Info;
            try
            {

                using (SIOTSDB_HHZXDataContext db = new SIOTSDB_HHZXDataContext())
                {
                    IQueryable<Sys_RoleMaster_rlm> taQuery =
                        (from ta in db.Sys_RoleMaster_rlm
                         where ta.rlm_iRecordID == rlm.rlm_iRecordID
                         //orderby dpms.dpm_iRecordID ascending
                         select ta).Take(1);

                    if (taQuery != null)
                    {
                        //foreach (var t in taQuery)
                        foreach (Sys_RoleMaster_rlm t in taQuery)
                        {
                            info = Common.General.CopyObjectValue<Sys_RoleMaster_rlm, Sys_RoleMaster_rlm_Info>(t);
                            FindUserRole(info);
                        }
                    }
                    return info;
                }
            }
            catch (Exception Ex)
            {
                throw Ex;
            }
        }
        private void btnFind_Click(object sender, EventArgs e)
        {
            try
            {
                Sys_RoleMaster_rlm_Info info = new Sys_RoleMaster_rlm_Info();

                info.rlm_cRoleID = txtcNum.Text;

                DataBind(_sysRoleMasterBL.SearchRecords(info));
            }
            catch (Exception Ex)
            { ShowErrorMessage(Ex); }
        }
 private void DataBind(List<Model.IModel.IModelObject> list)
 {
     Sys_RoleMaster_rlm_Info info = new Sys_RoleMaster_rlm_Info();
     lvwMstr.Items.Clear();
     List<Sys_RoleMaster_rlm_Info> infoList = new List<Sys_RoleMaster_rlm_Info>();
     try
     {
         foreach (var t in list)
         {
             info = t as Sys_RoleMaster_rlm_Info;
             infoList.Add(info);
         }
         lvwMstr.SetDataSource<Sys_RoleMaster_rlm_Info>(infoList);
     }
     catch (Exception Ex)
     { ShowErrorMessage(Ex); }
     lbliCount.Text = list.Count().ToString();
 }
        public bool InsertRecord(Sys_RoleMaster_rlm_Info infoObject)
        {
            if (infoObject == null)
            {
                return false;
            }

            using (SIOTSDB_HHZXDataContext db = new SIOTSDB_HHZXDataContext())
            {
                Sys_RoleMaster_rlm rlm = new Sys_RoleMaster_rlm();
                try
                {
                    rlm = Common.General.CopyObjectValue<Sys_RoleMaster_rlm_Info, Sys_RoleMaster_rlm>(infoObject);

                    if (infoObject.userMasterList != null && infoObject.userMasterList.Count > 0)
                    {
                        for (int i = 0; i < infoObject.userMasterList.Count; i++)
                        {

                            Sys_UserMaster_usm_Info usmInfo = infoObject.userMasterList[i];

                            Sys_UserRoles_usr item = new Sys_UserRoles_usr();

                            item.usr_cUserLoginID = usmInfo.usm_cUserLoginID;
                            item.usr_cRoleID = infoObject.rlm_cRoleID;
                            //courseitem.cum_cNumber;
                            rlm.Sys_UserRoles_usr.Add(item);
                            //db.Sys_UserRoles_usrs.InsertOnSubmit(item);
                        }
                    }

                    db.Sys_RoleMaster_rlm.InsertOnSubmit(rlm);
                    db.SubmitChanges();
                    return true;
                }
                catch (Exception Ex)
                {
                    throw Ex;
                }
            }
        }
Exemple #5
0
        void SaveUSM()
        {
            Model.General.ReturnValueInfo msg = new Model.General.ReturnValueInfo();
            Sys_UserMaster_usm_Info info = new Sys_UserMaster_usm_Info();
            Sys_RoleMaster_rlm_Info userInfo = null;
            if (ChecktxtcName())
            {
                if (txtUserID.Text == string.Empty)
                {
                    msg.messageText = "登錄帳號" + Common.DefineConstantValue.SystemMessageText.strMessageText_W_CannotEmpty;
                    ShowWarningMessage(msg.messageText);
                    txtUserID.Focus();
                }
                else if (txtcName.Text == string.Empty)
                {
                    msg.messageText = "中文名" + Common.DefineConstantValue.SystemMessageText.strMessageText_W_CannotEmpty;
                    ShowWarningMessage(msg.messageText);
                    txtcName.Focus();
                }
                else
                {
                    try
                    {
                        if (this.EditState == DefineConstantValue.EditStateEnum.OE_Update)
                        {
                            info.usm_iRecordID = Convert.ToInt32(iRecordID);
                        }
                        info.usm_cUserLoginID = txtUserID.Text;
                        info.usm_cChaName = txtcName.Text;
                        if (txtcPwd.Text != string.Empty)
                        {
                            info.usm_cPasswork = Common.General.MD5(txtcPwd.Text);
                        }
                        else
                        {
                            if (this.EditState == DefineConstantValue.EditStateEnum.OE_Insert)
                                info.usm_cPasswork = Common.General.MD5(pwd);
                            else
                                info.usm_cPasswork = pwd;
                        }

                        info.usm_cEMail = txtcMail.Text;

                        info.usm_cRemark = txtcRemark.Text;

                        if (chkLock.Checked == true)
                        {
                            info.usm_iLock = true;
                        }
                        else
                        {
                            info.usm_iLock = false;
                        }
                        for (int i = 0; i < lvwMaster.Items.Count; i++)
                        {
                            userInfo = new Sys_RoleMaster_rlm_Info();
                            userInfo.rlm_cRoleID = lvwMaster.Items[i].SubItems[0].Text;
                            info.roleMasterList.Add(userInfo);
                        }
                        if (this.EditState == DefineConstantValue.EditStateEnum.OE_Insert)
                        {
                            info.usm_cAdd = UserInformation.usm_cUserLoginID;
                            info.usm_dAddDate = DateTime.Now;
                        }
                        info.usm_cLast = UserInformation.usm_cUserLoginID;
                        info.usm_dLastDate = DateTime.Now;
                        if (this.EditState == DefineConstantValue.EditStateEnum.OE_Update)
                        {
                            msg = _sysUserMasterBL.Save(info, DefineConstantValue.EditStateEnum.OE_Update);
                            isSaveTrue = msg.boolValue;
                        }
                        else
                        {
                            msg = _sysUserMasterBL.Save(info, DefineConstantValue.EditStateEnum.OE_Insert);
                            isSaveTrue = msg.boolValue;
                        }

                        if (msg.messageText != null)
                            ShowInformationMessage(msg.messageText);
                        else
                        {
                            SetOpenToolBar();
                        }
                    }
                    catch (Exception Ex)
                    { ShowErrorMessage(Ex); }
                }
            }
        }
Exemple #6
0
        void Change()
        {
            Sys_FunctionMaster_fum_Info fumInfo = new Sys_FunctionMaster_fum_Info();
            usmTemp = new Sys_UserMaster_usm_Info();
            rlmTemp = new Sys_RoleMaster_rlm_Info();

            try
            {
                if (_lvwUserType == UserType.User.ToString())
                {
                    usmTemp.usm_cUserLoginID = _num;
                    usmTemp.functionMasterList.Clear();
                    for (int i = 0; i < lvwPur.Items.Count; i++)
                    {
                        if (lvwPur.Items[i].Checked == true)
                        {
                            fumInfo = new Sys_FunctionMaster_fum_Info();
                            fumInfo.fum_cFunctionNumber = lvwPur.Items[i].SubItems[0].Text;
                            usmTemp.functionMasterList.Add(fumInfo);
                        }
                    }
                    for (int i = 0; i < uspInfoTemp.userMasterList.Count; i++)
                    {
                        if (uspInfoTemp.userMasterList[i].usm_cUserLoginID == _num)
                        {
                            uspInfoTemp.userMasterList[i] = usmTemp;
                        }
                    }
                }
                else
                {
                    rlmTemp.rlm_cRoleID = _num;
                    rlmTemp.functionMasterList.Clear();
                    for (int i = 0; i < lvwPur.Items.Count; i++)
                    {
                        if (lvwPur.Items[i].Checked == true)
                        {
                            fumInfo = new Sys_FunctionMaster_fum_Info();
                            fumInfo.fum_cFunctionNumber = lvwPur.Items[i].SubItems[0].Text;
                            rlmTemp.functionMasterList.Add(fumInfo);
                        }
                    }
                    for (int i = 0; i < uspInfoTemp.roleMasterList.Count; i++)
                    {
                        if (uspInfoTemp.roleMasterList[i].rlm_cRoleID == _num)
                        {
                            uspInfoTemp.roleMasterList[i] = rlmTemp;
                        }
                    }
                }
            }
            catch (Exception Ex)
            {
                ShowErrorMessage(Ex);
            }
        }
 /// <summary>
 /// 删除角色
 /// </summary>
 void DeleteRole()
 {
     if (lvRole.SelectedItems.Count > 0)
     {
         this._EditStatus = DefineConstantValue.EditStateEnum.OE_Delete;
         string strRoleID = lvRole.SelectedItems[0].SubItems[1].Text;
         if (this.ShowQuestionMessage("確定要刪除角色【" + strRoleID + "】嗎?"))
         {
             Sys_RoleMaster_rlm_Info role = new Sys_RoleMaster_rlm_Info();
             role.rlm_iRecordID = Convert.ToInt32(lvRole.SelectedItems[0].SubItems[0].Text);
             ReturnValueInfo rvInfo = this._ISysRoleMasterBL.Save(role, DefineConstantValue.EditStateEnum.OE_Delete);
             if (rvInfo.boolValue && !rvInfo.isError)
             {
                 this.ShowInformationMessage("刪除成功。");
                 this._EditStatus = DefineConstantValue.EditStateEnum.OE_ReaOnly;
             }
             else
             {
                 this.ShowInformationMessage("刪除失敗。異常信息:" + rvInfo.messageText);
                 this._EditStatus = DefineConstantValue.EditStateEnum.OE_ReaOnly;
             }
         }
     }
 }
        private void btnSaveRole_Click(object sender, EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;
            try
            {
                Sys_RoleMaster_rlm_Info role = new Sys_RoleMaster_rlm_Info();

                if (this._EditStatus == DefineConstantValue.EditStateEnum.OE_Insert)//插入新增角色
                {
                    role.rlm_cRoleID = tbxRoleNum.Text.Trim();
                    role.rlm_cRoleDesc = tbxRoleDesc.Text.Trim();
                    role.rlm_cAdd = base.UserInformation != null ? base.UserInformation.usm_cUserLoginID : "sys";
                    role.rlm_dAddDate = DateTime.Now;
                    role.rlm_cLast = base.UserInformation != null ? base.UserInformation.usm_cUserLoginID : "sys";
                    role.rlm_dLastDate = DateTime.Now;
                    role.userMasterList = GetRoleUserList(lvRoleUserList);

                    ReturnValueInfo res = this._ISysRoleMasterBL.Save(role, DefineConstantValue.EditStateEnum.OE_Insert);
                    if (res.boolValue && !res.isError)
                    {
                        this.ShowInformationMessage("新增記錄成功。");

                        BindRoleInfos();

                        RoleSaveSuccOpt();

                        this._EditStatus = DefineConstantValue.EditStateEnum.OE_ReaOnly;
                    }
                    else
                    {
                        this.ShowWarningMessage("新增記錄失敗。異常信息:" + res.messageText);
                    }
                }
                else if (this._EditStatus == DefineConstantValue.EditStateEnum.OE_Update)//更新原有角色信息記錄
                {
                    role = this._ISysRoleMasterBL.SearchRecords(new Sys_RoleMaster_rlm_Info() { rlm_iRecordID = this._CurrentRoleID }).FirstOrDefault() as Sys_RoleMaster_rlm_Info;
                    if (role == null)
                    {
                        role = this._ListRoleMasterInfo.Find(x => x.rlm_iRecordID == this._CurrentRoleID);
                    }
                    //role.rlm_cRoleID = tbxRoleNum.Text.Trim();
                    role.rlm_cRoleDesc = tbxRoleDesc.Text.Trim();
                    role.rlm_cLast = base.UserInformation != null ? base.UserInformation.usm_cUserLoginID : "sys";
                    role.rlm_dLastDate = DateTime.Now;
                    role.userMasterList = GetRoleUserList(lvRoleUserList);

                    ReturnValueInfo res = this._ISysRoleMasterBL.Save(role, DefineConstantValue.EditStateEnum.OE_Update);
                    if (res.boolValue && !res.isError)
                    {
                        this.ShowInformationMessage("更新記錄成功。");

                        BindRoleInfos();

                        RoleSaveSuccOpt();

                        this._EditStatus = DefineConstantValue.EditStateEnum.OE_ReaOnly;
                    }
                    else
                    {
                        this.ShowWarningMessage("更新記錄失敗。異常信息:" + res.messageText);
                    }
                }
            }
            catch (Exception ex)
            {
                this.ShowErrorMessage(ex);
            }

            this.Cursor = Cursors.Default;
        }
Exemple #9
0
        //------
        private void ToolBar_BtnCancelClick(object sender, EventArgs e)
        {
            this.EditState = DefineConstantValue.EditStateEnum.OE_ReaOnly;
            Model.Base.DataBaseCommandKeyInfo comkey = new Model.Base.DataBaseCommandKeyInfo();
            Sys_RoleMaster_rlm_Info Info = new Sys_RoleMaster_rlm_Info();
            try
            {
                comkey.KeyValue = iRecordID;
                if (comkey.KeyValue != string.Empty && comkey.KeyValue != "0")
                {
                    Info.rlm_iRecordID = Convert.ToInt32(comkey.KeyValue);
                    Model.IModel.IModelObject result = _sysRoleMasterBL.DisplayRecord(Info);
                    Info = result as Sys_RoleMaster_rlm_Info;
                    ShowInfo(Info);
                    SetOpenToolBar();
                    SetTxtBox(DefineConstantValue.EditStateEnum.OE_ReaOnly);
                }

                else
                {
                    Handel(DefineConstantValue.GetReocrdEnum.GR_Last);
                }
            }
            catch (Exception Ex)
            {
                ShowErrorMessage(Ex);
            }
        }
        void Find()
        {
            Sys_RoleMaster_rlm_Info smcitem = null;
            _RtvInfo = new List<Sys_RoleMaster_rlm_Info>();
            try
            {
                if (lvwMstr.SelectedItems.Count > 0)
                {
                    for (int i = 0; i < lvwMstr.SelectedItems.Count; i++)
                    {
                        smcitem = new Sys_RoleMaster_rlm_Info();
                        smcitem.rlm_iRecordID = Convert.ToInt32(lvwMstr.SelectedItems[i].SubItems[(int)enmLvwMaster.rlm_iRecordID].Text);
                        smcitem.rlm_cRoleID = lvwMstr.SelectedItems[i].SubItems[(int)enmLvwMaster.rlm_cRoleID].Text;
                        smcitem.rlm_cRoleDesc = lvwMstr.SelectedItems[i].SubItems[(int)enmLvwMaster.rlm_cRoleDesc].Text;
                        _RtvInfo.Add(smcitem);
                    }
                }

            }
            catch (Exception Ex)
            { ShowErrorMessage(Ex); }
            this.DialogResult = DialogResult.OK;
        }
Exemple #11
0
        public bool UpdateRecord(Sys_RoleMaster_rlm_Info infoObject)
        {
            string sqlString = string.Empty;
            using (MainDBDataContext db = new MainDBDataContext())
            {
                Sys_RoleMaster_rlm rlm = new Sys_RoleMaster_rlm();
                Sys_RoleMaster_rlm_Info info = new Sys_RoleMaster_rlm_Info();
                try
                {

                    rlm = db.Sys_RoleMaster_rlm.SingleOrDefault(t => t.rlm_iRecordID == infoObject.rlm_iRecordID);
                    List<Sys_UserRoles_usr> usrs = db.Sys_UserRoles_usr.Where(d => d.usr_cRoleID == infoObject.rlm_cRoleID).ToList();
                    for (int i = 0; i < usrs.Count; i++)
                    {
                        Sys_UserRoles_usr sta = usrs[i];
                        db.Sys_UserRoles_usr.DeleteOnSubmit(sta);
                    }

                    IEnumerable<Sys_RoleMaster_rlm_Info> IErlm = null;
                    IEnumerable<Sys_UserRoles_usr_Info> IEusr = null;

                    sqlString += "UPDATE Sys_RoleMaster_rlm" + Environment.NewLine;
                    sqlString += " SET rlm_cRoleID='" + infoObject.rlm_cRoleID + "'," + Environment.NewLine;
                    sqlString += " rlm_cRoleDesc='" + infoObject.rlm_cRoleDesc + "'," + Environment.NewLine;
                    sqlString += " rlm_cLast='" + infoObject.rlm_cLast + "'," + Environment.NewLine;
                    sqlString += " rlm_dLastDate='" + DateTime.Now.ToString(DefineConstantValue.gc_DateTimeFormat) + "'" + Environment.NewLine;
                    sqlString += " WHERE rlm_iRecordID='" + infoObject.rlm_iRecordID + "'";

                    IErlm = db.ExecuteQuery<Sys_RoleMaster_rlm_Info>(sqlString, new object[] { });

                    sqlString = string.Empty;
                    sqlString += "DELETE FROM Sys_UserRoles_usr WHERE usr_cRoleID='" + infoObject.rlm_cRoleID + "'";
                    IEusr = db.ExecuteQuery<Sys_UserRoles_usr_Info>(sqlString, new object[] { });

                    if (infoObject.userMasterList != null && infoObject.userMasterList.Count > 0)
                    {
                        for (int i = 0; i < infoObject.userMasterList.Count; i++)
                        {
                            sqlString = string.Empty;
                            Sys_UserMaster_usm_Info usmInfo = infoObject.userMasterList[i];

                            sqlString += "INSERT INTO Sys_UserRoles_usr" + Environment.NewLine;
                            sqlString += "(usr_cUserLoginID, usr_cRoleID)" + Environment.NewLine;
                            sqlString += " VALUES " + Environment.NewLine;
                            sqlString += "('" + usmInfo.usm_cUserLoginID + "','" + infoObject.rlm_cRoleID + "')";

                            IEusr = db.ExecuteQuery<Sys_UserRoles_usr_Info>(sqlString, new object[] { });
                        }
                    }

                    return true;
                }
                catch (Exception Ex)
                {
                    throw Ex;
                }
            }
        }
Exemple #12
0
        private void ToolBar_BtnSearchClick(object sender, EventArgs e)
        {
            SysRoleMasterSearch win = new SysRoleMasterSearch();
            win.ShowDialog();

            if (win.DialogResult == DialogResult.OK)
            {
                //iRecordID = win.displayRecordID;
                iRecordID = win._RtvInfo[0].rlm_iRecordID.ToString();
                Sys_RoleMaster_rlm_Info info = new Sys_RoleMaster_rlm_Info();
                try
                {
                    info.rlm_iRecordID = Convert.ToInt32(iRecordID);
                    Model.IModel.IModelObject result = _sysRoleMasterBL.DisplayRecord(info);
                    info = result as Sys_RoleMaster_rlm_Info;
                }
                catch (Exception Ex)
                {
                    ShowErrorMessage(Ex);
                }
                this.EditState = DefineConstantValue.EditStateEnum.OE_ReaOnly;
                SetTxtBox(DefineConstantValue.EditStateEnum.OE_ReaOnly);
                SetOpenToolBar();
                ShowInfo(info);
            }

            win.Dispose();
            win = null;
        }
Exemple #13
0
        private void ToolBar_BtnSaveClick(object sender, EventArgs e)
        {
            Model.General.ReturnValueInfo msg = new Model.General.ReturnValueInfo();
            Sys_RoleMaster_rlm_Info info = new Sys_RoleMaster_rlm_Info();
            Sys_UserMaster_usm_Info userInfo = null;
            if (ChecktxtcName())
            {
                if (txtUserID.Text == "")
                {
                    msg.messageText = "登陆ID" + Common.DefineConstantValue.SystemMessageText.strMessageText_W_CannotEmpty;
                    ShowWarningMessage(msg.messageText);
                    txtUserID.Focus();
                }
                //else if (txtcName.Text == "")
                //{
                //    msg.messageText = "中文名" + Common.DefineConstantValue.SystemMessageText.strMessageText_W_CannotEmpty;
                //    ShowWarningMessage(msg.messageText);
                //    txtcName.Focus();
                //}
                else
                {
                    try
                    {
                        if (this.EditState == DefineConstantValue.EditStateEnum.OE_Update)
                        {
                            info.rlm_iRecordID = Convert.ToInt32(iRecordID);
                        }
                        info.rlm_cRoleID = txtUserID.Text;
                        info.rlm_cRoleDesc = txtcDesc.Text;

                        for (int i = 0; i < lvwMaster.Items.Count; i++)
                        {
                            userInfo = new Sys_UserMaster_usm_Info();
                            userInfo.usm_cUserLoginID = lvwMaster.Items[i].SubItems[0].Text;
                            //userInfo.cum_cName = lvwMaster.Items[i].SubItems[1].Text;
                            info.userMasterList.Add(userInfo);
                        }

                        if (this.EditState == DefineConstantValue.EditStateEnum.OE_Insert)
                        {
                            info.rlm_cAdd = UserInformation.usm_cUserLoginID;
                            info.rlm_dAddDate = DateTime.Now;
                        }
                        info.rlm_cLast = UserInformation.usm_cUserLoginID;
                        info.rlm_dLastDate = DateTime.Now;
                        if (this.EditState == DefineConstantValue.EditStateEnum.OE_Update)
                        {
                            msg = _sysRoleMasterBL.Save(info, DefineConstantValue.EditStateEnum.OE_Update);
                        }
                        else
                        {
                            msg = _sysRoleMasterBL.Save(info, DefineConstantValue.EditStateEnum.OE_Insert);
                            if (msg.boolValue)
                            {
                                Handel(DefineConstantValue.GetReocrdEnum.GR_Last);
                            }
                        }

                        if (msg.messageText != null)
                            ShowInformationMessage(msg.messageText);
                        else
                        {
                            SetOpenToolBar();
                            SetTxtBox(DefineConstantValue.EditStateEnum.OE_ReaOnly);
                        }
                    }
                    catch (Exception Ex)
                    { ShowErrorMessage(Ex); }
                }
            }
        }
Exemple #14
0
        private void ToolBar_BtnDeleteClick(object sender, EventArgs e)
        {
            this.EditState = DefineConstantValue.EditStateEnum.OE_Delete;
            Model.General.ReturnValueInfo msg = new Model.General.ReturnValueInfo();
            Model.Base.DataBaseCommandInfo com = new Model.Base.DataBaseCommandInfo();
            Model.Base.DataBaseCommandKeyInfo comkey = new Model.Base.DataBaseCommandKeyInfo();
            Sys_RoleMaster_rlm_Info Info = new Sys_RoleMaster_rlm_Info();
            try
            {
                comkey.KeyValue = iRecordID;
                if (comkey.KeyValue != string.Empty && comkey.KeyValue != "0")
                {
                    Info.rlm_iRecordID = Convert.ToInt32(comkey.KeyValue);
                    _sysRoleMasterBL.Save(Info, Common.DefineConstantValue.EditStateEnum.OE_Delete);

                    // SetOpenToolBar();
                    Handel(Common.DefineConstantValue.GetReocrdEnum.GR_Next);
                    if (Info.rlm_iRecordID == int.Parse(iRecordID))
                    {
                        Handel(DefineConstantValue.GetReocrdEnum.GR_Previous);
                    }
                    SetOpenToolBar();
                    if (Info.rlm_iRecordID == int.Parse(iRecordID))
                    {
                        SetOpenToolBar();
                        ToolBar.BtnPreviousEnabled = false;
                        ToolBar.BtnLastEnabled = false;
                        ToolBar.BtnFirstEnabled = false;
                        ToolBar.BtnNextEnabled = false;
                        ToolBar.BtnModifyEnabled = false;
                        ToolBar.BtnDeleteEnabled = false;
                        ToolBar.BtnSearchEnabled = false;
                    }
                }
            }
            catch (Exception Ex)
            { ShowErrorMessage(Ex); }
        }
        public bool UpdateRecord(Sys_RoleMaster_rlm_Info infoObject)
        {
            string sqlString = string.Empty;
            using (SIOTSDB_HHZXDataContext db = new SIOTSDB_HHZXDataContext())
            {
                Sys_RoleMaster_rlm rlm = new Sys_RoleMaster_rlm();
                Sys_RoleMaster_rlm_Info info = new Sys_RoleMaster_rlm_Info();
                try
                {

                    rlm = db.Sys_RoleMaster_rlm.SingleOrDefault(t => t.rlm_iRecordID == infoObject.rlm_iRecordID);

                    for (int i = 0; i < rlm.Sys_UserRoles_usr.Count; i++)
                    {
                        Sys_UserRoles_usr sta = rlm.Sys_UserRoles_usr[i];
                        db.Sys_UserRoles_usr.DeleteOnSubmit(sta);
                    }

                    info = Common.General.CopyObjectValue<Sys_RoleMaster_rlm, Sys_RoleMaster_rlm_Info>(rlm);

                    IEnumerable<Sys_RoleMaster_rlm_Info> IErlm = null;
                    IEnumerable<Sys_UserRoles_usr_Info> IEusr = null;

                    sqlString += "UPDATE Sys_RoleMaster_rlm" + Environment.NewLine;
                    sqlString += " SET rlm_cRoleID='" + infoObject.rlm_cRoleID + "'," + Environment.NewLine;
                    sqlString += " rlm_cRoleDesc='" + infoObject.rlm_cRoleDesc + "'," + Environment.NewLine;
                    sqlString += " rlm_cLast='" + infoObject.rlm_cLast + "'," + Environment.NewLine;
                    sqlString += " rlm_dLastDate='" + infoObject.rlm_dLastDate.Value.ToString(DefineConstantValue.gc_DateTimeFormat) + "'" + Environment.NewLine;
                    sqlString += " WHERE rlm_iRecordID='" + infoObject.rlm_iRecordID + "'";

                    IErlm = db.ExecuteQuery<Sys_RoleMaster_rlm_Info>(sqlString, new object[] { });

                    sqlString = string.Empty;
                    sqlString += "DELETE FROM Sys_UserRoles_usr WHERE usr_cRoleID='" + infoObject.rlm_cRoleID + "'";
                    IEusr = db.ExecuteQuery<Sys_UserRoles_usr_Info>(sqlString, new object[] { });

                    if (infoObject.userMasterList != null && infoObject.userMasterList.Count > 0)
                    {
                        for (int i = 0; i < infoObject.userMasterList.Count; i++)
                        {
                            sqlString = string.Empty;
                            Sys_UserMaster_usm_Info usmInfo = infoObject.userMasterList[i];

                            sqlString += "INSERT INTO Sys_UserRoles_usr" + Environment.NewLine;
                            sqlString += "(usr_cUserLoginID, usr_cRoleID)" + Environment.NewLine;
                            sqlString += " VALUES " + Environment.NewLine;
                            sqlString += "('" + usmInfo.usm_cUserLoginID + "','" + infoObject.rlm_cRoleID + "')";

                            IEusr = db.ExecuteQuery<Sys_UserRoles_usr_Info>(sqlString, new object[] { });
                        }
                    }

                    //if (rlm != null)
                    //{
                    //    //usm = Common.General.SetDataToLingQEntity(usm, infoObject);//时间溢出
                    //    rlm.rlm_cRoleDesc = infoObject.rlm_cRoleDesc;
                    //    rlm.rlm_cLast = infoObject.rlm_cLast;
                    //    rlm.rlm_dLastDate = infoObject.rlm_dLastDate.Value;

                    //    if (infoObject.userMasterList != null && infoObject.userMasterList.Count > 0)
                    //    {
                    //        for (int i = 0; i < infoObject.userMasterList.Count; i++)
                    //        {
                    //            Sys_UserMaster_usm_Info usmInfo = infoObject.userMasterList[i];

                    //            Sys_UserRoles_usr item = new Sys_UserRoles_usr();

                    //            item.usr_cUserLoginID = usmInfo.usm_cUserLoginID;
                    //            item.usr_cRoleID = infoObject.rlm_cRoleID;
                    //            //courseitem.cum_cNumber;
                    //            rlm.Sys_UserRoles_usrs.Add(item);
                    //            //db.Sys_UserRoles_usrs.InsertOnSubmit(item);
                    //        }
                    //    }
                    //    db.SubmitChanges();
                    //}
                    return true;
                }
                catch (Exception Ex)
                {
                    throw Ex;
                }
            }
        }
        /// <summary>
        /// 綁定角色信息
        /// </summary>
        private void BindRoleInfos()
        {
            this.Cursor = Cursors.WaitCursor;

            try
            {
                Sys_RoleMaster_rlm_Info searchInfo = new Sys_RoleMaster_rlm_Info();
                List<IModelObject> listObjRole = this._ISysRoleMasterBL.SearchRecords(searchInfo);
                List<Sys_RoleMaster_rlm_Info> listRoleInfos = new List<Sys_RoleMaster_rlm_Info>();
                foreach (Sys_RoleMaster_rlm_Info roleItem in listObjRole)
                {
                    if (roleItem != null)
                    {
                        listRoleInfos.Add(roleItem);
                    }
                }
                this._ListRoleMasterInfo = listRoleInfos;
                lvRole.SetDataSource<Sys_RoleMaster_rlm_Info>(listRoleInfos);
                lvPurviewRole.SetDataSource(listRoleInfos);

                this._isEdited = false;
                this._ListRoleMasterInfo = listRoleInfos;
            }
            catch (Exception ex)
            {
                this.ShowErrorMessage("系統異常,異常信息:" + ex.Message);
                this.Cursor = Cursors.Default;
            }

            this.Cursor = Cursors.Default;
        }
        private Sys_RoleMaster_rlm_Info FindUserRole(Sys_RoleMaster_rlm_Info info)
        {
            string sqlString = string.Empty;
            sqlString += "SELECT usm_cUserLoginID,usm_cChaName " + Environment.NewLine;
            sqlString += "FROM Sys_UserMaster_usm " + Environment.NewLine;
            sqlString += "LEFT JOIN  Sys_UserRoles_usr" + Environment.NewLine;
            sqlString += "ON usm_cUserLoginID=usr_cUserLoginID" + Environment.NewLine;
            sqlString += "LEFT JOIN Sys_RoleMaster_rlm" + Environment.NewLine;
            sqlString += "ON rlm_cRoleID=usr_cRoleID WHERE rlm_cRoleID='" + info.rlm_cRoleID + "'";

            IEnumerable<Sys_UserMaster_usm_Info> infos = null;
            List<Sys_UserMaster_usm_Info> infoList = null;

            try
            {
                using (SIOTSDB_HHZXDataContext db = new SIOTSDB_HHZXDataContext())
                {
                    infos = db.ExecuteQuery<Sys_UserMaster_usm_Info>(sqlString, new object[] { });

                    if (infos != null)
                    {
                        infoList = infos.ToList<Sys_UserMaster_usm_Info>();
                    }
                    foreach (Sys_UserMaster_usm_Info t in infoList)
                    {
                        info.userMasterList.Add(t);
                    }
                    return info;
                }
            }
            catch (Exception Ex)
            {
                throw Ex;
            }
        }
        private void btnSaveFormRight_Click(object sender, EventArgs e)
        {
            string objID = string.Empty;

            List<Sys_UserPurview_usp_Info> saveList = new List<Sys_UserPurview_usp_Info>();

            List<Sys_UserMaster_usm_Info> userList = new List<Sys_UserMaster_usm_Info>();

            List<Sys_RoleMaster_rlm_Info> roleList = new List<Sys_RoleMaster_rlm_Info>();

            List<Sys_FormMaster_fom_Info> formList = new List<Sys_FormMaster_fom_Info>();

            #region MyRegion
            if (lvUserAndRole.SelectedItems != null && lvUserAndRole.SelectedItems.Count > 0)
            {
                foreach (ListViewItem item in lvUserAndRole.SelectedItems)
                {
                    if (item.SubItems[4].Text == Sys_UserAndRoleGeneral_Info.accountType.userID.ToString())
                    {
                        Sys_UserMaster_usm_Info info = new Sys_UserMaster_usm_Info();

                        info.RecordID = Convert.ToInt32(item.SubItems[0].Text);

                        info.usm_cUserLoginID = item.SubItems[1].Text;

                        objID = info.usm_cUserLoginID;

                        userList.Add(info);

                        saveTypeID = Sys_UserAndRoleGeneral_Info.accountType.userID;
                    }
                    else
                    {
                        Sys_RoleMaster_rlm_Info info = new Sys_RoleMaster_rlm_Info();

                        info.rlm_iRecordID = Convert.ToInt32(item.SubItems[0].Text);

                        info.rlm_cRoleID = item.SubItems[1].Text;

                        objID = info.rlm_cRoleID;

                        roleList.Add(info);

                        saveTypeID = Sys_UserAndRoleGeneral_Info.accountType.roleID;
                    }
                }
            }
            #endregion

            HandelFormRight(tvFromMain2.Nodes[0], formList);

            foreach (Sys_UserMaster_usm_Info user in userList)
            {
                foreach (Sys_FormMaster_fom_Info form in formList)
                {
                    Sys_UserPurview_usp_Info info = new Sys_UserPurview_usp_Info();

                    info.usp_iFormID = form.fom_iRecordID;

                    info.usp_cUserLoginID = user.usm_cUserLoginID;

                    info.usp_cAdd = this.UserInformation.usm_cUserLoginID;

                    info.usp_cLast = this.UserInformation.usm_cUserLoginID;

                    saveList.Add(info);
                }
            }

            foreach (Sys_RoleMaster_rlm_Info role in roleList)
            {
                foreach (Sys_FormMaster_fom_Info form in formList)
                {
                    Sys_UserPurview_usp_Info info = new Sys_UserPurview_usp_Info();

                    info.usp_iFormID = form.fom_iRecordID;

                    info.usp_cRoleID = role.rlm_cRoleID;

                    info.usp_cAdd = this.UserInformation.usm_cUserLoginID;

                    info.usp_cLast = this.UserInformation.usm_cUserLoginID;

                    saveList.Add(info);
                }
            }

            try
            {
                ReturnValueInfo returnInfo = this._IUserPurviewBL.SavePruview(saveList, objID, saveTypeID);

                if (returnInfo.boolValue)
                {
                    ShowInformationMessage(DefineConstantValue.SystemMessageText.strMessageText_I_SaveSuccess);

                    gbFormTree.Enabled = false;

                    gbxUserAndRole.Enabled = true;

                    btnSaveFormRight.Enabled = false;

                    btnCancelFormRight.Enabled = false;

                    btnSetRight.Enabled = true;
                }
                else
                {
                    ShowErrorMessage(returnInfo.messageText);
                }
            }
            catch (Exception Ex)
            {

                ShowErrorMessage(Ex.Message);
            }
            this._EditStatus = DefineConstantValue.EditStateEnum.OE_ReaOnly;
        }
        public Sys_RoleMaster_rlm_Info GetRecord_First()
        {
            try
            {

                using (SIOTSDB_HHZXDataContext db = new SIOTSDB_HHZXDataContext())
                {
                    IQueryable<Sys_RoleMaster_rlm> taQuery =
                        (from ta in db.Sys_RoleMaster_rlm
                         orderby ta.rlm_iRecordID ascending
                         select ta).Take(1);
                    Sys_RoleMaster_rlm_Info info = new Sys_RoleMaster_rlm_Info();
                    if (taQuery.Count() > 0)
                    {
                        foreach (var t in taQuery)
                        {
                            info = Common.General.CopyObjectValue<Sys_RoleMaster_rlm, Sys_RoleMaster_rlm_Info>(t);
                            FindUserRole(info);
                        }
                    }
                    return info;
                }
            }
            catch (Exception Ex)
            {
                throw Ex;
            }
        }
Exemple #20
0
        //顯示數據
        private void ShowInfo(Sys_RoleMaster_rlm_Info info)
        {
            try
            {
                if (info != null)
                {
                    iRecordID = info.rlm_iRecordID.ToString();
                    txtcAdd.Text = info.rlm_cAdd.ToString();
                    txtcLast.Text = info.rlm_cLast.ToString();

                    txtUserID.Text = info.rlm_cRoleID.ToString();
                    txtcDesc.Text = info.rlm_cRoleDesc.ToString();

                    lvwMaster.Items.Clear();

                    lvwMaster.SetDataSource<Sys_UserMaster_usm_Info>(info.userMasterList);

                    txtdAddDate.Text = info.rlm_dAddDate != null ? info.rlm_dAddDate.Value.ToString(Common.DefineConstantValue.gc_DateFormat) : "";
                    txtdLastDate.Text = info.rlm_dLastDate != null ? info.rlm_dLastDate.Value.ToString(Common.DefineConstantValue.gc_DateFormat) : "";
                }
            }
            catch (Exception Ex)
            { ShowErrorMessage(Ex); }
        }