Exemplo n.º 1
0
 /// <summary>
 /// 可復寫,也可用dgv  事件
 /// </summary>
 public override void CellValidated(object sender, DataGridViewCellEventArgs e)
 {
     DataGridView dgv = (DataGridView)sender;
     if (dgv.Name.ToLower() == "dgview1")
     {
         if (e.ColumnIndex == this.Column2.Index)
         {
             //檢查是否有重複
             if (Exists(dgv))
             {
                 MessageBox.Show("對不起,此編號已經存在!", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information);
                 dgv.EditingControl.Text = "" + histroyValue;
                 dgv.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = histroyValue;
                 return;
             }
             Js.BLL.BaseDal dal = new Js.BLL.BaseDal("BU_Enterprise");
             string filter = string.Format("EnterpriseID='{0}'", dgv.Rows[e.RowIndex].Cells[e.ColumnIndex].Value);
             DataTable dt = dal.GetRecord(filter);
             if (dt.Rows.Count > 0)
             {
                 dgv.Rows[e.RowIndex].Cells[this.Column3.Index].Value = dt.Rows[0]["EnterpriseName"].ToString();
             }
         }
     }
 }
Exemplo n.º 2
0
 private void BindComboBox()
 {
     Js.BLL.BaseDal dal = new Js.BLL.BaseDal(FormID);
     DataTable dt = dal.GetDistinctRecord("ManageGroup");
     this.cmbManageGroup.DataSource = dt;
     this.cmbManageGroup.DisplayMember = "ManageGroup";
     this.cmbManageGroup.ValueMember = "ManageGroup";
 }
Exemplo n.º 3
0
        private void btnCheck_Click(object sender, EventArgs e)
        {
            DataRow dr = dt.Rows[0];
            Js.BLL.BaseDal dal = new Js.BLL.BaseDal(FormID);

            if (this.txtCheckUserName.Text.Length > 0)
            {
                dr["CheckUserName"] = "";
                dr["CheckDate"] = DBNull.Value;
                this.btnCheck.Text = "營運覆核";
            }
            else
            {
                dr["CheckUserName"] = Js.Com.User.UserID;
                dr["CheckDate"] = DateTime.Now;
                this.btnCheck.Text = "取消覆核";
            }
            dal.Update(dr, this.txtSQLServer.Text);

            BindData(dt);
        }
Exemplo n.º 4
0
 private void frmLabelNoDbView_Load(object sender, EventArgs e)
 {
     Js.BLL.BaseDal dal = new Js.BLL.BaseDal(FormID);
     string filter = string.Format("DbName='{0}'", DbName);
        dt = dal.GetRecord(filter);
     BindData(dt);
 }
Exemplo n.º 5
0
        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 (this.dataGridView1.Rows[this.dataGridView1.CurrentRow.Index].Cells[9].Value.ToString().Length >0)
            {
                MessageBox.Show("除企業管理員[" + KeyValue + "]之資料已經覆核,不能刪除!", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;

            }
            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);
                SetBtnEnabled("");
            }
        }
Exemplo n.º 6
0
        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("");
            }
        }
