Example #1
0
        private void pmLoadFormData()
        {
            DataRow dtrBrow = this.gridView1.GetDataRow(this.gridView1.FocusedRowHandle);

            if (dtrBrow != null)
            {
                this.mstrEditRowID = dtrBrow["fcSkid"].ToString();

                string strErrorMsg = "";
                WS.Data.Agents.cDBMSAgent pobjSQLUtil = new WS.Data.Agents.cDBMSAgent(App.ConnectionString, App.DatabaseReside);
                pobjSQLUtil.SetPara(new object[] { this.mstrEditRowID });
                if (pobjSQLUtil.SQLExec(ref this.dtsDataEnv, this.mstrRefTable, this.mstrRefTable, "select * from " + this.mstrRefTable + " where fcSkid = ?", ref strErrorMsg))
                {
                    DataRow dtrLoadForm = this.dtsDataEnv.Tables[this.mstrRefTable].Rows[0];
                    this.txtCode.Text  = dtrLoadForm["FCCODE"].ToString().TrimEnd();
                    this.txtName.Text  = dtrLoadForm["FCNAME"].ToString().TrimEnd();
                    this.txtName2.Text = dtrLoadForm["FCNAME2"].ToString().TrimEnd();

                    //this.txtQcDept.Tag = dtrLoadForm[QEMSectInfo.Field.DeptID].ToString();
                    //pobjSQLUtil.SetPara(new object[] { this.txtQcDept.Tag });
                    //if (pobjSQLUtil.SQLExec(ref this.dtsDataEnv, "QProj", QEMDeptInfo.TableName, "select * from " + QEMDeptInfo.TableName + " where fcSkid = ?", ref strErrorMsg))
                    //{
                    //    this.txtQcDept.Text = this.dtsDataEnv.Tables["QProj"].Rows[0][QEMDeptInfo.Field.Code].ToString().TrimEnd();
                    //    this.txtQnDept.Text = this.dtsDataEnv.Tables["QProj"].Rows[0][QEMDeptInfo.Field.Name].ToString().TrimEnd();
                    //}

                    //string strLevel = dtrLoadForm[QEMSectInfo.Field.Type].ToString().TrimEnd();
                    //int intSel = -1;
                    //switch (strLevel)
                    //{
                    //    case "D":
                    //        intSel = 0;
                    //        break;
                    //    case "G":
                    //        intSel = 1;
                    //        break;
                    //}
                    //this.cmbType.SelectedIndex = intSel;
                }
                this.pmLoadOldVar();
            }
        }
        private void pmSetBrowView_SUPPL()
        {
            string strErrorMsg = "";

            WS.Data.Agents.cDBMSAgent pobjSQLUtil = new WS.Data.Agents.cDBMSAgent(App.ERPConnectionString, App.DatabaseReside);

            string strFMDBName = App.ConfigurationManager.ConnectionInfo.ERPDBMSName;
            string strEmplRTab = strFMDBName + ".dbo.EMPLR";

            string strStat = "CSTATUS = case {0}.FCSTATUS when 'I' then 'INACTIVE' when '' then 'ACTIVE' end";

            string strSQLExec = "select {0}.FCSKID as FCSKID, {0}.FCCODE as CCODE, {0}.FCSNAME as CSNAME, {0}.FCNAME as CNAME, " + strStat + ", {0}.FDINACTIVE as DINACTIVE, {0}.FTDATETIME as DCREATE, {0}.FTLASTUPD as DLASTUPD from {0} ";

            strSQLExec += " where {0}.FCCORP = ? and {0}.FCISSUPP = 'Y' ";
            strSQLExec  = string.Format(strSQLExec, new string[] { "COOR" });

            pobjSQLUtil.NotUpperSQLExecString = true;
            pobjSQLUtil.SetPara(new object[] { App.gcCorp });
            pobjSQLUtil.SQLExec(ref this.dtsDataEnv, "SUPPL", "SUPPL", strSQLExec, ref strErrorMsg);
        }
