Example #1
0
        private bool pmCheckHasUsed(string inRowID, string inCode, ref string ioErrorMsg)
        {
            WS.Data.Agents.cDBMSAgent objSQLHelper = new WS.Data.Agents.cDBMSAgent(App.ERPConnectionString, App.DatabaseReside);
            Business.Entity.QMasterUM QRefChild    = new QMasterUM(App.ConnectionString, App.DatabaseReside);
            bool bllHasUsed = QRefChild.HasUsedChildTable(objSQLHelper, inCode, ref ioErrorMsg);

            if (bllHasUsed)
            {
                ioErrorMsg = "äÁèÊÒÁÒöź¢éÍÁÙÅä´éà¹×èͧ¨Ò¡ÁÕ¡ÒÃÍéÒ§ÍÔ§¶Ö§ã¹ " + ioErrorMsg;
            }
            return(bllHasUsed);
        }
Example #2
0
            override protected void OnInitComponent()
            {
                this.mobjTabRefer = new QMasterUM(App.ConnectionString, App.DatabaseReside);

                this.AddSearchKey("ÃËÑÊ", "CCODE");
                this.AddSearchKey("ª×èÍ", "CNAME");
                base.OnInitComponent();

                this.mstrSearchVal = "";
                this.mstrSearchKey = "CCODE";
                this.pmSetBrowView();
                this.pmInitGridProp();
            }
Example #3
0
        private void pmUpdateRecord()
        {
            string strErrorMsg = "";
            bool   bllIsNewRow = false;
            bool   bllIsCommit = false;

            WS.Data.Agents.cDBMSAgent objSQLHelper = new WS.Data.Agents.cDBMSAgent(App.ConnectionString, App.DatabaseReside);

            DataRow dtrSaveInfo = this.dtsDataEnv.Tables[this.mstrRefTable].NewRow();

            if (this.mFormEditMode == UIHelper.AppFormState.Insert ||
                (objSQLHelper.SetPara(new object[] { this.mstrEditRowID }) &&
                 !objSQLHelper.SQLExec(ref this.dtsDataEnv, "QChkRow", this.mstrRefTable, "select cRowID from " + this.mstrRefTable + " where cRowID = ?", ref strErrorMsg)))
            {
                bllIsNewRow = true;
                if (this.mstrEditRowID == string.Empty)
                {
                    WS.Data.Agents.cConn objConn = WS.Data.Agents.cConn.GetInStance();
                    this.mstrEditRowID = objConn.RunRowID(this.mstrRefTable);
                }
                dtrSaveInfo["cCreateBy"] = App.FMAppUserID;
            }

            dtrSaveInfo["cRowID"]     = this.mstrEditRowID;
            dtrSaveInfo["cCode"]      = this.txtCode.Text.TrimEnd();
            dtrSaveInfo["cName"]      = this.txtName.Text.TrimEnd();
            dtrSaveInfo["cFChr"]      = AppUtil.StringHelper.GetFChr(this.txtName.Text.TrimEnd());
            dtrSaveInfo["cName2"]     = this.txtName2.Text.TrimEnd();
            dtrSaveInfo["cLastUpdBy"] = App.FMAppUserID;
            dtrSaveInfo["dLastUpd"]   = objSQLHelper.GetDBServerDateTime();;

            this.mSaveDBAgent       = new WS.Data.Agents.cDBMSAgent(App.ConnectionString, App.DatabaseReside);
            this.mSaveDBAgent.AppID = App.AppID;
            this.mdbConn            = this.mSaveDBAgent.GetDBConnection();

            this.mSaveDBAgent2       = new WS.Data.Agents.cDBMSAgent(App.ERPConnectionString, App.DatabaseReside);
            this.mSaveDBAgent2.AppID = App.AppID;
            this.mdbConn2            = this.mSaveDBAgent2.GetDBConnection();

            try
            {
                this.mdbConn.Open();
                this.mdbTran = this.mdbConn.BeginTransaction(IsolationLevel.ReadUncommitted);

                this.mdbConn2.Open();
                this.mdbTran2 = this.mdbConn2.BeginTransaction(IsolationLevel.ReadUncommitted);

                string   strSQLUpdateStr = "";
                object[] pAPara          = null;
                cDBMSAgent.GenUpdateSQLString(dtrSaveInfo, "CROWID", bllIsNewRow, ref strSQLUpdateStr, ref pAPara);

                this.mSaveDBAgent.BatchSQLExec(strSQLUpdateStr, pAPara, ref strErrorMsg, this.mdbConn, this.mdbTran);

                Business.Entity.QMasterUM QRefChild = new QMasterUM(App.ConnectionString, App.DatabaseReside);
                QRefChild.SetSaveDBAgent(this.mSaveDBAgent, this.mdbConn, this.mdbTran);
                QRefChild.SetSaveDBAgent2(this.mSaveDBAgent2, this.mdbConn2, this.mdbTran2);
                QRefChild.SaveChildTable(dtrSaveInfo, this.mstrOldCode);

                this.mdbTran.Commit();
                this.mdbTran2.Commit();
                bllIsCommit = true;

                if (this.mFormEditMode == UIHelper.AppFormState.Insert)
                {
                    KeepLogAgent.KeepLog(objSQLHelper, KeepLogType.Insert, TASKNAME, this.txtCode.Text, this.txtName.Text, App.FMAppUserID, App.AppUserName);
                }
                else if (this.mFormEditMode == UIHelper.AppFormState.Edit)
                {
                    if (this.mstrOldCode == this.txtCode.Text && this.mstrOldName == this.txtName.Text)
                    {
                        KeepLogAgent.KeepLog(objSQLHelper, KeepLogType.Update, TASKNAME, this.txtCode.Text, this.txtName.Text, App.FMAppUserID, App.AppUserName);
                    }
                    else
                    {
                        KeepLogAgent.KeepLogChgValue(objSQLHelper, KeepLogType.Update, TASKNAME, this.txtCode.Text, this.txtName.Text, App.FMAppUserID, App.AppUserName, this.mstrOldCode, this.mstrOldName);
                    }
                }
            }
            catch (Exception ex)
            {
                if (!bllIsCommit)
                {
                    this.mdbTran.Rollback();
                    this.mdbTran2.Rollback();
                }
                App.WriteEventsLog(ex);
#if xd_RUNMODE_DEBUG
                MessageBox.Show("Message : " + ex.Message + "\n" + ex.Source + "\n" + ex.StackTrace);
#endif
            }

            finally
            {
                this.mdbConn.Close();
                this.mdbConn2.Close();
            }
        }
