Пример #1
0
        private static void pmSaveKeepLog(WS.Data.Agents.cDBMSAgent inSQLHelper, Entity.KeepLogType inType, string inTaskName, string inCode, string inName, string inAppUser, string inLoginName, string inOldCode, string inOldName)
        {
            string strErrorMsg = "";

            WS.Data.Agents.cDBMSAgent objSQLHelper = inSQLHelper;
            objSQLHelper.SetPara(new object[] { inTaskName });
            if (objSQLHelper.SQLExec(ref KeepLogAgent.dtsDataEnv, "QAppObj", MapTable.Table.AppObj, "select * from " + MapTable.Table.AppObj + " where cTaskName = ?", ref strErrorMsg))
            {
                DataRow dtrAppObj   = KeepLogAgent.dtsDataEnv.Tables["QAppObj"].Rows[0];
                string  strMenuName = dtrAppObj["cText"].ToString();
                string  strUpdType  = "";
                switch (inType)
                {
                case Entity.KeepLogType.Insert:
                    strUpdType = BusinessEnum.gc_KEEPLOG_TYPE_INSERT;
                    break;

                case Entity.KeepLogType.Update:
                    strUpdType = BusinessEnum.gc_KEEPLOG_TYPE_UPDATE;
                    break;

                case Entity.KeepLogType.Delete:
                    strUpdType = BusinessEnum.gc_KEEPLOG_TYPE_DELETE;
                    break;

                case Entity.KeepLogType.LogIn:
                    strUpdType = BusinessEnum.gc_KEEPLOG_TYPE_LOG_IN;
                    break;

                case Entity.KeepLogType.LogOut:
                    strUpdType = BusinessEnum.gc_KEEPLOG_TYPE_LOG_OUT;
                    break;
                }

                DataRow dtrSaveInfo = null;
                objSQLHelper.SQLExec(ref KeepLogAgent.dtsDataEnv, mstrRefTable, mstrRefTable, "select * from " + mstrRefTable + " where 0=1", ref strErrorMsg);

                dtrSaveInfo = KeepLogAgent.dtsDataEnv.Tables[mstrRefTable].NewRow();
                WS.Data.Agents.cConn objConn = WS.Data.Agents.cConn.GetInStance();

                dtrSaveInfo["cRowID"]     = objConn.RunRowID(mstrRefTable);
                dtrSaveInfo["cType"]      = strUpdType;
                dtrSaveInfo["cTaskName"]  = inTaskName;
                dtrSaveInfo["cMenuName"]  = strMenuName.TrimEnd();
                dtrSaveInfo["cCode"]      = inCode;
                dtrSaveInfo["cName"]      = inName;
                dtrSaveInfo["cOldCode"]   = inOldCode;
                dtrSaveInfo["cOldName"]   = inOldName;
                dtrSaveInfo["cLoginName"] = inLoginName;
                dtrSaveInfo["cCreateBy"]  = inAppUser;

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

                objSQLHelper.SetPara(pAPara);
                objSQLHelper.SQLExec(strSQLUpdateStr, ref strErrorMsg);
            }
        }
Пример #2
0
        private bool pmSaveChildTable(DataRow inMaster, string inOldCode, string inDeptCode)
        {
            string strErrorMsg  = "";
            string strEditRowID = "";

            object[] pAPara      = null;
            bool     bllIsNewRow = false;
            DataRow  dtrSaveInfo = null;

            if (this.mSaveDBAgent2.BatchSQLExec(ref this.dtsDataEnv, "QCorp", MapTable.Table.Corp, "select fcSkid, fcCode, fcName from " + MapTable.Table.Corp, null, ref strErrorMsg, this.mdbConn2, this.mdbTran2))
            {
                foreach (DataRow dtrCorp in this.dtsDataEnv.Tables["QCorp"].Rows)
                {
                    UIBase.WaitWind("¡ÓÅѧºÑ¹·Ö¡¢éÍÁÙźÃÔÉÑ· (" + dtrCorp["fcSkid"].ToString().TrimEnd() + ")");
                    string strSeekCode = (inOldCode.TrimEnd() == "" ? inMaster["cCode"].ToString() : inOldCode);
                    pAPara = new object[] { dtrCorp["fcSkid"].ToString(), strSeekCode.TrimEnd() };
                    if (!this.mSaveDBAgent2.BatchSQLExec(ref this.dtsDataEnv, this.mstrRefChildTable, this.mstrRefChildTable, "select * from " + this.mstrRefChildTable + " where " + this.mstrSQLPrefix2, pAPara, ref strErrorMsg, this.mdbConn2, this.mdbTran2))
                    {
                        //Insert Child Record
                        bllIsNewRow = true;
                        WS.Data.Agents.cConn objConn = WS.Data.Agents.cConn.GetInStance();
                        strEditRowID = objConn.RunRowID(this.mstrRefChildTable);
                        dtrSaveInfo  = this.dtsDataEnv.Tables[this.mstrRefChildTable].NewRow();
                        //dtrSaveInfo["fcCreateBy"] = App.FMAppUserID;
                    }
                    else
                    {
                        //Update Child Record
                        dtrSaveInfo  = this.dtsDataEnv.Tables[this.mstrRefChildTable].Rows[0];
                        strEditRowID = dtrSaveInfo["fcSkid"].ToString();
                        bllIsNewRow  = false;
                    }

                    string strDept = "";
                    pAPara = new object[] { dtrCorp["fcSkid"].ToString(), inDeptCode.TrimEnd() };
                    if (this.mSaveDBAgent2.BatchSQLExec(ref this.dtsDataEnv, "QDept", "DEPT", "select * from DEPT where fcCorp = ? and fcCode = ?", pAPara, ref strErrorMsg, this.mdbConn2, this.mdbTran2))
                    {
                        strDept = this.dtsDataEnv.Tables["QDept"].Rows[0]["fcSkid"].ToString();
                    }

                    dtrSaveInfo["fcSkid"]     = strEditRowID;
                    dtrSaveInfo["fcCorp"]     = dtrCorp["fcSkid"].ToString();
                    dtrSaveInfo["fcCode"]     = inMaster["cCode"].ToString().TrimEnd();
                    dtrSaveInfo["fcName"]     = inMaster["cName"].ToString().TrimEnd();
                    dtrSaveInfo["fcFChr"]     = inMaster["cFChr"].ToString().TrimEnd();
                    dtrSaveInfo["fcName2"]    = inMaster["cName2"].ToString().TrimEnd();
                    dtrSaveInfo["fcDept"]     = strDept;
                    dtrSaveInfo["fcCreateAp"] = this.mSaveDBAgent2.AppID;
                    dtrSaveInfo["ftLastUpd"]  = this.mSaveDBAgent2.GetDBServerDateTime();;
                    dtrSaveInfo["fcEAfterR"]  = "E";

                    string strSQLUpdateStr = "";
                    cDBMSAgent.GenUpdateSQLString(dtrSaveInfo, "fcSkid", bllIsNewRow, ref strSQLUpdateStr, ref pAPara);
                    this.mSaveDBAgent2.BatchSQLExec(strSQLUpdateStr, pAPara, ref strErrorMsg, this.mdbConn2, this.mdbTran2);
                }
            }
            return(true);
        }