Example #3
0
        private void pmSetBrowView()
        {
            string strErrorMsg = "";

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

            string strFMDBName = App.ConfigurationManager.ConnectionInfo.ERPDBMSName;
            string strEmplRTab = strFMDBName + ".dbo.EMPLR";

            string strSQLExec = "select {0}.FCSKID, {0}.FCCODE, {0}.FCNAME, {0}.FTDATETIME, {0}.FTLASTEDIT, EM1.FCLOGIN as CLOGIN_ADD, EM2.FCLOGIN as CLOGIN_UPD from {0} ";

            strSQLExec += " left join {1} EM1 ON EM1.FCSKID = {0}.CCREATEBY ";
            strSQLExec += " left join {1} EM2 ON EM2.FCSKID = {0}.CLASTUPDBY ";
            strSQLExec += " where {0}.FCCORP = ? and {0}.FCBRANCH = ? and {0}.FCREFTYPE = ? ";
            strSQLExec  = string.Format(strSQLExec, new string[] { this.mstrRefTable, strEmplRTab });

            pobjSQLUtil.NotUpperSQLExecString = true;
            pobjSQLUtil.SetPara(new object[] { App.ActiveCorp.RowID, this.mstrBranchID, this.mstrRefType });
            pobjSQLUtil.SQLExec(ref this.dtsDataEnv, this.mstrBrowViewAlias, "WSBOOK", strSQLExec, ref strErrorMsg);
        }
        private void pmSetBrowView_WHOUSE()
        {
            string strErrorMsg = "";

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

            string strSQLExec = "select BRANCH.FCCODE as QCBRANCH,EMWHOUSE.FCSKID, EMWHOUSE.FCCODE as CCODE, EMWHOUSE.FCNAME as CNAME, EMWHOUSE.FCNAME2 as CNAME2";

            strSQLExec += " , LC1.FCCODE as QCWHLOCA_INPUT, LC2.FCCODE as QCWHLOCA_OUTPUT, LC3.FCCODE as QCWHLOCA_STOCK ";
            strSQLExec += " , EMWHOUSE.FTLASTUPD as FDCREATE, EMWHOUSE.FTDATETIME as FDLASTUPDBY  ";
            strSQLExec += " from WHOUSE as EMWHOUSE ";
            strSQLExec += " left join BRANCH on BRANCH.FCSKID = EMWHOUSE.FCBRANCH ";
            strSQLExec += " left join WHLOCATION LC1 on LC1.FCSKID = EMWHOUSE.FCWHLOCA_INPUT ";
            strSQLExec += " left join WHLOCATION LC2 on LC2.FCSKID = EMWHOUSE.FCWHLOCA_OUTPUT ";
            strSQLExec += " left join WHLOCATION LC3 on LC3.FCSKID = EMWHOUSE.FCWHLOCA_STOCK ";
            strSQLExec += " where EMWHOUSE.FCCORP = ? ";

            pobjSQLUtil.SetPara(new object[] { App.ActiveCorp.RowID });
            pobjSQLUtil.SQLExec(ref this.dtsDataEnv, "WHOUSE", "WHOUSE", strSQLExec, ref strErrorMsg);
        }
        private void pmSetBrowView()
        {
            string strErrorMsg = "";

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

            string strSQLExec = "select MFMCType.CROWID, MFMCType.CCODE, MFMCType.CNAME, MFMCType.CNAME2, MFMCType.DCREATE, MFMCType.DLASTUPDBY, EM1.CLOGIN as CLOGIN_ADD, EM2.CLOGIN as CLOGIN_UPD from {0} MFMCType ";

            strSQLExec += " left join {1} EM1 ON EM1.CROWID = MFMCType.CCREATEBY ";
            strSQLExec += " left join {1} EM2 ON EM2.CROWID = MFMCType.CLASTUPDBY ";
            strSQLExec += " where MFMCType.CCORP = ? and MFMCType.CTYPE = ? ";
            strSQLExec  = string.Format(strSQLExec, new string[] { this.mstrRefTable, "APPLOGIN" });

            if (this.mstrFixType != string.Empty)
            {
                this.mstrType = this.mstrFixType;
            }

            pobjSQLUtil.SetPara(new object[] { App.ActiveCorp.RowID, this.mstrType });
            pobjSQLUtil.SQLExec(ref this.dtsDataEnv, this.mstrBrowViewAlias, "MFMCType", strSQLExec, ref strErrorMsg);
        }
        private void pmSetBrowView()
        {
            string strErrorMsg = "";

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

            //string strSQLExec = "select BGCHARTHD.CROWID, BGCHARTHD.CCODE, BGCHARTHD.CNAME from BGCHARTHD where CCORP = ? and CTYPE = ? ";
            string strSQLExec = "";

            strSQLExec  = "select ";
            strSQLExec += " BGCHARTHD.CROWID, BGCHARTHD.CCODE, BGCHARTHD.CNAME, PRCHART.CCODE as QCPRNAME, PRCHART.CNAME as QNPRNAME";
            strSQLExec += " , BGBALANCE.NBGYEAR , BGBALANCE.NAMT , BGBALANCE.NRECVAMT , (BGBALANCE.NAMT - BGBALANCE.NRECVAMT) as NBALAMT ";
            strSQLExec += " from BGBALANCE  ";
            strSQLExec += " left join BGCHARTHD on BGCHARTHD.CROWID = BGBALANCE.CBGCHARTHD ";
            strSQLExec += " left join BGCHARTHD PRCHART on PRCHART.CROWID = BGCHARTHD.CPRBGCHART ";
            strSQLExec += " where BGBALANCE.CCORP = ? and BGBALANCE.CJOB = ? and BGBALANCE.NBGYEAR = ? ";

            object[] pAPara = new object[] { App.ActiveCorp.RowID, this.mstrJob, this.mintBGYear };
            pobjSQLUtil.SetPara(pAPara);
            pobjSQLUtil.SQLExec(ref this.dtsDataEnv, this.mstrBrowViewAlias, this.mstrRefTable, strSQLExec, ref strErrorMsg);
        }
Example #7
0
        public DataRow RetrieveValue()
        {
            DataRow dtrBrow = this.gridView1.GetDataRow(this.gridView1.FocusedRowHandle);

            if (dtrBrow == null)
            {
                return(null);
            }

            string strErrorMsg = "";

            WS.Data.Agents.cDBMSAgent pobjSQLUtil = new WS.Data.Agents.cDBMSAgent(App.ConnectionString, App.DatabaseReside);
            pobjSQLUtil.SetPara(new object[1] {
                dtrBrow["cRowID"].ToString()
            });
            if (pobjSQLUtil.SQLExec(ref this.dtsDataEnv, "QVFLD_Table", this.mstrRefTable, "select * from " + this.mstrRefTable + " where cRowID = ? ", ref strErrorMsg))
            {
                return(this.dtsDataEnv.Tables["QVFLD_Table"].Rows[0]);
            }
            return(null);
        }
Example #8
0
        private void pmSetBrowView()
        {
            string strErrorMsg = "";

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

            string strFMDBName = App.ConfigurationManager.ConnectionInfo.ERPDBMSName;
            string strEmplRTab = strFMDBName + ".dbo.EMPLR";

            string strSQLExec = "select {0}.CROWID, {0}.CCODE, {0}.CNAME, {0}.DCREATE, {0}.DLASTUPD, EM1.FCLOGIN as CLOGIN_ADD, EM2.FCLOGIN as CLOGIN_UPD from {0} ";

            strSQLExec += " left join {1} EM1 ON EM1.FCSKID = {0}.CCREATEBY ";
            strSQLExec += " left join {1} EM2 ON EM2.FCSKID = {0}.CLASTUPDBY ";
            strSQLExec += " where {0}.CCORP = ? ";
            strSQLExec  = string.Format(strSQLExec, new string[] { this.mstrRefTable, strEmplRTab });

            //pobjSQLUtil.SetPara(pAPara);
            pobjSQLUtil.NotUpperSQLExecString = true;
            pobjSQLUtil.SetPara(new object[] { App.gcCorp });
            pobjSQLUtil.SQLExec(ref this.dtsDataEnv, this.mstrBrowViewAlias, "PdClass", strSQLExec, ref strErrorMsg);
        }
