Beispiel #1
0
        //根据账户名和密码,或者ID,用户名,菜单权限
        public UserInfo GetMenu(string loginName, string password)
        {
            UserInfo userInfo = new UserInfo();

            string sql = string.Format("select id uid, userName uname, deptId deptid,deptLevel flagtier,supplierId, subName menu,userId " +
                                       "from v_user_sub " +
                                       "where userId ='{0}' and  userPassword = '******'", loginName, password);


            try
            {
                DataTable table = dbHelper.GetDataSet(sql).Tables[0];
                if (table.Rows.Count == 1)
                {
                    userId                = table.Rows[0][0].ToString();
                    userInfo.ID           = table.Rows[0][0].ToString();
                    userInfo.ShowName     = table.Rows[0][1].ToString();
                    userInfo.DepartmentID = table.Rows[0][2].ToString();
                    userInfo.FlagTier     = table.Rows[0][3].ToString();
                    userInfo.SupplierId   = table.Rows[0][4].ToString();
                    userInfo.Menus.AddRange(table.Rows[0][5].ToString().Split(new char[] { ',' }));
                    userInfo.LoginName = table.Rows[0][6].ToString();
                }
                return(userInfo);
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine("GetMenu异常");
                throw new Exception(e.Message);
            }
        }
        //根据账户名和密码,或者ID,用户名,菜单权限
        public UserInfo GetMenu(string loginName, string password)
        {
            UserInfo userInfo = new UserInfo();

            string sql = string.Format("select reco_pkid uid, INFO_USER uname, fk_dept deptid, FLAG_TIER flagtier,supplierId, SUB_NAME menu,NUMB_USER,INFO_NAME deptname " +
                                       "from v_user_sub " +
                                       "where NUMB_USER ='******' and  INFO_PASSWORD = '******'", loginName, password);


            try
            {
                DataTable table = dbHelper.GetDataSet(sql).Tables[0];
                if (table.Rows.Count == 1)
                {
                    userId                = table.Rows[0][0].ToString();
                    userInfo.ID           = table.Rows[0][0].ToString();
                    userInfo.ShowName     = table.Rows[0][1].ToString();
                    userInfo.DepartmentID = table.Rows[0][2].ToString();
                    userInfo.FlagTier     = table.Rows[0][3].ToString();
                    userInfo.SupplierId   = table.Rows[0][4].ToString();
                    userInfo.Menus.AddRange(table.Rows[0][5].ToString().Split(new char[] { ',' }));
                    userInfo.LoginName      = table.Rows[0][6].ToString();
                    userInfo.DepartmentName = table.Rows[0][7].ToString();
                }
                return(userInfo);
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine("GetMenu异常");
                throw new Exception(e.Message);
            }
        }