Пример #3
0
        private void pmUpdateProcess_S1()
        {
            string strErrorMsg = "";

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

            string strSQLStr = "select * from Stock01 where cCorp = ? and cPdGrp = ? and dDate = ?";

            foreach (DataRow dtrSaleSum in this.dtsDataEnv.Tables[this.mstrTemPd].Rows)
            {
                string strRowID    = "";
                bool   bllIsNewRow = false;

                DataRow  dtrSaveInfo = null;
                DateTime dttDate     = Convert.ToDateTime(dtrSaleSum["dDate"]);
                objSQLHelper.SetPara(new object[] { App.gcCorp, dtrSaleSum["cPdGrp"].ToString(), dttDate.Date });
                if (!objSQLHelper.SQLExec(ref this.dtsDataEnv, this.mstrRefTable, this.mstrRefTable, strSQLStr, ref strErrorMsg))
                {
                    bllIsNewRow = true;
                    WS.Data.Agents.cConn objConn = WS.Data.Agents.cConn.GetInStance();
                    strRowID              = objConn.RunRowID(this.mstrRefTable);
                    dtrSaveInfo           = this.dtsDataEnv.Tables[this.mstrRefTable].NewRow();
                    dtrSaveInfo["cRowID"] = strRowID;
                }
                else
                {
                    dtrSaveInfo = this.dtsDataEnv.Tables[this.mstrRefTable].Rows[0];
                }

                dtrSaveInfo["cCorp"]  = App.gcCorp;
                dtrSaveInfo["dDate"]  = dttDate;
                dtrSaveInfo["cYear"]  = dtrSaleSum["cYear"].ToString();
                dtrSaveInfo["cPdGrp"] = dtrSaleSum["cPdGrp"].ToString();

                dtrSaveInfo["QcPdGrp"] = dtrSaleSum["cQcPdGrp"].ToString();
                dtrSaveInfo["QnPdGrp"] = dtrSaleSum["cQnPdGrp"].ToString();
                dtrSaveInfo["Qty_IN"]  = Convert.ToDecimal(dtrSaleSum["nQty_IN"]);
                dtrSaveInfo["Qty_Out"] = Convert.ToDecimal(dtrSaleSum["nQty_Out"]);
                dtrSaveInfo["Qty_Ret"] = Convert.ToDecimal(dtrSaleSum["nQty_Ret"]);

                dtrSaveInfo["Amt_IN"]  = Convert.ToDecimal(dtrSaleSum["nAmt_IN"]);
                dtrSaveInfo["Amt_Out"] = Convert.ToDecimal(dtrSaleSum["nAmt_Out"]);
                dtrSaveInfo["Amt_Ret"] = Convert.ToDecimal(dtrSaleSum["nAmt_Ret"]);

                string   strSQLUpdateStr = "";
                object[] pAPara          = null;
                cDBMSAgent.GenUpdateSQLString(dtrSaveInfo, "CROWID", bllIsNewRow, ref strSQLUpdateStr, ref pAPara);
                objSQLHelper.SetPara(pAPara);
                objSQLHelper.SQLExec(strSQLUpdateStr, ref strErrorMsg);
            }
        }
Пример #4
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 fcSkid from " + this.mstrRefTable + " where fcSkid = ?", 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["fcCorp"] = App.ActiveCorp.RowID;
            dtrSaveInfo["fcSkid"] = this.mstrEditRowID;
            dtrSaveInfo["fcType"] = "G";
            dtrSaveInfo["fcCode"] = this.txtCode.Text.TrimEnd();
            dtrSaveInfo["fcName"] = this.txtName.Text.TrimEnd();
            //dtrSaveInfo["cFChr"] = AppUtil.StringHelper.GetFChr(this.txtName.Text.TrimEnd());
            dtrSaveInfo["fcName2"] = 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, "FCSKID", 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();
            }
        }
Пример #5
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 fcSkid from " + this.mstrRefTable + " where fcSkid = ?", 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[MapTable.ShareField.CreateBy] = App.FMAppUserID;
                //dtrSaveInfo[MapTable.ShareField.CreateDate] = objSQLHelper.GetDBServerDateTime();
                dtrSaveInfo["FTDATETIME"] = objSQLHelper.GetDBServerDateTime();
                dtrSaveInfo["FTLASTUPD"]  = objSQLHelper.GetDBServerDateTime();
            }

            // Control Field ที่ทุก Form ต้องมี
            //dtrSaveInfo[MapTable.ShareField.RowID] = this.mstrEditRowID;
            //dtrSaveInfo[MapTable.ShareField.LastUpdateBy] = App.FMAppUserID;
            //dtrSaveInfo[MapTable.ShareField.LastUpdate] = objSQLHelper.GetDBServerDateTime();
            dtrSaveInfo[MapTable.ShareField.fcSkid] = this.mstrEditRowID;
            dtrSaveInfo["FTLASTUPD"] = objSQLHelper.GetDBServerDateTime();
            // Control Field ที่ทุก Form ต้องมี

            dtrSaveInfo[QCoorInfo.Field.CorpID] = App.ActiveCorp.RowID;
            dtrSaveInfo[QCoorInfo.Field.Code]   = this.txtCode.Text.TrimEnd();
            dtrSaveInfo[QCoorInfo.Field.Name]   = this.txtName.Text.TrimEnd();
            //dtrSaveInfo[QCoorInfo.Field.Addr1] = this.txtAddr11.Text.TrimEnd();
            //dtrSaveInfo[QCoorInfo.Field.Addr2] = this.txtAddr12.Text.TrimEnd();
            dtrSaveInfo[QCoorInfo.Field.Name2] = this.txtName2.Text.TrimEnd();

            dtrSaveInfo["fcSName"]  = this.txtSName.Text.TrimEnd();
            dtrSaveInfo["fcSName2"] = this.txtSName2.Text.TrimEnd();

            //dtrSaveInfo[QCoorInfo.Field.Addr12] = this.txtAddr21.Text.TrimEnd();
            //dtrSaveInfo[QCoorInfo.Field.Addr22] = this.txtAddr22.Text.TrimEnd();
            dtrSaveInfo[QCoorInfo.Field.TelNo] = this.txtTel.Text.TrimEnd();
            //dtrSaveInfo[QCoorInfo.Field.FaxNo] = this.txtFax.Text.TrimEnd();

            string gcTemStr01 = BizRule.SetMemData(this.txtAddr11.Text.Trim(), x_CMAd11);

            gcTemStr01 += BizRule.SetMemData(this.txtAddr21.Text.Trim(), x_CMAd21);
            //gcTemStr01 += BizRule.SetMemData(this.txtAddr31.Text.Trim(), x_CMAd31);
            gcTemStr01 += BizRule.SetMemData(this.txtAddr12.Text.Trim(), x_CMAd12);
            gcTemStr01 += BizRule.SetMemData(this.txtAddr22.Text.Trim(), x_CMAd22);
            //gcTemStr01 += BizRule.SetMemData(this.txtAddr32.Text.Trim(), x_CMAd32);
            gcTemStr01 += BizRule.SetMemData(this.txtTel.Text.Trim(), x_CMTel);
            gcTemStr01 += BizRule.SetMemData(this.txtFax.Text.Trim(), x_CMFax);
            gcTemStr01 += BizRule.SetMemData(this.txtTaxID.Text.Trim(), x_CMTaxId);

            string gcTemStr02, gcTemStr03, gcTemStr04, gcTemStr05, gcTemStr06;
            int    intVarCharLen = 500;

            gcTemStr02 = (gcTemStr01.Length > 0 ? StringHelper.SubStr(gcTemStr01, 1, intVarCharLen) : DBEnum.NullString);
            gcTemStr03 = (gcTemStr01.Length > intVarCharLen ? StringHelper.SubStr(gcTemStr01, intVarCharLen + 1, intVarCharLen) : DBEnum.NullString);
            gcTemStr04 = (gcTemStr01.Length > intVarCharLen * 2 ? StringHelper.SubStr(gcTemStr01, intVarCharLen * 2 + 1, intVarCharLen) : DBEnum.NullString);
            gcTemStr05 = (gcTemStr01.Length > intVarCharLen * 3 ? StringHelper.SubStr(gcTemStr01, intVarCharLen * 3 + 1, intVarCharLen) : DBEnum.NullString);
            gcTemStr06 = (gcTemStr01.Length > intVarCharLen * 4 ? StringHelper.SubStr(gcTemStr01, intVarCharLen * 4 + 1, intVarCharLen) : DBEnum.NullString);

            dtrSaveInfo["fmMemData"]  = gcTemStr02;
            dtrSaveInfo["fmMemData2"] = gcTemStr03;
            dtrSaveInfo["fmMemData3"] = gcTemStr04;
            dtrSaveInfo["fmMemData4"] = gcTemStr05;
            dtrSaveInfo["fmMemData5"] = gcTemStr06;
            dtrSaveInfo["fcIsSupp"]   = "Y";
            dtrSaveInfo["fcZip"]      = this.txtZip.Text.TrimEnd();

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

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

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

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

                this.mdbTran.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();
                }
                App.WriteEventsLog(ex);