Example #9
0
        private void pmBlankFormData()
        {
            string strErrorMsg = "";

            WS.Data.Agents.cDBMSAgent pobjSQLUtil = new WS.Data.Agents.cDBMSAgent(App.ConnectionString, App.DatabaseReside);
            pobjSQLUtil.SQLExec(ref this.dtsDataEnv, this.mstrRefTable, this.mstrRefTable, "select * from " + this.mstrRefTable + " where 0=1", ref strErrorMsg);

            pobjSQLUtil.SetPara(new object[] { this.mstrRefType });
            if (pobjSQLUtil.SQLExec(ref this.dtsDataEnv, "QRefType", "DOCTYPE", "select * from DOCTYPE where cCode = ?", ref strErrorMsg))
            {
                DataRow dtrRefType = this.dtsDataEnv.Tables["QRefType"].Rows[0];
                this.txtQcRefType.Text = dtrRefType["cCode"].ToString().TrimEnd();
                this.txtQnRefType.Text = dtrRefType["cName"].ToString().TrimEnd();
            }

            this.mstrEditRowID = "";
            this.txtCode.Text  = "";
            this.txtName.Text  = "";
            this.txtName2.Text = "";
            this.txtName2.Text = "";
        }
Example #10
0
        private void pmSetBrowView()
        {
            string strErrorMsg = "";

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

            string strFMDBName = App.ConfigurationManager.ConnectionInfo.ERPDBMSName;
            string strEmplRTab = strFMDBName + ".dbo.EMPLR";

            //string strSQLExec = "select EMCOOR.CROWID, EMCOOR.CCODE, EMCOOR.CNAME, EMCOOR.CNAME2, EMCOOR.DCREATE, EMCOOR.DLASTUPDBY, EM1.CLOGIN as CLOGIN_ADD, EM2.CLOGIN as CLOGIN_UPD from {0} EMCOOR ";
            //strSQLExec += " left join {1} EM1 ON EM1.fcSkid = EMCOOR.CCREATEBY ";
            //strSQLExec += " left join {1} EM2 ON EM2.fcSkid = EMCOOR.CLASTUPDBY ";
            string strSQLExec = "select EMCOOR.FCSKID, EMCOOR.FCCODE, EMCOOR.FCNAME, EMCOOR.FCNAME2, EMCOOR.FTDATETIME as FDCREATE, EMCOOR.FTLASTUPD as FDLASTUPDBY from {0} EMCOOR ";

            strSQLExec += " where EMCOOR.FCCORP = ? and FCISSUPP = 'Y'";
            strSQLExec  = string.Format(strSQLExec, new string[] { this.mstrRefTable });

            pobjSQLUtil.SetPara(new object[] { App.ActiveCorp.RowID });
            pobjSQLUtil.NotUpperSQLExecString = true;
            pobjSQLUtil.SQLExec(ref this.dtsDataEnv, this.mstrBrowViewAlias, "EMCOOR", strSQLExec, ref strErrorMsg);
        }
Example #11
0
        private void pmLoadFormData()
        {
            DataRow dtrBrow = this.gridView1.GetDataRow(this.gridView1.FocusedRowHandle);

            if (dtrBrow != null)
            {
                this.mstrEditRowID = dtrBrow["fcSkid"].ToString();

                string strErrorMsg = "";
                WS.Data.Agents.cDBMSAgent pobjSQLUtil = new WS.Data.Agents.cDBMSAgent(App.ConnectionString, App.DatabaseReside);
                pobjSQLUtil.SetPara(new object[] { this.mstrEditRowID });
                if (pobjSQLUtil.SQLExec(ref this.dtsDataEnv, this.mstrRefTable, this.mstrRefTable, "select * from " + this.mstrRefTable + " where fcSkid = ?", ref strErrorMsg))
                {
                    DataRow dtrLoadForm = this.dtsDataEnv.Tables[this.mstrRefTable].Rows[0];
                    this.txtCode.Text  = dtrLoadForm["fcCode"].ToString().TrimEnd();
                    this.txtName.Text  = dtrLoadForm["fcName"].ToString().TrimEnd();
                    this.txtName2.Text = dtrLoadForm["fcName2"].ToString().TrimEnd();
                }
                this.pmLoadOldVar();
            }
        }
Example #12
0
        private bool pmCheckHasUsed(string inRowID, string inCode, ref string ioErrorMsg)
        {
            string strErrorMsg = "";
            bool   bllHasUsed  = false;

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

            objSQLHelper.SetPara(new object[] { App.gcCorp, inRowID });
            if (objSQLHelper.SQLExec(ref this.dtsDataEnv, "QChkUsed", this.mstrRefTable, "select * from " + MapTable.Table.MasterCoor + " where cCorp = ? and cBizType = ? ", ref strErrorMsg))
            {
                DataRow dtrUsed = this.dtsDataEnv.Tables["QChkUsed"].Rows[0];
                ioErrorMsg = "ÅÙ¡¤éÒ : (" + dtrUsed["cCode"].ToString().TrimEnd() + ")" + dtrUsed["cName"].ToString().TrimEnd();
                bllHasUsed = true;
            }

            if (bllHasUsed)
            {
                ioErrorMsg = "äÁèÊÒÁÒöź¢éÍÁÙÅä´éà¹×èͧ¨Ò¡ÁÕ¡ÒÃÍéÒ§ÍÔ§¶Ö§ã¹ " + ioErrorMsg;
            }
            return(bllHasUsed);
        }
