private void UpdateConfigByUser(DataRow dr) { string frcode = dr["frcode"].ToString(); //管理员账号 不更新 ; 同步更新站点数 sdk等信息 if (!frcode.Equals("000000")) { //更新县区编码 Util.Util.WriteAppSetting("rcode", frcode, false); //更新站点号 string site = dr["site"].ToString(); Util.Util.WriteAppSetting("site", site, false); //获取农合办配置信息 更新sdk信息 string forgid = dr["forgid"].ToString(); ScanDataSet scanDataSet = new Business.ConfigInfo().GetConfigInfoByStr(" and forgid='" + forgid + "' and site=" + site); DataRow configInfoRow; if (scanDataSet.ConfigInfo.Rows.Count > 0) { configInfoRow = scanDataSet.ConfigInfo.Rows[0]; string sdkPath = configInfoRow["sdkpath"] == null ? "" : configInfoRow["sdkpath"].ToString(); string sdkSN = configInfoRow["sdkSN"] == null ? "" : configInfoRow["sdkSN"].ToString(); string username = configInfoRow["username"] == null ? "" : configInfoRow["username"].ToString(); string password = configInfoRow["password"] == null ? "" : configInfoRow["password"].ToString(); string server = configInfoRow["server"] == null ? "" : configInfoRow["server"].ToString(); string dbName = configInfoRow["dbname"] == null ? "" : configInfoRow["dbname"].ToString(); string dbType = configInfoRow["dbtype"] == null ? "" : configInfoRow["dbtype"].ToString(); if (!String.IsNullOrEmpty(sdkPath)) { Util.Util.WriteAppSetting("sdkPath", sdkPath, false); } if (!String.IsNullOrEmpty(sdkSN)) { Util.Util.WriteAppSetting("sn", sdkSN, true); } if (!String.IsNullOrEmpty(server) && !String.IsNullOrEmpty(username) && !String.IsNullOrEmpty(password) && !String.IsNullOrEmpty(dbName) && dbType.Equals("1")) { //拼接连接字符串 Server=125.46.57.165;Database=waizhen;User ID=waizhen;Password=xyh!@#xyh string str = @"Server = " + server + "; Database = " + dbName + "; User ID = " + username + "; Password = "******"ConStr", str, true); } } else { MessageBox.Show("获取配置信息失败!"); this.DialogResult = DialogResult.Cancel; return; } } }
private void LoadUserInfo() { //如果是修改加载user信息 用户账号不允许修改 if (this.Owner is ConfigManager) { ConfigManager configManager = (ConfigManager)this.Owner; if (configManager.flag.Equals("2")) { ScanDataSet scandataset = new Business.ConfigInfo().GetConfigInfoByID(configManager.configID); if (scandataset.ConfigInfo.Rows.Count > 0) { configTable = scandataset.ConfigInfo; configRow = scandataset.ConfigInfo.Rows[0]; this.tbsite.Text = configRow["site"].ToString(); this.tbSDKPath.Text = configRow["sdkpath"].ToString(); this.tbSDKSN.Text = configRow["sdksn"].ToString(); this.cbDBType.SelectedValue = configRow["dbtype"].ToString(); this.tbServer.Text = configRow["server"].ToString(); this.tbUserName.Text = configRow["username"].ToString(); this.tbPassWord.Text = configRow["password"].ToString(); string status = configRow["status"].ToString(); switch (status) { case "1": this.StartRadioButton.Checked = true; break; case "0": this.ForbidRadioButton.Checked = true; break; default: this.StartRadioButton.Checked = true; break; } } else { MessageBox.Show("获取用户信息错误!"); return; } } } }
private void btnUpdateStatus_Click(object sender, EventArgs e) { //判断选中几行 try { int count = 0; bool result = false; for (int i = 0; i < this.dgvConfigInfo.Rows.Count; i++) { if (this.dgvConfigInfo.Rows[i].Cells[this.dgvConfigInfo.Columns["SelectCheck"].Index].EditedFormattedValue.ToString() == "True") { count++; this.configID = this.dgvConfigInfo.Rows[i].Cells["id"].Value.ToString(); string status = this.dgvConfigInfo.Rows[i].Cells["status"].Value.ToString(); ScanDataSet scanDataSet = new Business.ConfigInfo().GetConfigInfoByID(this.configID); if (scanDataSet.ConfigInfo.Rows.Count > 0) { ScanDataSet.ConfigInfoDataTable dt = scanDataSet.ConfigInfo; dt.Rows[0]["status"] = status == "1" ? "0" : "1"; result = new Business.ConfigInfo().AddConfig(dt); } } } if (count == 0) { MessageBox.Show("请选择要修改的行!"); return; } else if (count > 1) { MessageBox.Show("请选择一行修改记录!"); return; } if (result) { MessageBox.Show("更新成功!"); return; } } catch (Exception ex) { throw ex; } }
private void btnSearch_Click(object sender, EventArgs e) { //获取所选机构 GetOwnOrg(); //获取查询条件 string str = "and forgid='" + this.orgID + "'"; if (!String.IsNullOrEmpty(this.tbCondition.Text.Trim())) { str += " and (username like '%" + this.tbCondition.Text.Trim() + "%' or usercode like '%" + this.tbCondition.Text.Trim() + "%' )"; } ScanDataSet scanDataSet = new Business.ConfigInfo().GetConfigInfoByStr(str); if (scanDataSet.ConfigInfo.Rows.Count > 0) { dtInfo = scanDataSet.ConfigInfo; InitDataSet(); } }
private void btnSave_Click(object sender, EventArgs e) { try { //校验数据 CheckContent(); bool result; ConfigManager configManager; //判断是新增 or 修改 if (this.Owner is ConfigManager) { configManager = (ConfigManager)this.Owner; if (configManager.flag.Equals("1")) { configTable = new ScanDataSet.ConfigInfoDataTable(); configInfoRow = configTable.NewConfigInfoRow(); configInfoRow.Site = this.tbsite.Text.Trim(); configInfoRow.SdkPath = this.tbSDKPath.Text.Trim(); configInfoRow.SdkSn = this.tbSDKSN.Text.Trim(); configInfoRow.Forgid = ((ConfigManager)this.Owner).orgID; configInfoRow.Frcode = ((ConfigManager)this.Owner).frcode; configInfoRow.DbType = this.cbDBType.SelectedValue.ToString(); configInfoRow.Server = this.tbServer.Text.Trim(); configInfoRow.UserName = this.tbUserName.Text.Trim(); configInfoRow.PassWord = this.tbPassWord.Text.Trim(); configInfoRow.DbName = this.tbDBName.Text.Trim(); string status = ""; if (this.StartRadioButton.Checked) { status = "1"; } if (this.ForbidRadioButton.Checked) { status = "0"; } configInfoRow.Status = status; configTable.AddConfigInfoRow(configInfoRow); result = new Business.ConfigInfo().AddConfig(configTable); } else if (configManager.flag.Equals("2")) { ScanDataSet scandataset = new Business.ConfigInfo().GetConfigInfoByID(configManager.configID); if (scandataset.ConfigInfo.Rows.Count > 0) { configTable = scandataset.ConfigInfo; configRow = scandataset.ConfigInfo.Rows[0]; configRow["site"] = this.tbsite.Text.Trim(); configRow["sdkpath"] = this.tbSDKPath.Text.Trim(); configRow["sdksn"] = this.tbSDKSN.Text.Trim(); configRow["dbtype"] = this.cbDBType.SelectedValue.ToString(); configRow["server"] = this.tbServer.Text.Trim(); configRow["username"] = this.tbUserName.Text.Trim(); configRow["password"] = this.tbPassWord.Text.Trim(); configRow["dbname"] = this.tbDBName.Text.Trim(); string status = ""; if (this.StartRadioButton.Checked) { status = "1"; } if (this.ForbidRadioButton.Checked) { status = "0"; } configRow["status"] = status; if (!String.IsNullOrEmpty(((ConfigManager)this.Owner).configID)) { configRow["id"] = ((ConfigManager)this.Owner).configID; } result = new Business.ConfigInfo().AddConfig(configTable); } else { MessageBox.Show("获取用户信息错误!"); return; } } else { MessageBox.Show("获取业务标记错误!"); return; } } else { MessageBox.Show("获取父窗口错误!"); return; } if (result) { MessageBox.Show("保存成功!"); configManager.SearchData(); this.Close(); return; } else { MessageBox.Show("保存失败!"); return; } } catch (Exception ex) { throw ex; } }