#if xd_RUNMODE_DEBUG
                MessageBox.Show("Message : " + ex.Message + "\n" + ex.Source + "\n" + ex.StackTrace);
#endif
            }

            finally
            {
                this.mdbConn.Close();
            }
        }
Пример #6
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 fcSkid from " + this.mstrRefTable + " where fcSkid = ?", 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["fcCorp"]     = App.gcCorp;
            dtrSaveInfo["fcBranch"]   = this.mstrBranchID;
            dtrSaveInfo["fcSkid"]     = this.mstrEditRowID;
            dtrSaveInfo["fcRefType"]  = this.mstrRefType;
            dtrSaveInfo["fcCode"]     = this.txtCode.Text.TrimEnd();
            dtrSaveInfo["FCNAME"]     = this.txtName.Text.TrimEnd();
            dtrSaveInfo["FCNAME2"]    = this.txtName2.Text.TrimEnd();
            dtrSaveInfo["fcFChr"]     = AppUtil.StringHelper.GetFChr(this.txtName.Text.TrimEnd());
            dtrSaveInfo["cLastUpdBy"] = App.FMAppUserID;

            dtrSaveInfo["fcWHouse"] = this.txtQcWHouse.Tag.ToString();

            int    intSel  = this.cmbRunCodeType.SelectedIndex;
            string strType = "";

            switch (intSel)
            {
            case 0:
                strType = "1";
                break;

            case 1:
                strType = "2";
                break;

            case 2:
                strType = "3";
                break;
            }

            dtrSaveInfo["FCDOCRUNFM"] = strType;

            dtrSaveInfo["FTLASTEDIT"] = 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, "fcSkid", bllIsNewRow, ref strSQLUpdateStr, ref pAPara);

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

                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();
            }
        }
Пример #7
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[MapTable.ShareField.CreateBy]   = App.FMAppUserID;
                dtrSaveInfo[MapTable.ShareField.CreateDate] = objSQLHelper.GetDBServerDateTime();
            }

            // Control Field ·Õè·Ø¡ Form µéͧÁÕ
            dtrSaveInfo[MapTable.ShareField.RowID]        = this.mstrEditRowID;
            dtrSaveInfo[MapTable.ShareField.LastUpdateBy] = App.FMAppUserID;
            dtrSaveInfo[MapTable.ShareField.LastUpdate]   = objSQLHelper.GetDBServerDateTime();
            // Control Field ·Õè·Ø¡ Form µéͧÁÕ

            dtrSaveInfo[QBGTypeInfo.Field.CorpID] = App.ActiveCorp.RowID;
            dtrSaveInfo[QBGTypeInfo.Field.Code]   = this.txtCode.Text.TrimEnd();
            dtrSaveInfo[QBGTypeInfo.Field.Name]   = this.txtName.Text.TrimEnd();
            dtrSaveInfo[QBGTypeInfo.Field.Name2]  = this.txtName2.Text.TrimEnd();

            string strCateg = "";

            switch (this.cmbCateg.SelectedIndex)
            {
            case 0:
                strCateg = SysDef.gc_BGCHART_CATEG_HR;
                break;

            case 1:
                strCateg = SysDef.gc_BGCHART_CATEG_OPERATE;
                break;

            case 2:
                strCateg = SysDef.gc_BGCHART_CATEG_INVEST;
                break;

            case 3:
                strCateg = SysDef.gc_BGCHART_CATEG_SUPPORT;
                break;

            case 4:
                strCateg = SysDef.gc_BGCHART_CATEG_OTHER;
                break;
            }
            dtrSaveInfo[QBGTypeInfo.Field.Category] = strCateg;

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

            try
            {
                this.mdbConn.Open();
                this.mdbTran = this.mdbConn.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);

                this.mdbTran.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();
                }
                App.WriteEventsLog(ex);

#if xd_RUNMODE_DEBUG
                MessageBox.Show("Message : " + ex.Message + "\n" + ex.Source + "\n" + ex.StackTrace);
#endif
            }

            finally
            {
                this.mdbConn.Close();
            }
        }
Пример #8
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 fcSkid from " + this.mstrRefTable + " where fcSkid = ?", 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[MapTable.ShareField.CreateBy] = App.FMAppUserID;
                //dtrSaveInfo[MapTable.ShareField.CreateDate] = objSQLHelper.GetDBServerDateTime();
                dtrSaveInfo["FTLASTUPD"] = objSQLHelper.GetDBServerDateTime();
            }

            // Control Field ที่ทุก Form ต้องมี
            //dtrSaveInfo[MapTable.ShareField.RowID] = this.mstrEditRowID;
            //dtrSaveInfo[MapTable.ShareField.LastUpdateBy] = App.FMAppUserID;
            //dtrSaveInfo[MapTable.ShareField.LastUpdate] = objSQLHelper.GetDBServerDateTime();
            dtrSaveInfo[MapTable.ShareField.fcSkid] = this.mstrEditRowID;
            dtrSaveInfo["FTLASTUPD"] = objSQLHelper.GetDBServerDateTime();
            // Control Field ที่ทุก Form ต้องมี

            dtrSaveInfo[QEMSectInfo.Field.CorpID] = App.ActiveCorp.RowID;
            dtrSaveInfo[QEMSectInfo.Field.Code]   = this.txtCode.Text.TrimEnd();
            dtrSaveInfo[QEMSectInfo.Field.Name]   = this.txtName.Text.TrimEnd();
            dtrSaveInfo[QEMSectInfo.Field.Name2]  = this.txtName2.Text.TrimEnd();
            dtrSaveInfo[QEMSectInfo.Field.DeptID] = this.txtQcDept.Tag.ToString();

            //string strLevel = "";
            //switch (this.cmbType.SelectedIndex)
            //{
            //    case 0:
            //        strLevel = "D";
            //        break;
            //    case 1:
            //        strLevel = "G";
            //        break;
            //}
            //dtrSaveInfo[QEMSectInfo.Field.Type] = strLevel;

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

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

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

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

                this.mdbTran.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();
                }
                App.WriteEventsLog(ex);