Example #13
0
        private static void pmSuBeSmartMRPGroup(
            WS.Data.Agents.cDBMSAgent inSQLHelper
            , string inCorp
            , string inBranch
            , string inType
            , int inBGYear
            , string inSect
            , string inJob
            , string inQcBGChart
            , ref decimal ioAmt, ref decimal ioRecvAmt, ref decimal ioUseAmt, ref decimal ioBalAmt)
        {
            string strSumCode  = inQcBGChart.TrimEnd() + "%";
            string strErrorMsg = "";
            string strSQLText  = "select ";

            strSQLText += " sum(BGBALANCE.NAMT) as AMT ";
            strSQLText += " ,sum(BGBALANCE.NRECVAMT) as RECVAMT ";
            strSQLText += " ,sum(BGBALANCE.NUSEAMT) as USEAMT ";
            strSQLText += " ,sum(BGBALANCE.NAMT - BGBALANCE.NRECVAMT) as BALAMT ";
            strSQLText += " from " + QBGBalanceInfo.TableName;
            strSQLText += " left join BGCHARTHD on BGCHARTHD.CROWID = BGBALANCE.CBGCHARTHD ";
            strSQLText += " left join BGCHARTHD PRCHART on PRCHART.CROWID = BGCHARTHD.CPRBGCHART ";
            strSQLText += " where BGBALANCE.CCORP = ? AND BGBALANCE.CBRANCH = ? AND BGBALANCE.CTYPE = ? AND BGBALANCE.NBGYEAR = ? AND BGBALANCE.CSECT = ? AND BGBALANCE.CJOB = ? ";
            strSQLText += " AND BGCHARTHD.CCODE like ? ";

            ioAmt = 0; ioRecvAmt = 0; ioUseAmt = 0; ioBalAmt = 0;
            WS.Data.Agents.cDBMSAgent objSQLHelper = inSQLHelper;
            objSQLHelper.SetPara(new object[] { inCorp, inBranch, inType, inBGYear, inSect, inJob, strSumCode });
            if (objSQLHelper.SQLExec(ref BudgetHelper.dtsDataEnv, "QSumBG", QBGBalanceInfo.TableName, strSQLText, ref strErrorMsg))
            {
                foreach (DataRow dtrBGBal in BudgetHelper.dtsDataEnv.Tables["QSumBG"].Rows)
                {
                    ioAmt     += Convert.IsDBNull(dtrBGBal["AMT"]) ? 0 : Convert.ToDecimal(dtrBGBal["AMT"]);
                    ioRecvAmt += Convert.IsDBNull(dtrBGBal["RECVAMT"]) ? 0 : Convert.ToDecimal(dtrBGBal["RECVAMT"]);
                    ioUseAmt  += Convert.IsDBNull(dtrBGBal["USEAMT"]) ? 0 : Convert.ToDecimal(dtrBGBal["USEAMT"]);
                    ioBalAmt  += Convert.IsDBNull(dtrBGBal["BALAMT"]) ? 0 : Convert.ToDecimal(dtrBGBal["BALAMT"]);
                }
            }
        }
Example #14
0
        private bool pmCheckHasUsed(string inRowID, string inCode, ref string ioErrorMsg)
        {
            string strErrorMsg = "";

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

            string strMsg1    = "ไม่สามารถลบได้เนื่องจาก";
            string strMsg2    = "";
            bool   bllHasUsed = true;

            if (objSQLHelper.SetPara(new object[] { this.mstrEditRowID }) &&
                objSQLHelper.SQLExec(ref this.dtsDataEnv, "QHasUsed", this.mstrRefTable, "select * from " + MapTable.Table.BudTranHD + " where cSect = ? ", ref strErrorMsg))
            {
                //strMsg2 = "(" + this.dtsDataEnv.Tables["QHasUsed"].Rows[0]["cCode"].ToString().TrimEnd() + ") " + this.dtsDataEnv.Tables["QHasUsed"].Rows[0]["cName"].ToString().TrimEnd();
                ioErrorMsg = strMsg1 + "มี Transaction อ้างถึงแล้ว";
            }
            else
            {
                bllHasUsed = false;
            }
            return(bllHasUsed);
        }
Example #15
0
        private void pmLoadFormData()
        {
            DataRow dtrBrow = this.gridView1.GetDataRow(this.gridView1.FocusedRowHandle);

            if (dtrBrow != null)
            {
                this.mstrEditRowID = dtrBrow["cRowID"].ToString();

                string strErrorMsg = "";
                WS.Data.Agents.cDBMSAgent pobjSQLUtil = new WS.Data.Agents.cDBMSAgent(App.ConnectionString, App.DatabaseReside);
                pobjSQLUtil.SetPara(new object[] { this.mstrEditRowID });
                if (pobjSQLUtil.SQLExec(ref this.dtsDataEnv, this.mstrRefTable, this.mstrRefTable, "select * from " + this.mstrRefTable + " where cRowID = ?", ref strErrorMsg))
                {
                    DataRow dtrLoadForm = this.dtsDataEnv.Tables[this.mstrRefTable].Rows[0];
                    this.txtCode.Text  = dtrLoadForm[QAppRoleInfo.Field.Code].ToString().TrimEnd();
                    this.txtName.Text  = dtrLoadForm[QAppRoleInfo.Field.Name].ToString().TrimEnd();
                    this.txtName2.Text = dtrLoadForm[QAppRoleInfo.Field.Name2].ToString().TrimEnd();

                    string strLevel = dtrLoadForm[QAppRoleInfo.Field.Level].ToString().TrimEnd();
                    int    intSel   = -1;
                    switch (strLevel)
                    {
                    case "O":
                        intSel = 0;
                        break;

                    case "M":
                        intSel = 1;
                        break;

                    case "T":
                        intSel = 2;
                        break;
                    }
                    this.cmbLevel.SelectedIndex = intSel;
                }
                this.pmLoadOldVar();
            }
        }
