示例#1
0
    private bool CreatePointsProgram(PointsProgram pointsProgram)
    {
        bool result           = false;
        SQLParametersList lst = new SQLParametersList();

        try
        {
            lst.Add("@CAMProgram", SqlDbType.Bit).Value      = 0;
            lst.Add("@ExternalProgram", SqlDbType.Bit).Value = 0;
            lst.Add("@AutoDelete", SqlDbType.Bit).Value      = 1;

            if (pointsProgram.ProgramID == 0)
            {
                lst.Add("@ProgramName", SqlDbType.NVarChar, 200).Value = pointsProgram.ProgramName;
                lst.Add("@ProgramID", SqlDbType.BigInt).Direction      = ParameterDirection.Output;
                m_dbAccess.ExecuteNonQuery(DataBases.LogixRT, CommandType.StoredProcedure, "pt_PointsPrograms_Insert", lst);
                pointsProgram.ProgramID = lst["@ProgramID"].Value.ConvertToLong();
                result = true;
                if (MyCommon.LRTadoConn.State == ConnectionState.Closed)
                {
                    MyCommon.Open_LogixRT();
                }
                MyCommon.Activity_Log(7, pointsProgram.ProgramID, CurrentUser.AdminUser.ID, Copient.PhraseLib.Lookup("history.point-create", LanguageID));

                lst = new SQLParametersList();
                lst.Add("@ProgramID", SqlDbType.NVarChar, 200).Value = pointsProgram.ProgramID;
                lst.Add("@VarID", SqlDbType.BigInt).Direction        = ParameterDirection.Output;
                m_dbAccess.ExecuteNonQuery(DataBases.LogixXS, CommandType.StoredProcedure, "dbo.pc_PointsVar_Create", lst);
                long PromoVarID = lst["@VarID"].Value.ConvertToLong();

                if (PromoVarID != 0)
                {
                    MyCommon.QueryStr = " update PointsPrograms with (RowLock) SET " +
                                        " PromoVarID=" + PromoVarID + " " + " where ProgramID=" + pointsProgram.ProgramID + ";";
                    MyCommon.LRT_Execute();
                }
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }
        finally
        {
            MyCommon.Close_LogixRT();
        }
        lst = null;
        return(result);
    }