#if xd_RUNMODE_DEBUG
                MessageBox.Show("Message : " + ex.Message + "\n" + ex.Source + "\n" + ex.StackTrace);
#endif
            }

            finally
            {
                this.mdbConn.Close();
            }
        }
Пример #9
0
        private bool pmSaveChildTable(DataRow inMaster, string inOldCode
                                      , string inMemoS1
                                      , string inMemoS2
                                      , string inMemoS3
                                      , string inMemoS4
                                      , string inMemoS5
                                      , string inQcPdGrp
                                      , string inQcSuppl
                                      , string inQcUM
                                      , string inQcUM1
                                      , string inQcUM2
                                      , string inQcStUm
                                      , string inQcStUm1
                                      , string inQcStUm2
                                      , string inAccCode1
                                      , string inAccCode2
                                      , string inAccCode3
                                      , string inAccCode4)
        {
            string strErrorMsg  = "";
            string strEditRowID = "";

            object[] pAPara      = null;
            bool     bllIsNewRow = false;
            DataRow  dtrSaveInfo = null;

            if (this.mstrFixCorp != string.Empty)
            {
                this.mSaveDBAgent2.BatchSQLExec(ref this.dtsDataEnv, "QCorp", MapTable.Table.Corp, "select fcSkid, fcCode, fcName from " + MapTable.Table.Corp + " where fcSkid = ? ", new object[] { this.mstrFixCorp }, ref strErrorMsg, this.mdbConn2, this.mdbTran2);
            }
            else
            {
                this.mSaveDBAgent2.BatchSQLExec(ref this.dtsDataEnv, "QCorp", MapTable.Table.Corp, "select fcSkid, fcCode, fcName from " + MapTable.Table.Corp, null, ref strErrorMsg, this.mdbConn2, this.mdbTran2);
            }

            if (this.dtsDataEnv.Tables["QCorp"].Rows.Count > 0)
            {
                foreach (DataRow dtrCorp in this.dtsDataEnv.Tables["QCorp"].Rows)
                {
                    UIBase.WaitWind("¡ÓÅѧºÑ¹·Ö¡¢éÍÁÙźÃÔÉÑ· (" + dtrCorp["fcSkid"].ToString().TrimEnd() + ")");
                    string strSeekCode = (inOldCode.TrimEnd() == "" ? inMaster["cCode"].ToString() : inOldCode);
                    pAPara = new object[] { dtrCorp["fcSkid"].ToString(), strSeekCode.TrimEnd() };
                    if (!this.mSaveDBAgent2.BatchSQLExec(ref this.dtsDataEnv, this.mstrRefChildTable, this.mstrRefChildTable, "select * from " + this.mstrRefChildTable + " where " + this.mstrSQLPrefix2, pAPara, ref strErrorMsg, this.mdbConn2, this.mdbTran2))
                    {
                        //Insert Child Record
                        bllIsNewRow = true;
                        WS.Data.Agents.cConn objConn = WS.Data.Agents.cConn.GetInStance();
                        strEditRowID = objConn.RunRowID(this.mstrRefChildTable);
                        dtrSaveInfo  = this.dtsDataEnv.Tables[this.mstrRefChildTable].NewRow();
                        //dtrSaveInfo["fcCreateBy"] = App.FMAppUserID;
                    }
                    else
                    {
                        //Update Child Record
                        dtrSaveInfo  = this.dtsDataEnv.Tables[this.mstrRefChildTable].Rows[0];
                        strEditRowID = dtrSaveInfo["fcSkid"].ToString();
                        bllIsNewRow  = false;
                    }

                    string strAccBCash = "";
                    string strAccBCred = "";
                    string strAccSCash = "";
                    string strAccSCred = "";
                    string strPdGrp    = "";
                    string strCoor     = "";
                    string strUM       = "";
                    string strUM1      = "";
                    string strUM2      = "";
                    string strStUm     = "";
                    string strStUm1    = "";
                    string strStUm2    = "";

                    pAPara = new object[] { dtrCorp["fcSkid"].ToString(), inAccCode1.TrimEnd() };
                    if (this.mSaveDBAgent2.BatchSQLExec(ref this.dtsDataEnv, "QAcChart", "ACCHART", "select fcSkid from ACCHART where fcCorpChar = ? and fcCode = ?", pAPara, ref strErrorMsg, this.mdbConn2, this.mdbTran2))
                    {
                        strAccBCash = this.dtsDataEnv.Tables["QAcChart"].Rows[0]["fcSkid"].ToString();
                    }

                    pAPara = new object[] { dtrCorp["fcSkid"].ToString(), inAccCode2.TrimEnd() };
                    if (this.mSaveDBAgent2.BatchSQLExec(ref this.dtsDataEnv, "QAcChart", "ACCHART", "select fcSkid from ACCHART where fcCorpChar = ? and fcCode = ?", pAPara, ref strErrorMsg, this.mdbConn2, this.mdbTran2))
                    {
                        strAccBCred = this.dtsDataEnv.Tables["QAcChart"].Rows[0]["fcSkid"].ToString();
                    }

                    pAPara = new object[] { dtrCorp["fcSkid"].ToString(), inAccCode3.TrimEnd() };
                    if (this.mSaveDBAgent2.BatchSQLExec(ref this.dtsDataEnv, "QAcChart", "ACCHART", "select fcSkid from ACCHART where fcCorpChar = ? and fcCode = ?", pAPara, ref strErrorMsg, this.mdbConn2, this.mdbTran2))
                    {
                        strAccSCash = this.dtsDataEnv.Tables["QAcChart"].Rows[0]["fcSkid"].ToString();
                    }

                    pAPara = new object[] { dtrCorp["fcSkid"].ToString(), inAccCode4.TrimEnd() };
                    if (this.mSaveDBAgent2.BatchSQLExec(ref this.dtsDataEnv, "QAcChart", "ACCHART", "select fcSkid from ACCHART where fcCorpChar = ? and fcCode = ?", pAPara, ref strErrorMsg, this.mdbConn2, this.mdbTran2))
                    {
                        strAccSCred = this.dtsDataEnv.Tables["QAcChart"].Rows[0]["fcSkid"].ToString();
                    }

                    pAPara = new object[] { dtrCorp["fcSkid"].ToString(), inQcPdGrp.TrimEnd() };
                    if (this.mSaveDBAgent2.BatchSQLExec(ref this.dtsDataEnv, "QPdGrp", "PDGRP", "select fcSkid from PDGRP where fcCorp = ? and fcCode = ?", pAPara, ref strErrorMsg, this.mdbConn2, this.mdbTran2))
                    {
                        strPdGrp = this.dtsDataEnv.Tables["QPdGrp"].Rows[0]["fcSkid"].ToString();
                    }

                    pAPara = new object[] { dtrCorp["fcSkid"].ToString(), inQcSuppl.TrimEnd() };
                    if (this.mSaveDBAgent2.BatchSQLExec(ref this.dtsDataEnv, "QCoor", "COOR", "select fcSkid from COOR where fcCorp = ? and fcIsSupp = 'Y' and fcCode = ?", pAPara, ref strErrorMsg, this.mdbConn2, this.mdbTran2))
                    {
                        strCoor = this.dtsDataEnv.Tables["QCoor"].Rows[0]["fcSkid"].ToString();
                    }

                    pAPara = new object[] { dtrCorp["fcSkid"].ToString(), inQcUM.TrimEnd() };
                    if (this.mSaveDBAgent2.BatchSQLExec(ref this.dtsDataEnv, "QUM", "UM", "select fcSkid from UM where fcCorp = ? and fcCode = ?", pAPara, ref strErrorMsg, this.mdbConn2, this.mdbTran2))
                    {
                        strUM = this.dtsDataEnv.Tables["QUM"].Rows[0]["fcSkid"].ToString();
                    }

                    pAPara = new object[] { dtrCorp["fcSkid"].ToString(), inQcUM1.TrimEnd() };
                    if (this.mSaveDBAgent2.BatchSQLExec(ref this.dtsDataEnv, "QUM", "UM", "select fcSkid from UM where fcCorp = ? and fcCode = ?", pAPara, ref strErrorMsg, this.mdbConn2, this.mdbTran2))
                    {
                        strUM1 = this.dtsDataEnv.Tables["QUM"].Rows[0]["fcSkid"].ToString();
                    }

                    pAPara = new object[] { dtrCorp["fcSkid"].ToString(), inQcUM2.TrimEnd() };
                    if (this.mSaveDBAgent2.BatchSQLExec(ref this.dtsDataEnv, "QUM", "UM", "select fcSkid from UM where fcCorp = ? and fcCode = ?", pAPara, ref strErrorMsg, this.mdbConn2, this.mdbTran2))
                    {
                        strUM2 = this.dtsDataEnv.Tables["QUM"].Rows[0]["fcSkid"].ToString();
                    }

                    pAPara = new object[] { dtrCorp["fcSkid"].ToString(), inQcStUm.TrimEnd() };
                    if (this.mSaveDBAgent2.BatchSQLExec(ref this.dtsDataEnv, "QUM", "UM", "select fcSkid from UM where fcCorp = ? and fcCode = ?", pAPara, ref strErrorMsg, this.mdbConn2, this.mdbTran2))
                    {
                        strStUm = this.dtsDataEnv.Tables["QUM"].Rows[0]["fcSkid"].ToString();
                    }

                    pAPara = new object[] { dtrCorp["fcSkid"].ToString(), inQcStUm1.TrimEnd() };
                    if (this.mSaveDBAgent2.BatchSQLExec(ref this.dtsDataEnv, "QUM", "UM", "select fcSkid from UM where fcCorp = ? and fcCode = ?", pAPara, ref strErrorMsg, this.mdbConn2, this.mdbTran2))
                    {
                        strStUm1 = this.dtsDataEnv.Tables["QUM"].Rows[0]["fcSkid"].ToString();
                    }

                    pAPara = new object[] { dtrCorp["fcSkid"].ToString(), inQcStUm2.TrimEnd() };
                    if (this.mSaveDBAgent2.BatchSQLExec(ref this.dtsDataEnv, "QUM", "UM", "select fcSkid from UM where fcCorp = ? and fcCode = ?", pAPara, ref strErrorMsg, this.mdbConn2, this.mdbTran2))
                    {
                        strStUm2 = this.dtsDataEnv.Tables["QUM"].Rows[0]["fcSkid"].ToString();
                    }

                    dtrSaveInfo["fcSkid"]     = strEditRowID;
                    dtrSaveInfo["fcCorp"]     = dtrCorp["fcSkid"].ToString();
                    dtrSaveInfo["fcType"]     = inMaster["cType"].ToString().TrimEnd();
                    dtrSaveInfo["fcCode"]     = inMaster["cCode"].ToString().TrimEnd();
                    dtrSaveInfo["fcName"]     = inMaster["cName"].ToString().TrimEnd();
                    dtrSaveInfo["fcSName"]    = inMaster["cSName"].ToString().TrimEnd();
                    dtrSaveInfo["fcFChr"]     = inMaster["cFChr"].ToString().TrimEnd();
                    dtrSaveInfo["fcName2"]    = inMaster["cName2"].ToString().TrimEnd();
                    dtrSaveInfo["fcSName2"]   = inMaster["cSName2"].ToString().TrimEnd();
                    dtrSaveInfo["fcVatIsOut"] = inMaster["cVatIsOut"].ToString().TrimEnd();
                    dtrSaveInfo["fcCtrlStoc"] = inMaster["cCtrlStoc"].ToString().TrimEnd();
                    dtrSaveInfo["fnIsConsum"] = Convert.ToInt32(inMaster["nIsConsum"]);
                    dtrSaveInfo["fnStdCost"]  = Convert.ToDecimal(inMaster["nStdCost"]);

                    dtrSaveInfo["fcStatus"]   = inMaster["cStatus"].ToString();
                    dtrSaveInfo["fdInActive"] = (Convert.IsDBNull(inMaster["dInActive"]) ? Convert.DBNull : Convert.ToDateTime(inMaster["dInActive"]).Date);

                    dtrSaveInfo["fmPicName"] = inMaster["cPicName"].ToString();

                    dtrSaveInfo["fcUM"]    = strUM;
                    dtrSaveInfo["fcUM1"]   = strUM1;
                    dtrSaveInfo["fcUM2"]   = strUM2;
                    dtrSaveInfo["fcStUm"]  = strStUm;
                    dtrSaveInfo["fcStUm1"] = strStUm1;
                    dtrSaveInfo["fcStUm2"] = strStUm2;

                    dtrSaveInfo["fnUmQty1"]   = Convert.ToDecimal(inMaster["nUmQty1"]);
                    dtrSaveInfo["fnUmQty2"]   = Convert.ToDecimal(inMaster["nUmQty2"]);
                    dtrSaveInfo["fnStUmQty1"] = Convert.ToDecimal(inMaster["nStUmQty1"]);
                    dtrSaveInfo["fnStUmQty2"] = Convert.ToDecimal(inMaster["nStUmQty2"]);

                    dtrSaveInfo["fcPdGrp"] = strPdGrp;
                    dtrSaveInfo["fcSupp"]  = strCoor;

                    dtrSaveInfo["fcAccBCash"] = strAccBCash;
                    dtrSaveInfo["fcAccBCred"] = strAccBCred;
                    dtrSaveInfo["fcAccSCash"] = strAccSCash;
                    dtrSaveInfo["fcAccSCred"] = strAccSCred;

                    //dtrSaveInfo["fcAccSCost"] = strAccSCost;
                    //dtrSaveInfo["fcAccItem"] = strAccItem;

                    dtrSaveInfo["fcCreateAp"] = this.mSaveDBAgent2.AppID;
                    dtrSaveInfo["ftLastUpd"]  = this.mSaveDBAgent2.GetDBServerDateTime();;
                    dtrSaveInfo["fcEAfterR"]  = "E";

                    string strSQLUpdateStr = "";
                    cDBMSAgent.GenUpdateSQLString(dtrSaveInfo, "fcSkid", bllIsNewRow, ref strSQLUpdateStr, ref pAPara);
                    this.mSaveDBAgent2.BatchSQLExec(strSQLUpdateStr, pAPara, ref strErrorMsg, this.mdbConn2, this.mdbTran2);

                    this.mstrMemoS1 = inMemoS1;
                    this.mstrMemoS2 = inMemoS2;
                    this.mstrMemoS3 = inMemoS3;
                    this.mstrMemoS4 = inMemoS4;
                    this.mstrMemoS5 = inMemoS5;
                    this.pmSaveProdX4(strEditRowID);
                }
            }
            return(true);
        }