Example #16
0
        private void pmLoadWorkCenterItem()
        {
            string strErrorMsg = "";

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

            string strSQLStr = "select * from MFWKCTRHD where CROWID in (select CWKCTRH from MFWORDERIT_OPPLAN where CWORDERH in (" + this.mstrDefaSQL_MOrderH + " ) group by CWKCTRH)";

            objSQLHelper.SetPara(new object[] { App.ActiveCorp.RowID, this.mstrBranch, this.mstrPlant, this.mstrRefType, this.mstrBook, this.mdttBegDate, this.mdttEndDate });
            if (objSQLHelper.SQLExec(ref this.dtsDataEnv, "QLoadWkCtr", "MFWKCTRHD", strSQLStr, ref strErrorMsg))
            {
                //Loop for Load WorkCenter Cap
                foreach (DataRow dtrWkCtr in this.dtsDataEnv.Tables["QLoadWkCtr"].Rows)
                {
                    decimal decCapPerHour = Convert.ToDecimal(dtrWkCtr["NCAPACITY"]);

                    DataRow dtrNewWkCtr = this.dtsDataEnv.Tables[this.mstrTemWkCtrCap].NewRow();
                    dtrNewWkCtr["QcWorkCtr"]  = dtrWkCtr["cCode"].ToString();
                    dtrNewWkCtr["QnWorkCtr"]  = dtrWkCtr["cName"].ToString();
                    dtrNewWkCtr["CapPerHour"] = decCapPerHour;
                    this.dtsDataEnv.Tables[this.mstrTemWkCtrCap].Rows.Add(dtrNewWkCtr);

                    foreach (DataRow dtrWorkCal in this.dtsDataEnv.Tables[this.mstrTemWorkCal].Rows)
                    {
                        decimal decWorkHour  = Convert.ToDecimal(dtrWorkCal["TotWkHour"]);
                        decimal decCapPerDay = decCapPerHour * decWorkHour;

                        //DataRow[] dtaSel = this.dtsDataEnv.Tables[mstrTemMapField].Select("CDATE = '" + dtrWorkCal["CDATE"].ToString()+ "'");
                        string strFldName = this.pmGetMapField(dtrWorkCal["CDATE"].ToString());
                        if (strFldName.Trim() != string.Empty)
                        {
                            //string strFldName = dtaSel[0]["cField"].ToString();
                            dtrNewWkCtr[strFldName] = Convert.ToDecimal(dtrNewWkCtr[strFldName]) + decCapPerDay;
                        }
                    }
                }
            }
        }
Example #17
0
        private void pmSetBrowView()
        {
            object[] pAPara      = null;
            string   strErrorMsg = "";

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

            string strSQLExec = "";

            strSQLExec  = "select ";
            strSQLExec += " MFWORDERHD.CROWID, MFWORDERHD.CCODE, MFWORDERHD.CREFNO, MFWORDERHD.DDATE";
            strSQLExec += " from MFWORDERHD ";
            strSQLExec += " where MFWORDERHD.CCORP = ? and MFWORDERHD.CBRANCH = ? and MFWORDERHD.CPLANT = ? and MFWORDERHD.CREFTYPE = ? and MFWORDERHD.CMFGBOOK = ? ";

            //if (this.mstrSortKey == "CCODE")
            //{
            //    strSQLExec += " and MFWORDERHD.DDATE between ? and ? ";
            //    pAPara = new object[] { App.ActiveCorp.RowID, this.mstrBranch, this.mstrPlant, this.mstrRefType, this.mstrBook };
            //}
            //else
            //{
            //    strSQLExec += " and MFWORDERHD.CCODE between ? and ? ";
            //    pAPara = new object[] { App.ActiveCorp.RowID, this.mstrBranch, this.mstrRefType, this.mstrBook, this.mstrJob, this.mintBGYear };
            //}

            if (this.mstrFilterStep.Trim() != "")
            {
                strSQLExec += this.mstrFilterStep;
            }
            else
            {
                strSQLExec += " and MFWORDERHD.CSTAT <> 'C' and MFWORDERHD.CMSTEP <> 'P' ";
            }
            pAPara = new object[] { App.ActiveCorp.RowID, this.mstrBranch, this.mstrPlant, this.mstrRefType, this.mstrBook };

            pobjSQLUtil.SetPara(pAPara);
            pobjSQLUtil.SQLExec(ref this.dtsDataEnv, this.mstrBrowViewAlias, this.mstrRefTable, strSQLExec, ref strErrorMsg);
        }
Example #18
0
        private void pmSetBrowView()
        {
            string strErrorMsg = "";

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

            string strSQLExec = this.mstrBrowViewSQLStr;

            //strSQLExec = string.Format(strSQLExec, new string[] { this.mstrRefTable });

            if (this.mAPara != null && this.mAPara.Length > 0)
            {
                pobjSQLUtil.SetPara(this.mAPara);
            }

            pobjSQLUtil.NotUpperSQLExecString = true;
            pobjSQLUtil.SQLExec(ref this.dtsDataEnv, this.mstrBrowViewAlias, this.mstrRefTable, strSQLExec, ref strErrorMsg);

            DataColumn dtcTagValue = new DataColumn("CTAGVALUE", Type.GetType("System.Boolean"));

            dtcTagValue.DefaultValue = false;
            this.dtsDataEnv.Tables[this.mstrBrowViewAlias].Columns.Add(dtcTagValue);
        }
