Beispiel #1
0
        private bool DBSave()
        {
            this.uniGrid1.UpdateData();
            cstdsY8101M2_KO883.I_PMS_PROJECT_RATE.Clear();
            DataTable saveDt = new DataTable();

            try
            {
                cstdsY8101M2_KO883.I_PMS_PROJECT_RATE.Merge(cstdsY8101M2_KO883.E_PMS_PROJECT_RATE.GetChanges(), false, MissingSchemaAction.Ignore);
                saveDt.Merge(cstdsY8101M2_KO883.I_PMS_PROJECT_RATE, false, MissingSchemaAction.Add);
                saveDt.AcceptChanges();

                using (uniCommand _uniCmd = uniBase.UDatabase.GetStoredProcCommand("dbo.USP_H4006M4_KO883_CUD"))
                {
                    uniBase.UDatabase.AddInParameter(_uniCmd, "@TBL_DATA", SqlDbType.Structured, saveDt);
                    uniBase.UDatabase.AddInParameter(_uniCmd, "@USER_ID", SqlDbType.NVarChar, 15, CommonVariable.gUsrID);
                    uniBase.UDatabase.AddOutParameter(_uniCmd, "@MSG_CD", SqlDbType.NVarChar, 6);
                    uniBase.UDatabase.AddOutParameter(_uniCmd, "@MESSAGE", SqlDbType.NVarChar, 200);
                    uniBase.UDatabase.AddOutParameter(_uniCmd, "@ERR_POS", SqlDbType.Int, 6);

                    uniBase.UDatabase.AddReturnParameter(_uniCmd, "RETURN_VALUE", SqlDbType.Int, 1);

                    uniBase.UDatabase.ExecuteNonQuery(_uniCmd, false);

                    int iReturn = (int)uniBase.UDatabase.GetParameterValue(_uniCmd, "RETURN_VALUE");

                    if (iReturn < 0)
                    {
                        string sMsgCd   = uniBase.UDatabase.GetParameterValue(_uniCmd, "@MSG_CD") as string;
                        string sMessage = uniBase.UDatabase.GetParameterValue(_uniCmd, "@MESSAGE") as string;

                        if (string.IsNullOrEmpty(sMsgCd))
                        {
                            sMsgCd = "DT9999";
                        }

                        uniBase.UMessage.DisplayMessageBox(sMsgCd, MessageBoxButtons.OK, sMessage);

                        return(false);
                    }
                }
            }
            catch (Exception ex)
            {
                bool reThrow = ExceptionControler.AutoProcessException(ex);
                if (reThrow)
                {
                    throw;
                }
                return(false);
            }
            finally
            {
            }


            return(true);
        }
Beispiel #2
0
        public DataTable SelectDataTable(string sQuery)
        {
            DataTable dtNew = new DataTable();

            try
            {
                SqlDataAdapter sqlDA = new SqlDataAdapter(sQuery, Connection);
                sqlDA.Fill(dtNew);
            }
            catch (Exception e)
            {
                /*
                 * SELECT errorSelect = new SELECT();
                 * errorSelect.addInQuery("BEGIN TRY");
                 * errorSelect.addInQuery("--- ----- ---");
                 * errorSelect.addInQuery( sQuery + ";");
                 * errorSelect.addInQuery("--- ----- ---");
                 * errorSelect.addInQuery("  END TRY  ");
                 * errorSelect.addInQuery("BEGIN CATCH");
                 * errorSelect.addInQuery("    SELECT ERROR_NUMBER()    AS ErrorNumber    ");
                 * errorSelect.addInQuery("         , ERROR_SEVERITY()  AS ErrorSeverity  ");
                 * errorSelect.addInQuery("         , ERROR_STATE()     AS ErrorState     ");
                 * errorSelect.addInQuery("         , ERROR_PROCEDURE() AS ErrorProcedure ");
                 * errorSelect.addInQuery("         , ERROR_LINE()      AS ErrorLine      ");
                 * errorSelect.addInQuery("         , ERROR_MESSAGE()   AS ErrorMessage   ");
                 * errorSelect.addInQuery("  END CATCH;");
                 *
                 * DataTable     dtError      = errorSelect.getData();
                 *
                 * StringBuilder errorMessage = new StringBuilder("Erro(s) = "+dtError.DefaultView.Count);
                 *
                 * foreach(DataRow row in dtError.Rows)
                 * {
                 *  errorMessage.Append("Error( "           +row[0].ToString()+" )");
                 *  errorMessage.Append(", Severity( "      +row[1].ToString()+" )");
                 *  errorMessage.Append(", State( "         +row[2].ToString()+" )");
                 *  errorMessage.AppendLine(", Procedure( " +row[3].ToString()+" )");
                 *  errorMessage.Append(", Line: "          +row[4].ToString() );
                 *  errorMessage.AppendLine(" - Message \" "+row[5].ToString()+" \"");
                 *
                 *  errorMessage.AppendLine(new string('=', 100));
                 * }
                 *
                 * errorMessage.Append(ExceptionControler.getFullException(e));
                 * throw new Exception( errorMessage.ToString() );
                 * //*/

                throw ExceptionControler.getFullException(e);
            }

            return(dtNew);
        }
Beispiel #3
0
        private bool DBQuery()
        {
            cstdsY8101M2_KO883.Clear();

            DataSet dsResult = null;


            try
            {
                using (uniCommand uniCommand = uniBase.UDatabase.GetStoredProcCommand("USP_H4006M1_KO883P_111"))
                {
                    uniBase.UDatabase.AddInParameter(uniCommand, "@YYYY", SqlDbType.NVarChar, dtYYYYMM.uniValue.ToString("yyyy"));
                    uniBase.UDatabase.AddInParameter(uniCommand, "@DILIG_EMP_NO", SqlDbType.NVarChar, popEmpNo.CodeValue.Trim());
                    uniBase.UDatabase.AddInParameter(uniCommand, "@DEPT_CD", SqlDbType.NVarChar, popDeptCd.CodeValue.Trim());
                    uniBase.UDatabase.AddInParameter(uniCommand, "@STD_DATE", SqlDbType.DateTime, dtDocumentDt.uniValue.ToString());


                    dsResult = uniBase.UDatabase.ExecuteDataSet(uniCommand);
                }

                if (dsResult == null || dsResult.Tables.Count == 0 || dsResult.Tables[0].Rows.Count == 0)
                {
                    uniBase.UMessage.DisplayMessageBox("900014", MessageBoxButtons.OK);
                    return(false);
                }
                cstdsY8101M2_KO883.E_PMS_PROJECT_RATE.Merge(dsResult.Tables[0], false, MissingSchemaAction.Ignore);
            }

            catch (Exception ex)
            {
                bool reThrow = ExceptionControler.AutoProcessException(ex);
                if (reThrow)
                {
                    throw;
                }
                return(false);
            }
            finally
            {
            }

            return(true);
        }