Пример #10
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 = null;

            objSQLHelper.SQLExec(ref this.dtsDataEnv, this.mstrRefTable, this.mstrRefTable, "select * from " + this.mstrRefTable + " where 0 = 1", ref strErrorMsg);

            dtrSaveInfo = this.dtsDataEnv.Tables[this.mstrRefTable].NewRow();
            bllIsNewRow = true;
            if (this.mstrEditRowID == string.Empty)
            {
                WS.Data.Agents.cConn objConn = WS.Data.Agents.cConn.GetInStance();
                this.mstrEditRowID = objConn.RunRowID(this.mstrRefTable);
            }
            dtrSaveInfo[MapTable.ShareField.CreateBy]   = App.FMAppUserID;
            dtrSaveInfo[MapTable.ShareField.CreateDate] = objSQLHelper.GetDBServerDateTime();
            this.dtsDataEnv.Tables[this.mstrRefTable].Rows.Add(dtrSaveInfo);

            this.mstrCode = this.txtDate.DateTime.Year.ToString("0000");
            this.mstrName = this.txtDate.DateTime.Year.ToString("0000");

            // Control Field ที่ทุก Form ต้องมี
            dtrSaveInfo[MapTable.ShareField.RowID]        = this.mstrEditRowID;
            dtrSaveInfo[MapTable.ShareField.LastUpdateBy] = App.FMAppUserID;
            dtrSaveInfo[MapTable.ShareField.LastUpdate]   = objSQLHelper.GetDBServerDateTime();
            // Control Field ที่ทุก Form ต้องมี

            dtrSaveInfo[QEMStdWorkHourInfo.Field.CorpID]  = App.ActiveCorp.RowID;
            dtrSaveInfo[QEMStdWorkHourInfo.Field.Code]    = this.mstrCode;
            dtrSaveInfo[QEMStdWorkHourInfo.Field.Name]    = this.mstrName;
            dtrSaveInfo[QEMStdWorkHourInfo.Field.Date]    = new DateTime(this.txtDate.DateTime.Year, 1, 1);
            dtrSaveInfo[QEMStdWorkHourInfo.Field.Year]    = this.txtDate.DateTime.Year;
            dtrSaveInfo[QEMStdWorkHourInfo.Field.PlantID] = this.txtQcPlant.Tag.ToString();

            //Sum work hour and OT hour
            decimal decSumWorkHr = (from p1 in this.dtsDataEnv.Tables[this.mstrTemPd].AsEnumerable()
                                    where p1["cType"].ToString().Trim() == ""
                                    select new { TotHour = p1["nTotHour"] }).Sum(p1 => Convert.ToDecimal(p1.TotHour));

            decimal decSumOTHr = (from p1 in this.dtsDataEnv.Tables[this.mstrTemPd].AsEnumerable()
                                  where p1["cType"].ToString().Trim() == "O"
                                  select new { TotHour = p1["nTotHour"] }).Sum(p1 => Convert.ToDecimal(p1.TotHour));

            dtrSaveInfo["NTOTWORKHR"] = decSumWorkHr;
            dtrSaveInfo["NTOTOTHR"]   = decSumOTHr;
            dtrSaveInfo["CWORKHOUR"]  = this.txtQcStdWorkHr.Tag.ToString();
            dtrSaveInfo["CHOLIDAY"]   = this.txtQcHoliday.Tag.ToString();

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

            try
            {
                this.mdbConn.Open();
                this.mdbTran = this.mdbConn.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);

                this.pmUpdateWorkCalIT();

                this.mdbTran.Commit();
                bllIsCommit = true;
            }
            catch (Exception ex)
            {
                if (!bllIsCommit)
                {
                    this.mdbTran.Rollback();
                }
                App.WriteEventsLog(ex);

#if xd_RUNMODE_DEBUG
                MessageBox.Show("Message : " + ex.Message + "\n" + ex.Source + "\n" + ex.StackTrace);
#endif
            }

            finally
            {
                this.mdbConn.Close();
            }
        }