Example #19
0
        private void pmLoadFormData()
        {
            DataRow dtrBrow = this.gridView1.GetDataRow(this.gridView1.FocusedRowHandle);

            if (dtrBrow != null)
            {
                this.mstrEditRowID = dtrBrow["cRowID"].ToString();

                string strErrorMsg = "";
                WS.Data.Agents.cDBMSAgent pobjSQLUtil = new WS.Data.Agents.cDBMSAgent(App.ConnectionString, App.DatabaseReside);
                pobjSQLUtil.SetPara(new object[] { this.mstrEditRowID });
                if (pobjSQLUtil.SQLExec(ref this.dtsDataEnv, this.mstrRefTable, this.mstrRefTable, "select * from " + this.mstrRefTable + " where cRowID = ?", ref strErrorMsg))
                {
                    DataRow dtrLoadForm = this.dtsDataEnv.Tables[this.mstrRefTable].Rows[0];
                    this.txtCode.Text        = dtrLoadForm[QBGYearInfo.Field.Code].ToString().TrimEnd();
                    this.txtDesc.Text        = dtrLoadForm[QBGYearInfo.Field.Desc].ToString().TrimEnd();
                    this.chkIsActive.Checked = (dtrLoadForm[QBGYearInfo.Field.IsActive].ToString().TrimEnd() == "Y");
                    this.txtYear.Value       = Convert.ToInt32(dtrLoadForm[QBGYearInfo.Field.Year]) + 543;

                    this.chkIsLock.Checked = (dtrLoadForm[QBGYearInfo.Field.IsLock].ToString().TrimEnd() == "Y");
                }
                this.pmLoadOldVar();
            }
        }
Example #20
0
        private void pmLoadWorkCalendarIT()
        {
            string strErrorMsg = "";

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

            int intRow = 0;

            pobjSQLUtil.SetPara(new object[] { this.mstrEditRowID, "" });
            if (pobjSQLUtil.SQLExec(ref this.dtsDataEnv, "QWkCtrIT", "WkCtrIT", "select * from " + this.mstrITable + " where cWkCtrH = ? and cType = ? order by cSeq", ref strErrorMsg))
            {
                foreach (DataRow dtrWkCtrIT in this.dtsDataEnv.Tables["QWkCtrIT"].Rows)
                {
                    DataRow dtrNewRow = this.dtsDataEnv.Tables[this.mstrTemWorkHr].NewRow();

                    intRow++;
                    //dtrNewRow["nRecNo"] = intRow;
                    dtrNewRow["cRowID"]   = dtrWkCtrIT["cRowID"].ToString();
                    dtrNewRow["cMachine"] = dtrWkCtrIT["cResource"].ToString();

                    this.dtsDataEnv.Tables[this.mstrTemWorkHr].Rows.Add(dtrNewRow);
                }
            }
        }
Example #21
0
        private void pmAddRow_OPPlanCap(DataRow inSource)
        {
            DataRow dr = this.dtsDataEnv.Tables[this.mstrTemOPPlanCap].NewRow();

            dr["QcWorkCtr"] = inSource["QcWorkCtr"].ToString();
            dr["Code_MO"]   = "MO" + inSource["QcBook"].ToString().Trim() + "/" + inSource["CCODE"].ToString();
            dr["StartDate"] = Convert.ToDateTime(inSource["dStart"]);
            dr["DueDate"]   = Convert.ToDateTime(inSource["dDueDate"]);

            string strErrorMsg = "";

            WS.Data.Agents.cDBMSAgent objSQLHelper = new WS.Data.Agents.cDBMSAgent(App.ConnectionString, App.DatabaseReside);
            string strSQLStr = "select * from MFWKCTRHD where CROWID = ?";

            //CWKCTRH
            decimal decCapPerHour = 0;

            objSQLHelper.SetPara(new object[] { inSource["CWKCTRH"].ToString() });
            if (objSQLHelper.SQLExec(ref this.dtsDataEnv, "QWkCtr", "MFWKCTRHD", strSQLStr, ref strErrorMsg))
            {
                //Loop for Load WorkCenter Cap
                foreach (DataRow dtrWkCtr in this.dtsDataEnv.Tables["QWkCtr"].Rows)
                {
                    decCapPerHour = Convert.ToDecimal(dtrWkCtr["NCAPACITY"]);
                }
            }

            string strFldName = this.pmGetMapField(Convert.ToDateTime(inSource["DDATE"]).ToString("yyyyMMdd"));

            if (strFldName.Trim() != string.Empty)
            {
                dr[strFldName] = decCapPerHour * Convert.ToDecimal(inSource["nUseHour"]);
            }

            this.dtsDataEnv.Tables[mstrTemOPPlanCap].Rows.Add(dr);
        }
Example #22
0
        private void pmSetBrowView()
        {
            string strErrorMsg = "";

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

            string strFMDBName = App.ConfigurationManager.ConnectionInfo.ERPDBMSName;
            string strEmplRTab = strFMDBName + ".dbo.EMPLR";

            //string strSQLExec = "select {0}.CROWID, {0}.CCODE, {0}.CNAME, {0}.DCREATE, {0}.DLASTUPD, EM1.FCLOGIN as CLOGIN_ADD, EM2.FCLOGIN as CLOGIN_UPD from {0} ";
            //string strSQLExec = "select {0}.CROWID, {0}.CCODE, {0}.CNAME,  EM1.FCLOGIN as CLOGIN_ADD, EM2.FCLOGIN as CLOGIN_UPD from {0} where CCORP = ? ";
            //strSQLExec = string.Format(strSQLExec, new string[] { this.mstrRefTable });
            string strSQLExec = "select BGDEPT.CROWID, BGDEPT.CCODE, BGDEPT.CNAME from BGDEPT where CCORP = ? ";

            object[] pAPara = new object[] { App.gcCorp };
            pobjSQLUtil.SetPara(pAPara);
            // pobjSQLUtil.NotUpperSQLExecString = true;
            //pobjSQLUtil.SQLExec(ref this.dtsDataEnv, this.mstrBrowViewAlias, "Master_Dept", strSQLExec, ref strErrorMsg);

            //string strSQLExec = "select BGDEPT.CROWID, BGDEPT.CCODE, BGDEPT.CNAME from BGDEPT where CCORP = ? ";
            //strSQLExec = string.Format(strSQLExec, new string[] { this.mstrRefTable });

            pobjSQLUtil.SQLExec(ref this.dtsDataEnv, this.mstrBrowViewAlias, this.mstrRefTable, strSQLExec, ref strErrorMsg);
        }