Example #4
0
        private bool pmDeleteRow(string inRowID, string inCode, string inName, ref string ioErrorMsg)
        {
            bool bllIsCommit = false;
            bool bllResult   = false;

            this.mSaveDBAgent       = new WS.Data.Agents.cDBMSAgent(App.ConnectionString, App.DatabaseReside);
            this.mSaveDBAgent.AppID = App.AppID;
            this.mdbConn            = this.mSaveDBAgent.GetDBConnection();

            this.mSaveDBAgent2       = new WS.Data.Agents.cDBMSAgent(App.ERPConnectionString, App.DatabaseReside);
            this.mSaveDBAgent2.AppID = App.AppID;
            this.mdbConn2            = this.mSaveDBAgent2.GetDBConnection();

            try
            {
                this.mdbConn.Open();
                this.mdbTran = this.mdbConn.BeginTransaction(IsolationLevel.ReadUncommitted);

                this.mdbConn2.Open();
                this.mdbTran2 = this.mdbConn2.BeginTransaction(IsolationLevel.ReadUncommitted);

                string strErrorMsg = "";

                //Delete Child Table
                Business.Entity.QMasterUM QRefChild = new QMasterUM(App.ConnectionString, App.DatabaseReside);
                QRefChild.SetSaveDBAgent(this.mSaveDBAgent, this.mdbConn, this.mdbTran);
                QRefChild.SetSaveDBAgent2(this.mSaveDBAgent2, this.mdbConn2, this.mdbTran2);
                QRefChild.DeleteChildTable(inCode);

                object[] pAPara = new object[1] {
                    inRowID
                };
                this.mSaveDBAgent.BatchSQLExec("delete from " + this.mstrRefTable + " where cRowID = ?", pAPara, ref strErrorMsg, this.mdbConn, this.mdbTran);

                this.mdbTran.Commit();
                this.mdbTran2.Commit();
                bllIsCommit = true;

                WS.Data.Agents.cDBMSAgent objSQLHelper = new WS.Data.Agents.cDBMSAgent(App.ConnectionString, App.DatabaseReside);
                KeepLogAgent.KeepLog(objSQLHelper, KeepLogType.Delete, TASKNAME, inCode, inName, App.FMAppUserID, App.AppUserName);

                bllResult = true;
            }
            catch (Exception ex)
            {
                ioErrorMsg = ex.Message;
                bllResult  = false;

                if (!bllIsCommit)
                {
                    this.mdbTran.Rollback();
                    this.mdbTran2.Rollback();
                }
                App.WriteEventsLog(ex);
            }
            finally
            {
                this.mdbConn.Close();
                this.mdbConn2.Close();
            }
            return(bllResult);
        }