private void btnOK_Click(object sender, EventArgs e) { if (txtServer.Text.Trim() == "") { MessageBox.Show("請輸入資料庫Server名稱﹒然後再試一次﹒", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (rbtDataSQL.Checked) { if (txtUid.Text.Trim() == "") { MessageBox.Show("請輸入資料庫使用者名稱﹒然後再試一次﹒", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); return; } } Js.BLL.Sys.SysComDal bll = new Js.BLL.Sys.SysComDal(); string strCn = bll.GetConnection(this.txtServer.Text, DataBase, this.txtUid.Text, this.txtPwd.Text, this.rbtDataWind.Checked); if (strCn.Length > 0) { Js.Com.ConfigHelper.SetKeyValue(System.Windows.Forms.Application.ExecutablePath, "BusinessUnit", Js.Com.DEncrypt.DESEncrypt.Encrypt(strCn)); Js.Com.User.ConnectStringBU = strCn; Js.Com.User.ServerBU = txtServer.Text.Trim(); Js.Com.User.UidBU = txtUid.Text.Trim(); Js.Com.User.PwdBU = this.txtPwd.Text.Trim(); Js.Com.User.AuthenticationBU = this.rbtDataWind.Checked; this.DialogResult = DialogResult.OK; } else { MessageBox.Show("因在初始化提供者時遭遇錯誤,系統登錄失敗.。", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void BindComboBox() { Js.BLL.Sys.SysComDal dal = new Js.BLL.Sys.SysComDal(); DataTable dt = dal.SearchTable(FormID, false).Tables[0]; this.cmbField.DataSource = dt; this.cmbField.DisplayMember = "FieldCName"; this.cmbField.ValueMember = "FieldName"; }
private void btnConnect_Click(object sender, EventArgs e) { if (txtServer.Text.ToLower() == "local" || txtServer.Text == ".") txtServer.Text = "(local)"; Js.BLL.Sys.SysComDal bll = new Js.BLL.Sys.SysComDal(); if (bll.OpenConnection(this.txtServer.Text, DataBase, this.txtUid.Text, this.txtPwd.Text, this.rbtDataWind.Checked)) { MessageBox.Show("測試連接成功!", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("因在初始化提供者時遭遇錯誤,測試連接失敗。", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// 綁定GirdView /// </summary> /// <param name="pageIndex"></param> private void BindGridView(int pageIndex) { BindCount++; Js.BLL.Sys.SysComDal dal = new Js.BLL.Sys.SysComDal(); DataSet ds = new DataSet(); int RecordCount, PageCount; //dtData = dal.SelectTable(FormID, pageIndex, strWhere, PageSize, "", out PageCount, out RecordCount).Tables[0]; dtData = dal.GetSearchSelectSQL(FormID, pageIndex, strWhere, PageSize, out PageCount, out RecordCount).Tables[0]; if (CurrentPage == 0) CurrentPage = PageCount; if (RecordCount != 0) { this.btnLast.Enabled = true; this.btnFirst.Enabled = true; this.btnToPage.Enabled = true; if (CurrentPage > 1) this.btnPre.Enabled = true; else this.btnPre.Enabled = false; if (CurrentPage < PageCount) this.btnNext.Enabled = true; else this.btnNext.Enabled = false; lblCurrentPage.Visible = true; lblCurrentPage.Text = "共 [" + RecordCount.ToString() + "] 筆記錄 第 [" + CurrentPage.ToString() + "] 頁 共 [" + PageCount.ToString() + "] 頁"; } else { this.btnFirst.Enabled = false; this.btnPre.Enabled = false; this.btnNext.Enabled = false; this.btnLast.Enabled = false; this.btnToPage.Enabled = false; lblCurrentPage.Visible = false; } this.dataGridView1.DataSource = dtData.DefaultView; if(BindCount==1) dtSelect = dtData.Clone(); }
private void btnDelete_Click(object sender, EventArgs e) { if (this.dataGridView1.CurrentRow.Index < 0) return; string KeyValue = this.dataGridView1.Rows[this.dataGridView1.CurrentRow.Index].Cells[2].Value.ToString(); if (MessageBox.Show("您確定要刪除企業用戶[" + KeyValue + "]之資料嗎?", Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes) { Js.BLL.BaseDal dal = new Js.BLL.BaseDal(FormID); dal.Delete(KeyValue); Js.BLL.Sys.SysComDal dalnew = new Js.BLL.Sys.SysComDal(); dalnew.DeleteDataBase(this.dataGridView1.Rows[this.dataGridView1.CurrentRow.Index].Cells[4].Value.ToString(), this.dataGridView1.Rows[this.dataGridView1.CurrentRow.Index].Cells[7].Value.ToString()); SetBtnEnabled(""); } }
private void btnConnect_Click(object sender, EventArgs e) { if (this.txtEnterpriseID.Text.Trim() == "") { MessageBox.Show("請輸入企業編號!", "存檔", MessageBoxButtons.OK, MessageBoxIcon.Information); this.txtEnterpriseID.Focus(); return; } if (this.txtSQLServer.Text.Trim() == "") { MessageBox.Show("請輸入SQL Server名稱!", "存檔", MessageBoxButtons.OK, MessageBoxIcon.Information); this.txtSQLServer.Focus(); return; } Js.BLL.Sys.SysComDal dal = new Js.BLL.Sys.SysComDal(); if (dal.OpenConnection(this.txtSQLServer.Text, "master", "", "", true)) MessageBox.Show("測試連接成功!", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information); else MessageBox.Show("因在初始化提供者時遭遇錯誤,測試連接失敗。", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information); }
private void btnSave_Click(object sender, EventArgs e) { if (this.txtEnterpriseID.Text.Trim() == "") { MessageBox.Show("請輸入企業編號!", "存檔", MessageBoxButtons.OK, MessageBoxIcon.Information); this.txtEnterpriseID.Focus(); return; } if (this.txtSQLServer.Text.Trim() == "") { MessageBox.Show("請輸入SQL Server名稱!", "存檔", MessageBoxButtons.OK, MessageBoxIcon.Information); this.txtSQLServer.Focus(); return; } if (this.txtDbDataPath.Text.Trim() == "") { MessageBox.Show("請輸入資料庫存放路徑!", "存檔", MessageBoxButtons.OK, MessageBoxIcon.Information); this.txtDbDataPath.Focus(); return; } //Js.BLL.Sys.SysComDal sdal = new Js.BLL.Sys.SysComDal(); //if (!sdal.OpenConnection(this.txtSQLServer.Text, this.txtDbName.Text, "", "", true)) //{ // MessageBox.Show("因在初始化提供者時遭遇錯誤,測試連接失敗。", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information); // return; //} if(!System.IO.Directory.Exists(this.txtDbDataPath.Text.Trim())) { MessageBox.Show("資料庫路徑不存在或無法存取,請確認!", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information); return; } Js.BLL.BaseDal dal = new Js.BLL.BaseDal(FormID); if (EnterpriseID.Length > 0 && this.txtEnterpriseID.Text.Trim() != EnterpriseID || EnterpriseID.Length <= 0) { if (dal.Exists(this.txtEnterpriseID.Text.Trim())) { MessageBox.Show("此企業編號已經存在,請選取其他企業編號!", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information); return; } } if (!blnExists) { MessageBox.Show("此企業編號不存在,請選取其他企業編號!", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information); return; } Js.BLL.Sys.SysComDal SysComDal = new Js.BLL.Sys.SysComDal(); if (!SysComDal.OpenConnection(this.txtSQLServer.Text, "master", "", "", true)) { MessageBox.Show("因在初始化提供者時遭遇錯誤,測試連接失敗。", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information); return; } DataTable dt = dal.GetRecord("1=1"); DataRow dr = dt.NewRow(); dr["EnterpriseID"] = this.txtEnterpriseID.Text.Trim(); dr["EnterpriseName"] = this.txtEnterpriseName.Text.Trim(); dr["SQLServer"] = this.txtSQLServer.Text.Trim(); dr["DbDataPath"] = this.txtDbDataPath.Text.Trim(); dr["DbName"] = "SD" + this.txtEnterpriseID.Text.Trim(); dr["UserName"] = "******"; //if (this.txtState.Text == "未啟用") dr["State"] = 0; //else // dr["State"] = 1; dr["ManageGroup"] = this.cmbManageGroup.Text; dr["Memo"] = this.txtMemo.Text.Trim(); dr["CreateUserName"] = Js.Com.User.UserID; if (EnterpriseID.Length > 0) dr["CreateDate"] = this.txtCreateDate.Text; else dr["CreateDate"] = DateTime.Now.ToString("yyyy/MM/dd HH:mm"); dr["LastModifyUserName"] = Js.Com.User.UserID; dr["LastModifyDate"] = DateTime.Now.ToString("yyyy/MM/dd HH:mm"); dr["CheckUserName"] = this.txtCheckUserName.Text; if (this.txtCheckDate.Text.Length > 0) dr["CheckDate"] = this.txtCheckDate.Text; if (EnterpriseID.Length > 0) dal.Update(dr, EnterpriseID); else dal.Add(dr); this.DialogResult = System.Windows.Forms.DialogResult.OK; }
private void frmConnection_Load(object sender, EventArgs e) { string strCn = Js.Com.DEncrypt.DESEncrypt.Decrypt(Js.Com.ConfigHelper.GetAppConfigValue(Application.ExecutablePath, "BusinessUnit")); if (Js.Com.ConfigHelper.GetAppConfigValue(Application.ExecutablePath, "LinkedOption") == "1") rbtDataSQL.Checked = true; else rbtDataWind.Checked = true; Js.BLL.Sys.SysComDal bll = new Js.BLL.Sys.SysComDal(); if (bll.OpenConnection(this.txtServer.Text, DataBase, this.txtUid.Text, this.txtPwd.Text, this.rbtDataWind.Checked)) { Js.Com.User.ServerBU = txtServer.Text.Trim(); Js.Com.User.UidBU = txtUid.Text.Trim(); Js.Com.User.PwdBU = this.txtPwd.Text.Trim(); Js.Com.User.AuthenticationBU = this.rbtDataWind.Checked; this.DialogResult = DialogResult.OK; return; } }