Exemplo n.º 7
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (this.txtUserName.Text.Trim() == "")
            {
                MessageBox.Show("請輸入登入帳號!", "存檔", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.txtUserName.Focus();
                return;
            }
            if (dtsub[0].Rows.Count <= 0)
            {
                MessageBox.Show("明細不能為空!", "存檔", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            for (int i = 0; i < dgView1.Rows.Count; i++)
            {
                if (dgView1.Rows[i].IsNewRow)
                    continue;
                if (dgView1.Rows[i].Cells[1].Value.ToString().Trim() == "")
                {
                    MessageBox.Show("企業編號不能為空!", "存檔", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                else if(dgView1.Rows[i].Cells[2].Value.ToString().Trim() == "")
                {
                    MessageBox.Show("企業編號不存在!", "存檔", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
            }

            Js.BLL.BaseDal dal = new Js.BLL.BaseDal(FormID);
            if (UserName.Length > 0 && this.txtUserName.Text.Trim() != UserName || UserName.Length <= 0)
            {
                if (dal.Exists(this.txtUserName.Text.Trim()))
                {
                    MessageBox.Show("此登入帳號已經存在,請選取其他登入帳號!", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
            }
            DataTable dt = dal.GetRecord("1=1");
            DataRow dr = dt.NewRow();
            dr["UserName"] = this.txtUserName.Text.Trim();
            dr["PersonName"] = this.txtPersonName.Text.Trim();
            dr["PersonID"] = this.txtPersonID.Text.Trim();

            dr["CreateUserName"] = Js.Com.User.UserID;
            if (UserName.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 (UserName.Length > 0)
                dal.Update(dr, UserName);
            else
                dal.Add(dr);
            dgView1.Update();

            for (int i = 0; i < dtsub[0].Rows.Count; i++)
            {
                if (dgView1.Rows[i].IsNewRow)
                {
                    dtsub[0].Rows.RemoveAt(i);
                }
                else
                {
                    dtsub[0].Rows[i]["UserName"] = this.txtUserName.Text;
                }
            }
            dal.SaveDetail(dtsub, UserName);

            this.DialogResult = System.Windows.Forms.DialogResult.OK;
        }
Exemplo n.º 8
0
        private void txtUserName_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                this.txtUserName.Text = this.txtUserName.Text.Trim();
                Js.BLL.BaseDal dal = new Js.BLL.BaseDal("BU_User");
                string filter = string.Format("UserName='******'", this.txtUserName.Text);
                DataTable dt = dal.GetRecord(filter);

                if (dt.Rows.Count > 0)
                {
                    this.txtUserName.Text = dt.Rows[0]["UserName"].ToString();
                    this.txtPersonID.Text = dt.Rows[0]["PersonID"].ToString();
                    this.txtPersonName.Text = dt.Rows[0]["PersonName"].ToString();
                }
            }
        }
Exemplo n.º 9
0
        private void frmUserManagerEdit_Load(object sender, EventArgs e)
        {
            Js.BLL.BaseDal dal = new Js.BLL.BaseDal(FormID);
            if (UserName.Length > 0)
            {
                string filter = string.Format("UserName='******'", UserName);
                DataTable dt = dal.GetRecord(filter);
                BindData(dt);
            }
            else
            {
                this.txtLastModifyUserName.Text = Js.Com.User.UserID;
                this.txtLastModifyDate.Text = DateTime.Now.ToString("yyyy/MM/dd HH:mm");
                this.txtCreateUserName.Text = Js.Com.User.UserID;
                this.txtCreateDate.Text = DateTime.Now.ToString("yyyy/MM/dd HH:mm");
            }

            dtsub = new DataTable[1];
            dtsub[0] = dal.GetSubDetail(this.txtUserName.Text.Trim()).Tables[0];
            BindGridEventDoFormat();
            BindGridView();
            dgView1.Columns[2].ReadOnly = true;
        }
Exemplo n.º 10
0
        private void txtEnterpriseID_TextChanged(object sender, EventArgs e)
        {
            this.txtEnterpriseID.Text = this.txtEnterpriseID.Text.Trim();
            Js.BLL.BaseDal dal = new Js.BLL.BaseDal("BU_Enterprise");
            string filter = string.Format("EnterpriseID='{0}'", this.txtEnterpriseID.Text);
            DataTable dt = dal.GetViewRecord(filter);
            if (dt.Rows.Count > 0)
            {

                this.txtEnterpriseName.Text = dt.Rows[0]["EnterpriseName"].ToString();
                filter = string.Format("EnterpriseID='{0}' and EnterpriseID not in (select distinct EnterpriseID from Com_EnterpriseDb)", this.txtEnterpriseID.Text);
                dt = dal.GetViewRecord(filter);
                if (dt.Rows.Count == 0 && EnterpriseID.Length==0)
                {
                    blnExists = false;
                    this.txtEnterpriseName.Text = "";
                    MessageBox.Show("該企業編號已經建立數據庫,請輸入正確的企業編號!", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            else
            {
                blnExists = false;
                MessageBox.Show("企業編號不存在,請輸入正確的企業編號!",Application.ProductName,MessageBoxButtons.OK,MessageBoxIcon.Information);
            }
        }
Exemplo n.º 11
0
 private void frmfrmEnterpriseDbEdit_Load(object sender, EventArgs e)
 {
     BindComboBox();
     if (EnterpriseID.Length>0)
     {
         Js.BLL.BaseDal dal = new Js.BLL.BaseDal(FormID);
         string filter = string.Format("EnterpriseID='{0}'", EnterpriseID);
         DataTable dt = dal.GetRecord(filter);
         BindData(dt);
     }
     else
     {
         this.txtState.Text = "未開立";
         this.txtLastModifyUserName.Text = Js.Com.User.UserID;
         this.txtLastModifyDate.Text = DateTime.Now.ToString("yyyy/MM/dd HH:mm");
         this.txtCreateUserName.Text = Js.Com.User.UserID;
         this.txtCreateDate.Text = DateTime.Now.ToString("yyyy/MM/dd HH:mm");
     }
 }
Exemplo n.º 12
0
        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;
        }