Exemple #1
0
 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);
     }
 }
        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;
        }
Exemple #4
0
        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;
            }
        }