Beispiel #3
0
        private void Init()
        {
            try
            {
                DirectoryInfo topDir = Directory.GetParent(AppDomain.CurrentDomain.BaseDirectory);
                CommonPars.ScreenTipConfigFilePath = topDir.Parent.FullName + "\\Configuration\\SuperMap.ZS.Config.xml";
                XElement root = XElement.Load(CommonPars.ScreenTipConfigFilePath);

                CommonPars.ScreenTipName = root.Element("ScreenTipProgremName").Value;
                CommonPars.ScreenTipType = (ScreenTipType)Enum.Parse(typeof(ScreenTipType), root.Element("ScreenTipType").Value);
                if (CommonPars.ScreenTipType == ScreenTipType.Next)
                {
                    MessageServer server = new MessageServer();
                    server.StartReceive();
                    server.OnReceived += Server_OnReceived;
                }

                string  sql = "select * from workspaceserverinfo";
                DataSet dt  = DbHelperMySQL.GetDataSet(DbHelperMySQL.Conn, CommandType.Text, sql);
                if (dt.Tables.Count > 0 && dt.Tables[0].Rows.Count > 0)
                {
                    CommonPars.DataRootDirInServer = dt.Tables[0].Rows[0]["WorkspaceServerPath"].ToString();
                    CommonPars.OriginalDirInServer = dt.Tables[0].Rows[0]["OriginalDir"].ToString();
                }
            }
            catch (Exception ex)
            {
                Log.OutputBox(ex);
            }
        }
        /// <summary>
        /// 从内存表中查询角色名称
        /// </summary>

        private void SelectRole(string RoleName, string Rolelevel)
        {
            StringBuilder strsql = new StringBuilder();

            DataTable dt_SelectRole = null;

            lvlist.DataContext = null;
            strsql.Append("select NUMB_ROLE,INFO_NAME,INFO_EXPL,FLAG_TIER FROM sys_client_role where 1=1 ");

            if (RoleName != "")
            {
                strsql.Append(" and INFO_NAME like '%" + RoleName + "%'");
            }
            if (Rolelevel != "-1")
            {
                strsql.Append(" and FLAG_TIER = " + Convert.ToInt16(Rolelevel) + "");
            }
            try
            {
                dt_SelectRole      = dbHelper.GetDataSet(strsql.ToString()).Tables[0];
                lvlist.DataContext = null;
                lvlist.DataContext = dt_SelectRole;
            }
            catch (Exception)
            {
                return;
            }
        }
        public UcDetectBillManager()
        {
            InitializeComponent();
            dbOperation       = DBUtility.DbHelperMySQL.CreateDbHelper();
            ProvinceCityTable = Application.Current.Resources["省市表"] as DataTable;
            DataTable table = dbOperation.GetDataSet("select proviceid as id , name " +
                                                     "from t_set_area LEFT JOIN sys_city  ON t_set_area.proviceid = sys_city.id " +
                                                     "where  deptid = " + deptid).Tables[0];

            DataRow[] rows;
            if (table.Rows.Count == 0)
            {
                rows = ProvinceCityTable.Select("pid = '0001'");
            }
            else
            {
                rows = table.Select();
            }

            //画面初始化-新增检测单画面
            ComboboxTool.InitComboboxSource(_province, rows, "lr");
            _province.SelectionChanged += new SelectionChangedEventHandler(_province_SelectionChanged);

            //查找登录者部门所属的省份
            string proviceid = dbOperation.GetSingle("select province from sys_client_sysdept where INFO_CODE = " + deptid).ToString();
            int    i         = 1;

            foreach (DataRow row in rows)
            {
                if (row["id"].ToString() == proviceid)
                {
                    _province.SelectedIndex = i;
                }
                i = i + 1;
            }

            ComboboxTool.InitComboboxSource(_source_company, "SELECT COMPANYID,COMPANYNAME FROM v_user_company WHERE userid =  " + userId, "lr");
            //if (supplierId == "nkrx")
            //{
            //    ComboboxTool.InitComboboxSource(_detect_trade, "select tradeId,tradeName from t_trade where openFlag = '1' order by orderId", "lr");
            //}
            //else
            //{
            //    ComboboxTool.InitComboboxSource(_detect_trade, "select tradeId,tradeName from t_trade where openFlag = '1'", "lr");
            //}
            //_detect_trade.SelectionChanged += new SelectionChangedEventHandler(_detect_trade_SelectionChanged);
            //_detect_trade.SelectedIndex = 1;
            //ComboboxTool.InitComboboxSource(_detect_item, "SELECT itemid,ItemNAME FROM v_user_item WHERE userid = " + userId);
            //ComboboxTool.InitComboboxSource(_detect_object, " SELECT objectId,objectName FROM v_user_object WHERE userid = " + userId);
            //ComboboxTool.InitComboboxSource(_detect_sample, "  SELECT sampleId,sampleName FROM v_user_sample WHERE userid = " + userId);
            //ComboboxTool.InitComboboxSource(_detect_sensitivity, "SELECT sensitivityId,sensitivityName FROM t_det_sensitivity where openFlag = '1'", "lr");
            ComboboxTool.InitComboboxSource(_detect_item, string.Format("SELECT ItemID,ItemNAME FROM t_det_item WHERE  (tradeId ='1'or ifnull(tradeId,'') = '') and OPENFLAG = '1' order by orderId"), "lr");
            _detect_item.SelectionChanged += new SelectionChangedEventHandler(_detect_item_SelectionChanged);
            ComboboxTool.InitComboboxSource(_detect_result, "SELECT resultId,resultName FROM t_det_result where openFlag = '1' ORDER BY id", "lr");
            ComboboxTool.InitComboboxSource(_card_brand, "SELECT cardbrandid,cardbrandname FROM t_cardbrand where openFlag = '1'", "lr");
            _entering_datetime.Text           = string.Format("{0:g}", System.DateTime.Now);
            _source_company.SelectionChanged += new SelectionChangedEventHandler(_source_company_SelectionChanged);
            _detect_person.Text = (Application.Current.Resources["User"] as UserInfo).ShowName;
            _detect_site.Text   = dbOperation.GetSingle("SELECT INFO_NAME  from  sys_client_sysdept WHERE INFO_CODE = " + (Application.Current.Resources["User"] as UserInfo).DepartmentID).ToString();
        }
        private void btnModify_Click(object sender, RoutedEventArgs e)
        {
            user_details.Visibility       = Visibility.Visible;
            btnSave.Visibility            = Visibility.Visible;
            btnCancel.Visibility          = Visibility.Visible;
            this._department.IsEnabled    = true;
            this._cmbRoleType.IsEnabled   = true;
            this._loginName.IsEnabled     = true;
            this._loginPassword.IsEnabled = true;
            this.txtUserName.IsEnabled    = true;
            this._user_manger.IsEnabled   = true;
            this._user_manger_2.IsEnabled = true;
            this._dept_flag.Text          = "(必填)";
            this._role_flag.Text          = "(必填)";
            this._user_flag.Text          = "(必填)";
            this._password_flag.Text      = "(必填)";
            this._name_flag.Text          = "(必填)";
            this._manager_flag.Text       = "(必填)";
            string id = (sender as Button).Tag.ToString();

            DataRow dr = dbHelper.GetDataSet("SELECT RECO_PKID,NUMB_USER,INFO_USER,INFO_PASSWORD,fk_dept,sys_client_sysdept.INFO_NAME,ROLE_ID,expired " +
                                             "FROM sys_client_user ,sys_client_sysdept " +
                                             "WHERE sys_client_user.fk_dept = sys_client_sysdept.INFO_CODE " +
                                             "AND sys_client_user.RECO_PKID = " + id).Tables[0].Rows[0];

            this.txtUserName.Text = dr["INFO_USER"].ToString();
            this._loginName.Text  = dr["NUMB_USER"].ToString();

            for (int i = 0; i < _department.Items.Count; i++)
            {
                if ((_department.Items[i] as Label).Tag.ToString() == dr["fk_dept"].ToString())
                {
                    _department.SelectedItem = _department.Items[i];
                    break;
                }
            }

            for (int i = 0; i < _cmbRoleType.Items.Count; i++)
            {
                if ((_cmbRoleType.Items[i] as Label).Tag.ToString() == dr["ROLE_ID"].ToString())
                {
                    _cmbRoleType.SelectedItem = _cmbRoleType.Items[i];
                    break;
                }
            }

            this._loginPassword.Password = dr["INFO_PASSWORD"].ToString();
            password_old = dr["INFO_PASSWORD"].ToString();
            if (dr["expired"].ToString() == "1")
            {
                this._user_manger.IsChecked = true;
            }
            else if (dr["expired"].ToString() == "0")
            {
                this._user_manger_2.IsChecked = true;
            }

            this.btnSave.Tag = id;
        }