Example #23
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();
            }
        }
Example #24
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();
            }
        }
Example #25
0
        private void pmSetBrowView()
        {
            string strErrorMsg = "";

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

            string strSQLExec = "select * from BGChartHD where cPRBGChart = ? order by BGChartHD.cCode";

            if (this.mstrBGChartGrp != string.Empty)
            {
                this.dtsDataEnv.Tables[this.mstrBrowViewAlias].Rows.Clear();

                //"select cPRBGChart from BGChartHD where cPRBGChart = ? order by BGChartHD.cCode"

                decimal decAmt = 0; decimal decRecvAmt = 0; decimal decUseAmt = 0; decimal decBalAmt = 0;
                DataRow dtrBGChart = null;
                string  strPRChart = "";
                pobjSQLUtil.SetPara(new object[] { this.mstrBGChartGrp });
                if (pobjSQLUtil.SQLExec(ref this.dtsDataEnv, "QGrp1", "BGCHARTHD", "select * from BGChartHD where cRowID = ? ", ref strErrorMsg))
                {
                    dtrBGChart = this.dtsDataEnv.Tables["QGrp1"].Rows[0];
                    strPRChart = dtrBGChart["cPRBGChart"].ToString();
                    if (strPRChart.Trim() == string.Empty)
                    {
                        //Parent Chart เป็นว่าง ๆ แสดงว่าเป็นประเภทหมวดซึ่ง Sum ได้เลย
                        BudgetHelper.SuBeSmartMRPGroup(pobjSQLUtil
                                                       , App.ActiveCorp.RowID, this.mstrBranch, this.mstrType, this.mintBGYear, this.mstrSect, this.mstrJob, dtrBGChart["cCode"].ToString()
                                                       , ref decAmt, ref decRecvAmt, ref decUseAmt, ref decBalAmt);

                        DataRow dtrBrow = this.dtsDataEnv.Tables[this.mstrBrowViewAlias].NewRow();
                        dtrBrow["Type"]      = "1";
                        dtrBrow["QcBGChart"] = dtrBGChart["cCode"].ToString();
                        dtrBrow["QnBGChart"] = dtrBGChart["cName"].ToString();
                        dtrBrow["nBGAmt"]    = decAmt;
                        dtrBrow["nUseAmt"]   = decRecvAmt;
                        dtrBrow["nBalAmt"]   = decBalAmt;
                        this.dtsDataEnv.Tables[this.mstrBrowViewAlias].Rows.Add(dtrBrow);
                    }
                    else
                    {
                        pobjSQLUtil.SetPara(new object[] { strPRChart });
                        if (pobjSQLUtil.SQLExec(ref this.dtsDataEnv, "QGrp1", "BGCHARTHD", "select * from BGChartHD where cRowID = ? ", ref strErrorMsg))
                        {
                            dtrBGChart = this.dtsDataEnv.Tables["QGrp1"].Rows[0];
                            BudgetHelper.SuBeSmartMRPGroup(pobjSQLUtil
                                                           , App.ActiveCorp.RowID, this.mstrBranch, this.mstrType, this.mintBGYear, this.mstrSect, this.mstrJob, dtrBGChart["cCode"].ToString()
                                                           , ref decAmt, ref decRecvAmt, ref decUseAmt, ref decBalAmt);

                            DataRow dtrBrow = this.dtsDataEnv.Tables[this.mstrBrowViewAlias].NewRow();
                            dtrBrow["Type"]      = "1";
                            dtrBrow["QcBGChart"] = dtrBGChart["cCode"].ToString();
                            dtrBrow["QnBGChart"] = dtrBGChart["cName"].ToString();
                            dtrBrow["nBGAmt"]    = decAmt;
                            dtrBrow["nUseAmt"]   = decRecvAmt;
                            dtrBrow["nBalAmt"]   = decBalAmt;
                            this.dtsDataEnv.Tables[this.mstrBrowViewAlias].Rows.Add(dtrBrow);
                        }

                        //กรณีมี Parent จะดึงรหัสใน Parent เดียวกันมาแสดง
                        pobjSQLUtil.SetPara(new object[] { strPRChart });
                        if (pobjSQLUtil.SQLExec(ref this.dtsDataEnv, "QGrp1", "BGCHARTHD", "select * from BGChartHD where cPRBGChart = ? ", ref strErrorMsg))
                        {
                            foreach (DataRow dtrP1Brow in this.dtsDataEnv.Tables["QGrp1"].Rows)
                            {
                                dtrBGChart = dtrP1Brow;
                                BudgetHelper.SuBeSmartMRPGroup(pobjSQLUtil
                                                               , App.ActiveCorp.RowID, this.mstrBranch, this.mstrType, this.mintBGYear, this.mstrSect, this.mstrJob, dtrBGChart["cCode"].ToString()
                                                               , ref decAmt, ref decRecvAmt, ref decUseAmt, ref decBalAmt);

                                DataRow dtrBrow = this.dtsDataEnv.Tables[this.mstrBrowViewAlias].NewRow();
                                dtrBrow["Type"]      = "2";
                                dtrBrow["QcBGChart"] = dtrBGChart["cCode"].ToString();
                                dtrBrow["QnBGChart"] = dtrBGChart["cName"].ToString();
                                dtrBrow["nBGAmt"]    = decAmt;
                                dtrBrow["nUseAmt"]   = decRecvAmt;
                                dtrBrow["nBalAmt"]   = decBalAmt;
                                this.dtsDataEnv.Tables[this.mstrBrowViewAlias].Rows.Add(dtrBrow);
                            }
                        }
                    }
                }
            }
        }