Пример #11
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[MapTable.ShareField.CreateBy]   = App.FMAppUserID;
                dtrSaveInfo[MapTable.ShareField.CreateDate] = objSQLHelper.GetDBServerDateTime();
            }

            // Control Field ที่ทุก Form ต้องมี
            dtrSaveInfo[MapTable.ShareField.RowID]        = this.mstrEditRowID;
            dtrSaveInfo[MapTable.ShareField.LastUpdateBy] = App.FMAppUserID;
            dtrSaveInfo[MapTable.ShareField.LastUpdate]   = objSQLHelper.GetDBServerDateTime();
            // Control Field ที่ทุก Form ต้องมี

            dtrSaveInfo[QBGYearInfo.Field.CorpID]   = App.ActiveCorp.RowID;
            dtrSaveInfo[QBGYearInfo.Field.Code]     = this.txtCode.Text.TrimEnd();
            dtrSaveInfo[QBGYearInfo.Field.Desc]     = this.txtDesc.Text.TrimEnd();
            dtrSaveInfo[QBGYearInfo.Field.IsActive] = (this.chkIsActive.Checked ? "Y" : "N");
            dtrSaveInfo[QBGYearInfo.Field.Year]     = Convert.ToInt32(this.txtYear.Value) - 543;
            dtrSaveInfo[QBGYearInfo.Field.IsLock]   = (this.chkIsLock.Checked ? "Y" : "N");

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

            try
            {
                this.mdbConn.Open();
                this.mdbTran = this.mdbConn.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);

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

                if (this.mFormEditMode == UIHelper.AppFormState.Insert)
                {
                    KeepLogAgent.KeepLog(objSQLHelper, KeepLogType.Insert, TASKNAME, this.txtCode.Text, this.txtDesc.Text, App.FMAppUserID, App.AppUserName);
                }
                else if (this.mFormEditMode == UIHelper.AppFormState.Edit)
                {
                    if (this.mstrOldCode == this.txtCode.Text && this.mstrOldName == this.txtDesc.Text)
                    {
                        KeepLogAgent.KeepLog(objSQLHelper, KeepLogType.Update, TASKNAME, this.txtCode.Text, this.txtDesc.Text, App.FMAppUserID, App.AppUserName);
                    }
                    else
                    {
                        KeepLogAgent.KeepLogChgValue(objSQLHelper, KeepLogType.Update, TASKNAME, this.txtCode.Text, this.txtDesc.Text, App.FMAppUserID, App.AppUserName, this.mstrOldCode, this.mstrOldName);
                    }
                }
            }
            catch (Exception ex)
            {
                if (!bllIsCommit)
                {
                    this.mdbTran.Rollback();
                }
                App.WriteEventsLog(ex);

#if xd_RUNMODE_DEBUG
                MessageBox.Show("Message : " + ex.Message + "\n" + ex.Source + "\n" + ex.StackTrace);
#endif
            }

            finally
            {
                this.mdbConn.Close();
            }
        }