Beispiel #7
0
        private void BindData()
        {
            string strSql = "SELECT * FROM sys_client_person";

            try
            {
                currentTable            = dbHelper.GetDataSet(strSql).Tables[0];
                this.lvlist.DataContext = currentTable.DefaultView;
            }
            catch (Exception)
            {
                return;
            }
        }
Beispiel #8
0
        public List <string> GetAlarmMsg()
        {
            List <string> list   = new List <string>();
            string        str_sq = "SELECT a.NUMB_ALARM AS OID,a.FK_DEVICE_CODE AS MSFNBR,B.PERSON_NAME AS PersonName,c.INFO_LOACTIONNAME AS AREANAME,a.FK_INFO_NAME AS ALERM_TYPE,a.ALARM_DATETIME as CREATIME,a.FK_DEVICE_LOCATION AS BSFNBR FROM sys_alarm_data AS a LEFT JOIN sys_client_person AS b ON a.FK_DEVICE_CODE=b.FK_DEVICE_CODE LEFT JOIN sys_client_device AS c ON a.FK_DEVICE_LOCATION=c.INFO_CODE where a.ALARM_STATE='1'";
            DataSet       ds     = dbHelper.GetDataSet(str_sq);

            if (ds != null)
            {
                foreach (DataRow tr in ds.Tables[0].Rows)
                {
                    string re_value = tr["OID"].ToString() + "@#" + tr["MSFNBR"].ToString() + "@#" + tr["PersonName"].ToString() + "@#" + tr["BSFNBR"].ToString() + "@#" + tr["CREATIME"].ToString() + "@#" + tr["ALERM_TYPE"].ToString() + "@#" + tr["AREANAME"].ToString();
                    list.Add(re_value);
                }
            }
            return(list);
        }