Example #26
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();
            }
        }
Example #27
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();
            }
        }
Example #28
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();
            }
        }
Example #29
0
        private void pmSetBrowView2()
        {
            UIBase.WaitWind("Loading รายการสินค้า...");
            string strErrorMsg = " ";
            string strSQLStr   = "";

            WS.Data.Agents.cDBMSAgent pobjSQLUtil = new WS.Data.Agents.cDBMSAgent(App.ERPConnectionString, App.DatabaseReside);

            object[] pAPara = null;
            pAPara    = new object[] { App.ActiveCorp.RowID, this.mstrBranch, this.mstrRefType, this.mstrCoor, this.mstrProd, this.mstrBook };
            strSQLStr = " ";

            strSQLStr += " select ";
            strSQLStr += " (select H.FCREFNO from ORDERH H where H.FCSKID = ORDERI.FCORDERH) as FCREFNO ";
            strSQLStr += " , (select H.FCCODE from ORDERH H where H.FCSKID = ORDERI.FCORDERH) as FCCODE ";
            strSQLStr += " , (select H.FDDATE from ORDERH H where H.FCSKID = ORDERI.FCORDERH) as FDDATE ";
            strSQLStr += " , (select P.FCCODE from PROD P where P.FCSKID = ORDERI.FCPROD) as QCPROD ";
            strSQLStr += " , (select P.FCNAME from PROD P where P.FCSKID = ORDERI.FCPROD) as QNPROD ";
            strSQLStr += " , (select C.FCCODE from COOR C where C.FCSKID = ORDERI.FCCOOR) as QCCOOR ";
            strSQLStr += " , (select C.FCNAME from COOR C where C.FCSKID = ORDERI.FCCOOR) as QNCOOR ";
            strSQLStr += " , sum(ORDERI.FNBACKQTY) as FNBACKQTY ";
            strSQLStr += " , ORDERI.FCSKID, ORDERI.FCORDERH , ORDERI.FCCOOR, ORDERI.FCPROD";
            strSQLStr += " from ORDERI ";
            strSQLStr += " left join PROD on PROD.FCSKID = ORDERI.FCPROD ";
            strSQLStr += " left join COOR on COOR.FCSKID = ORDERI.FCCOOR ";
            strSQLStr += " left join ORDERH on ORDERH.FCSKID = ORDERI.FCORDERH ";
            //strSQLStr += " left join BOOK on BOOK.FCSKID = BOOK.FCBOOK ";
            strSQLStr += " where ORDERI.FCCORP = ? ";
            strSQLStr += " and ORDERI.FCBRANCH = ? ";
            strSQLStr += " and ORDERI.FCREFTYPE = ? ";
            strSQLStr += " and ORDERI.FCSTEP <> 'P' ";
            strSQLStr += " and ORDERI.FCSTEP <> 'L' ";
            strSQLStr += " and ORDERI.FCCOOR = ? ";
            strSQLStr += " and ORDERI.FCPROD = ? ";
            strSQLStr += " and ORDERI.FNBACKQTY <> 0 ";
            strSQLStr += " and ORDERH.FCBOOK = ? ";
            strSQLStr += " group by ORDERI.FCSKID, ORDERI.FCORDERH , ORDERI.FCCOOR, ORDERI.FCPROD ";
            strSQLStr += " order by FCREFNO,QCPROD,QCCOOR ";

            pobjSQLUtil.SetPara(pAPara);
            pobjSQLUtil.SQLExec(ref this.dtsDataEnv, this.mstrBrowViewAlias2, this.mstrRefTable, strSQLStr, ref strErrorMsg);
            for (int i = 0; i < this.dtsDataEnv.Tables[this.mstrBrowViewAlias2].Rows.Count; i++)
            {
                DataRow dtrBrow    = this.dtsDataEnv.Tables[this.mstrBrowViewAlias2].Rows[i];
                decimal decCutQty  = pmSumCutQty2(dtrBrow["FCSKID"].ToString());
                decimal decBackQty = Convert.ToDecimal(dtrBrow["FNBACKQTY"]);
                decimal decMOQty   = decBackQty - decCutQty;
                dtrBrow["FNBACKQTY"] = decMOQty;
                if (decMOQty <= 0)
                {
                    //this.dtsDataEnv.Tables[this.mstrBrowViewAlias2].Rows[i].Delete();
                    this.dtsDataEnv.Tables[this.mstrBrowViewAlias2].Rows.RemoveAt(i);
                }
            }

            DataColumn dtcTagValue = new DataColumn("CTAGVALUE", Type.GetType("System.Boolean"));

            dtcTagValue.DefaultValue = false;
            this.dtsDataEnv.Tables[this.mstrBrowViewAlias2].Columns.Add(dtcTagValue);

            UIBase.WaitClear();
        }
Example #30
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 strMenuName = dtrAppObj["cDesc"].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;

                case Entity.KeepLogType.Print:
                    strUpdType = BusinessEnum.gc_KEEPLOG_TYPE_PRINT;
                    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["cCorp"]     = KeepLogAgent.CORPID;
                dtrSaveInfo["cType"]     = strUpdType;
                dtrSaveInfo["cTaskName"] = inTaskName;
                //=> à»ÅÕèÂ¹ä» Select join ¡Ñº AppObj.cDesc1 á·¹
                //dtrSaveInfo["cMenuName"] = strMenuName.TrimEnd();
                dtrSaveInfo["cCode"]      = inCode;
                dtrSaveInfo["cName"]      = inName;
                dtrSaveInfo["cOldCode"]   = inOldCode;
                dtrSaveInfo["cOldName"]   = inOldName;
                dtrSaveInfo["cLoginName"] = inLoginName;
                dtrSaveInfo["cMachine"]   = System.Environment.MachineName;
                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);
            }
        }