Пример #12
0
        private bool pmSaveChildTable(DataRow inMaster, string inOldCode, string inMemoS1, string inMemoS2, string inQcCrGrp, string inQcAcChart)
        {
            string strErrorMsg  = "";
            string strEditRowID = "";

            object[] pAPara      = null;
            bool     bllIsNewRow = false;
            DataRow  dtrSaveInfo = null;

            if (this.mstrFixCorp != string.Empty)
            {
                this.mSaveDBAgent2.BatchSQLExec(ref this.dtsDataEnv, "QCorp", MapTable.Table.Corp, "select fcSkid, fcCode, fcName from " + MapTable.Table.Corp + " where fcSkid = ? ", new object[] { this.mstrFixCorp }, ref strErrorMsg, this.mdbConn2, this.mdbTran2);
            }
            else
            {
                this.mSaveDBAgent2.BatchSQLExec(ref this.dtsDataEnv, "QCorp", MapTable.Table.Corp, "select fcSkid, fcCode, fcName from " + MapTable.Table.Corp, null, ref strErrorMsg, this.mdbConn2, this.mdbTran2);
            }

            if (this.dtsDataEnv.Tables["QCorp"].Rows.Count > 0)
            {
                foreach (DataRow dtrCorp in this.dtsDataEnv.Tables["QCorp"].Rows)
                {
                    UIBase.WaitWind("¡ÓÅѧºÑ¹·Ö¡¢éÍÁÙźÃÔÉÑ· (" + dtrCorp["fcSkid"].ToString().TrimEnd() + ")");
                    string strSeekCode = (inOldCode.TrimEnd() == "" ? inMaster["cCode"].ToString() : inOldCode);
                    pAPara = new object[] { dtrCorp["fcSkid"].ToString(), "Y", strSeekCode.TrimEnd() };
                    if (!this.mSaveDBAgent2.BatchSQLExec(ref this.dtsDataEnv, this.mstrRefChildTable, this.mstrRefChildTable, "select * from " + this.mstrRefChildTable + " where " + this.mstrSQLPrefix2, pAPara, ref strErrorMsg, this.mdbConn2, this.mdbTran2))
                    {
                        //Insert Child Record
                        bllIsNewRow = true;
                        WS.Data.Agents.cConn objConn = WS.Data.Agents.cConn.GetInStance();
                        strEditRowID = objConn.RunRowID(this.mstrRefChildTable);
                        dtrSaveInfo  = this.dtsDataEnv.Tables[this.mstrRefChildTable].NewRow();
                        //dtrSaveInfo["fcCreateBy"] = App.FMAppUserID;
                    }
                    else
                    {
                        //Update Child Record
                        dtrSaveInfo  = this.dtsDataEnv.Tables[this.mstrRefChildTable].Rows[0];
                        strEditRowID = dtrSaveInfo["fcSkid"].ToString();
                        bllIsNewRow  = false;
                    }

                    string strCrGrp   = "";
                    string strAcChart = "";

                    pAPara = new object[] { dtrCorp["fcSkid"].ToString(), inQcAcChart.TrimEnd() };
                    if (this.mSaveDBAgent2.BatchSQLExec(ref this.dtsDataEnv, "QAcChart", "ACCHART", "select fcSkid from ACCHART where fcCorpChar = ? and fcCode = ?", pAPara, ref strErrorMsg, this.mdbConn2, this.mdbTran2))
                    {
                        strAcChart = this.dtsDataEnv.Tables["QAcChart"].Rows[0]["fcSkid"].ToString();
                    }

                    pAPara = new object[] { dtrCorp["fcSkid"].ToString(), this.mstrCoorType, inQcCrGrp.TrimEnd() };
                    if (this.mSaveDBAgent2.BatchSQLExec(ref this.dtsDataEnv, "QCrGrp", "CRGRP", "select fcSkid from CRGRP where fcCorp = ? and fcCoorType = ? and fcCode = ?", pAPara, ref strErrorMsg, this.mdbConn2, this.mdbTran2))
                    {
                        strCrGrp = this.dtsDataEnv.Tables["QCrGrp"].Rows[0]["fcSkid"].ToString();
                    }

                    dtrSaveInfo["fcSkid"] = strEditRowID;
                    dtrSaveInfo["fcCorp"] = dtrCorp["fcSkid"].ToString();

                    if (this.mstrCoorType == "C")
                    {
                        dtrSaveInfo["fcIsCust"] = "Y";
                        dtrSaveInfo["fcIsSupp"] = "";
                    }
                    else
                    {
                        dtrSaveInfo["fcIsCust"] = "";
                        dtrSaveInfo["fcIsSupp"] = "Y";
                    }

                    dtrSaveInfo["fcCode"]     = inMaster["cCode"].ToString().TrimEnd();
                    dtrSaveInfo["fcName"]     = inMaster["cName"].ToString().TrimEnd();
                    dtrSaveInfo["fcName2"]    = inMaster["cName2"].ToString().TrimEnd();
                    dtrSaveInfo["fcFChr"]     = inMaster["cFChr"].ToString().TrimEnd();
                    dtrSaveInfo["fcSName"]    = inMaster["cSName"].ToString().TrimEnd();
                    dtrSaveInfo["fcSName2"]   = inMaster["cSName2"].ToString().TrimEnd();
                    dtrSaveInfo["fcFChrS"]    = inMaster["cFChrS"].ToString().TrimEnd();
                    dtrSaveInfo["fcZip"]      = inMaster["cZip"].ToString();
                    dtrSaveInfo["fcStatus"]   = inMaster["cStatus"].ToString();
                    dtrSaveInfo["fdInActive"] = (Convert.IsDBNull(inMaster["dInActive"]) ? Convert.DBNull : Convert.ToDateTime(inMaster["dInActive"]).Date);
                    dtrSaveInfo["fdFstCont"]  = (Convert.IsDBNull(inMaster["dFstCont"]) ? Convert.DBNull : Convert.ToDateTime(inMaster["dFstCont"]).Date);

                    dtrSaveInfo["fcPersonty"] = inMaster["cPersonty"].ToString();
                    dtrSaveInfo["fcContactN"] = inMaster["cContactN"].ToString().TrimEnd();
                    dtrSaveInfo["fcCrGrp"]    = inMaster["cCrGrp"].ToString();
                    dtrSaveInfo["fcCrZone"]   = inMaster["cCrZone"].ToString();
                    dtrSaveInfo["fcEmpl"]     = inMaster["cEmpl"].ToString();
                    dtrSaveInfo["fcDeliEmpl"] = inMaster["cDeliEmpl"].ToString();
                    dtrSaveInfo["fcLayEmpl"]  = inMaster["cLayEmpl"].ToString();
                    dtrSaveInfo["fnCredTerm"] = Convert.ToInt32(inMaster["nCredTerm"]);
                    dtrSaveInfo["fnCredLim"]  = Convert.ToDecimal(inMaster["nCredLim"]);
                    dtrSaveInfo["fnBlack"]    = Convert.ToInt32(inMaster["nBlack"]);
                    dtrSaveInfo["fcPriceNo"]  = inMaster["cPriceNo"].ToString();
                    dtrSaveInfo["fcGrade"]    = inMaster["cGrade"].ToString();

                    dtrSaveInfo["fcVatCoor"]  = inMaster["cVatCoor"].ToString();
                    dtrSaveInfo["fcDeliCoor"] = inMaster["cDeliCoor"].ToString();
                    dtrSaveInfo["fcColCoor"]  = inMaster["cColCoor"].ToString();
                    dtrSaveInfo["fcPolicyPr"] = inMaster["cPolicyPr"].ToString();
                    dtrSaveInfo["fcPolicyDi"] = inMaster["cPolicyDi"].ToString();
                    dtrSaveInfo["fcVatType"]  = inMaster["cVatType"].ToString();
                    dtrSaveInfo["fcBank"]     = inMaster["cBank"].ToString();
                    dtrSaveInfo["fcDiscStr"]  = inMaster["cDiscStr"].ToString();
                    dtrSaveInfo["fcCurrency"] = inMaster["cCurrency"].ToString();

                    //dtrSaveInfo["fcCrGrp"] = strCrGrp;
                    dtrSaveInfo["fcAcChart"] = strAcChart;

                    dtrSaveInfo["fcBankNo"]  = inMaster["cBankNo"].ToString().TrimEnd();
                    dtrSaveInfo["fcBBranch"] = inMaster["cBBranch"].ToString().TrimEnd();

                    dtrSaveInfo["fmMapName"] = inMaster["cMapName"].ToString();

                    dtrSaveInfo["fmMemData"]  = inMaster["cMemData"].ToString();
                    dtrSaveInfo["fmMemData2"] = inMaster["cMemData2"].ToString();
                    dtrSaveInfo["fmMemData3"] = inMaster["cMemData3"].ToString();
                    dtrSaveInfo["fmMemData4"] = inMaster["cMemData4"].ToString();
                    dtrSaveInfo["fmMemData5"] = inMaster["cMemData5"].ToString();

                    dtrSaveInfo["fcCreateAp"] = this.mSaveDBAgent2.AppID;
                    dtrSaveInfo["ftLastUpd"]  = this.mSaveDBAgent2.GetDBServerDateTime();;
                    dtrSaveInfo["fcEAfterR"]  = "E";

                    string strSQLUpdateStr = "";
                    cDBMSAgent.GenUpdateSQLString(dtrSaveInfo, "fcSkid", bllIsNewRow, ref strSQLUpdateStr, ref pAPara);
                    this.mSaveDBAgent2.BatchSQLExec(strSQLUpdateStr, pAPara, ref strErrorMsg, this.mdbConn2, this.mdbTran2);

                    this.mstrMemoS1 = inMemoS1;
                    this.mstrMemoS2 = inMemoS2;
                    this.pmSaveCoorX5(strEditRowID);
                }
            }
            return(true);
        }