Beispiel #9
0
 private void Form1_Load(object sender, EventArgs e)
 {
     try
     {
         string  sql = "select WorkspaceServerPath from workspaceserverinfo";
         DataSet dt  = DbHelperMySQL.GetDataSet(DbHelperMySQL.Conn, CommandType.Text, sql);
         if (dt.Tables.Count > 0 && dt.Tables[0].Rows.Count > 0)
         {
             CommonPars.DataRootDirInServer = dt.Tables[0].Rows[0][0].ToString();
         }
     }
     catch (Exception ex)
     {
         Log.OutputBox(ex);
     }
 }
        private void btnModify_Click(object sender, RoutedEventArgs e)
        {
            this.txtUserName.IsEnabled = true;
            this._loginName.IsEnabled  = true;
            this.cmbRoleType.IsEnabled = true;
            this._department.IsEnabled = true;
            //this.txtPwd.IsEnabled = true;
            //this.txtConfirmPwd.IsEnabled = true;
            this.dtpStartDate.IsEnabled = true;
            this.dtpEndDate.IsEnabled   = true;
            this.txtComment.IsEnabled   = true;
            string id = (sender as Button).Tag.ToString();

            DataRow dr = dbHelper.GetDataSet("SELECT RECO_PKID,NUMB_USER,INFO_USER,INFO_PASSWORD,fk_dept,sys_client_sysdept.INFO_NAME,FK_CODE_ROLE,sys_client_user.INFO_NOTE,START_DATE,END_DATE " +
                                             "FROM sys_client_user ,sys_client_sysdept " +
                                             "WHERE sys_client_user.fk_dept = sys_client_sysdept.INFO_CODE " +
                                             "AND sys_client_user.RECO_PKID = " + id).Tables[0].Rows[0];

            this.txtUserName.Text = dr["INFO_USER"].ToString();
            this._loginName.Text  = dr["NUMB_USER"].ToString();

            for (int i = 0; i < cmbRoleType.Items.Count; i++)
            {
                if ((cmbRoleType.Items[i] as Label).Tag.ToString() == dr["FK_CODE_ROLE"].ToString())
                {
                    cmbRoleType.SelectedItem = cmbRoleType.Items[i];
                    break;
                }
            }

            for (int i = 0; i < _department.Items.Count; i++)
            {
                if ((_department.Items[i] as Label).Tag.ToString() == dr["fk_dept"].ToString())
                {
                    _department.SelectedItem = _department.Items[i];
                    break;
                }
            }

            //this.txtPwd.Password = dr["INFO_PASSWORD"].ToString();
            //this.txtConfirmPwd.Password = dr["INFO_PASSWORD"].ToString();
            this.dtpStartDate.Value = Convert.ToDateTime(dr["START_DATE"]);
            this.dtpEndDate.Value   = Convert.ToDateTime(dr["END_DATE"]);
            this.txtComment.Text    = dr["INFO_NOTE"].ToString();

            this.btnSave.Tag = id;
        }
        /// <summary>
        /// 从数据库获取数据
        /// </summary>
        private void BindData()
        {
            string strSql = "select RECO_PKID,NUMB_USER,INFO_USER from sys_client_user where cuserid = " + (Application.Current.Resources["User"] as UserInfo).ID;

            try
            {
                dbHelper = DbHelperMySQL.CreateDbHelper();
                DataTable dt = dbHelper.GetDataSet(strSql).Tables[0];
                lvlist.DataContext = null;
                lvlist.DataContext = dt;
                lvlist.Tag         = dt;
            }
            catch (Exception)
            {
                return;
            }
        }
        void _source_company_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            //获取变更前的状态
            bool flag = _province.IsEnabled;

            //来源单位下拉选择的是有效内容,则将省市区的下拉灰显并且自动赋值
            if (_source_company.SelectedIndex >= 1)
            {
                _province.IsEnabled = false;
                _city.IsEnabled     = false;
                _region.IsEnabled   = false;

                string areaid = dbOperation.GetDataSet("SELECT AREAID from t_company where COMPANYID = " + (_source_company.SelectedItem as Label).Tag.ToString()).Tables[0].Rows[0][0].ToString();

                _source_company.Tag = areaid;
                if (areaid.Length > 0)
                {
                    string _areaid = areaid.Substring(0, 2);
                    _province.Text = ProvinceCityTable.Select("id = '" + _areaid + "'")[0]["name"].ToString();
                }
                if (areaid.Length > 2)
                {
                    string _areaid = areaid.Substring(0, 4);
                    _city.Text = ProvinceCityTable.Select("id = '" + _areaid + "'")[0]["name"].ToString();
                }
                if (areaid.Length > 4)
                {
                    _region.Text = ProvinceCityTable.Select("id = '" + areaid + "'")[0]["name"].ToString();
                }
            }
            //来源单位下拉选择的是“-请选择-”或是手动输入来源单位,则将省市区的下拉激活并且内容清空
            else if (_source_company.SelectedIndex < 1)
            {
                if (flag == false)
                {
                    _province.IsEnabled = true;
                    _city.IsEnabled     = true;
                    _region.IsEnabled   = true;

                    _province.SelectedIndex = 0;
                    _city.SelectedIndex     = 0;
                    _region.SelectedIndex   = 0;
                }
            }
        }
        /// <summary>
        /// 从数据库获取数据
        /// </summary>
        ///
        private void BindData()
        {
            DataTable dt = null;

            lvlist.DataContext = null;
            string strSql = string.Format("select NUMB_ROLE,INFO_NAME,INFO_EXPL,FLAG_TIER FROM sys_client_role where cuserid = '{0}'", (Application.Current.Resources["User"] as UserInfo).ID);

            try
            {
                dbHelper           = DbHelperMySQL.CreateDbHelper();
                dt                 = dbHelper.GetDataSet(strSql).Tables[0];
                lvlist.DataContext = dt;
                currentTable       = dt;
            }
            catch (Exception)
            {
                return;
            }
        }
        /// <summary>
        /// 从数据库获取数据
        /// </summary>
        private void BindData()
        {
            string strSql = "select RECO_PKID,NUMB_USER,sys_client_user.INFO_USER,sys_client_sysdept.INFO_NAME,sys_client_role.INFO_NAME as role_expl " +
                            "FROM sys_client_user ,sys_client_sysdept,sys_client_role " +
                            "WHERE sys_client_user.fk_dept = sys_client_sysdept.INFO_CODE " +
                            "and sys_client_user.ROLE_ID = sys_client_role.NUMB_ROLE " +
                            "and sys_client_user.cuserid = " + (Application.Current.Resources["User"] as UserInfo).ID;

            try
            {
                dbHelper = DbHelperMySQL.CreateDbHelper();
                DataTable dt = dbHelper.GetDataSet(strSql).Tables[0];
                lvlist.DataContext = null;
                lvlist.DataContext = dt;
                lvlist.Tag         = dt;
            }
            catch (Exception)
            {
                return;
            }
        }
        void _detect_station_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            lastTextboxValues.Clear();
            _grid_detail.Children.Clear();
            _grid_detail.RowDefinitions.Clear();
            _grid_detail.ColumnDefinitions.Clear();
            textBoxs.Clear();

            for (int i = 0; i < tableHeaders.Count; i++)
            {
                _grid_detail.ColumnDefinitions.Add(new ColumnDefinition());
                if (i == 0)
                {
                    _grid_detail.ColumnDefinitions[0].Width = new GridLength(2, GridUnitType.Star);
                }
                else
                {
                    _grid_detail.ColumnDefinitions[0].Width = new GridLength(1, GridUnitType.Star);
                }
            }
            _grid_detail.RowDefinitions.Add(new RowDefinition());
            for (int i = 0; i < tableHeaders.Count; i++)
            {
                Border border = new Border();
                border.BorderBrush         = Brushes.Black;
                border.HorizontalAlignment = HorizontalAlignment.Center;
                border.BorderThickness     = new Thickness(0.2);
                TextBox textBox = new TextBox();
                textBox.Margin                     = new Thickness(0);
                textBox.IsReadOnly                 = true;
                textBox.Text                       = tableHeaders[i];
                textBox.HorizontalAlignment        = HorizontalAlignment.Center;
                textBox.HorizontalContentAlignment = HorizontalAlignment.Center;
                border.Child                       = textBox;
                border.SetValue(Grid.RowProperty, 0);
                border.SetValue(Grid.ColumnProperty, i);
                _grid_detail.Children.Add(border);
            }

            string    sql   = string.Format("select itemid,ItemNAME from v_item_details  WHERE deptid = '{0}'", (_detect_station.SelectedItem as Label).Tag);
            DataTable table = dbOperation.GetDataSet(sql).Tables[0];

            _grid_detail.Tag = table;
            for (int i = 0; i < table.Rows.Count; i++)
            {
                _grid_detail.RowDefinitions.Add(new RowDefinition());
                for (int j = 0; j < tableHeaders.Count; j++)
                {
                    Border border = new Border();
                    border.BorderBrush         = Brushes.Black;
                    border.HorizontalAlignment = HorizontalAlignment.Center;
                    border.BorderThickness     = new Thickness(0.2);
                    TextBox textBox = new TextBox();
                    textBox.Margin = new Thickness(0);
                    if (j == 0)
                    {
                        textBox.IsReadOnly = true;
                        textBox.Text       = table.Rows[i][1].ToString();
                        textBox.Tag        = table.Rows[i][0].ToString();
                    }
                    else
                    {
                        textBox.Text = "0";
                        if (j == tableHeaders.Count - 1)
                        {
                            textBox.IsReadOnly = true;
                            textBoxs.Add("行合计" + (_grid_detail.RowDefinitions.Count - 1), textBox);
                        }
                        else
                        {
                            textBox.TextChanged += new TextChangedEventHandler(textBox_TextChanged);
                            textBox.Tag          = (i + 1) + "," + j;
                            textBoxs.Add((i + 1) + "," + j, textBox);
                        }
                    }
                    textBox.HorizontalAlignment        = HorizontalAlignment.Center;
                    textBox.HorizontalContentAlignment = HorizontalAlignment.Center;
                    border.Child = textBox;
                    border.SetValue(Grid.RowProperty, i + 1);
                    border.SetValue(Grid.ColumnProperty, j);
                    _grid_detail.Children.Add(border);
                }
            }

            _grid_detail.RowDefinitions.Add(new RowDefinition());
            for (int j = 0; j < tableHeaders.Count; j++)
            {
                Border border = new Border();
                border.BorderBrush         = Brushes.Black;
                border.HorizontalAlignment = HorizontalAlignment.Center;
                border.BorderThickness     = new Thickness(0.2);
                TextBox textBox = new TextBox();
                textBox.Margin     = new Thickness(0);
                textBox.IsReadOnly = true;
                if (j == 0)
                {
                    textBox.Text = "合计";
                }
                else
                {
                    textBox.Text = "0";
                    textBoxs.Add("列合计" + j, textBox);
                }
                textBox.Foreground                 = Brushes.Blue;
                textBox.HorizontalAlignment        = HorizontalAlignment.Center;
                textBox.HorizontalContentAlignment = HorizontalAlignment.Center;
                border.Child = textBox;
                border.SetValue(Grid.RowProperty, _grid_detail.RowDefinitions.Count - 1);
                border.SetValue(Grid.ColumnProperty, j);
                _grid_detail.Children.Add(border);
            }
        }
Beispiel #16
0
        private void btn_TestDataSource_Click(object sender, EventArgs e)
        {
            DataSet dt = DbHelperMySQL.GetDataSet(DbHelperMySQL.Conn, CommandType.Text, "select * from test", null);

            lblResult.Text = dt.Tables[0].Rows.Count.ToString();
        }