Пример #13
0
        private bool pmSaveChildTable(DataRow inMaster, string inOldCode)
        {
            string strErrorMsg   = "";
            string strEditRowID  = "";
            bool   bllHasChgCode = false;

            object[] pAPara      = null;
            bool     bllIsNewRow = false;
            DataRow  dtrSaveInfo = null;

            //à¾×èÍãËéÃͧÃѺ¡ÒÃãªé FCCORPCHAR ÃèÇÁ¡Ñ¹
            //if (this.mSaveDBAgent2.BatchSQLExec(ref this.dtsDataEnv, "QCorp", MapTable.Table.Corp, "select fcSkid, fcCode, fcName from " + MapTable.Table.Corp, null, ref strErrorMsg, this.mdbConn2, this.mdbTran2))
            if (this.mSaveDBAgent2.BatchSQLExec(ref this.dtsDataEnv, "QCorp", MapTable.Table.Corp, "select fcCorpChar from " + MapTable.Table.Corp + " group by fcCorpChar", null, ref strErrorMsg, this.mdbConn2, this.mdbTran2))
            {
                foreach (DataRow dtrCorp in this.dtsDataEnv.Tables["QCorp"].Rows)
                {
                    UIBase.WaitWind("¡ÓÅѧºÑ¹·Ö¡¢éÍÁÙźÃÔÉÑ· (" + dtrCorp["fcCorpChar"].ToString().TrimEnd() + ")");
                    string strSeekCode = (inOldCode.TrimEnd() == "" ? inMaster["cCode"].ToString() : inOldCode);
                    pAPara = new object[] { dtrCorp["fcCorpChar"].ToString(), strSeekCode.TrimEnd() };
                    if (!this.mSaveDBAgent2.BatchSQLExec(ref this.dtsDataEnv, this.mstrRefChildTable, this.mstrRefChildTable, "select * from " + this.mstrRefChildTable + " where " + this.mstrSQLPrefix2, pAPara, ref strErrorMsg, this.mdbConn2, this.mdbTran2))
                    {
                        //Insert Child Record
                        bllIsNewRow   = true;
                        bllHasChgCode = false;
                        WS.Data.Agents.cConn objConn = WS.Data.Agents.cConn.GetInStance();
                        strEditRowID = objConn.RunRowID(this.mstrRefChildTable);
                        dtrSaveInfo  = this.dtsDataEnv.Tables[this.mstrRefChildTable].NewRow();
                        dtrSaveInfo["fcCreateBy"] = App.FMAppUserID;
                    }
                    else
                    {
                        //Update Child Record
                        dtrSaveInfo  = this.dtsDataEnv.Tables[this.mstrRefChildTable].Rows[0];
                        strEditRowID = dtrSaveInfo["fcSkid"].ToString();
                        bllIsNewRow  = false;

                        if (dtrSaveInfo["fcCode"].ToString().TrimEnd() != inMaster["cCode"].ToString().TrimEnd())
                        {
                            bllHasChgCode = true;
                        }
                    }

                    dtrSaveInfo["fcSkid"]     = strEditRowID;
                    dtrSaveInfo["fcCorpchar"] = dtrCorp["fcCorpChar"].ToString();
                    dtrSaveInfo["fcGroup"]    = inMaster["cGroup"].ToString();
                    dtrSaveInfo["fcCode"]     = inMaster["cCode"].ToString().TrimEnd();
                    dtrSaveInfo["fcName"]     = inMaster["cName"].ToString().TrimEnd();
                    dtrSaveInfo["fcFChr"]     = inMaster["cFChr"].ToString().TrimEnd();
                    dtrSaveInfo["fcName2"]    = inMaster["cName2"].ToString().TrimEnd();
                    dtrSaveInfo["fcCateg"]    = (inMaster["cCateg"].ToString().TrimEnd() == "G" ? "¡ÅØèÁ" : "ºÑ­ªÕ");
                    dtrSaveInfo["fcCateg2"]   = (inMaster["cCateg"].ToString().TrimEnd() == "G" ? "GENERAL" : "DETAIL");
                    dtrSaveInfo["fnLevel"]    = inMaster["cCode"].ToString().TrimEnd().Length;
                    dtrSaveInfo["fcCreateAp"] = this.mSaveDBAgent2.AppID;
                    dtrSaveInfo["ftLastUpd"]  = this.mSaveDBAgent2.GetDBServerDateTime();;
                    dtrSaveInfo["fcEAfterR"]  = "E";

                    string strSQLUpdateStr = "";
                    cDBMSAgent.GenUpdateSQLString(dtrSaveInfo, "fcSkid", bllIsNewRow, ref strSQLUpdateStr, ref pAPara);
                    this.mSaveDBAgent2.BatchSQLExec(strSQLUpdateStr, pAPara, ref strErrorMsg, this.mdbConn2, this.mdbTran2);

                    if (bllHasChgCode)
                    {
                        pAPara = new object[] { strEditRowID };
                        if (this.mSaveDBAgent2.BatchSQLExec(ref this.dtsDataEnv, "QAsset", "ASSET", "select fcSkid from Asset where Asset.fcAcChart = ?", pAPara, ref strErrorMsg, this.mdbConn2, this.mdbTran2))
                        {
                            pAPara = new object[] { inMaster["cCode"].ToString(), strEditRowID };
                            this.mSaveDBAgent2.BatchSQLExec("Update Asset set fcQcAcChar = ? where Asset.fcAcChart = ?", pAPara, ref strErrorMsg, this.mdbConn2, this.mdbTran2);
                        }
                    }
                }
            }
            return(true);
        }